use of org.antlr.v4.runtime.Lexer in project antlr4 by tunnelvisionlabs.
the class TestATNInterpreter method testSimpleLoop.
@Test
public void testSimpleLoop() throws Exception {
LexerGrammar lg = new LexerGrammar("lexer grammar L;\n" + "A : 'a' ;\n" + "B : 'b' ;\n" + "C : 'c' ;\n" + "D : 'd' ;\n");
Grammar g = new Grammar("parser grammar T;\n" + "a : A+ B ;");
checkMatchedAlt(lg, g, "ab", 1);
checkMatchedAlt(lg, g, "aab", 1);
checkMatchedAlt(lg, g, "aaaaaab", 1);
checkMatchedAlt(lg, g, "aabd", 1);
}
use of org.antlr.v4.runtime.Lexer in project antlr4 by tunnelvisionlabs.
the class TestATNLexerInterpreter method testRecursiveLexerRuleRefWithWildcard.
@Test
public void testRecursiveLexerRuleRefWithWildcard() throws Exception {
LexerGrammar lg = new LexerGrammar("lexer grammar L;\n" + "CMT : '/*' (CMT | .)*? '*/' ;\n" + "WS : (' '|'\\n')+ ;");
String expecting = "CMT, WS, CMT, WS, EOF";
checkLexerMatches(lg, "/* ick */\n" + "/* /* */\n" + "/* /*nested*/ */\n", expecting);
}
use of org.antlr.v4.runtime.Lexer in project antlr4 by tunnelvisionlabs.
the class TestATNLexerInterpreter method testLexerNotSet.
@Test
public void testLexerNotSet() throws Exception {
LexerGrammar lg = new LexerGrammar("lexer grammar L;\n" + "ID : ~('a'|'b')\n ;");
String expecting = "ID, EOF";
checkLexerMatches(lg, "c", expecting);
}
use of org.antlr.v4.runtime.Lexer in project antlr4 by tunnelvisionlabs.
the class TestATNLexerInterpreter method testLexerWildcardGreedyLoopByDefault.
@Test
public void testLexerWildcardGreedyLoopByDefault() throws Exception {
LexerGrammar lg = new LexerGrammar("lexer grammar L;\n" + "CMT : '//' .* '\\n' ;\n");
String expecting = "CMT, EOF";
checkLexerMatches(lg, "//x\n//y\n", expecting);
}
use of org.antlr.v4.runtime.Lexer in project antlr4 by tunnelvisionlabs.
the class TestATNLexerInterpreter method testLexerSetUnicodeBMP.
@Test
public void testLexerSetUnicodeBMP() throws Exception {
LexerGrammar lg = new LexerGrammar("lexer grammar L;\n" + "ID : ('\u611B'|'\u611C')\n ;");
String expecting = "ID, EOF";
checkLexerMatches(lg, "\u611B", expecting);
}
Aggregations