Package org.antlr.v4.runtime.misc

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


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

  @Test public void testNotSet() throws Exception {
    IntervalSet vocabulary = IntervalSet.of(1,1000);
    IntervalSet s = IntervalSet.of(50,60);
    s.add(5);
    s.add(250,300);
    String expecting = "{1..4, 6..49, 61..249, 301..1000}";
    String result = (s.complement(vocabulary)).toString();
    assertEquals(expecting, result);
  }
View Full Code Here


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

  @Test public void testNotEqualSet() throws Exception {
    IntervalSet vocabulary = IntervalSet.of(1,1000);
    IntervalSet s = IntervalSet.of(1,1000);
    String expecting = "{}";
    String result = (s.complement(vocabulary)).toString();
    assertEquals(expecting, result);
  }
View Full Code Here

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

  @Test public void testNotSetEdgeElement() throws Exception {
    IntervalSet vocabulary = IntervalSet.of(1,2);
    IntervalSet s = IntervalSet.of(1);
    String expecting = "2";
    String result = (s.complement(vocabulary)).toString();
    assertEquals(expecting, result);
  }
View Full Code Here

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

    @Test public void testNotSetFragmentedVocabulary() throws Exception {
        IntervalSet vocabulary = IntervalSet.of(1,255);
        vocabulary.add(1000,2000);
        vocabulary.add(9999);
        IntervalSet s = IntervalSet.of(50, 60);
        s.add(3);
        s.add(250,300);
        s.add(10000); // this is outside range of vocab and should be ignored
        String expecting = "{1..2, 4..49, 61..249, 1000..2000, 9999}";
        String result = (s.complement(vocabulary)).toString();
        assertEquals(expecting, result);
    }
View Full Code Here

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

    @Test public void testSubtractOfCompletelyContainedRange() throws Exception {
        IntervalSet s = IntervalSet.of(10,20);
        IntervalSet s2 = IntervalSet.of(12,15);
        String expecting = "{10..11, 16..20}";
        String result = (s.subtract(s2)).toString();
        assertEquals(expecting, result);
    }
View Full Code Here

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

  @Test public void testSubtractFromSetWithEOF() throws Exception {
    IntervalSet s = IntervalSet.of(10,20);
    s.add(Token.EOF);
    IntervalSet s2 = IntervalSet.of(12,15);
    String expecting = "{<EOF>, 10..11, 16..20}";
    String result = (s.subtract(s2)).toString();
    assertEquals(expecting, result);
  }
View Full Code Here

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

  @Test public void testSubtractOfOverlappingRangeFromLeft() throws Exception {
    IntervalSet s = IntervalSet.of(10,20);
    IntervalSet s2 = IntervalSet.of(5,11);
    String expecting = "{12..20}";
        String result = (s.subtract(s2)).toString();
        assertEquals(expecting, result);

        IntervalSet s3 = IntervalSet.of(5,10);
        expecting = "{11..20}";
        result = (s.subtract(s3)).toString();
        assertEquals(expecting, result);
    }
View Full Code Here

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

    @Test public void testSubtractOfOverlappingRangeFromRight() throws Exception {
        IntervalSet s = IntervalSet.of(10,20);
        IntervalSet s2 = IntervalSet.of(15,25);
        String expecting = "{10..14}";
        String result = (s.subtract(s2)).toString();
        assertEquals(expecting, result);

        IntervalSet s3 = IntervalSet.of(20,25);
        expecting = "{10..19}";
        result = (s.subtract(s3)).toString();
        assertEquals(expecting, result);
    }
View Full Code Here

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

    @Test public void testSubtractOfCompletelyCoveredRange() throws Exception {
        IntervalSet s = IntervalSet.of(10,20);
        IntervalSet s2 = IntervalSet.of(1,25);
        String expecting = "{}";
        String result = (s.subtract(s2)).toString();
        assertEquals(expecting, result);
    }
View Full Code Here

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

    @Test public void testSubtractOfRangeSpanningMultipleRanges() throws Exception {
        IntervalSet s = IntervalSet.of(10,20);
        s.add(30,40);
        s.add(50,60); // s has 3 ranges now: 10..20, 30..40, 50..60
        IntervalSet s2 = IntervalSet.of(5,55); // covers one and touches 2nd range
        String expecting = "{56..60}";
        String result = (s.subtract(s2)).toString();
        assertEquals(expecting, result);

        IntervalSet s3 = IntervalSet.of(15,55); // touches both
        expecting = "{10..14, 56..60}";
        result = (s.subtract(s3)).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.