Examples of LL1Analyzer


Examples of org.antlr.v4.runtime.atn.LL1Analyzer

    for (Rule rule : g.rules.values()) {
      if (rule.isFragment()) {
        continue;
      }

      LL1Analyzer analyzer = new LL1Analyzer(g.atn);
      IntervalSet look = analyzer.LOOK(g.atn.ruleToStartState[rule.index], null);
      if (look.contains(Token.EPSILON)) {
        g.tool.errMgr.grammarError(ErrorType.EPSILON_TOKEN, g.fileName, ((GrammarAST)rule.ast.getChild(0)).getToken(), rule.name);
      }
    }
  }
View Full Code Here

Examples of org.antlr.v4.runtime.atn.LL1Analyzer

      IntervalSet[] look;
      if ( s.nonGreedy ) { // nongreedy decisions can't be LL(1)
        look = new IntervalSet[s.getNumberOfTransitions()+1];
      }
      else {
        LL1Analyzer anal = new LL1Analyzer(g.atn);
        look = anal.getDecisionLookahead(s);
        g.tool.log("LL1", "look=" + Arrays.toString(look));
      }

      assert s.decision + 1 >= g.decisionLOOK.size();
      Utils.setSize(g.decisionLOOK, s.decision+1);
View Full Code Here

Examples of org.antlr.v4.runtime.atn.LL1Analyzer

        addRuleFollowLinks();
    addEOFTransitionToStartRules();
    ATNOptimizer.optimize(g, atn);

    for (Triple<Rule, ATNState, ATNState> pair : preventEpsilonClosureBlocks) {
      LL1Analyzer analyzer = new LL1Analyzer(atn);
      if (analyzer.LOOK(pair.b, pair.c, null).contains(org.antlr.v4.runtime.Token.EPSILON)) {
        ErrorType errorType = pair.a instanceof LeftRecursiveRule ? ErrorType.EPSILON_LR_FOLLOW : ErrorType.EPSILON_CLOSURE;
        g.tool.errMgr.grammarError(errorType, g.fileName, ((GrammarAST)pair.a.ast.getChild(0)).getToken(), pair.a.name);
      }
    }

    optionalCheck:
    for (Triple<Rule, ATNState, ATNState> pair : preventEpsilonOptionalBlocks) {
      int bypassCount = 0;
      for (int i = 0; i < pair.b.getNumberOfTransitions(); i++) {
        ATNState startState = pair.b.transition(i).target;
        if (startState == pair.c) {
          bypassCount++;
          continue;
        }

        LL1Analyzer analyzer = new LL1Analyzer(atn);
        if (analyzer.LOOK(startState, pair.c, null).contains(org.antlr.v4.runtime.Token.EPSILON)) {
          g.tool.errMgr.grammarError(ErrorType.EPSILON_OPTIONAL, g.fileName, ((GrammarAST)pair.a.ast.getChild(0)).getToken(), pair.a.name);
          continue optionalCheck;
        }
      }
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.