The ‘more’ command forces the lexer to get another token but without throwing out the current text. The token type will be that of the “final” rule matched (i.e., the one without a more or skip command).
TestParser.g4:
1 | parser grammar TestParser; |
TestLexer.g4:
1 | lexer grammar TestLexer; |
Java Code:
1 | import org.antlr.v4.runtime.CharStream; |
Output:
1 | (root "abc" <EOF>) |
Reference
Lexer Rules - mode(), pushMode(), popMode, and more
antlr4/Lexer.java at 4.9.2 · antlr/antlr4 · GitHub