Write a calculator for the Reverse Polish Notation (aka postfix notation).
Pay careful attention to:
- lexical subtleties, e.g. ones related to negative numbers:
1 2 -3 ++
1 2- 3 +
1 2--3-
- the "lexer" in this task should be written by hand
- possible extensions: floating point numbers e.g. -6.28e+23, .3E-4, pi; hexadecimal numbers, e.g. 0xCafeBabe etc..
- decent error reporting
When you're done, you can rewrite your program so that instead of computing the value of an expression it will build its tree and output it in infix notation (non-trivial: parentheses).