Package net.sf.lapg.lex

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


      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]");
      rp.compile(1, "string2", "[b-c][y-z]");
      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, 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, 2, 5, 5, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 4, 4, 4, 4, 4, 4, 4, 4, 3, 6, 6, 1, 1, 1, 1, 1]", Arrays.toString(rp.getCharacterMap()));
      int[][] p = rp.getSetToSymbolsMap();
      Assert.assertEquals("[2, 4, 5]", Arrays.toString(p[0]));
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, 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]");
      rp.compile(1, "string2", "[b-c][y-z]");
      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, 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, 2, 5, 5, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 4, 4, 4, 4, 4, 4, 4, 4, 3, 6, 6, 1, 1, 1, 1, 1]", Arrays.toString(rp.getCharacterMap()));
      int[][] p = rp.getSetToSymbolsMap();
      Assert.assertEquals("[2, 4, 5]", Arrays.toString(p[0]));
      Assert.assertEquals("[3, 4, 6]", Arrays.toString(p[1]));
View Full Code Here

  }

  public void testUnicode() {
    RegexpParser rp = new RegexpParser();
    try {
      rp.compile(0, "string", "[\\x5151-\\x5252][\\x1000-\\x2000]");
    } catch (RegexpParseException ex) {
      Assert.fail("parse failed: " + ex.getMessage());
    }
    int[] expected = new int[0x8000];
    Arrays.fill(expected, 1);
View Full Code Here

  }

  public void testParserExc() {
    RegexpParser rp = new RegexpParser();
    try {
      rp.compile(0, "string", "[\\x5151-\\x5252][\\x1000-\\x2000");
    } catch (RegexpParseException ex) {
      Assert.assertEquals("regexp contains unpaired brackets", ex.getMessage());
      Assert.assertEquals(29, ex.getErrorOffset());
    }
View Full Code Here

      Assert.assertEquals("regexp contains unpaired brackets", ex.getMessage());
      Assert.assertEquals(29, ex.getErrorOffset());
    }

    try {
      rp.compile(1, "string1", "[\\x5151]]-\\x5252]][\\x1000-\\x2000");
    } catch (RegexpParseException ex) {
      Assert.assertEquals("unexpected closing brace, escape it to use as character", ex.getMessage());
      Assert.assertEquals(8, ex.getErrorOffset());
    }
View Full Code Here

      Assert.assertEquals("unexpected closing brace, escape it to use as character", ex.getMessage());
      Assert.assertEquals(8, ex.getErrorOffset());
    }

    try {
      rp.compile(2, "empty", "");
    } catch (RegexpParseException ex) {
      Assert.assertEquals("regexp is empty", ex.getMessage());
      Assert.assertEquals(0, ex.getErrorOffset());
    }
View Full Code Here

      Assert.assertEquals("regexp is empty", ex.getMessage());
      Assert.assertEquals(0, ex.getErrorOffset());
    }

    try {
      rp.compile(3, "paren", "(abc");
    } catch (RegexpParseException ex) {
      Assert.assertEquals("regexp contains unpaired parentheses", ex.getMessage());
      Assert.assertEquals(4, ex.getErrorOffset());
    }
View Full Code Here

      Assert.assertEquals("regexp contains unpaired parentheses", ex.getMessage());
      Assert.assertEquals(4, ex.getErrorOffset());
    }

    try {
      rp.compile(4, "paren2", "(abc))xyz");
    } catch (RegexpParseException ex) {
      Assert.assertEquals("regexp contains unpaired parentheses", ex.getMessage());
      Assert.assertEquals(5, ex.getErrorOffset());
    }
View Full Code Here

      Assert.assertEquals("regexp contains unpaired parentheses", ex.getMessage());
      Assert.assertEquals(5, ex.getErrorOffset());
    }

    try {
      rp.compile(5, "paren3", "((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((abc))");
    } catch (RegexpParseException ex) {
      Assert.assertEquals("regexp contains too much parentheses", ex.getMessage());
      Assert.assertEquals(126, ex.getErrorOffset());
    }
View Full Code Here

      Assert.assertEquals("regexp contains too much parentheses", ex.getMessage());
      Assert.assertEquals(126, ex.getErrorOffset());
    }

    try {
      rp.compile(5, "paren3", "aaa\\");
    } catch (RegexpParseException ex) {
      Assert.assertEquals("regexp contains \\ at the end of expression", ex.getMessage());
      Assert.assertEquals(4, ex.getErrorOffset());
    }
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.