Declarations are given one per line. They all start with a % sign.
%
Declare the given symbols as tokens (terminal symbols). These symbols become constructors (without arguments) in the token datatype.
Declare the given symbols as tokens with an attached attribute of the given type. These symbols become constructors (with arguments of the given type) in the token datatype. The type part is an arbitrary Moscow ML type expression, but all type constructor names must be fully qualified (e.g. Unitname.typename) for all types except standard built-in types, even if the proper open declarations (e.g. open Unitname) were given in the header section.
Declare the given symbol as entry point for the grammar. For each entry point, a parsing function with the same name is defined in the output file grammar.sml. Non-terminals that are not declared as entry points have no such parsing function.
Specify the type of the semantic attributes for the given symbols. Every non-terminal symbol, including the start symbols, must have the type of its semantic attribute declared this way. This ensures that the generated parser is type-safe. The type part may be an arbitrary Moscow ML type expression, but all type constructor names must be fully qualified (e.g. Unitname.typename) for all types except standard built-in types, even if the proper open declaration (e.g. open Unitname) were given in the header section.
Declare the precedence and associativity of the given symbols. All symbols on the same line are given the same precedence. They have higher precedence than symbols declared in previous %left, %right or %nonassoc lines. They have lower precedence than symbols declared in subsequent %left, %right or %nonassoc lines. The symbols are declared to associate to the left (%left), to the right (%right), or to be non-associative (%nonassoc). The symbols are usually tokens, but can also be dummy nonterminals, for use with the %prec directive inside the rules.