Search in sources :

Example 1 with SuperExpr

use of dyvilx.tools.compiler.ast.expression.SuperExpr in project Dyvil by Dyvil.

the class ThisSuperParser method parse.

@Override
public void parse(IParserManager pm, IToken token) {
    final int type = token.type();
    switch(this.mode) {
        case THIS_SUPER:
            switch(type) {
                case DyvilKeywords.THIS:
                    this.mode = TYPE;
                    this.value = new ThisExpr(token.raw());
                    return;
                case DyvilKeywords.SUPER:
                    this.mode = TYPE;
                    this.value = new SuperExpr(token.raw());
                    return;
            }
            pm.popParser(true);
            return;
        case TYPE:
            if (ExpressionParser.isGenericCall(token, type)) {
                this.mode = TYPE_END;
                pm.splitJump(token, 1);
                pm.pushParser(new TypeParser(this.value, true));
                return;
            }
            this.valueConsumer.setValue(this.value);
            pm.popParser(true);
            return;
        case TYPE_END:
            pm.popParser();
            this.valueConsumer.setValue(this.value);
            if (!TypeParser.isGenericEnd(token, type)) {
                pm.reparse();
                pm.report(token, this.value.valueTag() == IValue.SUPER ? "super.close_angle" : "this.close_angle");
                return;
            }
            pm.splitJump(token, 1);
    }
}
Also used : TypeParser(dyvilx.tools.compiler.parser.type.TypeParser) SuperExpr(dyvilx.tools.compiler.ast.expression.SuperExpr) ThisExpr(dyvilx.tools.compiler.ast.expression.ThisExpr)

Aggregations

SuperExpr (dyvilx.tools.compiler.ast.expression.SuperExpr)1 ThisExpr (dyvilx.tools.compiler.ast.expression.ThisExpr)1 TypeParser (dyvilx.tools.compiler.parser.type.TypeParser)1