next up previous contents
Next: Command-line options of mosmlyac Up: The format of grammar Previous: Declarations

The format of grammar rules


program1235

Each right-hand side consists of a (possibly empty) sequence of symbols, followed by a semantic action.

The directive `%prec symbol' may occur among the symbols in a rule right-hand side, to specify that the rule has the same precedence and associativity as the given symbol.

Semantic actions are arbitrary Moscow ML expressions, which are evaluated to produce the semantic attribute attached to the defined nonterminal. The semantic actions can access the semantic attributes of the symbols in the right-hand side of the rule with the $ notation: $1 is the attribute of the first (leftmost) symbol, $2 is the attribute of the second symbol, etc. An empty semantic action evaluates to () : unit.

Actions occurring in the middle of rules are not supported. Error recovery is not implemented.


next up previous contents
Next: Command-line options of mosmlyac Up: The format of grammar Previous: Declarations

Peter Sestoft
Mon Aug 30 19:25:57 MEST 1999