use of org.antlr.v4.runtime.Recognizer.EOF in project antlr4 by tunnelvisionlabs.
the class TestATNLexerInterpreter method testLexerWildcardExplicitNonGreedyPlusLoop.
@Test
public void testLexerWildcardExplicitNonGreedyPlusLoop() throws Exception {
LexerGrammar lg = new LexerGrammar("lexer grammar L;\n" + "CMT : '//' .+? '\\n' ;\n");
String expecting = "CMT, CMT, EOF";
checkLexerMatches(lg, "//x\n//y\n", expecting);
}
use of org.antlr.v4.runtime.Recognizer.EOF in project antlr4 by tunnelvisionlabs.
the class TestATNLexerInterpreter method testLexerTwoRules.
@Test
public void testLexerTwoRules() throws Exception {
LexerGrammar lg = new LexerGrammar("lexer grammar L;\n" + "A : 'a' ;\n" + "B : 'b' ;\n");
String expecting = "A, B, A, B, EOF";
checkLexerMatches(lg, "abab", expecting);
}
use of org.antlr.v4.runtime.Recognizer.EOF in project antlr4 by tunnelvisionlabs.
the class TestATNLexerInterpreter method testShortLongRule.
@Test
public void testShortLongRule() throws Exception {
LexerGrammar lg = new LexerGrammar("lexer grammar L;\n" + "A : 'xy'\n" + // this alt is preferred since there are no non-greedy configs
" | 'xyz'\n" + " ;\n" + "Z : 'z'\n" + " ;\n");
checkLexerMatches(lg, "xy", "A, EOF");
checkLexerMatches(lg, "xyz", "A, EOF");
}
use of org.antlr.v4.runtime.Recognizer.EOF in project antlr4 by tunnelvisionlabs.
the class TestATNLexerInterpreter method testWildOnEndFirstAlt.
@Test
public void testWildOnEndFirstAlt() throws Exception {
LexerGrammar lg = new LexerGrammar("lexer grammar L;\n" + // should pursue '.' since xyz hits stop first, before 2nd alt
"A : 'xy' .\n" + " | 'xy'\n" + " ;\n" + "Z : 'z'\n" + " ;\n");
checkLexerMatches(lg, "xy", "A, EOF");
checkLexerMatches(lg, "xyz", "A, EOF");
}
use of org.antlr.v4.runtime.Recognizer.EOF in project antlr4 by tunnelvisionlabs.
the class TestATNLexerInterpreter method testShortLongRule2.
@Test
public void testShortLongRule2() throws Exception {
LexerGrammar lg = new LexerGrammar("lexer grammar L;\n" + // make sure nongreedy mech cut off doesn't kill this alt
"A : 'xyz'\n" + " | 'xy'\n" + " ;\n");
checkLexerMatches(lg, "xy", "A, EOF");
checkLexerMatches(lg, "xyz", "A, EOF");
}
Aggregations