Package org.antlr.v4.runtime.misc

Examples of org.antlr.v4.runtime.misc.Interval


    ATNState eofTarget = newState(null); // one unique EOF target for all rules
    for (Rule r : g.rules.values()) {
      ATNState stop = atn.ruleToStopState[r.index];
      if ( stop.getNumberOfTransitions()>0 ) continue;
      n++;
      Transition t = new AtomTransition(eofTarget, Token.EOF);
      stop.addTransition(t);
    }
    return n;
  }
View Full Code Here


    visited.add(s.stateNumber);

    visitState(s);
    int n = s.getNumberOfTransitions();
    for (int i=0; i<n; i++) {
      Transition t = s.transition(i);
      visit_(t.target, visited);
    }
  }
View Full Code Here

    //System.out.println("visit "+s);
    int n = s.getNumberOfTransitions();
    boolean stateReachesStopState = false;
    for (int i=0; i<n; i++) {
      Transition t = s.transition(i);
      if ( t instanceof RuleTransition ) {
        RuleTransition rt = (RuleTransition) t;
        Rule r = g.getRule(rt.ruleIndex);
        if ( rulesVisitedPerRuleCheck.contains((RuleStartState)t.target) ) {
          addRulesToCycle(enclosingRule, r);
        }
        else {
          // must visit if not already visited; mark target, pop when done
          rulesVisitedPerRuleCheck.add((RuleStartState)t.target);
          // send new visitedStates set per rule invocation
          boolean nullable = check(r, t.target, new HashSet<ATNState>());
          // we're back from visiting that rule
          rulesVisitedPerRuleCheck.remove((RuleStartState)t.target);
          if ( nullable ) {
            stateReachesStopState |= check(enclosingRule, rt.followState, visitedStates);
          }
        }
      }
      else if ( t.isEpsilon() ) {
        stateReachesStopState |= check(enclosingRule, t.target, visitedStates);
      }
      // else ignore non-epsilon transitions
    }
    return stateReachesStopState;
View Full Code Here

  @NotNull
  @Override
  public Handle wildcard(@NotNull GrammarAST node) {
    ATNState left = newState(node);
    ATNState right = newState(node);
    left.addTransition(new WildcardTransition(right));
    node.atnState = left;
    return new Handle(left, right);
  }
View Full Code Here

    }
  }

  protected void reportAttemptingFullContext(@NotNull DFA dfa, @Nullable BitSet conflictingAlts, @NotNull ATNConfigSet configs, int startIndex, int stopIndex) {
        if ( debug || retry_debug ) {
      Interval interval = Interval.of(startIndex, stopIndex);
      System.out.println("reportAttemptingFullContext decision="+dfa.decision+":"+configs+
                               ", input="+parser.getTokenStream().getText(interval));
        }
        if ( parser!=null ) parser.getErrorListenerDispatch().reportAttemptingFullContext(parser, dfa, startIndex, stopIndex, conflictingAlts, configs);
    }
View Full Code Here

        if ( parser!=null ) parser.getErrorListenerDispatch().reportAttemptingFullContext(parser, dfa, startIndex, stopIndex, conflictingAlts, configs);
    }

  protected void reportContextSensitivity(@NotNull DFA dfa, int prediction, @NotNull ATNConfigSet configs, int startIndex, int stopIndex) {
        if ( debug || retry_debug ) {
      Interval interval = Interval.of(startIndex, stopIndex);
            System.out.println("reportContextSensitivity decision="+dfa.decision+":"+configs+
                               ", input="+parser.getTokenStream().getText(interval));
        }
        if ( parser!=null ) parser.getErrorListenerDispatch().reportContextSensitivity(parser, dfa, startIndex, stopIndex, prediction, configs);
    }
View Full Code Here

                   boolean exact,
                   @Nullable BitSet ambigAlts,
                   @NotNull ATNConfigSet configs)
  {
    if ( debug || retry_debug ) {
      Interval interval = Interval.of(startIndex, stopIndex);
      System.out.println("reportAmbiguity "+
                 ambigAlts+":"+configs+
                               ", input="+parser.getTokenStream().getText(interval));
        }
        if ( parser!=null ) parser.getErrorListenerDispatch().reportAmbiguity(parser, dfa, startIndex, stopIndex,
View Full Code Here

  @Override
  public Interval getSourceInterval() {
    if ( symbol ==null ) return Interval.INVALID;

    int tokenIndex = symbol.getTokenIndex();
    return new Interval(tokenIndex, tokenIndex);
  }
View Full Code Here

      left.addTransition(new NotSetTransition(right, set));
    }
    else {
      Transition transition;
      if (set.getIntervals().size() == 1) {
        Interval interval = set.getIntervals().get(0);
        transition = new RangeTransition(right, interval.a, interval.b);
      } else {
        transition = new SetTransition(right, set);
      }
View Full Code Here

    if ( ast==null ) return stateToGrammarRegionMap;

    List<GrammarAST> nodes = ast.getNodesWithType(grammarTokenTypes);
    for (GrammarAST n : nodes) {
      if (n.atnState != null) {
        Interval tokenRegion = Interval.of(n.getTokenStartIndex(), n.getTokenStopIndex());
        org.antlr.runtime.tree.Tree ruleNode = null;
        // RULEs, BLOCKs of transformed recursive rules point to original token interval
        switch ( n.getType() ) {
          case ANTLRParser.RULE :
            ruleNode = n;
View Full Code Here

TOP

Related Classes of org.antlr.v4.runtime.misc.Interval

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.