[NEXT] [PREV]    HANDBOOK / GENTLE PRIMER / Optimal Rule Selection /

Unparsing

Gentle
Applications
Concepts
Examples
Handbook
Support
Download

The above scheme is called an unparsing scheme. While a parser reads a source text (driven by the structure of the source text) and constructs abstract syntax, an unparser processes abstract syntax terms (driven by their structure) and emits a concrete target program.

The rules of an unparser are similar to grammar rules. Predicates like StackCode correspond to nonterminals, and predicates that directly emit target code correspond to tokens. In a source grammar, symbols are decorated with output parameters that specify their abstract representation. In a target grammar, symbols are decorated with abstract input parameters for which a concrete representation has to be generated.

In many cases an unparsing scheme simply follows the structure of terms. In general there is one rule for each functor, although sometimes larger patterns are used. This results in a functional description such as that for the stack-computer code generator.

This will especially be the case if the target language is a higher-level language, as in source-to-source translations (e.g. if a parallel extension of C is translated into plain C).





[NEXT] [PREV]