Examples of RuleStartState


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

  /* start->ruleblock->end */
  @NotNull
  @Override
  public Handle rule(@NotNull GrammarAST ruleAST, @NotNull String name, @NotNull Handle blk) {
    Rule r = g.getRule(name);
    RuleStartState start = atn.ruleToStartState[r.index];
    epsilon(start, blk.left);
    RuleStopState stop = atn.ruleToStopState[r.index];
    epsilon(blk.right, stop);
    Handle h = new Handle(start, stop);
//    ATNPrinter ser = new ATNPrinter(g, h.left);
View Full Code Here

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

    Rule r = g.getRule(node.getText());
    if ( r==null ) {
      g.tool.errMgr.grammarError(ErrorType.INTERNAL_ERROR, g.fileName, node.getToken(), "Rule "+node.getText()+" undefined");
      return null;
    }
    RuleStartState start = atn.ruleToStartState[r.index];
    ATNState left = newState(node);
    ATNState right = newState(node);
    int precedence = 0;
    if (((GrammarASTWithOptions)node).getOptionString(LeftRecursiveRuleTransformer.PRECEDENCE_OPTION_NAME) != null) {
      precedence = Integer.parseInt(((GrammarASTWithOptions)node).getOptionString(LeftRecursiveRuleTransformer.PRECEDENCE_OPTION_NAME));
View Full Code Here

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

   */
  void createRuleStartAndStopATNStates() {
    atn.ruleToStartState = new RuleStartState[g.rules.size()];
    atn.ruleToStopState = new RuleStopState[g.rules.size()];
    for (Rule r : g.rules.values()) {
      RuleStartState start = newState(RuleStartState.class, r.ast);
      RuleStopState stop = newState(RuleStopState.class, r.ast);
      start.stopState = stop;
      start.isPrecedenceRule = r instanceof LeftRecursiveRule;
      start.setRuleIndex(r.index);
      stop.setRuleIndex(r.index);
      atn.ruleToStartState[r.index] = start;
      atn.ruleToStopState[r.index] = stop;
    }
  }
View Full Code Here

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

    return grammarFileName;
  }

  /** Begin parsing at startRuleIndex */
  public ParserRuleContext parse(int startRuleIndex) {
    RuleStartState startRuleStartState = atn.ruleToStartState[startRuleIndex];

    InterpreterRuleContext rootContext = new InterpreterRuleContext(null, ATNState.INVALID_STATE_NUMBER, startRuleIndex);
    if (startRuleStartState.isPrecedenceRule) {
      enterRecursionRule(rootContext, startRuleStartState.stateNumber, startRuleIndex, 0);
    }
View Full Code Here

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

    case Transition.WILDCARD:
      matchWildcard();
      break;

    case Transition.RULE:
      RuleStartState ruleStartState = (RuleStartState)transition.target;
      int ruleIndex = ruleStartState.ruleIndex;
      InterpreterRuleContext ctx = new InterpreterRuleContext(_ctx, p.stateNumber, ruleIndex);
      if (ruleStartState.isPrecedenceRule) {
        enterRecursionRule(ctx, ruleStartState.stateNumber, ruleIndex, ((RuleTransition)transition).precedence);
      }
View Full Code Here

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

    setState(transition.target.stateNumber);
  }

  protected void visitRuleStopState(ATNState p) {
    RuleStartState ruleStartState = atn.ruleToStartState[p.ruleIndex];
    if (ruleStartState.isPrecedenceRule) {
      Pair<ParserRuleContext, Integer> parentContext = _parentContextStack.pop();
      unrollRecursionContexts(parentContext.a);
      setState(parentContext.b);
    }
View Full Code Here

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

    for (String modeName : modes) {
      List<Rule> rules = ((LexerGrammar)g).modes.get(modeName);
      TokensStartState startState = atn.modeNameToStartState.get(modeName);
      for (Rule r : rules) {
        if ( !r.isFragment() ) {
          RuleStartState s = atn.ruleToStartState[r.index];
          epsilon(startState, s);
        }
      }
    }
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.