Package org.antlr.v4.tool

Examples of org.antlr.v4.tool.GrammarTransformPipeline.process()


    this.g = g;
  }

  public ParserInterpreterForTesting(@NotNull Grammar g, @NotNull TokenStream input) {
    Tool antlr = new Tool();
    antlr.process(g,false);
    parser = new DummyParser(g, g.atn, input);
    atnSimulator =
      new ParserATNSimulator(parser, g.atn, parser.decisionToDFA,
                      parser.sharedContextCache);
  }
View Full Code Here


      GrammarRootAST grammarRootAST = tool.parseGrammarFromString(gstr);
      assertEquals(0, errorQueue.size());
      Grammar g = tool.createGrammar(grammarRootAST);
      assertEquals(0, errorQueue.size());
      g.fileName = "<string>";
      tool.process(g, false);
    }
    catch (Exception e) {
      threwException = true;
      e.printStackTrace();
    }
View Full Code Here

    if ( generate_ATN_dot ) generateATNs(g);

    // PERFORM GRAMMAR ANALYSIS ON ATN: BUILD DECISION DFAs
    AnalysisPipeline anal = new AnalysisPipeline(g);
    anal.process();

    //if ( generate_DFA_dot ) generateDFAs(g);

    if ( g.tool.getNumErrors()>prevErrors ) return;
View Full Code Here

    if ( g.tool.getNumErrors()>prevErrors ) return;

    // GENERATE CODE
    if ( gencode ) {
      CodeGenPipeline gen = new CodeGenPipeline(g);
      gen.process();
    }
  }

  /**
   * Important enough to avoid multiple definitions that we do very early,
View Full Code Here

    ErrorQueue equeue = new ErrorQueue();
    Grammar g = new Grammar(grammarString);
    List<String> evals = new ArrayList<String>();
    if ( g.ast!=null && !g.ast.hasErrors ) {
      SemanticPipeline sem = new SemanticPipeline(g);
      sem.process();

      ATNFactory factory = new ParserATNFactory(g);
      if (g.isLexer()) factory = new LexerATNFactory((LexerGrammar) g);
      g.atn = factory.createATN();
View Full Code Here

  protected void semanticProcess(Grammar g) {
    if ( g.ast!=null && !g.ast.hasErrors ) {
      System.out.println(g.ast.toStringTree());
      Tool antlr = new Tool();
      SemanticPipeline sem = new SemanticPipeline(g);
      sem.process();
      if ( g.getImportedGrammars()!=null ) { // process imported grammars (if any)
        for (Grammar imp : g.getImportedGrammars()) {
          antlr.processNonCombinedGrammar(imp, false);
        }
      }
View Full Code Here

    String grammar = st.render();
    ErrorQueue equeue = new ErrorQueue();
    Grammar g = new Grammar(grammar, equeue);
    if ( g.ast!=null && !g.ast.hasErrors ) {
      SemanticPipeline sem = new SemanticPipeline(g);
      sem.process();

      ATNFactory factory = new ParserATNFactory(g);
      if ( g.isLexer() ) factory = new LexerATNFactory((LexerGrammar)g);
      g.atn = factory.createATN();
View Full Code Here

    if ( ruleFail ) return;

    int prevErrors = errMgr.getNumErrors();
    // MAKE SURE GRAMMAR IS SEMANTICALLY CORRECT (FILL IN GRAMMAR OBJECT)
    SemanticPipeline sem = new SemanticPipeline(g);
    sem.process();

    String language = g.getOptionString("language");
    if ( !CodeGenerator.targetExists(language) ) {
      errMgr.toolError(ErrorType.CANNOT_CREATE_TARGET_GENERATOR, language);
      return;
View Full Code Here

   */
  public void process(Grammar g, boolean gencode) {
    g.loadImportedGrammars();

    GrammarTransformPipeline transform = new GrammarTransformPipeline(g, this);
    transform.process();

    LexerGrammar lexerg;
    GrammarRootAST lexerAST;
    if ( g.ast!=null && g.ast.grammarType== ANTLRParser.COMBINED &&
       !g.ast.hasErrors )
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.