@Override public boolean matches(Object arg0) { RegexNode tree = (RegexNode) arg0; Collection<Class<? extends RegexNode>> types = tree.accept(new RegexNodeVisitorTypeCollector()); return types.contains(nodeType); }
private void debug(String regex, RegexTreeTransformer parser, RegexNode tree) { String transformed = tree.accept(new RegexNodeVisitorToString()); if (debug) { System.out.println(regex); System.out.println( "---------------------------------------------------------------------------------------------------"); System.out.println(parser); System.out.println( "---------------------------------------------------------------------------------------------------"); System.out.println(transformed); System.out.println( "***************************************************************************************************"); } }
private void assertTransform(String regex, String expectedTransformation) throws RegexParsingException { RegexNode tree = parse(regex); String transformed = tree.accept(new RegexNodeVisitorToString()); assertEquals(expectedTransformation, transformed); }
@Test public void characterClassWithRangesMustIncludeCharacterRange() throws RegexParsingException { RegexNode tree = parse("[a-z0-9abc]"); assertTrue(tree.accept(new RegexNodeVisitorTypeCollector()).contains(CharacterRange.class)); }
@Test public void dotAny() throws RegexParsingException { String regex = "."; RegexNode tree = parse(regex); assertEquals(DotAny.class, tree.getChildren().get(0).getClass()); }