use of org.antlr.v4.codegen.model.decl.ContextTokenListGetterDecl in project antlr4 by tunnelvisionlabs.
the class RuleFunction method getDeclForAltElement.
public List<Decl> getDeclForAltElement(GrammarAST t, String refLabelName, boolean needList, boolean optional) {
int lfIndex = refLabelName.indexOf(ATNSimulator.RULE_VARIANT_DELIMITER);
if (lfIndex >= 0) {
refLabelName = refLabelName.substring(0, lfIndex);
}
List<Decl> decls = new ArrayList<Decl>();
if (t.getType() == RULE_REF) {
Rule rref = factory.getGrammar().getRule(t.getText());
String ctxName = factory.getTarget().getRuleFunctionContextStructName(rref);
if (needList) {
if (factory.getTarget().supportsOverloadedMethods())
decls.add(new ContextRuleListGetterDecl(factory, refLabelName, ctxName));
decls.add(new ContextRuleListIndexedGetterDecl(factory, refLabelName, ctxName));
} else {
decls.add(new ContextRuleGetterDecl(factory, refLabelName, ctxName, optional));
}
} else {
if (needList) {
if (factory.getTarget().supportsOverloadedMethods())
decls.add(new ContextTokenListGetterDecl(factory, refLabelName));
decls.add(new ContextTokenListIndexedGetterDecl(factory, refLabelName));
} else {
decls.add(new ContextTokenGetterDecl(factory, refLabelName, optional));
}
}
return decls;
}
use of org.antlr.v4.codegen.model.decl.ContextTokenListGetterDecl in project antlr4 by antlr.
the class RuleFunction method getDeclForAltElement.
public List<Decl> getDeclForAltElement(GrammarAST t, String refLabelName, boolean needList, boolean optional) {
List<Decl> decls = new ArrayList<Decl>();
if (t.getType() == RULE_REF) {
Rule rref = factory.getGrammar().getRule(t.getText());
String ctxName = factory.getGenerator().getTarget().getRuleFunctionContextStructName(rref);
if (needList) {
if (factory.getGenerator().getTarget().supportsOverloadedMethods())
decls.add(new ContextRuleListGetterDecl(factory, refLabelName, ctxName));
decls.add(new ContextRuleListIndexedGetterDecl(factory, refLabelName, ctxName));
} else {
decls.add(new ContextRuleGetterDecl(factory, refLabelName, ctxName, optional));
}
} else {
if (needList) {
if (factory.getGenerator().getTarget().supportsOverloadedMethods())
decls.add(new ContextTokenListGetterDecl(factory, refLabelName));
decls.add(new ContextTokenListIndexedGetterDecl(factory, refLabelName));
} else {
decls.add(new ContextTokenGetterDecl(factory, refLabelName, optional));
}
}
return decls;
}
Aggregations