Package org.antlr.v4.runtime.atn

Examples of org.antlr.v4.runtime.atn.ATNState.transition()


    RuleContext ctx = recognizer._ctx;
    IntervalSet recoverSet = new IntervalSet();
    while ( ctx!=null && ctx.invokingState>=0 ) {
      // compute what follows who invoked us
      ATNState invokingState = atn.states.get(ctx.invokingState);
      RuleTransition rt = (RuleTransition)invokingState.transition(0);
      IntervalSet follow = atn.nextTokens(rt.followState);
      recoverSet.addAll(follow);
      ctx = ctx.parent;
    }
        recoverSet.remove(Token.EPSILON);
View Full Code Here


                  @Nullable String message)
  {
    super(formatMessage(predicate, message), recognizer, recognizer.getInputStream(), recognizer._ctx);
    ATNState s = recognizer.getInterpreter().atn.states.get(recognizer.getState());

    AbstractPredicateTransition trans = (AbstractPredicateTransition)s.transition(0);
    if (trans instanceof PredicateTransition) {
      this.ruleIndex = ((PredicateTransition)trans).ruleIndex;
      this.predicateIndex = ((PredicateTransition)trans).predIndex;
    }
    else {
View Full Code Here

//        System.out.println("following "+s+"="+following);
        if ( !following.contains(Token.EPSILON) ) return false;

        while ( ctx!=null && ctx.invokingState>=0 && following.contains(Token.EPSILON) ) {
            ATNState invokingState = atn.states.get(ctx.invokingState);
            RuleTransition rt = (RuleTransition)invokingState.transition(0);
            following = atn.nextTokens(rt.followState);
            if (following.contains(symbol)) {
                return true;
            }
View Full Code Here

      }
      if (q.getStateType() == ATNState.BASIC) {
        // we have p-x->q for x in {rule, action, pred, token, ...}
        // if edge out of q is single epsilon to block end
        // we can strip epsilon p-x->q-eps->r
        Transition trans = q.transition(0);
        if (q.getNumberOfTransitions() == 1 && trans instanceof EpsilonTransition) {
          ATNState r = trans.target;
          if (r instanceof BlockEndState || r instanceof PlusLoopbackState || r instanceof StarLoopbackState) {
            // skip over q
            if (p.transition(0) instanceof RuleTransition) {
View Full Code Here

      if ( marked.contains(s) ) continue;
      int n = s.getNumberOfTransitions();
//      System.out.println("visit "+s+"; edges="+n);
      marked.add(s);
      for (int i=0; i<n; i++) {
        Transition t = s.transition(i);
        if ( !(s instanceof RuleStopState) ) { // don't add follow states to work
          if ( t instanceof RuleTransition ) work.add(((RuleTransition)t).followState);
          else work.add( t.target );
        }
        buf.append(getStateString(s));
View Full Code Here

//      }

      // make a DOT edge for each transition
      ST edgeST;
      for (int i = 0; i < s.getNumberOfTransitions(); i++) {
        Transition edge = s.transition(i);
        if ( edge instanceof RuleTransition ) {
          RuleTransition rr = ((RuleTransition)edge);
          // don't jump to other rules, but display edge to follow node
          edgeST = stlib.getInstanceOf("edge");
View Full Code Here

    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];
    if ( startState.transition(0).target instanceof BlockStartState ) {
      startState = startState.transition(0).target;
    }

    DOTGenerator dot = new DOTGenerator(g);
    System.out.println(dot.getDOT(atn.ruleToStartState[g.getRule("a").index]));
View Full Code Here

    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];
    if ( startState.transition(0).target instanceof BlockStartState ) {
      startState = startState.transition(0).target;
    }

    DOTGenerator dot = new DOTGenerator(g);
    System.out.println(dot.getDOT(atn.ruleToStartState[g.getRule("a").index]));
    Rule r = g.getRule("e");
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.