Package org.antlr.v4.tool

Examples of org.antlr.v4.tool.Grammar


        "SLL_ATNTransitions=2, SLL_DFATransitions=0, LL_Fallback=0, LL_lookahead=0, LL_ATNTransitions=0}";
    assertEquals(expecting, info[0].toString());
  }

  @Test public void testRepeatedLL2() throws Exception {
    Grammar g = new Grammar(
        "parser grammar T;\n" +
        "s : ID ';'{}\n" +
        "  | ID '.'\n" +
        "  ;\n",
        lg);
View Full Code Here


        "SLL_ATNTransitions=2, SLL_DFATransitions=2, LL_Fallback=0, LL_lookahead=0, LL_ATNTransitions=0}";
    assertEquals(expecting, info[0].toString());
  }

  @Test public void test3xLL2() throws Exception {
    Grammar g = new Grammar(
        "parser grammar T;\n" +
        "s : ID ';'{}\n" +
        "  | ID '.'\n" +
        "  ;\n",
        lg);
View Full Code Here

        "SLL_ATNTransitions=3, SLL_DFATransitions=3, LL_Fallback=0, LL_lookahead=0, LL_ATNTransitions=0}";
    assertEquals(expecting, info[0].toString());
  }

  @Test public void testOptional() throws Exception {
    Grammar g = new Grammar(
        "parser grammar T;\n" +
        "s : ID ('.' ID)? ';'\n" +
        "  | ID INT \n" +
        "  ;\n",
        lg);
View Full Code Here

        "SLL_ATNTransitions=2, SLL_DFATransitions=0, LL_Fallback=0, LL_lookahead=0, LL_ATNTransitions=0}]";
    assertEquals(expecting, Arrays.toString(info));
  }

  @Test public void test2xOptional() throws Exception {
    Grammar g = new Grammar(
        "parser grammar T;\n" +
        "s : ID ('.' ID)? ';'\n" +
        "  | ID INT \n" +
        "  ;\n",
        lg);
View Full Code Here

        "SLL_ATNTransitions=2, SLL_DFATransitions=2, LL_Fallback=0, LL_lookahead=0, LL_ATNTransitions=0}]";
    assertEquals(expecting, Arrays.toString(info));
  }

  @Test public void testContextSensitivity() throws Exception {
    Grammar g = new Grammar(
      "parser grammar T;\n"+
      "a : '.' e ID \n" +
      "  | ';' e INT ID ;\n" +
      "e : INT | ;\n",
      lg);
View Full Code Here

    assertEquals(expecting, info[1].toString());
  }

  @Ignore
  @Test public void testSimpleLanguage() throws Exception {
    Grammar g = new Grammar(TestXPath.grammar);
    String input =
      "def f(x,y) { x = 3+4*1*1/5*1*1+1*1+1; y; ; }\n" +
      "def g(x,a,b,c,d,e) { return 1+2*x; }\n"+
      "def h(x) { a=3; x=0+1; return a*x; }\n";
    DecisionInfo[] info = interpAndGetDecisionInfo(g.getImplicitLexer(), g, "prog", input);
    String expecting =
      "[{decision=0, contextSensitivities=1, errors=0, ambiguities=0, SLL_lookahead=3, " +
      "SLL_ATNTransitions=2, SLL_DFATransitions=0, LL_Fallback=1, LL_ATNTransitions=1}]";


View Full Code Here

    assertEquals(1, info.length);
  }

  @Ignore
  @Test public void testDeepLookahead() throws Exception {
    Grammar g = new Grammar(
        "parser grammar T;\n" +
        "s : e ';'\n" +
        "  | e '.' \n" +
        "  ;\n" +
        "e : (ID|INT) ({true}? '+' e)*\n" +       // d=1 entry, d=2 bypass
View Full Code Here

    }
  }

  public List<String> getEvalInfoForString(String grammarString, String pattern) throws RecognitionException {
    ErrorQueue equeue = new ErrorQueue();
    Grammar g = new Grammar(grammarString);
    List<String> evals = new ArrayList<String>();
    if ( g.ast!=null && !g.ast.hasErrors ) {
      SemanticPipeline sem = new SemanticPipeline(g);
      sem.process();

      ATNFactory factory = new ParserATNFactory(g);
      if (g.isLexer()) factory = new LexerATNFactory((LexerGrammar) g);
      g.atn = factory.createATN();

      CodeGenerator gen = new CodeGenerator(g);
      ST outputFileST = gen.generateParser();
View Full Code Here

public class TestTokenTypeAssignment extends BaseTest {

  @Test
    public void testParserSimpleTokens() throws Exception {
    Grammar g = new Grammar(
        "parser grammar t;\n"+
        "a : A | B;\n" +
        "b : C ;");
    String rules = "a, b";
    String tokenNames = "A, B, C";
View Full Code Here

    String tokenNames = "A, B, C";
    checkSymbols(g, rules, tokenNames);
  }

  @Test public void testParserTokensSection() throws Exception {
    Grammar g = new Grammar(
        "parser grammar t;\n" +
        "tokens {\n" +
        "  C,\n" +
        "  D" +
        "}\n"+
View Full Code Here

TOP

Related Classes of org.antlr.v4.tool.Grammar

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.