About
Lexical mode in Antlr
Lexical modes allow to split a single lexer grammar file into multiple sublexers.
The lexer can then only return tokens matched by rules from the current mode.
Lexers start out in the so-called default mode.
All rules are considered to be within the default mode unless you specify a mode command.
Modes are not allowed within combined grammars, just lexer grammars.
Articles Related
Syntax
rules in default mode
/** ... **/
mode MODE1;
rules in MODE1
/** ... **/
mode MODEN;
rules in MODEN
/** ... **/
Example
https://github.com/antlr/grammars-v4/blob/master/xml/XMLParser.g4