Slide 7.1: A calculator language
Slide 7.3: The semantic domains of the calculator langauge
Home

The Syntactic Domains of the Calculator


The syntactic domains, on which the semantic functions act, of the calculator is given below. To simplify the definition of the denotational semantics for the calculator, the syntactic domains considerably reduces the complexity of the notation while still representing all the key sequences allowed by the previous syntax. Since +/- acts in much the same way as the answer keys, it has been included with them in the syntactic domains.


   P: Program            O: Operator        N: Numeral
   S: ExprSequence       A: Answer          D: Digit
   E: Expression

Program ::= ExprSequence
ExprSequence ::= Expression | Expression ExprSequence Expression ::= Numeral | MR | Clear | Expression Answer | Expression Operator Expression Operator ::= + | | × Answer ::= M+ | = | +/- Numeral ::= Digit | Numeral Digit Digit ::= 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9

Following the syntactic domains for the calculator language, given the sequence of keystrokes
   10 M+ + 6 +/- = × MR =
 = 10 + –6 = × MR =
 = 4 × MR =
 = 4 × 10 = 
 = 40
a parser will construct the syntax tree. Notice that most operations associate to the left because of the way keystrokes are processed from left to right.

To Divide use / Symbol