Search in sources :

Example 1 with LL1OptionalBlock

use of org.antlr.v4.codegen.model.LL1OptionalBlock in project antlr4 by antlr.

the class ParserFactory method getLL1EBNFBlock.

@Override
public Choice getLL1EBNFBlock(GrammarAST ebnfRoot, List<CodeBlockForAlt> alts) {
    int ebnf = 0;
    if (ebnfRoot != null)
        ebnf = ebnfRoot.getType();
    Choice c = null;
    switch(ebnf) {
        case ANTLRParser.OPTIONAL:
            if (alts.size() == 1)
                c = new LL1OptionalBlockSingleAlt(this, ebnfRoot, alts);
            else
                c = new LL1OptionalBlock(this, ebnfRoot, alts);
            break;
        case ANTLRParser.CLOSURE:
            if (alts.size() == 1)
                c = new LL1StarBlockSingleAlt(this, ebnfRoot, alts);
            else
                c = getComplexEBNFBlock(ebnfRoot, alts);
            break;
        case ANTLRParser.POSITIVE_CLOSURE:
            if (alts.size() == 1)
                c = new LL1PlusBlockSingleAlt(this, ebnfRoot, alts);
            else
                c = getComplexEBNFBlock(ebnfRoot, alts);
            break;
    }
    return c;
}
Also used : Choice(org.antlr.v4.codegen.model.Choice) LL1OptionalBlockSingleAlt(org.antlr.v4.codegen.model.LL1OptionalBlockSingleAlt) LL1PlusBlockSingleAlt(org.antlr.v4.codegen.model.LL1PlusBlockSingleAlt) LL1OptionalBlock(org.antlr.v4.codegen.model.LL1OptionalBlock) LL1StarBlockSingleAlt(org.antlr.v4.codegen.model.LL1StarBlockSingleAlt)

Aggregations

Choice (org.antlr.v4.codegen.model.Choice)1 LL1OptionalBlock (org.antlr.v4.codegen.model.LL1OptionalBlock)1 LL1OptionalBlockSingleAlt (org.antlr.v4.codegen.model.LL1OptionalBlockSingleAlt)1 LL1PlusBlockSingleAlt (org.antlr.v4.codegen.model.LL1PlusBlockSingleAlt)1 LL1StarBlockSingleAlt (org.antlr.v4.codegen.model.LL1StarBlockSingleAlt)1