use of dyvilx.tools.compiler.ast.statement.exception.CatchBlock in project Dyvil by Dyvil.
the class TryStatementParser method parse.
@Override
public void parse(IParserManager pm, IToken token) {
final int type = token.type();
switch(this.mode) {
case END:
pm.popParser(true);
return;
case ACTION:
pm.pushParser(new ExpressionParser(this), true);
this.mode = CATCH;
return;
case CATCH:
if (type == DyvilKeywords.CATCH) {
this.statement.addCatchBlock(this.catchBlock = new CatchBlock());
this.mode = CATCH_OPEN;
return;
}
if (type == DyvilKeywords.FINALLY) {
pm.pushParser(new ExpressionParser(this));
this.mode = END;
return;
}
if (BaseSymbols.isTerminator(type)) {
int nextType = token.next().type();
if (nextType == Tokens.EOF) {
pm.popParser(true);
return;
}
if (nextType == DyvilKeywords.CATCH || nextType == DyvilKeywords.FINALLY) {
return;
}
}
pm.popParser(true);
return;
case CATCH_OPEN:
if (type == BaseSymbols.OPEN_PARENTHESIS) {
this.mode = CATCH_CLOSE;
pm.pushParser(new DataMemberParser<>(this));
} else {
this.mode = CATCH_SEPARATOR;
pm.pushParser(new DataMemberParser<>(this), true);
}
return;
case CATCH_CLOSE:
this.mode = CATCH;
pm.pushParser(new ExpressionParser(this.catchBlock));
if (type != BaseSymbols.CLOSE_PARENTHESIS) {
pm.reparse();
pm.report(token, "try.catch.close_paren");
}
return;
case CATCH_SEPARATOR:
switch(type) {
case Tokens.EOF:
pm.popParser();
return;
case BaseSymbols.SEMICOLON:
this.mode = CATCH;
return;
case BaseSymbols.OPEN_CURLY_BRACKET:
this.mode = CATCH;
pm.pushParser(new StatementListParser(this.catchBlock), true);
return;
}
pm.report(token, "try.catch.separator");
}
}
Aggregations