This preview has intentionally blurred sections. Sign up to view the full version.
View Full DocumentThis preview has intentionally blurred sections. Sign up to view the full version.
View Full DocumentThis preview has intentionally blurred sections. Sign up to view the full version.
View Full DocumentThis preview has intentionally blurred sections. Sign up to view the full version.
View Full Document
Unformatted text preview: Arrange the nonterminals in some order A1, A2, …, An for i = 1 to n do begin for j = 1 to I1 do begin expand production of the form Ai >Aj w end for eliminate the immediate left recursion among Ai productions. End for (the algorithm can fail if the grammar has a cycle (A==> A), or A>e) Example 1: S>Aa  b A>Ac  Sd  e Example 2: X>YZ  a Y>ZX Xb Z>XY  ZZ  a Left factoring (to produce a grammar suitable for predictive parsing) replace productions by m n A γ αβ  ...    ...   1 2 1 → n m A A A β α  ...  '  ...   ' 1 1 → → Example: S>iEtS  iEtSeSa E>b Is a non ambiguous grammar LL(1) after eliminating common left factors and left recursion? When is a grammar LL(1)? COP4020 Spring 2011 8 02/20/12...
View
Full
Document
This note was uploaded on 02/20/2012 for the course COP 4020 taught by Professor Engelen during the Spring '11 term at FSU.
 Spring '11
 Engelen

Click to edit the document details