Programming Assigment 4


  • Background:

    This assignment requires you to write a bison-style parser for a simple four-function calculator. You will combine this parser with your scanner from the previous assignment to create a full four-function calculator.

  • Assigment:

    I recommend you take the following steps to create your parser:

    1. Decide which tokens you need (Hint: Consider the calc.tab.h file you were given for the previous assignment).
    2. Consider the entire body of input to be a single nonterminal, which should be your start symbol.
    3. This nonterminal should be produced from a list of expressions separated by semicolons.
    4. Create a grammar for expressions and implement their rules. Your calculator should output the value of the expression once the semicolon is reached.
    5. If a scanner error or parse error occurs, your calculator should indicate it and terminate.

    Don't forget that you need to include a short main() function somewhere in your program, and that you must link your parser with your scanner object file and the libfl library.

    You may discuss this assignment with other students and work the problems together. However, your programs should be your own individual work. Remember that all assignments are to be turned in in class on the date due.