use of org.antlr.v4.runtime.atn.Transition in project antlr4 by antlr.
the class ParserATNFactory method sempred.
/** Build what amounts to an epsilon transition with a semantic
* predicate action. The {@code pred} is a pointer into the AST of
* the {@link ANTLRParser#SEMPRED} token.
*/
@Override
public Handle sempred(PredAST pred) {
//System.out.println("sempred: "+ pred);
ATNState left = newState(pred);
ATNState right = newState(pred);
AbstractPredicateTransition p;
if (pred.getOptionString(LeftRecursiveRuleTransformer.PRECEDENCE_OPTION_NAME) != null) {
int precedence = Integer.parseInt(pred.getOptionString(LeftRecursiveRuleTransformer.PRECEDENCE_OPTION_NAME));
p = new PrecedencePredicateTransition(right, precedence);
} else {
boolean isCtxDependent = UseDefAnalyzer.actionIsContextDependent(pred);
p = new PredicateTransition(right, currentRule.index, g.sempreds.get(pred), isCtxDependent);
}
left.addTransition(p);
pred.atnState = left;
return new Handle(left, right);
}
use of org.antlr.v4.runtime.atn.Transition in project antlr4 by antlr.
the class ParserATNFactory method action.
/** Build what amounts to an epsilon transition with an action.
* The action goes into ATN though it is ignored during prediction
* if {@link ActionTransition#actionIndex actionIndex}{@code <0}.
*/
@Override
public Handle action(ActionAST action) {
//System.out.println("action: "+action);
ATNState left = newState(action);
ATNState right = newState(action);
ActionTransition a = new ActionTransition(right, currentRule.index);
left.addTransition(a);
action.atnState = left;
return new Handle(left, right);
}
Aggregations