return ret;
}
public static Scope parseProperties(List<Node> fields) throws ParserException {
Scope properties = new Scope();
for (Node field : fields) {
if (!(field instanceof Tuple &&
delimType(((Tuple) field).open, Constants.SQUARE_BEGIN) &&
((Tuple) field).elements.size() >= 2))
{
throw new ParserException("incorrect form of descriptor: " + field.toString(), field);
} else {
List<Node> elements = parseList(((Tuple) field).elements);
Node nameNode = elements.get(0);
if (!(nameNode instanceof Name)) {
throw new ParserException("expect a name, but got: " + nameNode.toString(), nameNode);
}
String id = ((Name) nameNode).id;
if (properties.containsKey(id)) {
throw new ParserException("duplicated name: " + nameNode.toString(), nameNode);
}
Node typeNode = elements.get(1);
if (!(typeNode instanceof Name)) {
throw new ParserException("type must be a name, but got: " + typeNode.toString(), typeNode);
}
properties.put(id, "type", typeNode);
Map<String, Node> props = parseMap(elements.subList(2, elements.size()));
Map<String, Object> propsObj = new LinkedHashMap<>();
for (Map.Entry<String, Node> e : props.entrySet()) {
propsObj.put(e.getKey(), e.getValue());
}
properties.putProperties(((Name) nameNode).id, propsObj);
}
}
return properties;
}