parseExpression(ctx, expr, ';');
new VariableDefinition(
ctx.block.owner, name, expr, lineno);
return;
} else if (symbol == '{') { //mixin definition
newBlock(ctx, new MixinDefinition(
ctx.block.owner, name,
new ArgumentDefinition[0], lineno));
return;
} else if (symbol == ';') { //use of function/mixin
Expression expr = new Expression(ctx.block.owner, lineno);
new FunctionValue(expr, name, lineno); //no parenthesis
return;
}
} else if (t0 instanceof Op && ((Op)t0).getValue() == LPAREN) {
//1) definition of function or mixin
//2) use of function or mixin
char cc = _in.peekAfterRPAREN();
if (cc == ';' || cc == '}' || cc == EOF) { //use of function/mixin
putback(t0);
putback(id);
parseExpression(ctx, new Expression(ctx.block.owner, lineno), EOPAREN);
t0 = next(ctx);
if (t0 instanceof Symbol) {
switch (((Symbol)t0).getValue()) {
case '}':
putback(t0);
//fall thru
case ';':
return; //done
}
}
throw error("';' expected; not "+t0, t0);
}
//definition of function/mixin
final ArgumentDefinition[] adefs = parseArguments(ctx);
t0 = next(ctx);
if (t0 instanceof Symbol) {
final char symbol = ((Symbol)t0).getValue();
if (symbol == ':') { //function definition
Token t1 = next(ctx);
if (t1 instanceof Keyword && ((Keyword)t1).getValue() == IMPORT) {
t0 = next(ctx);
if (!(t0 instanceof Other))
throw error("a class name expected, not "+t0, t0);
nextAndCheck(ctx, ';', true);
final Method mtd = Classes.getMethod(
((Other)t0).getValue(), name, adefs.length,
getFilename(), t0.getLine());
new FunctionDefinition(
ctx.block.owner, name, adefs, mtd, lineno);
return;
} else {
putback(t1);
final Expression expr = new Expression(t0.getLine());
//note: expr is NOT a child of any node but part of VariableDefinition below
parseExpression(ctx, expr, ';');
new FunctionDefinition(
ctx.block.owner, name, adefs, expr, lineno);
return;
}
} else if (symbol == '{') { //mixin
newBlock(ctx, new MixinDefinition(
ctx.block.owner, name, adefs, lineno));
return;
}
}
}