Package org.antlr.codegen

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


        "    : 'y' {" + action +"}\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,
      "rule",
      new CommonToken(ANTLRParser.ACTION,action),1);
    String found = translator.translate();
    assertEquals(expecting, found);
View Full Code Here


        "    : 'y' {" + action +"}\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,
      "rule",
      new CommonToken(ANTLRParser.ACTION,action),1);
    String found = translator.translate();
    assertEquals(expecting, found);
View Full Code Here

        "    : 'y' {" + action +"}\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,
      "rule",
      new CommonToken(ANTLRParser.ACTION,action),1);
    String rawTranslation =
      translator.translate();
View Full Code Here

        "    : 'y' {" + action +"}\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,
      "rule",
      new CommonToken(ANTLRParser.ACTION,action),1);
    String rawTranslation =
      translator.translate();
View Full Code Here

        "    : other=otherrule {" + action +"}\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,
      "rule",
      new CommonToken(ANTLRParser.ACTION,action),1);
    String rawTranslation =
      translator.translate();
View Full Code Here

        "    : ID {" + action +"}\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,
      "rule",
      new CommonToken(ANTLRParser.ACTION,action),1);
    String rawTranslation =
      translator.translate();
View Full Code Here

        ";");
    Tool antlr = newTool();

    CodeGenerator generator = new CodeGenerator(antlr, g, "Java");
    g.setCodeGenerator(generator);
    generator.genRecognizer(); // codegen phase sets some vars we need
    ST codeST = generator.getRecognizerST();
    String code = codeST.render();
    String found = code.substring(code.indexOf("###")+3,code.indexOf("!!!"));
    assertEquals(expecting, found);
View Full Code Here

        "ID : 'id';"
    );
    Tool antlr = newTool();
    CodeGenerator generator = new CodeGenerator(antlr, g, "Java");
    g.setCodeGenerator(generator);
    generator.genRecognizer();
    ActionTranslator translator = new ActionTranslator(generator,
      "RULE",
      new CommonToken(ANTLRParser.ACTION,action),1);
    String found = translator.translate();
    assertEquals("unexpected errors: "+equeue, 0, equeue.errors.size());
View Full Code Here

        "ID : 'id';"
    );
    Tool antlr = newTool();
    CodeGenerator generator = new CodeGenerator(antlr, g, "Java");
    g.setCodeGenerator(generator);
    generator.genRecognizer();
    ActionTranslator translator = new ActionTranslator(generator,
      "twoIDs",
      new CommonToken(ANTLRParser.ACTION,action),1);
    String rawTranslation =
      translator.translate();
View Full Code Here

    System.out.println(g.toString());
    Tool antlr = newTool();
    antlr.setOutputDirectory(null); // write to /dev/null
    CodeGenerator generator = new CodeGenerator(antlr, g, "Java");
    g.setCodeGenerator(generator);
    generator.genRecognizer(); // codegen phase sets some vars we need
    ST codeST = generator.getRecognizerST();
    String code = codeST.render();
    String found = code.substring(code.indexOf("###")+3,code.indexOf("!!!"));
    assertEquals(expecting, found);
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.