Header Ads Widget

Postfix Notation

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

  1. E  →  E1 op E2                       
  2. E  →  (E1)  
  3. E   →  id  
Semantic RuleProgram fragment
E.code = E1.code || E2.code || opprint op
E.code = E1.code
E.code = idprint id

Post a Comment

0 Comments