ANTLR Lexer rules in v4 Fragments


Example

Fragments are reusable parts of lexer rules which cannot match on their own - they need to be referenced from a lexer rule.

INTEGER: DIGIT+
       | '0' [Xx] HEX_DIGIT+
       ;

fragment DIGIT: [0-9];
fragment HEX_DIGIT: [0-9A-Fa-f];