Question: Part 3: A tiny language [Read Chapter 8] Let E (for expression) be a tiny programming language that supports the declaration of arith- metic expressions

 Part 3: A tiny language [Read Chapter 8] Let E (for

expression) be a tiny programming language that supports the declaration of arith-

Part 3: A tiny language [Read Chapter 8] Let E (for expression) be a tiny programming language that supports the declaration of arith- metic expressions involving only addition and multiplication, and equality comparisons on integers. Here is an example program in E: When evaluated, this program should evaluate to the truth value true. In this exercise, we will not write E programs as strings, but as values of a Haskell data type E, that can represent E programs as their abstract syntax trees (ASTs). Given the following data type E, data EIntLit Int -- for Int literal, e.g. , (IntLit 3) BoolLit Bool-- for Bool literal, e.g., (BoolLit False) | Plus E E | Mult E E _ for addition _ for multiplication Equals E E deriving (Eq, Show) The above example program is represented as its AST: program = Equals (Plus (IntLit 1) (IntLit 9)) (Mult (IntLit 5) (Plus (IntLit 1) (IntLit 1)))

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!