Blog picture

Asst. Professor

Blog image KHUSHBOO RANI Shared publicly - Apr 13 2020 4:05PM

Algorithm for construction of predictive parsing table (MCA 4)


Algorithm for construction of predictive parsing table:

 

 

Input : Grammar G

 

Output : Parsing table M

 

Method :

 

  1. For each production A → α of the grammar, do steps 2 and 3.

 

  1. For each terminal a in FIRST(α), add A → α to M[A, a].

 

  1. If ε is in FIRST(α), add A → α to M[A, b] for each terminal b in FOLLOW(A). If ε is in FIRST(α) and $ is in FOLLOW(A) , add A → α to M[A, $].

 

  1. Make each undefined entry of M be error.

 

Example:

 

Consider the following grammar :

 

E → TE’

E’ → +TE’ | ε

T → FT’

T’ → *FT’ | ε

F → (E) | id

 

Top down parsing and Bottom up Parsing



Post a Comment

Comments (0)