Theoretical Computer Science 42 (1986) 251-368 251 North-Holland PUSHDOWN MACHINES FOR THE MACRO TREE TRANSDUCER Joost ENGELFRIET* and Heiko VOGLER** Department of Computer Sciences, Twente University of Technology, 7500 AE Enschede, The Netherlands Communicated by M. Nivat Received February 1985 Abstract. The macro tree transducer can be considered as a system of recursive function procedures with parameters, where the recursion is on a tree (e.g., the syntax tree of a program). We investigate characterizations of the class of tree (tree-to-string) translations which is induced by macro tree transducers (macro tree-to-string transducers, respectively). For this purpose we define several pushdown machines of which the control is recursive without parameters, or even iterative, and which work on a generalized pushdown as storage. Because of the relevance for semantics of programming languages, we stress (besides the nondeterministic case) the study of machines for the total deterministic macro tree(-to-string) transducer, which translates every input tree into exactly one output tree (string, respectively). Finally, we characterize the n-fold composition of total deterministic macro tree transducers by recursive pushdown machines with an iterated pushdown as storage, which is a pushdown of pushdowns of.. of pushdowns. Contents 1. Introduction ...................................................................... 252 2. Preliminaries ...................................................................... 259 2.1. Generalnotation.. ............................................................ 259 2.2. Trees and substitution. ......................................................... 259 2.3. X-grammars .................................................................. 260 2.4. Treetransducers ............................................................... 262 3. Grammars with storage. ............................................................ 264 3.1. Storage types and X( S)-transducers ............................................. 265 3.2. Macro tree transducers and CFT(S)-transducers. .................................. 272 3.3. Pushdown storage type. ........................................................ 280 4. Simulation of.storage types ......................................................... 285 4.1. Flowcharts and simulation relation .............................................. 287 4.2. Justification theorem and transitivity of s,, ....................................... 290 4.3. Monotonicity of the pushdown operator. ......................................... 299 * Present affiliation: Department of Mathematics and Computer Science, University of Leiden, 2300 RA Leiden, The Netherlands. ** Present affiliation: Lehrstuhl fir Informatik II, RWTH Aachen, D-5100 Aachen, Fed. Rep. Germany. The work of the second author has been supported by the Dutch Organization for the Advancement of Pure Research (Z-W-0.). 0304-3975/86/$3.50 @ 1986, Elsevier Science Publishers B.V. (North-Holland1 252 J. Engelfriet, H. Vogler 5. Characterization of CFT(S) by indexed S-transducers .................................. 302 5.1. Implementation of CFT(S) on indexed S-transducers .............................. 303 5.2. Characterization of CFT(S) ..................................................... 314 5.3. Characterization of RT(P(S)) ................................................... 324 6. Characterization of MAC(S) by pushdown 2 S-to-string transducers ...................... 329 6.1. Nondeterministic MAC(S)-transducers ........................................... 329 6.2. Total deterministic MAC(S)-transducers ......................................... 334 7. Pushdown 2 versus nested stack ...................................................... 344 8. Characterizations of the macro tree transducer ........................................ 355 8.1. Total deterministic and nondeterministic transducers ............................... 355 8.2. Composition of total deterministic macro tree transducers .......................... 357 References ........................................................................ 367 I. Introduction It has become a custom to describe the semantics of programming languages in a syntax-directed way. There are more or less formalized metalanguages for the description of syntax-directed semantics such as generalized syntax-directed transla- tion schemes [3, 4], top-down tree transducers [37, 39, 11], and attribute grammars with synthesized attributes only [33]. These concepts have in common that the meaning of a syntactic construct is determined entirely by the meaning of its constituents. However, for the accomplishment of some tasks, it is necessary to take also the context of a syntactic construct into account, e.g., when the access to the environment specified by the declaration part of a program is needed. This additional requirement on metalanguages is captured, e.g., by attribute grammars [33] and denotational semantics [41]. More recently, macro tree transducers [14, 7, 22] were studied as another concept of syntax-directed semantics in which context can be handled. Actually, (deterministic) macro tree transducers model at least the features of denotational semantics needed to simulate attribute grammars, and thus can be viewed as a first modest approach to model denotational semantics of programming languages. We refer the reader to [15] for a detailed discussion of these recta- languages of syntax-directed semantics. In the framework of program (scheme) theory the deterministic macro tree transducer can be viewed as a system of recursive function procedures with para- meters, one function procedure corresponding to each state of the transducer (cf. [7, 15]). Every function procedure is of type T~ x T,~ ~ Ta for some n/>0, where T~ and Ta are the sets of trees over the ranked alphabets ,~ and A, respectively. Thus, the arguments of a function procedure are divided into two sorts: there is exactly one 'syntactic' parameter of type T~ and there may be some 'context' parameters of type Tz (top-down tree transducers are macro tree transducers without context parameters). The actual value of the syntactic parameter is a subtree of the input tree which is initially given to the main function procedure: this is a designated function procedure without context parameters, i.e., of type T~ ~ Tz (it determines the type of the translation which is induced by the macro tree transducer). During the evaluation of procedure calls, subtrees of the input tree are selected and in this Pushdown machines for the macro tree transducer 253 way the actual syntactic parameters decrease in height (this is the meaning of 'syntax-directed'). The context parameters keep context information for the current value of the syntactic parameter. Context information consists of a tree in Ta, to be viewed as an expression over the set A of basic operation symbols, denoting a value in some semantic domain (the fact that this domain is not specified, means that the macro tree transducer is a program scheme). Since the context parameters are not necessarily called by value, an actual context parameter may still contain procedure calls (note that the type of every function result is the same as that of the context parameters). As opposed to the syntactic parameters, the actual values of the context parameters usually increase in size: during the evaluation of a function procedure A, a new context value (i.e., the value of a context parameter of another call) is constructed out of function procedures, basic operations, and old context values of A. During evaluation of the macro tree transducer, there may be (many) parallel recursive calls of function procedures, and, moreover, these calls may be nested to any depth. This situation is closely related to the nesting of nonterminals in level-2 schemes [8], context-free tree grammars [20], and macro grammars [24]. Thus, as usual, we can distinguish between three different evaluation strategies for such a system of recursive function procedures: unrestricted, outside-in (OI), and inside-out (IO). In the unrestricted strategy, every function procedure call may be evaluated. In the OI-strategy, only those function procedure calls may be evaluated that do not occur in the context information of other calls. In the IO-strategy, a procedure call may only be evaluated if its context parameters do not contain other calls. Of course, for modelling semantics of programming languages, those translating devices should be considered that associate to every syntactic object (i.e., a syntax tree of a program) exactly one meaning. Consequently, in this paper our main interest is in the total deterministic macro tree transducer: for every input tree (of type T~) it computes exactly one output tree (of type Ta). The total deterministic macro tree transducer has the nice property that the three different evaluation strategies are equivalent [22]. However, besides the total deterministic case, we also study the nondeterministic case (and this, in fact, before the total deterministic case), because it is mostly easier to treat and it already provides some insight in the main features of the considered translation device. The aim of the present paper is to find machines which characterize the class of translations induced by macro tree transducers. Generally speaking, a machine consists of a 'storage' and a 'control' or 'program', where the program can work on the storage by testing and transforming the storage 'configurations'.
Details
-
File Typepdf
-
Upload Time-
-
Content LanguagesEnglish
-
Upload UserAnonymous/Not logged-in
-
File Pages118 Page
-
File Size-