|
Slide 7.5: The semantic functions of the calculator language Slide 7.7: A sample calculation Home |
|
meaning
perform on a sequence of one or more expressions that makes up a program, giving perform an initial state (0, nop, 0, 0) as its argument.
An expression sequence is evaluated one expression at a time by composing executions of the evaluate function.
Finally, meaning returns the display value given as a result of evaluating the last expression in the sequence.
evaluate
State → State as its result when applied to an expression.
compute and calculate
+ computes the pending operation with the accumulator and display, updating the accumulator and display but leaving the display unchanged.
Moreover, plus becomes the new pending operation.
In contrast, = places the computed value into the display with nop signaling that there is no longer a pending operation.
Observe that MR and +/- act only on the display.
evaluate[[E A]] = calculate[[A]] º evaluate[[E]]
is equivalent to writing
evaluate[[E A]](a, op, d, m) = calculate[[A]]( evaluate[[E]](a, op, d, m) )