The translation tool we have devised is called NewYacc, and is derived from the original UNIX program called yacc (yet another compiler compiler); yacc is a parser generator specification language for LALR(1) grammars .
NewYacc provides a concise notation for embedding translations in CFGs.
NewYacc rule translations are contained in the square brackets (the usual yacc actions, if there were any, would still be given as C source code within braces).
They symbols within parentheses at the start of each NewYacc rule translation identify display masks, which are symbols intended to direct the traversal path as will be described.
A traversal in NewYacc is the term for a dynamic path of control or "walk" through the constructed parse dag and corresponds to a single translation of the input.
Rather than assume translations are to be output to a fixed I/O port, NewYacc allows the user to specify his/her own I/O procedure.
The following NewYacc specification performs the translation using the display mask SILLY:
The C code in braces is executed while a sentence in the language is being accepted (i.e., when yyparse() is executed); the NewYacc rule translations, on the other hand, are applied during traversal of the parse dag (i.e., when nytraverse() is executed).
A traversal proceeds depth first in a parse dag starting from the root and proceeding downward according to the explicitly specified NewYacc rule translations for subsequent productions.
Numbers on the nodes indicate the order they are traversed as dictated by the NewYacc rule translation for that node (shown in square brackets) chosen according to the incoming arrow's mask.
Prefixing a grammar symbol with the character & in a NewYacc rule translation or using the NY SELECT option in an invocation of nytraverse() at the root specifies that the traversal should be selective: the default translation is a list of only the non-terminals on the right-hand side of a production.
NewYacc also provides conditional tests in rule translations based on string matching between translation items.