Package org.antlr.v4.tool

Examples of org.antlr.v4.tool.LexerGrammar


  /**
   * This is a regression test for antlr/antlr4#461.
   * https://github.com/antlr/antlr4/issues/461
   */
  @Test public void testLeftRecursiveStartRule() throws Exception {
    LexerGrammar lg = new LexerGrammar(
      "lexer grammar L;\n" +
      "A : 'a' ;\n" +
      "B : 'b' ;\n" +
      "C : 'c' ;\n" +
      "PLUS : '+' ;\n" +
View Full Code Here


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

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

        "s3->RuleStop_a_1\n" +
        "RuleStop_a_1-EOF->s4\n";
    checkRuleATN(g, "a", expecting);
  }
  @Test public void testLexerIsntSetMultiCharString() throws Exception {
    LexerGrammar g = new LexerGrammar(
      "lexer grammar P;\n"+
      "A : ('0x' | '0X') ;");
    String expecting =
      "s0->RuleStart_A_1\n" +
        "RuleStart_A_1->BlockStart_7\n" +
View Full Code Here

        "s6-'X'->BlockEnd_8\n" +
        "BlockEnd_8->RuleStop_A_2\n";
    checkTokensRule(g, null, expecting);
  }
  @Test public void testRange() throws Exception {
    LexerGrammar g = new LexerGrammar(
      "lexer grammar P;\n"+
      "A : 'a'..'c' ;"
    );
    String expecting =
      "s0->RuleStart_A_1\n" +
View Full Code Here

        "s3-'a'..'c'->s4\n" +
        "s4->RuleStop_A_2\n";
    checkTokensRule(g, null, expecting);
  }
  @Test public void testRangeOrRange() throws Exception {
    LexerGrammar g = new LexerGrammar(
      "lexer grammar P;\n"+
      "A : ('a'..'c' 'h' | 'q' 'j'..'l') ;"
    );
    String expecting =
      "s0->RuleStart_A_1\n" +
View Full Code Here

      ":s6-EOF->.s7\n";
    checkRule(g, "a", expecting);
  }
*/
  @Test public void testDefaultMode() throws Exception {
    LexerGrammar g = new LexerGrammar(
      "lexer grammar L;\n"+
      "A : 'a' ;\n" +
      "X : 'x' ;\n" +
      "mode FOO;\n" +
      "B : 'b' ;\n" +
View Full Code Here

        "s11->RuleStop_A_3\n" +
        "s13->RuleStop_X_5\n";
    checkTokensRule(g, "DEFAULT_MODE", expecting);
  }
  @Test public void testMode() throws Exception {
    LexerGrammar g = new LexerGrammar(
      "lexer grammar L;\n"+
      "A : 'a' ;\n" +
      "X : 'x' ;\n" +
      "mode FOO;\n" +
      "B : 'b' ;\n" +
View Full Code Here

      "e : E ;\n");
    checkDeserializationIsStable(g);
  }

  @Test public void testLexerTwoRules() throws Exception {
    LexerGrammar lg = new LexerGrammar(
      "lexer grammar L;\n"+
      "A : 'a' ;\n" +
      "B : 'b' ;\n");
    checkDeserializationIsStable(lg);
  }
View Full Code Here

      "B : 'b' ;\n");
    checkDeserializationIsStable(lg);
  }

  @Test public void testLexerEOF() throws Exception {
    LexerGrammar lg = new LexerGrammar(
      "lexer grammar L;\n"+
      "A : 'a' EOF ;\n");
    checkDeserializationIsStable(lg);
  }
View Full Code Here

      "A : 'a' EOF ;\n");
    checkDeserializationIsStable(lg);
  }

  @Test public void testLexerEOFInSet() throws Exception {
    LexerGrammar lg = new LexerGrammar(
      "lexer grammar L;\n"+
      "A : 'a' (EOF|'\\n') ;\n");
    checkDeserializationIsStable(lg);
  }
View Full Code Here

TOP

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

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.