Package org.antlr.grammar.v3

Examples of org.antlr.grammar.v3.TreeToNFAConverter


      "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 rawTranslation =
      translator.translate();
    STGroup templates =
      new STGroup();
    ST actionST = new ST(templates, rawTranslation);
    String found = actionST.render();
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 rawTranslation =
      translator.translate();
    STGroup templates =
      new STGroup();
    ST actionST = new ST(templates, rawTranslation);
    String found = actionST.render();
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 rawTranslation =
      translator.translate();
    STGroup templates =
      new STGroup();
    ST actionST = new ST(templates, rawTranslation);
    String found = actionST.render();
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 rawTranslation =
      translator.translate();
    STGroup templates =
      new STGroup();
    ST actionST = new ST(templates, rawTranslation);
    String found = actionST.render();
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 rawTranslation =
      translator.translate();
    STGroup templates =
      new STGroup();
    ST actionST = new ST(templates, rawTranslation);
    String found = actionST.render();
View Full Code Here

  }

  public void assignTokenTypes() throws RecognitionException {
    // ASSIGN TOKEN TYPES for all delegates (same walker)
    //System.out.println("### assign types");
    AssignTokenTypesWalker ttypesWalker = new AssignTokenTypesBehavior();
    List<Grammar> grammars = delegateGrammarTreeRoot.getPostOrderedGrammarList();
    for (int i = 0; grammars!=null && i < grammars.size(); i++) {
      Grammar g = grammars.get(i);
      ttypesWalker.setTreeNodeStream(new CommonTreeNodeStream(g.getGrammarTree()));
      try {
        //System.out.println("    walking "+g.name);
        ttypesWalker.grammar_(g);
      }
      catch (RecognitionException re) {
        ErrorManager.error(ErrorManager.MSG_BAD_AST_STRUCTURE,
                   re);
      }
    }
    // the walker has filled literals, tokens, and alias tables.
    // now tell it to define them in the root grammar
    ttypesWalker.defineTokens(delegateGrammarTreeRoot.grammar);
  }
View Full Code Here

    // GENERATE RECOGNIZER
    // Walk the AST holding the input grammar, this time generating code
    // Decisions are generated by using the precomputed DFAs
    // Fill in the various templates with data
    CodeGenTreeWalker gen = new CodeGenTreeWalker(new CommonTreeNodeStream(grammar.getGrammarTree()));
    try {
      gen.grammar_(
            grammar,
            recognizerST,
            outputFileST,
            headerFileST);
    }
View Full Code Here

      ErrorManager.internalError("can't parse template action",tse);
    }
    GrammarAST rewriteTree = parseResult.getTree();

    // then translate via codegen.g
    CodeGenTreeWalker gen = new CodeGenTreeWalker(new CommonTreeNodeStream(rewriteTree));
    gen.init(grammar);
    gen.setCurrentRuleName(ruleName);
    gen.setOuterAltNum(outerAltNum);
    ST st = null;
    try {
      st = gen.rewrite_template();
    }
    catch (RecognitionException re) {
      ErrorManager.error(ErrorManager.MSG_BAD_AST_STRUCTURE,
                 re);
    }
View Full Code Here

      System.out.println(grammarTree.toStringList());
    }

    // DEFINE RULES
    //System.out.println("### define "+name+" rules");
    DefineGrammarItemsWalker defineItemsWalker = new DefineGrammarItemsWalker(new CommonTreeNodeStream(getGrammarTree()));
    try {
      defineItemsWalker.grammar_(this);
    }
    catch (RecognitionException re) {
      ErrorManager.error(ErrorManager.MSG_BAD_AST_STRUCTURE,
                 re);
    }
View Full Code Here

    if ( getRules().isEmpty() ) {
      return;
    }

    CommonTreeNodeStream input = new CommonTreeNodeStream(getGrammarTree());
    TreeToNFAConverter nfaBuilder = new TreeToNFAConverter(input, this, nfa, factory);
    try {
      nfaBuilder.grammar_();
    }
    catch (RecognitionException re) {
      ErrorManager.error(ErrorManager.MSG_BAD_AST_STRUCTURE,
                 name,
                 re);
View Full Code Here

TOP

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

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.