RPN calculator - lyriarte/Cm7b5 GitHub Wiki
Reverse Polish Notation
RPN, or postfix notation, is a mathematical notation where the operator follows its operands.
- Can be evaluated without parenthesis as long as arity is fixed.
- Well fitted for stack-based machines.
Infix notation:
(123 - 5 * 4 - 3) / 4
Postfix rpn equivalent:
123 5 4 * - 3 - 4 /
Bare-bones parser
git checkout simple_rpn
cat rpn.c
Lex-based RPN calculator
git checkout rpn
git clean -f
make
echo "123 5 4 * - 3 - 4 /" | ./rpn
Semantic errors may cause a stack underflow.