use of dyvilx.tools.gensrc.ast.directive.CallDirective in project Dyvil by Dyvil.
the class CallDirectiveParser method parse.
@Override
public void parse(IParserManager pm, IToken token) {
final int type = token.type();
switch(this.mode) {
case NAME:
if (Tokens.isIdentifier(type)) {
this.mode = OPEN_PAREN;
this.directive = new CallDirective(token.raw(), token.nameValue());
return;
}
pm.report(token, "directive.identifier");
return;
case OPEN_PAREN:
if (type == BaseSymbols.OPEN_PARENTHESIS) {
pm.pushParser(new ArgumentListParser(this.directive));
this.mode = CLOSE_PAREN;
return;
}
// Fallthrough
case BODY:
if (type == BaseSymbols.OPEN_CURLY_BRACKET) {
final StatementList closure = new StatementList();
pm.pushParser(new BlockParser(closure));
this.directive.setBlock(closure);
this.mode = BODY_END;
return;
}
this.list.add(this.directive);
pm.popParser(true);
return;
case CLOSE_PAREN:
if (type == BaseSymbols.CLOSE_PARENTHESIS) {
this.mode = BODY;
return;
}
pm.report(token, "directive.close_paren");
return;
case BODY_END:
assert type == BaseSymbols.CLOSE_CURLY_BRACKET;
this.list.add(this.directive);
pm.popParser();
}
}
Aggregations