Package org.antlr

Examples of org.antlr.Tool


        // First thing we need is an instance of the ANTLR 3.1 build tool
        //
        try {
            // ANTLR Tool buld interface
            //
            tool = new Tool();
        } catch (Exception e) {
            log.error("The attempt to create the ANTLR build tool failed, see exception report for details");

            throw new MojoFailureException("Jim failed you!");
        }
View Full Code Here


      "a : x=b ;\n" +
      "b : B ;\n" +
      "B : 'b' ;\n";
    Grammar g = new Grammar(grammarStr);

    Tool antlr = newTool();
    CodeGenerator generator = new CodeGenerator(antlr, g, "Java");
    g.setCodeGenerator(generator);
    ST recogST = generator.genRecognizer();
    String code = recogST.render();
    assertTrue("not expecting label", code.indexOf("x=b();")<0);
View Full Code Here

  }

  @Test public void testBadGrammarOption() throws Exception {
    ErrorQueue equeue = new ErrorQueue();
    ErrorManager.setErrorListener(equeue); // unique listener per thread
    Tool antlr = newTool();
    Grammar g = new Grammar(antlr,
                "grammar t;\n"+
                "options {foo=3; language=Java;}\n" +
                "a : 'a';\n");
View Full Code Here

    String importer =
      "lexer grammar B; \n" +
      "options\t{tokenVocab=T;} \n" +
      "SEMI:';' ; \n" ;
    writeFile(tmpdir, "B.g", importer);
    Tool antlr = newTool(new String[] {"-lib", tmpdir});
    CompositeGrammar composite = new CompositeGrammar();
    Grammar g = new Grammar(antlr,tmpdir+"/B.g",composite);
    g.parseAndBuildAST();
    g.composite.assignTokenTypes();
View Full Code Here

    String importer =
      "grammar B; \n" +
      "options\t{tokenVocab=T;} \n" +
      "SEMI:';' ; \n" ;
    writeFile(tmpdir, "B.g", importer);
    Tool antlr = newTool(new String[] {"-lib", tmpdir});
    CompositeGrammar composite = new CompositeGrammar();
    Grammar g = new Grammar(antlr,tmpdir+"/B.g",composite);
    g.parseAndBuildAST();
    g.composite.assignTokenTypes();
View Full Code Here

      "B : 'b' ;\n" + // another order: B, A, C
      "A : 'a' ;\n" +
      "C : 'c' ;\n" +
      "WS : (' '|'\\n') {skip();} ;\n" ;
    writeFile(tmpdir, "M.g", master);
    Tool antlr = newTool(new String[] {"-lib", tmpdir});
    CompositeGrammar composite = new CompositeGrammar();
    Grammar g = new Grammar(antlr,tmpdir+"/M.g",composite);
    composite.setDelegationRoot(g);
    g.parseAndBuildAST();
    g.composite.assignTokenTypes();
View Full Code Here

    String master =
      "grammar M;\n" +
      "import S;\n" +
      "s : x INT ;\n";
    writeFile(tmpdir, "M.g", master);
    Tool antlr = newTool(new String[] {"-lib", tmpdir});
    CompositeGrammar composite = new CompositeGrammar();
    Grammar g = new Grammar(antlr,tmpdir+"/M.g",composite);
    composite.setDelegationRoot(g);
    g.parseAndBuildAST();
    g.composite.assignTokenTypes();
View Full Code Here

      "grammar M;\n" +
      "import S,T;\n" +
      "s : x y ;\n" +
      "WS : (' '|'\\n') {skip();} ;\n" ;
    writeFile(tmpdir, "M.g", master);
    Tool antlr = newTool(new String[] {"-lib", tmpdir});
    CompositeGrammar composite = new CompositeGrammar();
    Grammar g = new Grammar(antlr,tmpdir+"/M.g",composite);
    composite.setDelegationRoot(g);
    g.parseAndBuildAST();
    g.composite.assignTokenTypes();
View Full Code Here

      "grammar M;\n" +
      "import S,T;\n" +
      "s : x y ;\n" +
      "WS : (' '|'\\n') {skip();} ;\n" ;
    writeFile(tmpdir, "M.g", master);
    Tool antlr = newTool(new String[] {"-lib", tmpdir});
    CompositeGrammar composite = new CompositeGrammar();
    Grammar g = new Grammar(antlr,tmpdir+"/M.g",composite);
    composite.setDelegationRoot(g);
    g.parseAndBuildAST();
    g.composite.assignTokenTypes();
View Full Code Here

      "grammar M;\n" +
      "import S;\n" +
      "s : x ;\n" +
      "WS : (' '|'\\n') {skip();} ;\n" ;
    writeFile(tmpdir, "M.g", master);
    Tool antlr = newTool(new String[] {"-lib", tmpdir});
    CompositeGrammar composite = new CompositeGrammar();
    Grammar g = new Grammar(antlr,tmpdir+"/M.g",composite);
    composite.setDelegationRoot(g);
    g.parseAndBuildAST();
    g.composite.assignTokenTypes();
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.