One of the properties of an expression is its value. Every expression has a value, and this section deals only with expressions whose values are determined by local information. A binary operator is regarded as a function taking two values called Left and Right and delivering the result. All values are integers.
This macro is defined in definitions 35 and 37.
ATTR Value, Left, Right: int;
RULE: Exp ::= num
COMPUTE
Exp.Value=num;
END;
RULE: Exp ::= Exp Binop Exp
COMPUTE
Exp[1].Value=Binop.Value;
Binop.Left=Exp[2].Value;
Binop.Right=Exp[3].Value;
END;
RULE: Exp ::= '(' Stm ',' Exp ')'
COMPUTE
Exp[1].Value=Exp[2].Value;
END;
The dependences among computations in these rules are direct data dependences. For example, the value of a dyadic expression depends on the result of the binary operator because there is a direct assignment of one to the other.
All of the dyadic operations follow a general pattern, which can be described once. Again, the dependence of the result value on the left and right operand values is clear because it is the result of a function having them as arguments:
This macro is invoked in definition 37.
RULE: Binop ::=![]()
COMPUTE
Binop.Value=(Binop.Left,Binop.Right);
END;
The first parameter is the operator indication, and the second is the built-in LIDO operation implementing the corresponding operation on integer values:
This macro is defined in definitions 35 and 37.
Implementation of a binary operator[36](`'+'',`ADD')
Implementation of a binary operator[36](`'-'',`SUB')
Implementation of a binary operator[36](`'*'',`MUL')
Implementation of a binary operator[36](`'/'',`DIV')