General Information
Tutorials
Reference Manuals
Libraries
Translation Tasks
Tools
Administration
|
LIDO - Reference ManualComputed SubtreesIn general the tree represents the abstract structure of the input text and is built by scanning and parsing the input. That initial tree may be augmented by subtrees which result from certain computations. This feature can be used for translation into target trees which also contain computations that are executed in the usual way. The tree construction functions generated by LIGA are used to build such subtrees. They are inserted into the initial tree at certain positions specified in productions.
SyntaxSymbols ::= '$' SymbName
ExamplesRULE: Block ::= '{' Decl Stmts '}' $ Target COMPUTE Target.GENTREE = MkTBlock (COORDREF, Dels.tcode, Stmt.tcode); END; RULE TBlock: Target ::= TSeq TSeq COMPUTE ... END; Trees may be the result of computations using LIGA's tree construction functions as described below (see Tree Construction Functions).
Tree values may be propagated between computations using attributes of the
predefined type
Tree values are inserted into the tree in contexts where the right-hand
side of the production specifies insertion points
of the form
The insertion is specified by a computation of the attribute The tree grammar productions for computed trees may be disjoint from or may overlap with the productions for the initial tree. Computed trees may again have insertion points in their productions.
RestrictionsThere must be exactly one insertion computation for each insertion point of a rule context. There may not be an insertion computation for a symbol that is not an insertion point. Inserted trees must be legal with respect to the tree grammar. This property is checked at runtime of the evaluator. No computation that establishes a precondition for a tree insertion may depended on a computation within the inserted tree.
Contexts that may belong to subtrees which are built by
computations may not have
computations that are marked
Tree Construction FunctionsLIGA generates a set of tree construction functions, one for each rule context. They may be used in computations to build trees which are then inserted at insertion points. Their names and signatures reflect the rule name and the right-hand side of the production. For a rule RULE pBlock: Block::= '{' Decls Stmts '}' END there is a function NODEPTR MkpBlock (POSITION *c, NODEPTR d1, NODEPTR d2)
The function name is the rule name prefixed by LIGA's tree construction functions are ready to be used in attribute computations. If they are to be applied in user-supplied C-code an include directive
#include "treecon.h" has to be used to make the function definitions available. The first parameter of every function is a pointer to a source coordinate. That argument may be obtained from the coordinate of the context where the function is called. It is used for error reporting, see Predefined Entities.
The following parameters correspond to the sequence of non-literal
symbols of the right-hand side of the production.
For each nonterminal in the production there is a parameter of type
Functions for chain productions, the right-hand side of which consists of exactly one nonterminal, need not be called explicitly. The nodes for those contexts are inserted implicitly when the upper context is built.
RULE pDecls: Decls LISTOF Var | Proc | END;the functions NODEPTR MkpDecls (POSITION *c, NODEPTR l) NODEPTR Mk2pDecls (POSITION *c, NODEPTR ll, NODEPTR lr)
are provided, where
The arguments for each of the parameters
The
The
|