3460:430/530:080  Theory of Programming Languages                                                                  Fall 2003

Dr. C.-C. Chan                                                                                                                             Due:  9/21/03

Project #2  (30 pts)

 

Problem:  Based on Project 1, extend the language to allow the following features:

 

1.      Use semicolon instead of newline to separate input expressions.

2.      Allow the command quit to terminate the interpreter.

3.      Allow variables with name length no more than 32 characters consisting of upper or lower case letters.  They are case-insensitive.

4.      Possible variable values include integers and real numbers.

5.      Allow assignment operator, =, has the lowest priority and is right associative.

6.      Allow an input expression to across multiple lines.  e.g.,

                             x =

                             1 + 3

                             + 4;

              should be treated as a valid input.

7.      The value assigned to a variable in an invalid input line should be discarded.

e.g.:  given the input sequence

                             a = 5.0;

                             a = 4 + 3  2;  //invalid inputs

                             a;

              the value of a should remain to be 5.0.

             

Implementation:

              1.  Add new token types for variable.

              2.  Add new rules and corresponding actions to reflect the new features.

              3.  Extend yylex function to recognize new features.

 

 

Submissions:

            Name your source file as yourlastname_p2.y and yourlastname_symbol.c

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

            The project is due by midnight of the due date.