Next: , Previous: put Decl, Up: Declarations

2.3.5 token Decl

The %token statement declares a terminal symbol (a token) which is not a keyword.

— %-Decl: %token [<type-name>] token-name match-value
— %-Decl: %token [<type-name>] token-name1 ...

Respectively declare one token with an optional type, and a match value, or several tokens with the optional same type, and no match value.

Is an optional symbol, enclosed between < and >, that specifies (and implicitly declares) a type for this token (see type Decl). If omitted the token has no type.
Is the terminal symbol used in grammar rules to represent this token.
Is an optional string. Depending on type-name properties, it will be interpreted as an ordinary string, a regular expression, or have a more elaborate meaning. If omitted the match value will be nil, which means that this token will be considered as the default token of its type (see type Decl for more information).

Please note:
For historical compatibility, the form ‘%token name value actually declares a keyword, and is strictly equivalent to ‘%keyword name value. Because the former is ambiguous and could be abandoned in future releases of semantic, we highly recommend to use the latter to declare keywords!

In the generated library, token definitions are stored in the table of declared types (see type Decl).