Search in sources :

Example 41 with NotNull

use of org.antlr.v4.runtime.misc.NotNull in project antlr4 by tunnelvisionlabs.

the class LexerATNSimulator method match.

public int match(@NotNull CharStream input, int mode) {
    match_calls++;
    this.mode = mode;
    int mark = input.mark();
    try {
        this.startIndex = input.index();
        this.prevAccept.reset();
        DFAState s0 = atn.modeToDFA[mode].s0.get();
        if (s0 == null) {
            return matchATN(input);
        } else {
            return execATN(input, s0);
        }
    } finally {
        input.release(mark);
    }
}
Also used : DFAState(org.antlr.v4.runtime.dfa.DFAState)

Example 42 with NotNull

use of org.antlr.v4.runtime.misc.NotNull in project antlr4 by tunnelvisionlabs.

the class ATN method defineDecisionState.

public int defineDecisionState(@NotNull DecisionState s) {
    decisionToState.add(s);
    s.decision = decisionToState.size() - 1;
    decisionToDFA = Arrays.copyOf(decisionToDFA, decisionToState.size());
    decisionToDFA[decisionToDFA.length - 1] = new DFA(s, s.decision);
    return s.decision;
}
Also used : DFA(org.antlr.v4.runtime.dfa.DFA)

Example 43 with NotNull

use of org.antlr.v4.runtime.misc.NotNull in project sqldelight by square.

the class AntlrParser method parse.

@NotNull
@Override
public ASTNode parse(IElementType root, PsiBuilder builder) {
    TParser parser = createParser(root, builder);
    ParseTree parseTree = parse(parser, root, builder);
    AstBuilderListener listener = createListener(parser, root, builder);
    walkParseTree(parseTree, listener, root, builder);
    return builder.getTreeBuilt();
}
Also used : ParseTree(org.antlr.v4.runtime.tree.ParseTree) NotNull(org.jetbrains.annotations.NotNull)

Example 44 with NotNull

use of org.antlr.v4.runtime.misc.NotNull in project scheduler by btrplace.

the class MyCstrSpecVisitor method visitCstrCall.

@Override
public ConstraintCall visitCstrCall(@NotNull CstrSpecParser.CstrCallContext ctx) {
    List<Term> ps = ctx.call().term().stream().map(t -> (Term<?>) visit(t)).collect(Collectors.toList());
    Function f = resolveFunction(ctx.call().ID().getSymbol(), ps);
    return new ConstraintCall(f, ps);
}
Also used : FunctionCall(org.btrplace.safeplace.spec.term.func.FunctionCall) org.btrplace.safeplace.spec.term(org.btrplace.safeplace.spec.term) CstrSpecParser(org.btrplace.safeplace.spec.antlr.CstrSpecParser) Function(org.btrplace.safeplace.spec.term.func.Function) Token(org.antlr.v4.runtime.Token) NotNull(org.antlr.v4.runtime.misc.NotNull) org.btrplace.safeplace.spec.prop(org.btrplace.safeplace.spec.prop) Collectors(java.util.stream.Collectors) TerminalNode(org.antlr.v4.runtime.tree.TerminalNode) ArrayList(java.util.ArrayList) List(java.util.List) org.btrplace.safeplace.spec.type(org.btrplace.safeplace.spec.type) ValueAt(org.btrplace.safeplace.spec.term.func.ValueAt) ParseTree(org.antlr.v4.runtime.tree.ParseTree) CstrSpecBaseVisitor(org.btrplace.safeplace.spec.antlr.CstrSpecBaseVisitor) Function(org.btrplace.safeplace.spec.term.func.Function)

Example 45 with NotNull

use of org.antlr.v4.runtime.misc.NotNull in project redsnake by Taken0711.

the class TestUtils method parseStatement.

public static Statement parseStatement(@NotNull String s) {
    CharStream inputStream = CharStreams.fromString(s);
    RedsnakeLexer redsnakeLexer = new RedsnakeLexer(inputStream);
    TokenStream commonTokenStream = new CommonTokenStream(redsnakeLexer);
    RedsnakeParser parser = new RedsnakeParser(commonTokenStream);
    ParseTree t = parser.expression();
    return (Expression) new ASTBuilder().visit(t);
}
Also used : RedsnakeLexer(net.taken.redsnake.parser.RedsnakeLexer) RedsnakeParser(net.taken.redsnake.parser.RedsnakeParser) Expression(net.taken.redsnake.tree.statements.expressions.Expression) ASTBuilder(net.taken.redsnake.parser.visitors.ASTBuilder) ParseTree(org.antlr.v4.runtime.tree.ParseTree)

Aggregations

NotNull (org.antlr.v4.runtime.misc.NotNull)40 ATNState (org.antlr.v4.runtime.atn.ATNState)14 IntervalSet (org.antlr.v4.runtime.misc.IntervalSet)14 DFAState (org.antlr.v4.runtime.dfa.DFAState)12 ParseTree (org.antlr.v4.runtime.tree.ParseTree)9 ParserRuleContext (org.antlr.v4.runtime.ParserRuleContext)8 ArrayList (java.util.ArrayList)7 Token (org.antlr.v4.runtime.Token)7 RuleTransition (org.antlr.v4.runtime.atn.RuleTransition)4 DFA (org.antlr.v4.runtime.dfa.DFA)4 TerminalNode (org.antlr.v4.runtime.tree.TerminalNode)4 GrammarAST (org.antlr.v4.tool.ast.GrammarAST)4 QuantifierAST (org.antlr.v4.tool.ast.QuantifierAST)4 List (java.util.List)3 ATN (org.antlr.v4.runtime.atn.ATN)3 BlockEndState (org.antlr.v4.runtime.atn.BlockEndState)3 Transition (org.antlr.v4.runtime.atn.Transition)3 WildcardTransition (org.antlr.v4.runtime.atn.WildcardTransition)3 Interval (org.antlr.v4.runtime.misc.Interval)3 Nullable (org.antlr.v4.runtime.misc.Nullable)3