CS712/CS812
Programming Project Part 1
Spring 1997


Use flex and bison to write a calculator program for bitwise integer calculations.

At the 75% level, your program should support

The operators are listed in order of decreasing precedence. The shift operators all have equal precedence. All the operators are left associative except for the complement operator, which is right associative.

Your calculator should support 32-bit integers. Constants that do not fit in 32 bits should be flagged as errors.

Expressions may be parenthesized.

The calculator should accept a series of expressions, one per line. For each line, the value of the expression should be printed as 0x followed by eight hexadecimal digits (i.e. print the leading zeroes).

Blank lines should be ignored. Spaces and tabs should be ignored, as well. That is, they have no meaning except to separate tokens.

If an expression is entered that has a syntax error (structurally invalid), an error message should be issued and the parser should be synchronized at the next newline character. If an expression is entered that has a semantic error (e.g. constant too large), then issue the appropriate error message, internally patch the error (e.g. make a constant that is too large have value 0), and continue processing. The goal is to be able to detect multiple semantic errors per line.

At the 85% level, your program should support

At the 100% level, your program should support

Your program will be graded primarily by testing it for correct functionality. However, you may lose points if your program is not properly structured or adequately documented.

When ready, the public test files will be in ~cs712/public/proj1.

You can write your program in either C or C++. You must submit a Makefile (called "Makefile") so that we can conveniently build your programs. Your executable program should be called "proj1". Your programs will be graded using an Alpha machine (e.g. hopper and christa) so be sure to test in that environment.

Your programs should be submitted for grading from either hopper or christa. To turn in this assignment, type:
~cs712/bin/submit proj1 <list of files to submit>

Do not turn in any non-Ascii files (i.e. no object files, no executable files, etc.).

Submissions can be checked by typing:
~cs712/bin/scheck proj1

To receive full credit for the assignment, you must turn in your files prior to 8am on Monday February 10. Late submissions will be accepted at the penalty of 5% per day up to one week late.

Remember: as always you are expected to do your own work on this assignment.


Last modified on February 4, 1997.

Comments and questions should be directed to pjh@cs.unh.edu