CSCI 312 Assignment #5

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 .  Because I have already done some of the work required in Greenberg’s version of the assignment and wish to keep this code private, I will be mailing you the zipfile this time instead of posting it on our course webpage. As usual, you will proceed in stages:

    1. Test the existing parser code for arithmetic expressions without variables, by simply running the program you downloaded.
    2. Modify the Parser AExp code and add any other code necessary to support variables. 
    3. Add support for Boolean keywords ("true", "false", "AND", "OR").
    4. Add support for parsing Boolean constants true, false.
    5. Add support for parsing entire Boolean expressions.
    6. Add support for parsing statements

For extra credit, you might attempt the following:

    1. As you’ll see, my handling of keywords has quite a bit of redundancy, requiring both a lexer-like rule and a call to the kw function.  Although I was unable to make this code any less redundant, I suspect that there is a way to do it with more sophisticated kw function.
    2. There should also be a way to parse Skip statements.  Can you figure it out?
    3. 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 your stmt parser to handle such forms?