Grammar Evaluation |
Using the following grammar:
<expression> := <component> | <component> + <expression> <component> := <factor> | <factor> * <component> <factor> := <positive integer> | (<expression>)
write a program which analyses expressions conforming to the rules of this grammar and evaluates them, if the analysis has been successfully completed. It may be assumed that there is no overflow of float(C)/real(Pascal) numbers range.
5 32 12+34 1*(2+3)+3 1(2+3)+3 qwe323
32 46 8 ERROR ERROR