AbstractSome parser generators allow the user to attach actions, consisting of executable code, to syntax rules. Actions are usually in the local programming language, so they are simply copied into the generated parser. However, we show two situations in which it is convenient to allow actions to be in a different notation. A preprocessor is used to translate such notations into the local programming language. A preprocessor must know where to find actions and how to translate them. We show how these two activities can be programmed separately. Often, the user only has to worry about the second part: once the parser generator is known, the placement of the actions is known as well, so routines for finding actions can be separately compiled and linked in. Examples in the paper are based on the parser generator Yacc, but the approach is not limited to Yacc, or even to parser generators. Certain compositions of syntax‐directed translations can be implemented by preprocessing action
展开▼