3460:430/530  Theory of Programming Languages                                                                                  Fall 2005

Dr. C.-C. Chan     Project #1  (10 pts)                                                                                                    Due:  9/15/05

 

 

Problem:  Use bison to create an interpreter that can evaluate simple arithmetic expressions consisting of the operators:  +, -, *, /, ^, (, and ).  Parentheses can be nested in arbitrary number of levels.

            The interpreter will take a valid infix expression entered from standard input, evaluate it, then print the result to screen.  This read-eval-print loop is executed until end-of-file, i.e., <ctrl>+d, is entered.

            If an invalid expression is entered, the interpreter should print the line number, skip the rest of the line, and continue to process next input line.

            The first output of your interpreter should be a greeting message including your name and user id.  Use the character '>' as an input prompt to the user to enter an input expression.  It is optional to add line number before the prompt character.

 

Limitations:

            1.  Only literal constants of type double or int are allowed in an expression.

            2.  The priority of operators is the same as in ordinary arithmetics.

 

Submissions:

            Name your source file as yourlastname_p1.y

            Send the source file by e-mail to sk39@uakron.edu   and chan@cs.uakron.edu

            The project is due by midnight of the due date.