|CSE Home||About Us||Search||Contact Info|
As usual, turn in only one solution per group.
1. Researchy topic:
Use a compiler generator to build a handy double precision calculator. The calculator should support recursive expressions, the usual arithmetic operations (exponentiation included), and should support at least four functions (such as sin, cos, tan, atan). You should accept numbers in C-style double format (remember HW1?). In addition, provide a symbol for "the result of the last operation", such as 'x'. For example, here's a possible session with your calculator:
> 2.3 + 2.25 * 2
> x - 1
Bonus points: Consider adding the ability to define symbolic "memories" that you can assign to and read.
The nicest part of this homework is that you get to choose what parser generator to use. Here are some suggestions:
2. Change the lexer to scan the extended token set (also see the project description). Also extend the parser to understand for loops, continue statements, Booleans, and constant expressions as described in the project and in the extended language. It is assumed that you have comments and if-then-else statements in your pocket already.
Your modified parser doesn't need to generate (or evaluate) code, but it should build proper ASTs and print them.