Write the algorithm for FIRST and FOLLOW.


FIRST
1. If X is terminal, then FIRST(X) IS {X}.
2. If X → ε is a production, then add ε to FIRST(X).
3. If X is non terminal and X → Y1,Y2..Yk is a production, then place a in
FIRST(X) if for some i , a is in FIRST(Yi) , and ε is in all of
FIRST (Y1),…FIRST(Yi-1);
FOLLOW
1. Place $ in FOLLOW(S), where S is the start symbol and $ is the input right
End marker.
 2. If there is a production A → αBβ, then everything in FIRST (β) except for ε is
Placed in FOLLOW (B).
 3. If there is a production A → αB, or a production A→ αBβ where FIRST(β)
Contains ε , then everything in FOLLOW(A) is in FOLLOW(B).
77. List the advantages and disadvantages of operator precedence parsi

0 comments:

Post a Comment

 
page