Package org.antlr.v4.runtime.atn

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


    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));
    }
    RuleTransition call = new RuleTransition(start, r.index, precedence, right);
    left.addTransition(call);

    node.atnState = left;
    return new Handle(left, right);
  }
View Full Code Here


        for (ATNState p : atn.states) {
            if ( p!=null &&
                 p.getStateType() == ATNState.BASIC && p.getNumberOfTransitions()==1 &&
                 p.transition(0) instanceof RuleTransition )
            {
                RuleTransition rt = (RuleTransition) p.transition(0);
                addFollowLink(rt.ruleIndex, rt.followState);
            }
        }
    }
View Full Code Here

    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 {
View Full Code Here

    }
    if ( invert ) {
      left.addTransition(new NotSetTransition(right, set));
    }
    else {
      left.addTransition(new SetTransition(right, set));
    }
    associatedAST.atnState = left;
    return new Handle(left, right);
  }
View Full Code Here

      "}\n";
    assertEquals(expecting, toDOTString(r, fullCtx()));
  }

  @Test public void test_Aab_Ac() { // a,b + c
    SingletonPredictionContext a = a();
    SingletonPredictionContext b = b();
    SingletonPredictionContext c = c();
    ArrayPredictionContext A1 = array(a, b);
    ArrayPredictionContext A2 = array(c);
    PredictionContext r = PredictionContext.merge(A1, A2, rootIsWildcard(), null);
    System.out.println(toDOTString(r, rootIsWildcard()));
    String expecting =
View Full Code Here

      "}\n";
    assertEquals(expecting, toDOTString(r, rootIsWildcard()));
  }

  @Test public void test_Aa_Aa() {
    SingletonPredictionContext a1 = a();
    SingletonPredictionContext a2 = a();
    ArrayPredictionContext A1 = array(a1);
    ArrayPredictionContext A2 = array(a2);
    PredictionContext r = PredictionContext.merge(A1, A2, rootIsWildcard(), null);
    System.out.println(toDOTString(r, rootIsWildcard()));
    String expecting =
View Full Code Here

      "}\n";
    assertEquals(expecting, toDOTString(r, rootIsWildcard()));
  }

  @Test public void test_Aa_Abc() { // a + b,c
    SingletonPredictionContext a = a();
    SingletonPredictionContext b = b();
    SingletonPredictionContext c = c();
    ArrayPredictionContext A1 = array(a);
    ArrayPredictionContext A2 = array(b, c);
    PredictionContext r = PredictionContext.merge(A1, A2, rootIsWildcard(), null);
    System.out.println(toDOTString(r, rootIsWildcard()));
    String expecting =
View Full Code Here

      "}\n";
    assertEquals(expecting, toDOTString(r, rootIsWildcard()));
  }

  @Test public void test_Aac_Ab() { // a,c + b
    SingletonPredictionContext a = a();
    SingletonPredictionContext b = b();
    SingletonPredictionContext c = c();
    ArrayPredictionContext A1 = array(a, c);
    ArrayPredictionContext A2 = array(b);
    PredictionContext r = PredictionContext.merge(A1, A2, rootIsWildcard(), null);
    System.out.println(toDOTString(r, rootIsWildcard()));
    String expecting =
View Full Code Here

      "}\n";
    assertEquals(expecting, toDOTString(r, rootIsWildcard()));
  }

  @Test public void test_Aax_Aby() { // ax + by but in arrays
    SingletonPredictionContext a = createSingleton(x(), 1);
    SingletonPredictionContext b = createSingleton(y(), 2);
    ArrayPredictionContext A1 = array(a);
    ArrayPredictionContext A2 = array(b);
    PredictionContext r = PredictionContext.merge(A1, A2, rootIsWildcard(), null);
    System.out.println(toDOTString(r, rootIsWildcard()));
    String expecting =
View Full Code Here

      "}\n";
    assertEquals(expecting, toDOTString(r, rootIsWildcard()));
  }

  @Test public void test_Aax_Aay() { // ax + ay -> merged singleton a, array parent
    SingletonPredictionContext a1 = createSingleton(x(), 1);
    SingletonPredictionContext a2 = createSingleton(y(), 1);
    ArrayPredictionContext A1 = array(a1);
    ArrayPredictionContext A2 = array(a2);
    PredictionContext r = PredictionContext.merge(A1, A2, rootIsWildcard(), null);
    System.out.println(toDOTString(r, rootIsWildcard()));
    String expecting =
View Full Code Here

TOP

Related Classes of org.antlr.v4.runtime.atn.SingletonPredictionContext

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.