Header Ads Widget

Postfix Translation

Postfix Translation

In a production A → α, the translation rule of A.CODE consists of the concatenation of the CODE translations of the non-terminals in α in the same order as the non-terminals appear in α.

Production can be factored to achieve postfix form.

Postfix translation of while statement

The production

  1. S   →  while M1 E do M2 S1  

Can be factored as:

  1. S →    C S1  
  2.    C →    W E do  
  3.    W →    while  

A suitable transition scheme would be

Production RuleSemantic Action
W → whileW.QUAD = NEXTQUAD
C → W E doC W E do
S→ C S1BACKPATCH (S1.NEXT, C.QUAD)
S.NEXT = C.FALSE
GEN (goto C.QUAD)

Postfix translation of for statement

The production

  1. S     for L = E1 step E2 to E3 do S1  

Can be factored as

  1. F →    for L  
  2.    T  →   F = E1 by E2 to E3 do  
  3.    S  →   T S1  

Post a Comment

0 Comments