CSS 342: Mathematical Principles of Computing
Lab 6: Stacks and Compilers
Professor: Munehiro Fukuda
Assigned: See Our Syllabus
This laboratory work modifies the textbook's calculator program so as to accept binary C++ operators
including (, ), *, /, %, -, +, <<, >>, <, <=, >, >=, ==, !=, &, ^, |, &&, and ||.
You can find the textbook's calculator program (as shown in Figures 12.14 - 12.22) in
: The calculator's, (i.e., Evaluator's) class interface. It corresponds to Figures 12.14 and
: The calculator's, (i.e., Evaluator's) implementation that includes getValue( ),
getTop( ), binaryOp( ), and processToken( ), each corresponding to Figure 12.17 12.18, 12.19 and
: the Token class interface. This corresponds to Figure 12.15.
: The Tokenizer class interface. It corresponds to Figure 12.15.
: It includes the getToken routine for returning the next token in the input stream. It
corresponds to Figure 12.16.
: A simple main for evaluating expressions repeatedly. It corresponds to Figure 12.22.
This calculator accepts only five binary operators such as *, /, -, + and ^ as well as parentheses ( and ). Note
that ^ means exponential in the textbook rather than bit exclusive