Search in sources :

Example 1 with TypeOperator

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

the class TypeClassParser method parse.

@Override
public void parse(IParserManager pm, IToken token) {
    final int type = token.type();
    switch(this.mode) {
        case TYPE_CLASS:
            if (type == DyvilKeywords.CLASS) {
                this.value = new ClassOperator(token.raw());
                this.mode = TYPE;
                return;
            }
            if (type == DyvilKeywords.TYPE) {
                this.value = new TypeOperator(token.raw());
                this.mode = TYPE;
                return;
            }
            throw new Error();
        case TYPE:
            if (TypeParser.isGenericStart(token, type)) {
                this.mode = ANGLE_END;
                pm.splitJump(token, 1);
                pm.pushParser(new TypeParser(this.value, true));
                return;
            }
            if (type == BaseSymbols.OPEN_PARENTHESIS) {
                this.mode = PARENTHESES_END;
            } else {
                this.mode = END;
                pm.reparse();
            }
            pm.pushParser(new TypeParser(this.value));
            return;
        case PARENTHESES_END:
            if (type != BaseSymbols.CLOSE_PARENTHESIS) {
                pm.report(token, this.isClassOperator() ? "classoperator.close_paren" : "typeoperator.close_paren");
                return;
            }
            this.valueConsumer.setValue(this.value);
            pm.popParser();
            return;
        case ANGLE_END:
            if (!TypeParser.isGenericEnd(token, type)) {
                pm.report(token, this.isClassOperator() ? "classoperator.close_angle" : "typeoperator.close_angle");
                return;
            }
            this.valueConsumer.setValue(this.value);
            pm.popParser();
            pm.splitJump(token, 1);
            return;
        case END:
            this.valueConsumer.setValue(this.value);
            pm.popParser(true);
    }
}
Also used : TypeParser(dyvilx.tools.compiler.parser.type.TypeParser) TypeOperator(dyvilx.tools.compiler.ast.expression.TypeOperator) ClassOperator(dyvilx.tools.compiler.ast.expression.ClassOperator)

Aggregations

ClassOperator (dyvilx.tools.compiler.ast.expression.ClassOperator)1 TypeOperator (dyvilx.tools.compiler.ast.expression.TypeOperator)1 TypeParser (dyvilx.tools.compiler.parser.type.TypeParser)1