Package net.sf.lapg.lex

Examples of net.sf.lapg.lex.RegexpParser.compile()


      Assert.assertEquals("regexp contains \\ at the end of expression", ex.getMessage());
      Assert.assertEquals(4, ex.getErrorOffset());
    }

    try {
      rp.compile(5, "paren3", "aaa\\4a5!zzz");
    } catch (RegexpParseException ex) {
      Assert.assertEquals("regexp contains incomplete unicode symbol", ex.getMessage());
      Assert.assertEquals(7, ex.getErrorOffset());
    }
View Full Code Here


      Assert.assertEquals("regexp contains incomplete unicode symbol", ex.getMessage());
      Assert.assertEquals(7, ex.getErrorOffset());
    }

    try {
      rp.compile(5, "paren3", "aaa\\4a");
    } catch (RegexpParseException ex) {
      Assert.assertEquals("regexp contains incomplete unicode symbol", ex.getMessage());
      Assert.assertEquals(6, ex.getErrorOffset());
    }
  }
View Full Code Here

    Assert.assertEquals("75e1", toHex4(0x75e1));

    RegexpParser rp = new RegexpParser();
    try{
      for(int i = 0; i < 2000; i++) {
        rp.compile(i, "n"+i, "[\\x"+toHex4(i*10)+"-\\x"+toHex4(i*10+6)+"]");
      }
      for(int i = 0; i < 2000; i++) {
        rp.compile(i, "nb"+i, "[\\x"+toHex4(i*10+3)+"-\\x"+toHex4(i*10+8)+"]");
      }
    } catch(RegexpParseException ex) {
View Full Code Here

    try{
      for(int i = 0; i < 2000; i++) {
        rp.compile(i, "n"+i, "[\\x"+toHex4(i*10)+"-\\x"+toHex4(i*10+6)+"]");
      }
      for(int i = 0; i < 2000; i++) {
        rp.compile(i, "nb"+i, "[\\x"+toHex4(i*10+3)+"-\\x"+toHex4(i*10+8)+"]");
      }
    } catch(RegexpParseException ex) {
      Assert.fail("parse failed: " + ex.getMessage());
    }
    rp.buildSets();
View Full Code Here

  }

  public void testRegexpParserInvertedSet() {
    RegexpParser rp = new RegexpParser();
    try {
      rp.compile(0, "string", "'[^'\n]+'");
      rp.compile(1, "percent", "%");
    } catch(RegexpParseException ex) {
      Assert.fail("parse failed: " + ex.getMessage());
    }
    rp.buildSets();
View Full Code Here

  public void testRegexpParserInvertedSet() {
    RegexpParser rp = new RegexpParser();
    try {
      rp.compile(0, "string", "'[^'\n]+'");
      rp.compile(1, "percent", "%");
    } catch(RegexpParseException ex) {
      Assert.fail("parse failed: " + ex.getMessage());
    }
    rp.buildSets();
    Assert.assertEquals("[0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 4, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 3, 1, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]", Arrays.toString(rp.getCharacterMap()));
View Full Code Here

  }

  public void testRegexpParser() {
    RegexpParser rp = new RegexpParser();
    try {
      rp.compile(0, "string", "[a-zA-Z_][a-zA-Z0-9_]*");
      rp.buildSets();
      Assert.assertEquals("[0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 1, 1, 1, 2, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1]", Arrays.toString(rp.getCharacterMap()));

      rp = new RegexpParser();
      rp.compile(0, "string", "[a-zA-Z_][a-zA-Z0-9_]*");
 
View Full Code Here

      rp.compile(0, "string", "[a-zA-Z_][a-zA-Z0-9_]*");
      rp.buildSets();
      Assert.assertEquals("[0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 1, 1, 1, 2, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1]", Arrays.toString(rp.getCharacterMap()));

      rp = new RegexpParser();
      rp.compile(0, "string", "[a-zA-Z_][a-zA-Z0-9_]*");
      rp.compile(1, "keyw", "do");
      rp.buildSets();
      Assert.assertEquals("[0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 1, 1, 1, 1, 1, 1, 1, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 1, 1, 1, 1, 4, 1, 4, 4, 4, 2, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 3, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 1, 1, 1, 1, 1]", Arrays.toString(rp.getCharacterMap()));

      rp = new RegexpParser();
View Full Code Here

      rp.buildSets();
      Assert.assertEquals("[0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 1, 1, 1, 2, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1]", Arrays.toString(rp.getCharacterMap()));

      rp = new RegexpParser();
      rp.compile(0, "string", "[a-zA-Z_][a-zA-Z0-9_]*");
      rp.compile(1, "keyw", "do");
      rp.buildSets();
      Assert.assertEquals("[0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 1, 1, 1, 1, 1, 1, 1, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 1, 1, 1, 1, 4, 1, 4, 4, 4, 2, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 3, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 1, 1, 1, 1, 1]", Arrays.toString(rp.getCharacterMap()));

      rp = new RegexpParser();
      rp.compile(0, "string", "[a-w][p-z]");
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. 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.