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);
}
}
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);
}
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;
}
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);
}
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);
}
Aggregations