Search in sources :

Example 91 with ATNState

use of org.antlr.v4.runtime.atn.ATNState in project antlr4 by tunnelvisionlabs.

the class ATNVisitor method visit_.

public void visit_(@NotNull ATNState s, @NotNull Set<Integer> visited) {
    if (!visited.add(s.stateNumber))
        return;
    visited.add(s.stateNumber);
    visitState(s);
    int n = s.getNumberOfTransitions();
    for (int i = 0; i < n; i++) {
        Transition t = s.transition(i);
        visit_(t.target, visited);
    }
}
Also used : Transition(org.antlr.v4.runtime.atn.Transition)

Example 92 with ATNState

use of org.antlr.v4.runtime.atn.ATNState in project antlr4 by tunnelvisionlabs.

the class LexerATNFactory method action.

@Override
public Handle action(String action) {
    if (action.trim().isEmpty()) {
        ATNState left = newState(null);
        ATNState right = newState(null);
        epsilon(left, right);
        return new Handle(left, right);
    }
    // define action AST for this rule as if we had found in grammar
    ActionAST ast = new ActionAST(new CommonToken(ANTLRParser.ACTION, action));
    currentRule.defineActionInAlt(currentOuterAlt, ast);
    return action(ast);
}
Also used : CommonToken(org.antlr.runtime.CommonToken) ATNState(org.antlr.v4.runtime.atn.ATNState) ActionAST(org.antlr.v4.tool.ast.ActionAST)

Example 93 with ATNState

use of org.antlr.v4.runtime.atn.ATNState in project antlr4 by tunnelvisionlabs.

the class LexerATNFactory method action.

protected Handle action(GrammarAST node, LexerAction lexerAction) {
    ATNState left = newState(node);
    ATNState right = newState(node);
    boolean isCtxDependent = false;
    int lexerActionIndex = getLexerActionIndex(lexerAction);
    ActionTransition a = new ActionTransition(right, currentRule.index, lexerActionIndex, isCtxDependent);
    left.addTransition(a);
    node.atnState = left;
    Handle h = new Handle(left, right);
    return h;
}
Also used : ActionTransition(org.antlr.v4.runtime.atn.ActionTransition) ATNState(org.antlr.v4.runtime.atn.ATNState)

Example 94 with ATNState

use of org.antlr.v4.runtime.atn.ATNState in project antlr4 by tunnelvisionlabs.

the class ParserATNFactory method wildcard.

/**
 * Build an atom with all possible values in its label.
 */
@NotNull
@Override
public Handle wildcard(@NotNull GrammarAST node) {
    ATNState left = newState(node);
    ATNState right = newState(node);
    left.addTransition(new WildcardTransition(right));
    node.atnState = left;
    return new Handle(left, right);
}
Also used : WildcardTransition(org.antlr.v4.runtime.atn.WildcardTransition) ATNState(org.antlr.v4.runtime.atn.ATNState) NotNull(org.antlr.v4.runtime.misc.NotNull)

Example 95 with ATNState

use of org.antlr.v4.runtime.atn.ATNState in project antlr4 by tunnelvisionlabs.

the class ParserATNFactory method addFollowLink.

public void addFollowLink(int ruleIndex, ATNState right) {
    // add follow edge from end of invoked rule
    RuleStopState stop = atn.ruleToStopState[ruleIndex];
    // System.out.println("add follow link from "+ruleIndex+" to "+right);
    epsilon(stop, right);
}
Also used : RuleStopState(org.antlr.v4.runtime.atn.RuleStopState)

Aggregations

ATNState (org.antlr.v4.runtime.atn.ATNState)94 IntervalSet (org.antlr.v4.runtime.misc.IntervalSet)34 ATN (org.antlr.v4.runtime.atn.ATN)25 RuleTransition (org.antlr.v4.runtime.atn.RuleTransition)23 Rule (org.antlr.v4.tool.Rule)22 Transition (org.antlr.v4.runtime.atn.Transition)21 NotNull (org.antlr.v4.runtime.misc.NotNull)19 AtomTransition (org.antlr.v4.runtime.atn.AtomTransition)18 RuleStartState (org.antlr.v4.runtime.atn.RuleStartState)17 ActionTransition (org.antlr.v4.runtime.atn.ActionTransition)16 SetTransition (org.antlr.v4.runtime.atn.SetTransition)16 NotSetTransition (org.antlr.v4.runtime.atn.NotSetTransition)15 DecisionState (org.antlr.v4.runtime.atn.DecisionState)11 DOTGenerator (org.antlr.v4.tool.DOTGenerator)10 GrammarAST (org.antlr.v4.tool.ast.GrammarAST)10 ParserATNFactory (org.antlr.v4.automata.ParserATNFactory)9 LeftRecursiveRule (org.antlr.v4.tool.LeftRecursiveRule)9 ArrayList (java.util.ArrayList)8 EpsilonTransition (org.antlr.v4.runtime.atn.EpsilonTransition)8 PrecedencePredicateTransition (org.antlr.v4.runtime.atn.PrecedencePredicateTransition)8