Package org.antlr

Examples of org.antlr.Tool


      "tree grammar t;\n" +
        "options {ASTLabelType=CommonTree;}\n" +
        "a : {###"+action+"!!!}\n" +
        "  ;\n");

    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();
View Full Code Here


        "b\n" +
        "scope {\n" +
        "  int n;\n" +
        "} : '(' b ')' {"+action+"}\n" + // refers to current invocation's 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);
View Full Code Here

  public TestAttributes() {
  }

  @Test public void testEscapedLessThanInAction() throws Exception {
    Grammar g = new Grammar();
    Tool antlr = newTool();
    CodeGenerator generator = new CodeGenerator(antlr, g, "Java");
    String action = "i<3; '<xmltag>'";
    ActionTranslator translator = new ActionTranslator(generator,"a",
      new CommonToken(ANTLRParser.ACTION,action),0);
    String expecting = action;
View Full Code Here

      "parser grammar t;\n"+
        "@members {"+action+"}\n"+
        "a[User u, int i]\n" +
        "        : {"+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,
View Full Code Here

    Grammar g = new Grammar(
      "parser grammar t;\n"+
        "a[User u, int i]\n" +
        "        : {"+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,"a",
      new CommonToken(ANTLRParser.ACTION,action),1);
View Full Code Here

    Grammar g = new Grammar(
      "parser grammar t;\n"+
        "a[User u, int i]\n" +
        "        : A a["+action+"] B\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);
View Full Code Here

    Grammar g = new Grammar(
      "parser grammar t;\n"+
        "a[String[\\] ick, int i]\n" +
        "        : A \n"+
        "        ;");
    Tool antlr = newTool();
    CodeGenerator generator = new CodeGenerator(antlr, g, "Java");
    g.setCodeGenerator(generator);
    generator.genRecognizer(); // forces load of templates
    Rule r = g.getRule("a");
    AttributeScope parameters = r.parameterScope;
View Full Code Here

    Grammar g = new Grammar(
      "parser grammar t;\n"+
        "a[User u, int i]\n" +
        "        : A a["+action+"] B\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);
View Full Code Here

    Grammar g = new Grammar(
      "parser grammar t;\n"+
        "a[User u, int i]\n" +
        "        : A a["+action+"] B\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);
View Full Code Here

    Grammar g = new Grammar(
      "parser grammar t;\n"+
        "a[boolean b]\n" +
        "        : A a["+action+"] B\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);
View Full Code Here

TOP

Related Classes of org.antlr.Tool

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.