Next: , Previous: , Up: Bison Declarations   [Contents][Index]


3.7.5 Syntax of Symbol Declarations

The syntax of the various directives to declare symbols is as follows.

%token tag? ( id number? string? )+ ( tag ( id number? string? )+ )*
%left  tag? ( id number?)+ ( tag ( id number? )+ )*
%type  tag? ( id | char | string )+ ( tag ( id | char | string )+ )*
%nterm tag? id+ ( tag id+ )*

where tag denotes a type tag such as ‘<ival>’, id denotes an identifier such as ‘NUM’, number a decimal or hexadecimal integer such as ‘300’ or ‘0x12d’, char a character literal such as ‘'+'’, and string a string literal such as ‘"number"’. The postfix quantifiers are ‘?’ (zero or one), ‘*’ (zero or more) and ‘+’ (one or more).

The directives %precedence, %right and %nonassoc behave like %left.