What does “fragment” mean in ANTLR?
A fragment is somewhat akin to an inline function: It makes the grammar more readable and easier to maintain. A fragment will never be counted as a token, it only serves to simplify a grammar. Consider: NUMBER: DIGITS | OCTAL_DIGITS | HEX_DIGITS; fragment DIGITS: ‘1’..’9′ ‘0’..’9’*; fragment OCTAL_DIGITS: ‘0’ ‘0’..’7’+; fragment HEX_DIGITS: ‘0x’ (‘0’..’9′ | … Read more