Search in sources :

Example 1 with ContextRuleListIndexedGetterDecl

use of org.antlr.v4.codegen.model.decl.ContextRuleListIndexedGetterDecl 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;
}
Also used : ContextTokenListGetterDecl(org.antlr.v4.codegen.model.decl.ContextTokenListGetterDecl) ContextRuleListGetterDecl(org.antlr.v4.codegen.model.decl.ContextRuleListGetterDecl) ContextTokenGetterDecl(org.antlr.v4.codegen.model.decl.ContextTokenGetterDecl) ContextRuleGetterDecl(org.antlr.v4.codegen.model.decl.ContextRuleGetterDecl) ArrayList(java.util.ArrayList) ContextRuleListGetterDecl(org.antlr.v4.codegen.model.decl.ContextRuleListGetterDecl) Decl(org.antlr.v4.codegen.model.decl.Decl) StructDecl(org.antlr.v4.codegen.model.decl.StructDecl) AttributeDecl(org.antlr.v4.codegen.model.decl.AttributeDecl) AltLabelStructDecl(org.antlr.v4.codegen.model.decl.AltLabelStructDecl) ContextTokenListGetterDecl(org.antlr.v4.codegen.model.decl.ContextTokenListGetterDecl) ContextRuleListIndexedGetterDecl(org.antlr.v4.codegen.model.decl.ContextRuleListIndexedGetterDecl) ContextRuleGetterDecl(org.antlr.v4.codegen.model.decl.ContextRuleGetterDecl) ContextTokenListIndexedGetterDecl(org.antlr.v4.codegen.model.decl.ContextTokenListIndexedGetterDecl) ContextTokenGetterDecl(org.antlr.v4.codegen.model.decl.ContextTokenGetterDecl) ContextRuleListIndexedGetterDecl(org.antlr.v4.codegen.model.decl.ContextRuleListIndexedGetterDecl) Rule(org.antlr.v4.tool.Rule) ContextTokenListIndexedGetterDecl(org.antlr.v4.codegen.model.decl.ContextTokenListIndexedGetterDecl)

Aggregations

ArrayList (java.util.ArrayList)1 AltLabelStructDecl (org.antlr.v4.codegen.model.decl.AltLabelStructDecl)1 AttributeDecl (org.antlr.v4.codegen.model.decl.AttributeDecl)1 ContextRuleGetterDecl (org.antlr.v4.codegen.model.decl.ContextRuleGetterDecl)1 ContextRuleListGetterDecl (org.antlr.v4.codegen.model.decl.ContextRuleListGetterDecl)1 ContextRuleListIndexedGetterDecl (org.antlr.v4.codegen.model.decl.ContextRuleListIndexedGetterDecl)1 ContextTokenGetterDecl (org.antlr.v4.codegen.model.decl.ContextTokenGetterDecl)1 ContextTokenListGetterDecl (org.antlr.v4.codegen.model.decl.ContextTokenListGetterDecl)1 ContextTokenListIndexedGetterDecl (org.antlr.v4.codegen.model.decl.ContextTokenListIndexedGetterDecl)1 Decl (org.antlr.v4.codegen.model.decl.Decl)1 StructDecl (org.antlr.v4.codegen.model.decl.StructDecl)1 Rule (org.antlr.v4.tool.Rule)1