Codegenerator MiniLogo
Pfad: Startseite / Fächer / Informatik / Compiler / Codegenerator
Autor: mk
06.11.2008 09:30:39
784

Zitat aus Yacc: Yet Another Compiler-Compiler, Stephen C. Johnson

In many applications, output is not done directly by the actions; rather, a data structure, such as a parse tree, is constructed in memory, and transformations are applied to it before output is generated. Parse trees are particularly easy to construct, given routines to build and maintain the tree structure desired. For example, suppose there is a C function node, written so that the call

          node( L, n1, n2 )  

creates a node with label L, and descendants n1 and n2, and returns the index of the newly created node. Then parse tree can be built by supplying actions such as:

          expr    :       expr  '+'  expr
                                              {  $$ = node( '+', $1, $3 );  }

in the specification.

Links

Valid XHTML 1.0!