Package org.antlr.misc

Examples of org.antlr.misc.IntervalSet


        String result = (s.complement(s2)).toString();
        assertEquals(result, expecting);
    }

  @Test public void testComplement2() throws Exception {
    IntervalSet s = IntervalSet.of(100,101);
    IntervalSet s2 = IntervalSet.of(100,102);
    String expecting = "102";
    String result = (s.complement(s2)).toString();
    assertEquals(result, expecting);
  }
View Full Code Here


    String result = (s.complement(s2)).toString();
    assertEquals(result, expecting);
  }

  @Test public void testComplement3() throws Exception {
    IntervalSet s = IntervalSet.of(1,96);
    s.add(99,Label.MAX_CHAR_VALUE);
    String expecting = "97..98";
    String result = (s.complement(1,Label.MAX_CHAR_VALUE)).toString();
    assertEquals(result, expecting);
  }
View Full Code Here

    assertEquals(result, expecting);
  }

    @Test public void testMergeOfRangesAndSingleValues() throws Exception {
        // {0..41, 42, 43..65534}
        IntervalSet s = IntervalSet.of(0,41);
        s.add(42);
        s.add(43,65534);
        String expecting = "0..65534";
        String result = s.toString();
        assertEquals(result, expecting);
    }
View Full Code Here

        String result = s.toString();
        assertEquals(result, expecting);
    }

    @Test public void testMergeOfRangesAndSingleValuesReverse() throws Exception {
        IntervalSet s = IntervalSet.of(43,65534);
        s.add(42);
        s.add(0,41);
        String expecting = "0..65534";
        String result = s.toString();
        assertEquals(result, expecting);
    }
View Full Code Here

        assertEquals(result, expecting);
    }

    @Test public void testMergeWhereAdditionMergesTwoExistingIntervals() throws Exception {
        // 42, 10, {0..9, 11..41, 43..65534}
        IntervalSet s = IntervalSet.of(42);
        s.add(10);
        s.add(0,9);
        s.add(43,65534);
        s.add(11,41);
        String expecting = "0..65534";
        String result = s.toString();
        assertEquals(result, expecting);
    }
View Full Code Here

            smax = label.getAtom();
          }
        }
      }
      else if ( label.isSet() ) {
        IntervalSet labels = (IntervalSet)label.getSet();
        int lmin = labels.getMinElement();
        // if valid char (don't do EOF) and less than current min
        if ( lmin<smin && lmin>=Label.MIN_CHAR_VALUE ) {
          smin = labels.getMinElement();
        }
        if ( labels.getMaxElement()>smax ) {
          smax = labels.getMaxElement();
        }
      }
    }

    if ( smax<0 ) {
View Full Code Here

        int labelIndex = label.getAtom()-smin; // offset from 0
        stateTransitions.set(labelIndex,
                   Utils.integer(edge.target.stateNumber));
      }
      else if ( label.isSet() ) {
        IntervalSet labels = (IntervalSet)label.getSet();
        int[] atoms = labels.toArray();
        for (int a = 0; a < atoms.length; a++) {
          // set the transition if the label is valid (don't do EOF)
          if ( atoms[a]>=Label.MIN_CHAR_VALUE ) {
            int labelIndex = atoms[a]-smin; // offset from 0
            stateTransitions.set(labelIndex,
View Full Code Here

          // eof[s] points to accept state
          eof.set(s.stateNumber, Utils.integer(edge.target.stateNumber));
        }
      }
      else if ( label.isSet() ) {
        IntervalSet labels = (IntervalSet)label.getSet();
        int[] atoms = labels.toArray();
        for (int a = 0; a < atoms.length; a++) {
          if ( atoms[a]==Label.EOT ) {
            // eot[s] points to accept state
            eot.set(s.stateNumber, Utils.integer(edge.target.stateNumber));
          }
View Full Code Here

    this.decisionNumber = decisionNumber;
    this.decisionNFAStartState = decisionStartState;
    initAltRelatedInfo();
    unreachableAlts = null;
    for (Iterator it = edgeMap.keySet().iterator(); it.hasNext();) {
      IntervalSet edge = (IntervalSet)it.next();
      List<Integer> alts = edgeMap.get(edge);
      Collections.sort(alts); // make sure alts are attempted in order
      //System.out.println(edge+" -> "+alts);
      DFAState s = newState();
      s.k = 1;
View Full Code Here

  public Object clone() {
    Label l;
    try {
      l = (Label)super.clone();
      l.label = this.label;
            l.labelSet = new IntervalSet();
      l.labelSet.addAll(this.labelSet);
    }
    catch (CloneNotSupportedException e) {
      throw new InternalError();
    }
View Full Code Here

TOP

Related Classes of org.antlr.misc.IntervalSet

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.