Package org.antlr.v4.automata

Examples of org.antlr.v4.automata.ParserATNFactory


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

      CodeGenerator gen = new CodeGenerator(g);
      ST outputFileST = gen.generateParser();

//      STViz viz = outputFileST.inspect();
View Full Code Here


    semanticProcess(lg);
    g.importVocab(lg);
    semanticProcess(g);

    ParserATNFactory f = new ParserATNFactory(g);
    ATN atn = f.createATN();

    DOTGenerator dot = new DOTGenerator(g);

    Rule r = g.getRule("a");
    if ( r!=null) System.out.println(dot.getDOT(atn.ruleToStartState[r.index]));
View Full Code Here

  protected ATN createATN(Grammar g, boolean useSerializer) {
    if ( g.atn==null ) {
      semanticProcess(g);
      assertEquals(0, g.tool.getNumErrors());

      ParserATNFactory f;
      if ( g.isLexer() ) {
        f = new LexerATNFactory((LexerGrammar)g);
      }
      else {
        f = new ParserATNFactory(g);
      }

      g.atn = f.createATN();
      assertEquals(0, g.tool.getNumErrors());
    }

    ATN atn = g.atn;
    if (useSerializer) {
View Full Code Here

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

      CodeGenerator gen = new CodeGenerator(g);
      ST outputFileST = gen.generateParser();
      String output = outputFileST.render();
      //System.out.println(output);
View Full Code Here

    if ( errMgr.getNumErrors()>prevErrors ) return;

    // BUILD ATN FROM AST
    ATNFactory factory;
    if ( g.isLexer() ) factory = new LexerATNFactory((LexerGrammar)g);
    else factory = new ParserATNFactory(g);
    g.atn = factory.createATN();

    if ( generate_ATN_dot ) generateATNs(g);

    // PERFORM GRAMMAR ANALYSIS ON ATN: BUILD DECISION DFAs
View Full Code Here

    if ( modeName==null ) modeName = "DEFAULT_MODE";
    if ( g.modes.get(modeName)==null ) {
      System.err.println("no such mode "+modeName);
      return;
    }
    ParserATNFactory f = new LexerATNFactory(g);
    ATN nfa = f.createATN();
    ATNState startState = nfa.modeNameToStartState.get(modeName);
    ATNPrinter serializer = new ATNPrinter(g, startState);
    String result = serializer.asString();
    //System.out.print(result);
    assertEquals(expecting, result);
View Full Code Here

    IntegerList types = getTokenTypesViaATN(inputString, lexInterp);
    System.out.println(types);

    g.importVocab(lg);

    ParserATNFactory f = new ParserATNFactory(g);
    ATN atn = f.createATN();

    IntTokenStream input = new IntTokenStream(types);
    System.out.println("input="+input.types);
    ParserInterpreterForTesting interp = new ParserInterpreterForTesting(g, input);
    ATNState startState = atn.ruleToStartState[g.getRule("a").index];
View Full Code Here

    if ( !recRuleTemplates.isDefined("recRule") ) {
      tool.errMgr.toolError(ErrorType.MISSING_CODE_GEN_TEMPLATES, "LeftRecursiveRules");
    }

    // use codegen to get correct language templates; that's it though
    CodeGenerator gen = new CodeGenerator(tool, null, language);
    codegenTemplates = gen.getTemplates();
  }
View Full Code Here

    blk.ops = ops;
    return blk;
  }

  @Override
  public List<SrcOp> action(ActionAST ast) { return list(new Action(this, ast)); }
View Full Code Here

  @Override
  public List<SrcOp> ruleRef(GrammarAST ID, GrammarAST label, GrammarAST args) {
    InvokeRule invokeOp = new InvokeRule(this, ID, label);
    // If no manual label and action refs as token/rule not label, we need to define implicit label
    if ( controller.needsImplicitLabel(ID, invokeOp) ) defineImplicitLabel(ID, invokeOp);
    AddToLabelList listLabelOp = getAddToListOpIfListLabelPresent(invokeOp, label);
    return list(invokeOp, listLabelOp);
  }
View Full Code Here

TOP

Related Classes of org.antlr.v4.automata.ParserATNFactory

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.