HP Calculator Framework

In this assignment, you will:

You are permitted to work in groups of 2 in this assignment.

It is likely that you may not have used a Polish (prefix) calculator before. Any questions about the semantics of a calculation (e.g., what order do you place values on a stack) will be resolved by using the HP-35 calculator emulator below (just click on the image to pull up the calculator itself):



Part I: Install and complete both Kalc and KalcPP

kalc Started...

kalc> 4 5 2 + *
> .

4 5 2 + * = 28

kalc> 1 2 3 * +
> .

1 2 3 * + = 7

kalc> .

kalcPP Started...

kalcPP> 4 5 2 + *
> .
4 5 2 + * = ( 4 * ( 5 + 2 ) )
kalcPP> 4 5 2 * +
 > .

4 5 2 * + = ( 4 + ( 5 * 2 ) )

kalcPP> .
/ non-negative integer postfix calculator

// grammar.b : simple calculator

// Simple tokens specified in simple format

"+" ADD
"-" SUB
"*" MUL
"/" DIV
"%" MOD
"^" POW
"++" INC
"--" DEC
// Regular expression tokens specified in JavaCC format
TOKEN :
{
<INTEGER: ["0"-"9"] (["0"-"9"])* >
}
Exp : Action [Exp] :: Expr
;
Action : INTEGER :: Push
| ADD :: Add
| SUB :: Sub
| DIV :: Div
| MUL :: Mul
| MOD :: Mod // computes x%y (where x is on top of stack and y is immediately beneath top)
| POW :: Pow // computes x^y (raises x to the power y)
| INC :: Inc // computes x++ (increments value on the top of the stack)
| DEC :: Dec // computes x (decrements the value on the top of the stack)
;

In short, I created a parser from the above grammar and have generated all the classes that you'll need. Please note in the above grammar that the name of the class that is instantiated for a production is after the double colon (::).  So if there is a divide operation in an expression that you enter, you will see an instance of the Div class in a parse tree.  It is this naming convention that you should keep in mind as you proceed.

Your tasks are to:

Note: if you have any questions on the order in which arguments are to be entered, consult the HP-35 simulator at the top of this web pagre.  Any discrepancies between what I have written above and the HP simulator, go with the simulator.


Part 2: Create the KalcFramework and KalcPlugin and KalcPPPlugin

By now, you will have noticed that both Kalc and KalcPP are *really* similar programs.  Your next and last task if to move all of the commonalities into a package called KalcFramework, performing the usual tasks (that I indicated in the class notes) for separating out framework code from plugin code.  You will create two plugins, KalcPlugin and KalcPPPlugin to represent the extensions of the KalcFramework that correspond to the Kalc and KalcPP programs.

Your tasks are to:

What to Submit

From Part 1:
From Part 2:
And:
A critical part of any design is clarity and understandability.   Hence, you will be graded on the clarity of your project and its ability to work correctly.  Sloppy code, documentation, or anything that makes grading or understanding your program difficult will cost you points!  Beware, some of these "beauty" points are subjective. 

No late assignments/submissions will be accepted.