Package org.antlr.grammar.v3

Examples of org.antlr.grammar.v3.ActionTranslator


        "a returns [User u, int i]\n" +
        "        : {"+action+"}\n" +
        "        ;");
    Tool antlr = newTool();
    CodeGenerator generator = new CodeGenerator(antlr, g, "Java");
    ActionTranslator translator = new ActionTranslator(generator,"a",
      new CommonToken(ANTLRParser.ACTION,action),1);
    String found = translator.translate();
    assertEquals(expecting, found);

    int expectedMsgID = ErrorManager.MSG_UNKNOWN_SIMPLE_ATTRIBUTE;
    Object expectedArg = "x";
    GrammarSemanticsMessage expectedMessage =
View Full Code Here


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

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

        "  ;\n"+
        "b : r=a[3] {"+action+"}\n" +
        "  ;");
    Tool antlr = newTool();
    CodeGenerator generator = new CodeGenerator(antlr, g, "Java");
    ActionTranslator translator = new ActionTranslator(generator, "b",
      new CommonToken(ANTLRParser.ACTION,action),1);
    String found = translator.translate();    assertEquals(expecting, found);

    int expectedMsgID = ErrorManager.MSG_INVALID_RULE_PARAMETER_REF;
    Object expectedArg = "a";
    Object expectedArg2 = "z";
    GrammarSemanticsMessage expectedMessage =
View Full Code Here

        "  ;\n"+
        "b : r=a[3] {"+action+"}\n" +
        "  ;");
    Tool antlr = newTool();
    CodeGenerator generator = new CodeGenerator(antlr, g, "Java");
    ActionTranslator translator = new ActionTranslator(generator, "b",
      new CommonToken(ANTLRParser.ACTION,action),1);
    String found = translator.translate();
    assertEquals(expecting, found);

    int expectedMsgID = ErrorManager.MSG_INVALID_RULE_SCOPE_ATTRIBUTE_REF;
    Object expectedArg = "a";
    Object expectedArg2 = "n";
View Full Code Here

        "  ;\n"+
        "b : r=a[3] {"+action+"}\n" +
        "  ;");
    Tool antlr = newTool();
    CodeGenerator generator = new CodeGenerator(antlr, g, "Java");
    ActionTranslator translator = new ActionTranslator(generator, "b",
      new CommonToken(ANTLRParser.ACTION,action),1);
    String found = translator.translate();
    assertEquals(expecting, found);

    int expectedMsgID = ErrorManager.MSG_UNKNOWN_RULE_ATTRIBUTE;
    Object expectedArg = "a";
    Object expectedArg2 = "blort";
View Full Code Here

        "  ;\n"+
        "b : r=a[3] {"+action+"}\n" +
        "  ;");
    Tool antlr = newTool();
    CodeGenerator generator = new CodeGenerator(antlr, g, "Java");
    ActionTranslator translator = new ActionTranslator(generator, "b",
      new CommonToken(ANTLRParser.ACTION,action),1);
    String rawTranslation =
      translator.translate();

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

        "  ;\n"+
        "b : a {"+action+"}\n" +
        "  ;");
    Tool antlr = newTool();
    CodeGenerator generator = new CodeGenerator(antlr, g, "Java");
    ActionTranslator translator = new ActionTranslator(generator, "b",
      new CommonToken(ANTLRParser.ACTION,action),1);
    String rawTranslation =
      translator.translate();

    int expectedMsgID = ErrorManager.MSG_ISOLATED_RULE_SCOPE;
    Object expectedArg = "a";
    GrammarSemanticsMessage expectedMessage =
      new GrammarSemanticsMessage(expectedMsgID, g, null, expectedArg);
View Full Code Here

      "parser grammar t;\n"+
        "@members {'+action+'}\n" +
        "a : ;\n");
    Tool antlr = newTool();
    CodeGenerator generator = new CodeGenerator(antlr, g, "Java");
    ActionTranslator translator = new ActionTranslator(generator,
      null,
      new CommonToken(ANTLRParser.ACTION,action),0);
    String found = translator.translate();    assertEquals(expecting, found);

    int expectedMsgID = ErrorManager.MSG_ATTRIBUTE_REF_NOT_IN_RULE;
    Object expectedArg = "x";
    GrammarSemanticsMessage expectedMessage =
      new GrammarSemanticsMessage(expectedMsgID, g, null, expectedArg);
View Full Code Here

      "parser grammar t;\n"+
        "@members {'+action+'}\n" +
        "a : ;\n");
    Tool antlr = newTool();
    CodeGenerator generator = new CodeGenerator(antlr, g, "Java");
    ActionTranslator translator = new ActionTranslator(generator,
      null,
      new CommonToken(ANTLRParser.ACTION,action),0);
    String found = translator.translate();
    assertEquals(expecting, found);

    int expectedMsgID = ErrorManager.MSG_ATTRIBUTE_REF_NOT_IN_RULE;
    Object expectedArg = "x";
    Object expectedArg2 = "y";
View Full Code Here

        "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,"a",
      new CommonToken(ANTLRParser.ACTION,action),1);
    String found = translator.translate();
    assertEquals(expecting, found);

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

TOP

Related Classes of org.antlr.grammar.v3.ActionTranslator

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.