use of org.antlr.v4.codegen.model.Action in project antlr4 by antlr.
the class DefaultOutputModelFactory method rulePostamble.
@Override
public List<SrcOp> rulePostamble(RuleFunction function, Rule r) {
if (r.namedActions.containsKey("after") || r.namedActions.containsKey("finally")) {
// See OutputModelController.buildLeftRecursiveRuleFunction
// and Parser.exitRule for other places which set stop.
CodeGenerator gen = getGenerator();
STGroup codegenTemplates = gen.getTemplates();
ST setStopTokenAST = codegenTemplates.getInstanceOf("recRuleSetStopToken");
Action setStopTokenAction = new Action(this, function.ruleCtx, setStopTokenAST);
List<SrcOp> ops = new ArrayList<SrcOp>(1);
ops.add(setStopTokenAction);
return ops;
}
return super.rulePostamble(function, r);
}
use of org.antlr.v4.codegen.model.Action in project antlr4 by antlr.
the class RuleFunction method fillNamedActions.
public void fillNamedActions(OutputModelFactory factory, Rule r) {
if (r.finallyAction != null) {
finallyAction = new Action(factory, r.finallyAction);
}
namedActions = new HashMap<String, Action>();
for (String name : r.namedActions.keySet()) {
ActionAST ast = r.namedActions.get(name);
namedActions.put(name, new Action(factory, ast));
}
}
Aggregations