Package org.antlr.v4.tool

Examples of org.antlr.v4.tool.LexerGrammar


import static org.junit.Assert.assertEquals;


public class TestParserInterpreter extends BaseTest {
  @Test public void testA() throws Exception {
    LexerGrammar lg = new LexerGrammar(
      "lexer grammar L;\n" +
      "A : 'a' ;\n");
    Grammar g = new Grammar(
      "parser grammar T;\n" +
      "s : A ;",
View Full Code Here


    testInterp(lg, g, "s", "a", "(s a)");
  }

  @Test public void testAorB() throws Exception {
    LexerGrammar lg = new LexerGrammar(
      "lexer grammar L;\n" +
      "A : 'a' ;\n" +
      "B : 'b' ;\n" +
      "C : 'c' ;\n");
    Grammar g = new Grammar(
View Full Code Here

  LexerGrammar lg;

  @Override
  public void setUp() throws Exception {
    super.setUp();
    lg = new LexerGrammar(
        "lexer grammar L;\n" +
        "WS : [ \\r\\t\\n]+ -> channel(HIDDEN) ;\n" +
        "SEMI : ';' ;\n" +
        "DOT : '.' ;\n" +
        "ID : [a-zA-Z]+ ;\n" +
View Full Code Here

    testInterp(lg, g, "s", "a", "(s a)");
    testInterp(lg, g, "s", "b", "(s b)");
  }

  @Test public void testCall() throws Exception {
    LexerGrammar lg = new LexerGrammar(
      "lexer grammar L;\n" +
      "A : 'a' ;\n" +
      "B : 'b' ;\n" +
      "C : 'c' ;\n");
    Grammar g = new Grammar(
View Full Code Here

    testInterp(lg, g, "s", "ac", "(s (t a) c)");
    testInterp(lg, g, "s", "bc", "(s (t b) c)");
  }

  @Test public void testCall2() throws Exception {
    LexerGrammar lg = new LexerGrammar(
      "lexer grammar L;\n" +
      "A : 'a' ;\n" +
      "B : 'b' ;\n" +
      "C : 'c' ;\n");
    Grammar g = new Grammar(
View Full Code Here

    testInterp(lg, g, "s", "ac", "(s (t (u a)) c)");
    testInterp(lg, g, "s", "bc", "(s (t (u b)) c)");
  }

  @Test public void testOptionalA() throws Exception {
    LexerGrammar lg = new LexerGrammar(
      "lexer grammar L;\n" +
      "A : 'a' ;\n" +
      "B : 'b' ;\n" +
      "C : 'c' ;\n");
    Grammar g = new Grammar(
View Full Code Here

    testInterp(lg, g, "s", "b", "(s b)");
    testInterp(lg, g, "s", "ab", "(s a b)");
  }

  @Test public void testOptionalAorB() throws Exception {
    LexerGrammar lg = new LexerGrammar(
      "lexer grammar L;\n" +
      "A : 'a' ;\n" +
      "B : 'b' ;\n" +
      "C : 'c' ;\n");
    Grammar g = new Grammar(
View Full Code Here

    testInterp(lg, g, "s", "ac", "(s a c)");
    testInterp(lg, g, "s", "bc", "(s b c)");
  }

  @Test public void testStarA() throws Exception {
    LexerGrammar lg = new LexerGrammar(
      "lexer grammar L;\n" +
      "A : 'a' ;\n" +
      "B : 'b' ;\n" +
      "C : 'c' ;\n");
    Grammar g = new Grammar(
View Full Code Here

    testInterp(lg, g, "s", "ab", "(s a b)");
    testInterp(lg, g, "s", "aaaaaab", "(s a a a a a a b)");
  }

  @Test public void testStarAorB() throws Exception {
    LexerGrammar lg = new LexerGrammar(
      "lexer grammar L;\n" +
      "A : 'a' ;\n" +
      "B : 'b' ;\n" +
      "C : 'c' ;\n");
    Grammar g = new Grammar(
View Full Code Here

    testInterp(lg, g, "s", "abaaabc", "(s a b a a a b c)");
    testInterp(lg, g, "s", "babac", "(s b a b a c)");
  }

  @Test public void testLeftRecursion() 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

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.