Contents    Page-10    Prev    Next    Page+10    Index   

Reverse Polish Notation

Reverse Polish Notation (RPN) is an unambiguous, parenthesis-free notation for arithmetic expressions. [The description "Polish" refers to the nationality of logician Jan ukasiewicz, who invented (prefix) Polish notation in the 1920s. -- Wikipedia] Operands precede the operators that apply to them:


A + (B * C)   -->  A B C * +

(A + B) * C   -->  A B + C *

It is easy to produce RPN as output of an operator precedence parser:

  1. Operands go directly to the output; no operand stack is used.

  2. When an operator is reduced, it is removed from the operator stack and put into the output.