forked from jasder/antlr
Support zero-length empty lexer rules with lexer commands (fixes #687)
This commit is contained in:
parent
6790b25e5b
commit
e497efaa58
|
@ -547,11 +547,11 @@ lexerAlt
|
|||
( lexerCommands -> ^(LEXER_ALT_ACTION<AltAST> lexerElements lexerCommands)
|
||||
| -> lexerElements
|
||||
)
|
||||
| -> ^(ALT<AltAST> EPSILON) // empty alt
|
||||
;
|
||||
|
||||
lexerElements
|
||||
: lexerElement+ -> ^(ALT<AltAST> lexerElement+)
|
||||
: lexerElement+ -> ^(ALT<AltAST> lexerElement+)
|
||||
| -> ^(ALT<AltAST> EPSILON) // empty alt
|
||||
;
|
||||
|
||||
lexerElement
|
||||
|
|
|
@ -659,8 +659,10 @@ public class TestLexerExec extends BaseTest {
|
|||
}
|
||||
|
||||
/**
|
||||
* This is a regression test for antlr/antlr4#688 "Lexer cannot match
|
||||
* This is a regression test for antlr/antlr4#687 "Empty zero-length tokens
|
||||
* cannot have lexer commands" and antlr/antlr4#688 "Lexer cannot match
|
||||
* zero-length tokens"
|
||||
* https://github.com/antlr/antlr4/issues/687
|
||||
* https://github.com/antlr/antlr4/issues/688
|
||||
*/
|
||||
@Test public void testZeroLengthToken() throws Exception {
|
||||
|
@ -674,7 +676,7 @@ public class TestLexerExec extends BaseTest {
|
|||
"mode StringMode;\n" +
|
||||
"\n" +
|
||||
" StringMode_X : 'x' -> more;\n" +
|
||||
" StringMode_Done : {} -> more, mode(EndStringMode);\n" +
|
||||
" StringMode_Done : -> more, mode(EndStringMode);\n" +
|
||||
"\n" +
|
||||
"mode EndStringMode; \n" +
|
||||
"\n" +
|
||||
|
|
Loading…
Reference in New Issue