It is difficult to provide rules with substantial actions and still have a readable specification file. The following are a few style hints.
Use all uppercase letters for token names and all lowercase letters for nonterminal names. This is useful in debugging.
Put grammar rules and actions on separate lines to make editing easier.
Put all rules with the same left-hand side together. Put the left-hand side in only once and let all following rules begin with a vertical bar.
Put a semicolon only after the last rule with a given left-hand side and put the semicolon on a separate line. This allows new rules to be easily added.
Indent rule bodies by one tab stop and action bodies by two tab stops.
Put complicated actions into subroutines defined in separate files.
Examples in this section are written following this style. The central problem is to make the rules visible through the maze of action code.