meaning: Program → Integer
meaning[[P]] = d where perform[[P]]( 0, nop, 0, 0 ) = ( a, op, d, m )
perform: ExprSequence → ( State → State )
perform[[E S]] = perform[[S]] º evaluate[[E]]
perform[[E]] = evaluate[[E]]
evaluate: Expression → ( State → State )
evaluate[[N]]( a, op, d, m) = ( a, op, v, m ) where v = value[[N]]
evaluate[[MR]]( a, op, d, m ) = ( a, op, m, m )
evaluate[[Clear]]( a, op, d, m ) = ( 0, nop, 0, 0 )
evaluate[[E1 O E2]] = evaluate[[E2]] º compute[[O]] º evaluate[[E1]]
evaluate[[E A]] = calculate[[A]] º evaluate[[E]]
compute: Operator → ( State → State )
compute[[+]]( a, op, d, m ) = ( op( a, d ), plus, op( a, d ), m )
compute[[–]]( a, op, d, m ) = ( op( a, d ), minus, op( a, d ), m )
compute[[×]]( a, op, d, m ) = ( op( a, d ), times, op( a, d ), m )
calculate: Answer → ( State → State )
calculate[[=]]( a, op, d, m ) = ( a, nop, op( a, d ), m )
calculate[[M+]]( a, op, d, m ) = ( a, nop, v, plus( m, v ) )
where v = op( a, d )
calculate[[+/-]]( a, op, d, m ) = ( a, op, minus( 0, d ), m )
value: Numeral → Integer
value[[ND]] = 10 * value[[N]] + value[[D]]
value[[D]] = digit[[D]]
digit: Digit → Integer
digit[['0']] = 0, digit[['1']] = 1, ..., digit[['9']] = 9
|