A typical calculator provides four operations to remember value: add to memory (M+), subtract from memory (M-),recall
Question:
A typical calculator provides four operations to remember value: add to memory (M+), subtract from memory (M-),recall value stored in memory (MRec), and clear value stored in memory (Mclr). Extend the Arithlang programming language to support four expressions that model these operations.
1. Memory recall expression (MrecExp) with syntax ( Mrec ) should recall the current value stored in the interpreter’s memory.
2. Memory clear expression (MrecExp) with syntax ( Mclr ) should clear the current value stored in the interpreter’s memory.
3. Memory add expression (MaddExp) with syntax ( M+ exp0… expn ) should add the value of exp0 to expn to the current value stored in the interpreter’s memory.
4. Memory sub expression (MsubExp) with syntax ( M− exp0… expn ) should subtract the value of exp0 to expn from the current value stored in the interpreter’s memory.
Step by Step Answer:
An Experiential Introduction To Principles Of Programming Languages
ISBN: 9780262045452
1st Edition
Authors: Hridesh Rajan