Skip to content

Latest commit

 

History

History

Lab4-ParsingIntroductions

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Parsing

Q1: It involves the following algorithm:

  1. Arrange the non-terminal symbols in order: A1, A2, A3, ..., An
  2. For i=1 to n do:
     For j=1 to i-1 do:
      I) replace each production of the form Ai->AjY with the productions: Ai->Z1Y|Z2Y|...|ZkY where Aj->Z1|Z2|...|Zk are all the current productions of Aj.
      II) Eliminate the immediate left recursion among the Ai

Q2: It involves the following algorithm:
 1. For each non-terminal A, find the longest prefix, say a, common to two or more of its alternatives
 2. if (a!=epsilon) then replace all the A productions, A->ab1|ab2|ab3|...|abn|Z, where Z is anything that does not begin with a, with A->aY|Z and Y->b1|b2|b3|...|bn
 Repeat the above until no common prefixes remain.

Q3: It involves the basic DFS, where we expand each production and try to find a match. BFS has also been implemented.