BASIC INFORMATION Xiaoqing Tang xiaoqing.tang@rochester.edu Programming - C Week 3-4 LISTOFFILES char_classes.c char_classes.h (character classes. They're unmodified.) format.c (main program code file of calculating a single expression) grammar (the parser grammer. They'll also be appearing in the write-up) eval.c (main program code file of the main program) makefile (makefile, modified as required) makefile.dep (automatically generated by "make depend") parser.c parser.h (parser code) reader.c reader.h (reader code. unmodified) README (this file) scanner.c scanner.h (scanner code) vartable.c vartable.h (the variable table to implement variable storage) eval.pdf (the write-up) HOW TO COMPILE make eval HOW TO EXECUTE run ./eval Every time you're supposed to write a sequence of expressions. The expressions can be ordinary arithmetic expression such as 1+1; or assignment expression like a=1; or expression with variable such as 2^n; or with functions like sin(3.14/n); Any sequence is ended by an EOF(Ctrl-D), and then the program calculates all the expressions, outputing the value. Then you can go on with the next sequence of expressions. EOL (End of Line) does nothing in the input. Any two sequences do not share the variable table. i.e. the assignment of a variable can't be used in the previous or next sequences. The program supports the following functions: sin cos tan sqrt (square root) cbrt (cube root) sqr (square, i.e. ^2) cub (cube, i.e. ^3) log exp abs Note: 1. The pow operator (^) is right-associated, i.e. 2^2^2 == 2^(2^2) 2. Any unassigned variable is taken as the default value of 0. 3. Any assignment expression is also an expression, so they have a return value. It means the program will also calculate the result. Furthermore, it means that you can write expressions like "a=b=1". e.g. {Input} a=2; b=3; a+b; {Output} == 2.000000 == 3.000000 == 5.000000 {Input} n=3.0*2.0;sin(3.1415926/n); {Output} == 6.000000 == 0.500000 {Input} 1e0 + exp(log(2e-0)) * 3 + 2^2^2 {Output} == 23.000000 BUG REPORTS This is not a bug, but an uncomfortable GUI stuff. If you enter a long sequence of expressions, the program will output a sequence of ==, you have to match the result to your expression yourself.