Package org.antlr.v4.runtime.misc

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


      else if ( t.getClass() == WildcardTransition.class ) {
        look.addAll( IntervalSet.of(Token.MIN_USER_TOKEN_TYPE, atn.maxTokenType) );
      }
      else {
//        System.out.println("adding "+ t);
        IntervalSet set = t.label();
        if (set != null) {
          if (t instanceof NotSetTransition) {
            set = set.complement(IntervalSet.of(Token.MIN_USER_TOKEN_TYPE, atn.maxTokenType));
          }
          look.addAll(set);
        }
      }
    }
View Full Code Here


    /** Public default constructor used by TestRig */
    public TestIntervalSet() {
  }

  @Test public void testSingleElement() throws Exception {
    IntervalSet s = IntervalSet.of(99);
    String expecting = "99";
    assertEquals(s.toString(), expecting);
  }
View Full Code Here

    assertEquals(Token.EPSILON, IntervalSet.COMPLETE_CHAR_SET.or(IntervalSet.of(Token.EPSILON)).getMinElement());
    assertEquals(Token.EOF, IntervalSet.COMPLETE_CHAR_SET.or(IntervalSet.of(Token.EOF)).getMinElement());
  }

  @Test public void testIsolatedElements() throws Exception {
    IntervalSet s = new IntervalSet();
    s.add(1);
    s.add('z');
    s.add('\uFFF0');
    String expecting = "{1, 122, 65520}";
        assertEquals(s.toString(), expecting);
    }
View Full Code Here

    String expecting = "{1, 122, 65520}";
        assertEquals(s.toString(), expecting);
    }

    @Test public void testMixedRangesAndElements() throws Exception {
        IntervalSet s = new IntervalSet();
        s.add(1);
        s.add('a','z');
        s.add('0','9');
        String expecting = "{1, 48..57, 97..122}";
        assertEquals(s.toString(), expecting);
    }
View Full Code Here

        String expecting = "{1, 48..57, 97..122}";
        assertEquals(s.toString(), expecting);
    }

    @Test public void testSimpleAnd() throws Exception {
        IntervalSet s = IntervalSet.of(10,20);
        IntervalSet s2 = IntervalSet.of(13,15);
        String expecting = "{13..15}";
        String result = (s.and(s2)).toString();
        assertEquals(expecting, result);
    }
View Full Code Here

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

    @Test public void testRangeAndIsolatedElement() throws Exception {
        IntervalSet s = IntervalSet.of('a','z');
        IntervalSet s2 = IntervalSet.of('d');
        String expecting = "100";
        String result = (s.and(s2)).toString();
        assertEquals(expecting, result);
    }
View Full Code Here

    List<IntervalSet> sets = new ArrayList<IntervalSet>();
    int nsets = toInt(data[p++]);
    for (int i=0; i<nsets; i++) {
      int nintervals = toInt(data[p]);
      p++;
      IntervalSet set = new IntervalSet();
      sets.add(set);

      boolean containsEof = toInt(data[p++]) != 0;
      if (containsEof) {
        set.add(-1);
      }

      for (int j=0; j<nintervals; j++) {
        set.add(toInt(data[p]), toInt(data[p + 1]));
        p += 2;
      }
    }

    //
View Full Code Here

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

  @Test public void testEmptyIntersection() throws Exception {
    IntervalSet s = IntervalSet.of('a','z');
    IntervalSet s2 = IntervalSet.of('0','9');
    String expecting = "{}";
    String result = (s.and(s2)).toString();
    assertEquals(expecting, result);
  }
View Full Code Here

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

  @Test public void testEmptyIntersectionSingleElements() throws Exception {
    IntervalSet s = IntervalSet.of('a');
    IntervalSet s2 = IntervalSet.of('d');
    String expecting = "{}";
    String result = (s.and(s2)).toString();
    assertEquals(expecting, result);
  }
View Full Code Here

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

    @Test public void testNotSingleElement() throws Exception {
        IntervalSet vocabulary = IntervalSet.of(1,1000);
        vocabulary.add(2000,3000);
        IntervalSet s = IntervalSet.of(50,50);
        String expecting = "{1..49, 51..1000, 2000..3000}";
        String result = (s.complement(vocabulary)).toString();
        assertEquals(expecting, result);
    }
View Full Code Here

TOP

Related Classes of org.antlr.v4.runtime.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.