TokenLiteral lets you define names for the tokens created using literals directly in the grammar. (In the example above, the literals are:
“literal”, “=”, “,”, and “;”)
If before declaring a rule with literals, you assign names to these literals using
TokenLiteral, a field with a defined name will be created for these literals.
For example, If you assign
then a field named Assignment will be created for the literal
Names can be reassigned before the next use. The definition will be used starting from the location in which it is defined until next definition or the end of the scope it’s defined within.