Professional Documents
Culture Documents
Operator Pre
Operator Pre
Introduction:
Operator precedence grammar is kinds of shift reduce parsing method. It is
applied to a small class of operator grammars.
properties:
1. Production rule should not have Ɛ on its RHS (body of the production).
2. There is no two adjacent non-terminals on RHS of production.
Precedence Relations:
PROBLEM : 1
Construct Operator precedence table and function graph for the given
Grammar:
STEP TO SOLVE:
STEP 1:
Computation of LEADING ( ) and TRAILING ( )
(1) Computation of LEADING
TRAILING(A)={a}
5 Rules:
X=.Y
III. If A→XBY
X,Y - Terminals
B-Non Terminals
Set X=.Y
IV if A→XB
X – Terminal
X<. LEADING (B)
V if A -> BX
X→ Terminal
Trailing (B).> X
NOTE:
F →id
LEADING(T)={*, L(F)}={*,(,id}
LEADING(F)={(,id}
TRAILING(E) ={+,T(T}}={+,*,),id}
TRAILING(T)={*,T(F)}={*,),id}
TRAILING(F)={ ), id}
Step 2: COMPUTE Precedence relations:
F→( E)
(=.)
According to rule iv A→XB; X<.LEADING (B)
+ * id $
f 2 4 4 0
g 1 3 5 0