Package org.antlr.grammar.v3

Examples of org.antlr.grammar.v3.ActionTranslator.translate()


    generator.genRecognizer(); // forces load of templates
    ActionTranslator translator = new ActionTranslator(generator,
                                  "rule",
                                  new CommonToken(ANTLRParser.ACTION,action),1);
    String rawTranslation =
      translator.translate();

    int expectedMsgID = ErrorManager.MSG_WRITE_TO_READONLY_ATTR;
    Object expectedArg = "other";
    Object expectedArg2 = "tree";
    GrammarSemanticsMessage expectedMessage =
View Full Code Here


    String action = "i<3; '<xmltag>'";
    ActionTranslator translator = new ActionTranslator(generator,"a",
      new CommonToken(ANTLRParser.ACTION,action),0);
    String expecting = action;
    String rawTranslation =
      translator.translate();
    STGroup templates =
      new STGroup();
    ST actionST = new ST(templates, "<action>");
    actionST.add("action", rawTranslation);
    String found = actionST.render();
View Full Code Here

    generator.genRecognizer(); // forces load of templates
    ActionTranslator translator =
      new ActionTranslator(generator,
        "a",
        new CommonToken(ANTLRParser.ACTION,action),0);
    String found = translator.translate();    assertEquals(expecting, found);
  }

  @Test public void testArguments() throws Exception {
    String action = "$i; $i.x; $u; $u.x";
    String expecting = "i; i.x; u; u.x";
View Full Code Here

    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);

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

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

    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 rawTranslation =  translator.translate();
    assertEquals(expecting, rawTranslation);

    assertEquals("unexpected errors: "+equeue, 0, equeue.errors.size());
  }
View Full Code Here

    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 rawTranslation =  translator.translate();
    assertEquals(expecting, rawTranslation);

    List<String> expectArgs = new ArrayList<String>() {
      {add("34");}
      {add("'{'");}
View Full Code Here

    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 rawTranslation =  translator.translate();
    assertEquals(expecting, rawTranslation);

    assertEquals("unexpected errors: "+equeue, 0, equeue.errors.size());
  }
View Full Code Here

    g.setCodeGenerator(generator);
    generator.genRecognizer(); // forces load of templates
    ActionTranslator translator = new ActionTranslator(generator,"a",
      new CommonToken(ANTLRParser.ACTION,action),1);
    String rawTranslation =
      translator.translate();
    assertEquals(expecting, rawTranslation);

    assertEquals("unexpected errors: "+equeue, 0, equeue.errors.size());
  }
View Full Code Here

    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);

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

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

    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);

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

  @Test public void testGenericsAsReturnValue() throws Exception {
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.