Assignment #5: Parsing with Applicative Combinators
(Modified from Prof. Greenberg’s Homework #4).
For this assignment you will use Haskell’s Applicative Combinators to simplify your parser from the previous assignment, making the parsing rules much shorter and more grammar-like . As usual, you will proceed in stages:
-
- Test the existing parser code for arithmetic expressions without variables, by simply running the program you downloaded.
- Modify the
Parser AExpcode and add any other code necessary to support variables. - Add support for Boolean keywords (
"true","false","AND","OR"). - Add support for parsing Boolean constants
true,false. - Add support for parsing entire Boolean expressions.
- Add support for parsing statements
For extra credit, you might attempt the following:
-
- There should also be a way to parse
Skipstatements. Can you figure it out? - As in the previous assignment, I have not included a test for sequences, where a sequences is syntactically a pair of statements separated by a semicolon; e.g.,
x = 5; y = 3. Can you modify yourstmtparser to handle such forms?
- There should also be a way to parse