}
parameters = new ExpressionList(size);
int c = 0;
for (int i=0; i<n; i++) {
if (tag.getName(i).equalsIgnoreCase("param")) {
Expression expression = Grammar.parseExpression(tag.getValue(i), location, parser);
parameters.setChild(c++, expression);
}
}
}
String from = tag.getValue("from");
String method = tag.getValue("method");
boolean is_super = tag.contains("super");
if ((method != null) && !Grammar.isValidIdentifier(method)) {
parser.error(location, "Method '"+method+"' is invalid");
return;
}
if (is_super) {
if (method == null) {
// super(params, ...)
Statement parent = getParentStatement();
FunctionStatement function = getFunctionStatement();
if (function.getType() == Type.CONSTRUCTOR) {
BlockStatement block = function.getBlockStatement();
if (parent == function && block.isEmpty()) {
_expression = new Expression(new LinkNode(this, location,
new Name().add(Name.SUPER, "super"), parameters, LinkNode.SUPER), location);
} else {
parser.error(location, "Superclass constructor invoke must appear as a first statement (characters between tags are considered statements)");
}
} else {
parser.error(location, "Superclass constructor invoke may only appear in constructor");
}
} else {
// super.method(params, ...)
_expression = new Expression(new LinkNode(this, location,
new Name().add(Name.SUPER, "super").add(method), parameters, LinkNode.GET), location);
}
} else {
if (method == null) {
parser.error(location, "Attribute 'method' not given");
return;
}
if (from == null) {
// method(params, ...)
_expression = new Expression(new LinkNode(this, location,
new Name().add(method), parameters, LinkNode.GET), location);
} else {
// expr.method(params, ...)
Expression self = Grammar.parseExpression(from, location, parser);
_expression = new Expression(new InvokeNode(self, method, parameters), location);
}
}
}