General Information
Tutorials
Reference Manuals
Libraries
Translation Tasks
Tools
Administration
|
LIDO -- Computations in TreesEarly Computations During Tree ConstructionIn general the execution of specified computations begins when the tree is completely build. However, certain application tasks require that an action is performed immediately when an input construct is read. It may be not acceptable to wait until the input is completely processed. Typical examples are desktop calculators: A formula is evaluated and the result is output before the next formula is read. Another example is a computation which influences the input processing, e.g. switch to another input source.
In such cases, these computations (the output of the
expression value or the switch of the input file)
can be marked to be executed early using the keyword
RULE: Program ::= Sequence END; RULE: Sequence ::= Sequence Output NewLine END; RULE: Sequence ::= END; SYMBOL Expression: Value: int; RULE: Output ::= Expression COMPUTE printf ("%d\n", Expression.Value) BOTTOMUP; END; RULE: Expression ::= Number COMPUTE Expression.Value = Number; END; RULE: Expression ::= Expression BinOpr Expression COMPUTE Expression[1].Value = APPLY (BinOpr.Funct, Expression[2].Value, Expression[3].Value); END; SYMBOL BinOpr: Funct: BinFunct; RULE: BinOpr ::= '+' COMPUTE BinOpr.Funct = Add; END; RULE: BinOpr ::= '*' COMPUTE BinOpr.Funct = Mult; END;Figure 15: BOTTOMUP Computation for a Desktop Calculator
Figure 15 shows the LIDO specifications for a simple
desktop calculator. The
Many other computations in other contexts may contribute
values to the marked one: in this case computations
of the
Arranging computations on which a
The following technical detail needs to be considered for
tree grammar design in the presence of RULE: Output::= Expression NewLine COMPUTE ...Then this node would have been created and the BOTTOMUP
computation been executed later, when the token after
the NewLine has been read. That would not yield the desired
effect.
|