General Information
Tutorials
Reference Manuals
Libraries
Translation Tasks
Tools
Administration
|
Abstract Syntax Tree UnparsingParsing is the process of constructing a tree from a string of characters; unparsing is the reverse: constructing a string of characters from a tree. A so-called "pretty-printer" is an example of a processor that incorporates an unparser: It reads arbitrarily-formatted text, builds a tree representing the text's structure, and then unparses that tree using appropriate formatting rules to lay out the text in a standard way. An unparser is also used to produce a textual representation of a tree-structured data object. One example of such a textual representation is the XML file used to transmit a data object over the Internet; another is a Java program that can be executed to re-build the object. Arbitrary unparsers can be specified by means of a combination of attribute computations and PTG (see Pattern Specifications of PTG: Pattern-Based Text Generator) patterns. Writing these specifications by hand is a tedious process for a large tree grammar. Given a specification of the LIDO rules defining a tree grammar, Eli can derive the specifications of certain common unparsings. The result is a FunnelWeb file (see Introduction of FunnelWeb) that is used directly to produce output routines for a generated processor. Each of the common unparsings has certain characteristics that must be understood to use it effectively. Although a pre-packaged unparsing may suffice for almost all of the rules of a particular tree grammar, a user may need to make a few changes in structure or representation. The unparser generator provides facilities for specifying such changes, while retaining the bulk of the generated attribute computations and PTG patterns. Finally, an unparser must be derived from a specification of the tree grammar to be unparsed together with specifications of any changes in representation. The resulting FunnelWeb file must either be extracted or incorporated into the derivation of the processor using it.
|