use of org.antlr.v4.codegen.model.decl.RuleContextDecl in project antlr4 by tunnelvisionlabs.
the class ParserFactory method defineImplicitLabel.
// support
public void defineImplicitLabel(GrammarAST ast, LabeledOp op) {
Decl d;
if (ast.getType() == ANTLRParser.SET || ast.getType() == ANTLRParser.WILDCARD) {
String implLabel = getTarget().getImplicitSetLabel(String.valueOf(ast.token.getTokenIndex()));
d = getTokenLabelDecl(implLabel);
((TokenDecl) d).isImplicit = true;
} else if (ast.getType() == ANTLRParser.RULE_REF) {
// a rule reference?
Rule r = g.getRule(ast.getText());
String implLabel = getTarget().getImplicitRuleLabel(ast.getText());
String ctxName = getTarget().getRuleFunctionContextStructName(r);
d = new RuleContextDecl(this, implLabel, ctxName);
((RuleContextDecl) d).isImplicit = true;
} else {
String implLabel = getTarget().getImplicitTokenLabel(ast.getText());
d = getTokenLabelDecl(implLabel);
((TokenDecl) d).isImplicit = true;
}
op.getLabels().add(d);
// all labels must be in scope struct in case we exec action out of context
getCurrentRuleFunction().addContextDecl(ast.getAltLabel(), d);
}
use of org.antlr.v4.codegen.model.decl.RuleContextDecl in project antlr4 by antlr.
the class ParserFactory method defineImplicitLabel.
// support
public void defineImplicitLabel(GrammarAST ast, LabeledOp op) {
Decl d;
if (ast.getType() == ANTLRParser.SET || ast.getType() == ANTLRParser.WILDCARD) {
String implLabel = gen.getTarget().getImplicitSetLabel(String.valueOf(ast.token.getTokenIndex()));
d = getTokenLabelDecl(implLabel);
((TokenDecl) d).isImplicit = true;
} else if (ast.getType() == ANTLRParser.RULE_REF) {
// a rule reference?
Rule r = g.getRule(ast.getText());
String implLabel = gen.getTarget().getImplicitRuleLabel(ast.getText());
String ctxName = gen.getTarget().getRuleFunctionContextStructName(r);
d = new RuleContextDecl(this, implLabel, ctxName);
((RuleContextDecl) d).isImplicit = true;
} else {
String implLabel = gen.getTarget().getImplicitTokenLabel(ast.getText());
d = getTokenLabelDecl(implLabel);
((TokenDecl) d).isImplicit = true;
}
op.getLabels().add(d);
// all labels must be in scope struct in case we exec action out of context
getCurrentRuleFunction().addContextDecl(ast.getAltLabel(), d);
}
Aggregations