Package net.sf.lapg.lex

Examples of net.sf.lapg.lex.CharacterSet


    CharacterSet.Builder b = new CharacterSet.Builder();

    b.clear();
    b.addRange('a', 'z');
    b.addSymbol('_');
    CharacterSet set = b.create();

    b.clear();
    b.addSymbol('i');
    b.addSymbol('e');
    b.addSymbol('c');
    CharacterSet set2 = b.create();
    Assert.assertEquals("[95,97-98,100,102-104,106-122]", b.subtract(set, set2).toString());
  }
View Full Code Here


    CharacterSet.Builder b = new CharacterSet.Builder();

    b.clear();
    b.addRange('a', 'l');
    b.addSymbol('_');
    CharacterSet set = b.create();

    b.clear();
    b.addSymbol('i');
    b.addSymbol('e');
    b.addSymbol('c');
    CharacterSet set2 = b.create();

    set = b.subtract(set, set2);
    Iterator<int[]> it = set.iterator();

    Assert.assertEquals(true, it.hasNext());
View Full Code Here

  private static final int TESTLEN = 9;

  public void testSubtractGeneric() {
    CharacterSet.Builder b = new CharacterSet.Builder();
    CharacterSet s1, s2, s3;
    int[] array1 = new int[TESTLEN];
    int[] array2 = new int[TESTLEN];
    int[] array3 = new int[TESTLEN];

    fillArray(array1, 255);
View Full Code Here

    }
  }

  public void testIntersectGeneric() {
    CharacterSet.Builder b = new CharacterSet.Builder();
    CharacterSet s1, s2, s3;
    int[] array1 = new int[TESTLEN];
    int[] array2 = new int[TESTLEN];
    int[] array3 = new int[TESTLEN];

    for(int i = 0; i < (1<<TESTLEN); i++) {
View Full Code Here

  private static final int ARTESTLEN = 12;

  public void testAddRangeGeneric() {
    CharacterSet.Builder b = new CharacterSet.Builder();
    CharacterSet s2, s3;
    int[] array1 = new int[ARTESTLEN];
    int[] array2 = new int[ARTESTLEN];

    for(int i = 0; i < (1<<ARTESTLEN); i++) {
      fillArray(array1, i);

      for(int start = 0; start < ARTESTLEN; start++) {
        for(int end = start; end < ARTESTLEN; end++) {
          for(int e = 0; e < ARTESTLEN; e++) {
            array2[e] = (e >= start && e <= end) ? 1 : array1[e];
          }
          b.clear();

          int q = 0;
          while(q < array1.length) {
            if(array1[q] == 1) {
              int st = q;
              while(q+1 < array1.length && array1[q+1] == 1) {
                q++;
              }
              b.addRange(st, q);
            }
            q++;
          }

          b.addRange(start, end);
          s2 = b.create();

          s3 = fromArray(array2,b);
          Assert.assertEquals(i+": "+start+"-"+end,
              s3.toString(), s2.toString());
        }
      }
    }
  }
View Full Code Here

    }
  }

  private static void subtract(int[] a1, int[] a2, String result) {
    CharacterSet.Builder b = new CharacterSet.Builder();
    Assert.assertEquals(result, b.subtract(new CharacterSet(a1, a1.length), new CharacterSet(a2, a2.length)).toString());
  }
View Full Code Here

TOP

Related Classes of net.sf.lapg.lex.CharacterSet

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.