Package org.antlr.codegen

Examples of org.antlr.codegen.CodeGenerator.genRecognizer()


        "} : {"+action+"}\n" +
        "  ;\n");
    Tool antlr = newTool();
    CodeGenerator generator = new CodeGenerator(antlr, g, "Java");
    g.setCodeGenerator(generator);
    generator.genRecognizer(); // forces load of templates
    ActionTranslator translator = new ActionTranslator(generator,"a",
      new CommonToken(ANTLRParser.ACTION,action),1);
    String found = translator.translate();
    assertEquals(expecting, found);
View Full Code Here


        "} : {"+action+"}\n" +
        "  ;\n");
    Tool antlr = newTool();
    CodeGenerator generator = new CodeGenerator(antlr, g, "Java");
    g.setCodeGenerator(generator);
    generator.genRecognizer(); // forces load of templates

    int expectedMsgID = ErrorManager.MSG_ISOLATED_RULE_ATTRIBUTE;
    Object expectedArg = "n";
    Object expectedArg2 = null;
    GrammarSemanticsMessage expectedMessage =
View Full Code Here

        "b : {"+action+"}\n" +
        "  ;\n");
    Tool antlr = newTool();
    CodeGenerator generator = new CodeGenerator(antlr, g, "Java");
    g.setCodeGenerator(generator);
    generator.genRecognizer(); // forces load of templates
    ActionTranslator translator = new ActionTranslator(generator, "b",
      new CommonToken(ANTLRParser.ACTION,action),1);
    String found = translator.translate();
    assertEquals(expecting, found);
View Full Code Here

        "R : 'z' ID {"+action+"};" +
        "ID : 'a';\n");
    Tool antlr = newTool();
    CodeGenerator generator = new CodeGenerator(antlr, g, "Java");
    g.setCodeGenerator(generator);
    generator.genRecognizer(); // forces load of templates
    ActionTranslator translator =
      new ActionTranslator(generator,
        "R",
        new CommonToken(ANTLRParser.ACTION,action),1);
    String found = translator.translate();
View Full Code Here

        "R : 'z' ID {"+action+"};" +
        "ID : 'a';\n");
    Tool antlr = newTool();
    CodeGenerator generator = new CodeGenerator(antlr, g, "Java");
    g.setCodeGenerator(generator);
    generator.genRecognizer(); // forces load of templates
    ActionTranslator translator =
      new ActionTranslator(generator,
        "R",
        new CommonToken(ANTLRParser.ACTION,action),1);
    String found = translator.translate();
View Full Code Here

        "R : x='z' ;\n");

    Tool antlr = newTool();
    CodeGenerator generator = new CodeGenerator(antlr, g, "Java");
    g.setCodeGenerator(generator);
    generator.genRecognizer(); // forces load of templates

    assertEquals("unexpected errors: "+equeue, 0, equeue.errors.size());
  }

  @Test public void testCharListLabelInLexer() throws Exception {
View Full Code Here

        "R : x+='z' ;\n");

    Tool antlr = newTool();
    CodeGenerator generator = new CodeGenerator(antlr, g, "Java");
    g.setCodeGenerator(generator);
    generator.genRecognizer(); // forces load of templates
    assertEquals("unexpected errors: "+equeue, 0, equeue.errors.size());
  }

  @Test public void testWildcardCharLabelInLexer() throws Exception {
    ErrorQueue equeue = new ErrorQueue();
View Full Code Here

        "R : x=. ;\n");

    Tool antlr = newTool();
    CodeGenerator generator = new CodeGenerator(antlr, g, "Java");
    g.setCodeGenerator(generator);
    generator.genRecognizer(); // forces load of templates
    assertEquals("unexpected errors: "+equeue, 0, equeue.errors.size());
  }

  @Test public void testWildcardCharListLabelInLexer() throws Exception {
    ErrorQueue equeue = new ErrorQueue();
View Full Code Here

        "R : x+=. ;\n");

    Tool antlr = newTool();
    CodeGenerator generator = new CodeGenerator(antlr, g, "Java");
    g.setCodeGenerator(generator);
    generator.genRecognizer(); // forces load of templates
    assertEquals("unexpected errors: "+equeue, 0, equeue.errors.size());
  }

  @Test public void testMissingArgsInLexer() throws Exception {
    ErrorQueue equeue = new ErrorQueue();
View Full Code Here

        "R[int i] : 'a';\n");
    Tool antlr = newTool();
    antlr.setOutputDirectory(null); // write to /dev/null
    CodeGenerator generator = new CodeGenerator(antlr, g, "Java");
    g.setCodeGenerator(generator);
    generator.genRecognizer();

    int expectedMsgID = ErrorManager.MSG_MISSING_RULE_ARGS;
    Object expectedArg = "R";
    Object expectedArg2 = null;
    // getting a second error @1:12, probably from nextToken
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. 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.