next up previous
Next: Types Up: Tree Structure Previous: Ambiguous names


Relating Phrase Structure to Tree Structure

Although the phrase structure specified by the context-free grammar and the tree structure implicit in the attribute grammar are related, they are not identical. Eli determines their relationship by comparing the structures of the specifications and taking account of additional information provided by the user in a special mapping language.

The phrase structure of Java is completely specified by the context-free grammar contained in Phrase.con (defined above). A user can obtain this grammar from Eli by requesting the consyntax product. Tree.lido (defined above), on the other hand, specifies only those contexts in which computations take place. Eli deduces the remainder of the tree structure from Phrase.con and Tree.map (defined below). A user can obtain the complete set of rules describing the tree structure from Eli by requesting the abstree product.

There are two kinds of descriptions in the mapping language: symbol mappings and rule mappings. Symbol mappings specify that a number of symbols representing distinct phrases correspond to a single symbol representing a distinct tree node. Only the tree node symbol may appear in the attribute grammar. Rule mappings specify that a given phrase corresponds to a particular tree fragment. Only the tree fragments may appear in the attribute grammar.

A type-map file describes correspondences between the phrase structure of the input text and the tree that represents the program internally.

Tree.map[22]:

MAPSYM
Types[23]
Statements[25]
Expressions[24]
This macro is attached to a product file.



Subsections
next up previous
Next: Types Up: Tree Structure Previous: Ambiguous names
2008-09-11