Search in sources :

Example 11 with DecisionInfo

use of org.antlr.v4.runtime.atn.DecisionInfo in project antlr4 by antlr.

the class TestParserProfiler method testLL1.

@Test
public void testLL1() throws Exception {
    Grammar g = new Grammar("parser grammar T;\n" + "s : ';'{}\n" + "  | '.'\n" + "  ;\n", lg);
    DecisionInfo[] info = interpAndGetDecisionInfo(lg, g, "s", ";");
    assertEquals(1, info.length);
    String expecting = "{decision=0, contextSensitivities=0, errors=0, ambiguities=0, SLL_lookahead=1, " + "SLL_ATNTransitions=1, SLL_DFATransitions=0, LL_Fallback=0, LL_lookahead=0, LL_ATNTransitions=0}";
    assertEquals(expecting, info[0].toString());
}
Also used : DecisionInfo(org.antlr.v4.runtime.atn.DecisionInfo) Grammar(org.antlr.v4.tool.Grammar) LexerGrammar(org.antlr.v4.tool.LexerGrammar) Test(org.junit.Test)

Example 12 with DecisionInfo

use of org.antlr.v4.runtime.atn.DecisionInfo in project antlr4 by antlr.

the class TestParserProfiler method test3xLL2.

@Test
public void test3xLL2() throws Exception {
    Grammar g = new Grammar("parser grammar T;\n" + "s : ID ';'{}\n" + "  | ID '.'\n" + "  ;\n", lg);
    // The '.' vs ';' causes another ATN transition
    DecisionInfo[] info = interpAndGetDecisionInfo(lg, g, "s", "xyz;", "abc;", "z.");
    assertEquals(1, info.length);
    String expecting = "{decision=0, contextSensitivities=0, errors=0, ambiguities=0, SLL_lookahead=6, " + "SLL_ATNTransitions=3, SLL_DFATransitions=3, LL_Fallback=0, LL_lookahead=0, LL_ATNTransitions=0}";
    assertEquals(expecting, info[0].toString());
}
Also used : DecisionInfo(org.antlr.v4.runtime.atn.DecisionInfo) Grammar(org.antlr.v4.tool.Grammar) LexerGrammar(org.antlr.v4.tool.LexerGrammar) Test(org.junit.Test)

Aggregations

DecisionInfo (org.antlr.v4.runtime.atn.DecisionInfo)11 Grammar (org.antlr.v4.tool.Grammar)9 LexerGrammar (org.antlr.v4.tool.LexerGrammar)9 Test (org.junit.Test)9 ANTLRInputStream (org.antlr.v4.runtime.ANTLRInputStream)3 CommonTokenStream (org.antlr.v4.runtime.CommonTokenStream)3 LexerInterpreter (org.antlr.v4.runtime.LexerInterpreter)3 ParserRuleContext (org.antlr.v4.runtime.ParserRuleContext)3 GrammarParserInterpreter (org.antlr.v4.tool.GrammarParserInterpreter)2 Ignore (org.junit.Ignore)2 ParserInterpreter (org.antlr.v4.runtime.ParserInterpreter)1 AmbiguityInfo (org.antlr.v4.runtime.atn.AmbiguityInfo)1 LookaheadEventInfo (org.antlr.v4.runtime.atn.LookaheadEventInfo)1 ParseTree (org.antlr.v4.runtime.tree.ParseTree)1 Rule (org.antlr.v4.tool.Rule)1