16 May WHAT DOES IT MEAN TO CLAIM YOUR COMPILER IS CORRECT?
Questions 4-6 refer to the contents of HW2.lhs. Include two files in your submission: a text file with the answers to questions 1-3, and the completed HW2.lhs file.
1. (3 points)
Imagine you’re given an interpreter for C++ and asked to build a compiler from C++ to x86 machine code that implements the same semantics as the interpreter. What does it mean to claim your compiler is correct? How would you test this claim?
2. (4 points)
Consider the following Haskell code:
data Shape = Circle Double | Rect Double Double
area :: Shape -> Double
area (Circle radius) = 3.1415 * radius * radius
area (Rect width height) = width * height
Write out the full sequence of tokens in this program, in the order that they appear.
3. (8 points)
For each of the first four phases of a typical compiler pipeline (source input, lexical analysis, parsing, and semantic analysis), describe a small specific change that you could make to the code in question 2 that would trigger an error in that phase (and not any previous phase). Justify each answer. (You might find it helpful to copy the code into a Haskell file and load it in an interpreter to try to trigger errors there.)
4. (4 points)
Fill in the definitions of the Sing and (:.:) cases for the “check” function.
5. (2 points)
Fill in the definition of the “star” function.
6. (6 points)
Write at least three more regexes and at least two tests for each that demonstrate that “check” and “star” are working correctly.
Our website has a team of professional writers who can help you write any of your homework. They will write your papers from scratch. We also have a team of editors just to make sure all papers are of HIGH QUALITY & PLAGIARISM FREE. To make an Order you only need to click Ask A Question and we will direct you to our Order Page at WriteDemy. Then fill Our Order Form with all your assignment instructions. Select your deadline and pay for your paper. You will get it few hours before your set deadline.
Fill in all the assignment paper details that are required in the order form with the standard information being the page count, deadline, academic level and type of paper. It is advisable to have this information at hand so that you can quickly fill in the necessary information needed in the form for the essay writer to be immediately assigned to your writing project. Make payment for the custom essay order to enable us to assign a suitable writer to your order. Payments are made through Paypal on a secured billing page. Finally, sit back and relax.
About Writedemy
We are a professional paper writing website. If you have searched a question and bumped into our website just know you are in the right place to get help in your coursework. We offer HIGH QUALITY & PLAGIARISM FREE Papers.
How It Works
To make an Order you only need to click on “Order Now” and we will direct you to our Order Page. Fill Our Order Form with all your assignment instructions. Select your deadline and pay for your paper. You will get it few hours before your set deadline.
Are there Discounts?
All new clients are eligible for 20% off in their first Order. Our payment method is safe and secure.
