Search in sources :

Example 1 with SourceFileParser

use of dyvilx.tools.compiler.parser.header.SourceFileParser in project Dyvil by Dyvil.

the class REPLParser method parse.

@Override
public void parse(IParserManager pm, IToken token) {
    final int type = token.type();
    if (type == Tokens.EOF) {
        pm.popParser();
        return;
    }
    switch(this.mode) {
        case ELEMENT:
            this.mode = SEPARATOR;
            if (TRY_PARSER.tryParse(pm, new SourceFileParser(this.context).withFlags(ONE_ELEMENT | NO_CLASSES), token, EXIT_ON_ROOT)) {
                return;
            }
            if (TRY_PARSER.tryParse(pm, new MemberParser<>(this.context), token, EXIT_ON_ROOT)) {
                return;
            }
            pm.pushParser(new ExpressionParser(this.context));
            return;
        case SEPARATOR:
            this.mode = ELEMENT;
            switch(type) {
                case BaseSymbols.SEMICOLON:
                case BaseSymbols.COMMA:
                    return;
            }
            pm.report(token, "statement_list.semicolon");
    }
}
Also used : SourceFileParser(dyvilx.tools.compiler.parser.header.SourceFileParser) ExpressionParser(dyvilx.tools.compiler.parser.expression.ExpressionParser)

Example 2 with SourceFileParser

use of dyvilx.tools.compiler.parser.header.SourceFileParser in project Dyvil by Dyvil.

the class ClassUnit method parse.

@Override
public void parse() {
    new ParserManager(DyvilSymbols.INSTANCE, this.tokens.iterator(), this.markers).parse(new SourceFileParser(this));
    this.tokens = null;
}
Also used : ParserManager(dyvilx.tools.parsing.ParserManager) SourceFileParser(dyvilx.tools.compiler.parser.header.SourceFileParser)

Aggregations

SourceFileParser (dyvilx.tools.compiler.parser.header.SourceFileParser)2 ExpressionParser (dyvilx.tools.compiler.parser.expression.ExpressionParser)1 ParserManager (dyvilx.tools.parsing.ParserManager)1