Search in sources :

Example 11 with Wildcard

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

the class ParserATNFactory method wildcard.

/**
 * Build an atom with all possible values in its label.
 */
@Override
public Handle wildcard(GrammarAST node) {
    ATNState left = newState(node);
    ATNState right = newState(node);
    left.addTransition(new WildcardTransition(right));
    node.atnState = left;
    return new Handle(left, right);
}
Also used : WildcardTransition(org.antlr.v4.runtime.atn.WildcardTransition) ATNState(org.antlr.v4.runtime.atn.ATNState)

Example 12 with Wildcard

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

the class ParserFactory method wildcard.

@Override
public List<SrcOp> wildcard(GrammarAST ast, GrammarAST labelAST) {
    Wildcard wild = new Wildcard(this, ast);
    // TODO: dup with tokenRef
    if (labelAST != null) {
        String label = labelAST.getText();
        Decl d = getTokenLabelDecl(label);
        wild.labels.add(d);
        getCurrentRuleFunction().addContextDecl(ast.getAltLabel(), d);
        if (labelAST.parent.getType() == ANTLRParser.PLUS_ASSIGN) {
            TokenListDecl l = getTokenListLabelDecl(label);
            getCurrentRuleFunction().addContextDecl(ast.getAltLabel(), l);
        }
    }
    if (controller.needsImplicitLabel(ast, wild))
        defineImplicitLabel(ast, wild);
    AddToLabelList listLabelOp = getAddToListOpIfListLabelPresent(wild, labelAST);
    return list(wild, listLabelOp);
}
Also used : Wildcard(org.antlr.v4.codegen.model.Wildcard) TokenListDecl(org.antlr.v4.codegen.model.decl.TokenListDecl) TokenDecl(org.antlr.v4.codegen.model.decl.TokenDecl) Decl(org.antlr.v4.codegen.model.decl.Decl) TokenListDecl(org.antlr.v4.codegen.model.decl.TokenListDecl) RuleContextDecl(org.antlr.v4.codegen.model.decl.RuleContextDecl) AddToLabelList(org.antlr.v4.codegen.model.AddToLabelList)

Aggregations

LexerGrammar (org.antlr.v4.tool.LexerGrammar)6 Test (org.junit.Test)6 ATN (org.antlr.v4.runtime.atn.ATN)4 AddToLabelList (org.antlr.v4.codegen.model.AddToLabelList)2 Wildcard (org.antlr.v4.codegen.model.Wildcard)2 Decl (org.antlr.v4.codegen.model.decl.Decl)2 RuleContextDecl (org.antlr.v4.codegen.model.decl.RuleContextDecl)2 TokenDecl (org.antlr.v4.codegen.model.decl.TokenDecl)2 TokenListDecl (org.antlr.v4.codegen.model.decl.TokenListDecl)2 ATNState (org.antlr.v4.runtime.atn.ATNState)2 WildcardTransition (org.antlr.v4.runtime.atn.WildcardTransition)2 Grammar (org.antlr.v4.tool.Grammar)2 CommonToken (org.antlr.v4.runtime.CommonToken)1 LexerNoViableAltException (org.antlr.v4.runtime.LexerNoViableAltException)1 NotNull (org.antlr.v4.runtime.misc.NotNull)1 ParseTree (org.antlr.v4.runtime.tree.ParseTree)1 BatfishException (org.batfish.common.BatfishException)1 HierarchyPath (org.batfish.grammar.flatjuniper.Hierarchy.HierarchyTree.HierarchyPath)1