87
Postfix Notation
- Postfix notation is the useful form of intermediate code if the given language is expressions.
- Postfix notation is also called as ‘suffix notation’ and ‘reverse polish’.
- Postfix notation is a linear representation of a syntax tree.
- In the postfix notation, any expression can be written unambiguously without parentheses.
- The ordinary (infix) way of writing the sum of x and y is with operator in the middle: x * y. But in the postfix notation, we place the operator at the right end as xy *.
- In postfix notation, the operator follows the operand.
Example
Production
Semantic Rule | Program fragment |
---|---|
E.code = E1.code || E2.code || op | print op |
E.code = E1.code | |
E.code = id | print id |
Next TopicParse and syntax trees