General Information
Tutorials
Reference Manuals
Libraries
Translation Tasks
Tools
Administration
|
LIDO - Reference ManualExpressionsAn expression is evaluated as part of a computation. The evaluation may yield a value, cause an effect, or both.
Dependent ExpressionsThe evaluation of an expression depends on all attributes to which it refers. The expression is evaluated only after all those attributes are evaluated.
Further attributes may be added as preconditions for expression evaluation
without using their values for computing the expression's result. The
additional attributes may describe a computational state that has to be reached
before the expression is evaluated. These attributes are specified by a
SyntaxExpression ::= SimpExpr [ DependsClause ] DependsClause ::= '<-' DepAttrList DepAttrList ::= DepAttr | '(' DepAttrs ')' DepAttrs ::= DepAttrs ',' DepAttrs | DepAttr DepAttr ::= Attribute | RemoteAccess | RhsAttrs
ExamplesGetProp (UseId.Key,0) <- UseId.PropIsSet printf ("%s ", Opr.String) <- (Expr[2].printed, Expr.[3].printed)
A
Terminal AccessNamed terminal symbols that occur in a production represent values that are usually obtained from corresponding input tokens when the tree node is constructed. Those values can be used in both rule and symbol computations.
SyntaxSimpExpr ::= SymbolRef | 'TERM' [ '[' Number ']' ]
ExamplesRULE: DefIdent ::= Ident COMPUTE DefIdent.Key = DefineIdn (DefIdent.Env, Ident); END; RULE: Point ::= '(' Numb Numb ')' COMPUTE printf ("X = %d, Y = %d\n", Numb[1], Numb[2]); END; SYMBOL Point COMPUTE printf ("X = %d, Y = %d\n", TERM[1], TERM[2]); END;
In rule computations the value of a terminal in the production
is denoted by the Note: In a rule computation a non-indexed identifier that is not a name of a symbol in the production of this rule denotes some entity of the generated C program, even if it coincides with the name of a terminal that occurs in other productions.
In lower computations of a symbol
Restrictions
A terminal accessed in a symbol computation must exist in every production the computation is associated with.
Simple ExpressionsExpressions are written as nested function calls where the basic operands are attributes, C identifiers and C literals. The functions are either predefined in LIDO or their definitions are supplied by the user in the form of C functions or macros outside the LIDO specification. There is no operator notation for expressions in LIDO.
SyntaxSimpExpr ::= C_Name | C_Integer | C_Float | C_Char | C_String | Attribute | RemoteAccess | RhsAttrs | FunctionName '(' [ Arguments ] ')' Arguments ::= Arguments ',' Arguments | Expression
Examplesprintf ("Val = %d\n", Expr.val) IF (LT (Expr.val, 0), 0, Expr.val) Evaluation of a function call notation in LIDO has the same effect and result as the equivalent notation in C.
There are some predefined
Function calls need not yield a value if they are in a
Restrictions
Every
All arguments of non-predefined functions must yield a (non-
Type consistency for non-
A
|