![]() |
![]() |
![]() |
General Information
Tutorials
Reference Manuals
Libraries
Translation Tasks
Tools
Administration
![]() |
![]() |
LIDO - Reference ManualComputationsComputations are associated with rules or with symbols. Each computation (that is not overridden) is executed exactly once for every instance of its context in a particular tree. A computation may yield a value denoted as an attribute which may be used by other computations. Computations may also be specified as depending on one another without passing a value in order to specify dependencies on side-effects of computations (see Dependent Expressions).
SyntaxComputations ::= [ 'COMPUTE' Computation ] Computation ::= Computation Computation | | Expression Terminator | Attribute '=' Expression Terminator Terminator ::= ';' | 'BOTTOMUP' ';'
ExamplesCOMPUTE Expr.postType = boolType; Stmt[1].code = PTGWhile (Expr.code, Stmt[2].code); printf ("while loop in line %d\n", LINE); printf ("value = %d\n", Expr.val) BOTTOMUP; There are two forms of computations: attribute computations denoted as an assignment to an attribute, and plain computations that are simple expressions. A computation is executed by evaluating its expression. It depends on every attribute that occurs in the expression regardless whether the attribute is used for the evaluation. We say those attributes are the preconditions of the computation. The attribute on the left-hand side of an attribute computation represents the postcondition of that computation. Plain computations do not establish a postcondition for any other computation. The evaluator is generated such that the computations are executed in an order that obeys these dependencies for any tree of the tree grammar. If both a symbol computation and a rule computation define the same attribute of a symbol, the rule computation will be executed in that context, overriding the symbol computation.
An expression may occur in value context, where it must yield
a value, or it may occur in
If the left-hand side attribute of an attribute computation
has a type different from
A plain computation is in
Computations may be specified to be executed
Note: A
Note: Due to the parser's lookahead, one token beyond the last token
of the context of the
Restrictions
If the attribute in an attribute computation has a non- Multiple symbol computations that define the same attribute are forbidden. There must be exactly one attribute computation for each synthesized attribute of the left-hand side nonterminal and for each inherited attribute of each right-hand side nonterminal in the production of a rule context. There may not be any cyclic dependencies between computations for any tree of the tree grammar.
Contexts that may belong to subtrees which are built by
computations (see Computed Subtrees) may not have
computations that are marked
LIGA may fail to allocate
|