use of org.antlr.v4.misc.EscapeSequenceParsing.Result in project antlr4 by antlr.
the class TestParseTreeMatcher method testInvertedTags.
@Test
public void testInvertedTags() throws Exception {
ParseTreePatternMatcher m = new ParseTreePatternMatcher(null, null);
String result = null;
try {
m.split(">expr<");
} catch (IllegalArgumentException iae) {
result = iae.getMessage();
}
String expected = "tag delimiters out of order in pattern: >expr<";
assertEquals(expected, result);
}
use of org.antlr.v4.misc.EscapeSequenceParsing.Result in project antlr4 by antlr.
the class TestParseTreeMatcher method testDelimiters.
@Test
public void testDelimiters() throws Exception {
ParseTreePatternMatcher m = new ParseTreePatternMatcher(null, null);
m.setDelimiters("<<", ">>", "$");
String result = m.split("<<ID>> = <<expr>> ;$<< ick $>>").toString();
assertEquals("[ID, ' = ', expr, ' ;<< ick >>']", result);
}
use of org.antlr.v4.misc.EscapeSequenceParsing.Result in project antlr4 by antlr.
the class TestParseTreeMatcher method checkPatternMatch.
public ParseTreeMatch checkPatternMatch(String grammar, String startRule, String input, String pattern, String grammarName, boolean invertMatch) throws Exception {
String grammarFileName = grammarName + ".g4";
String parserName = grammarName + "Parser";
String lexerName = grammarName + "Lexer";
boolean ok = rawGenerateAndBuildRecognizer(grammarFileName, grammar, parserName, lexerName, false);
assertTrue(ok);
ParseTree result = execParser(startRule, input, parserName, lexerName);
ParseTreePattern p = getPattern(grammarName, pattern, startRule);
ParseTreeMatch match = p.match(result);
boolean matched = match.succeeded();
if (invertMatch)
assertFalse(matched);
else
assertTrue(matched);
return match;
}
use of org.antlr.v4.misc.EscapeSequenceParsing.Result in project antlr4 by antlr.
the class TestParseTreeMatcher method testUnclosedTag.
@Test
public void testUnclosedTag() throws Exception {
ParseTreePatternMatcher m = new ParseTreePatternMatcher(null, null);
String result = null;
try {
m.split("<expr hi mom");
} catch (IllegalArgumentException iae) {
result = iae.getMessage();
}
String expected = "unterminated tag in pattern: <expr hi mom";
assertEquals(expected, result);
}
use of org.antlr.v4.misc.EscapeSequenceParsing.Result in project antlr4 by antlr.
the class TestEscapeSequenceParsing method testParseUnicodePropertyInverted.
@Test
public void testParseUnicodePropertyInverted() {
IntervalSet expected = IntervalSet.of(0, 66559);
expected.add(66640, Character.MAX_CODE_POINT);
assertEquals(new Result(Result.Type.PROPERTY, -1, expected, 11), EscapeSequenceParsing.parseEscape("\\P{Deseret}", 0));
}
Aggregations