The denotational semantics for this calculator has a semantic function for each of the syntactic domains.
The Semantic Function meaning
It calls 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.
The Semantic Function evaluate
It produces a function in State → State
as its result when applied to an expression.
The Semantic Functions compute
and calculate
They give meaning to operators and “totaling” keys.
For example, +
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.
Compund Keystrokes
Compound keystrokes are handled as compositions, eliminating the need to give the argument tuple.
The semantic equation, given here as a composition,
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) )