review_lect9

review_lect9 - Make each undefined entry of M error. LL(1)...

Info iconThis preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon
Lecture 9 review What is in the First (a) and Follow (A)? Compute FIRST(X) If X is a terminal then FIRST(X) = {X} If X-> , add to FIRST(X) If and add every none in FIRST( ) to FIRST(X). If , add to FIRST(X). Compute Follow(A). If S is the start symbol, add $ to Follow(S). If A->aBb, add First(b)-{ } to Follow(B). If A->aB or A->aBb and b=> , add Follow(A) to Follow(B). COP4020 Spring 2011 1 02/20/12 ε k Y Y Y X ... 2 1 ... 1 2 1 - i Y Y Y i Y ... 2 1 k Y Y Y
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Construct the LL(1) parsing table? With first(a) and follow(A), we can build the parsing table. For each production A->a: Add A->a to M[A, t] for each t in First(a). If First(a) contains empty string Add A->a to M[A, t] for each t in Follow(A) if $ is in Follow(A), add A->a to M[A, $]
Background image of page 2
Background image of page 3
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: Make each undefined entry of M error. LL(1) grammar: A grammar whose parsing table has no multiply-defined entries is a LL(1) grammar. use one input symbol of lookahead at each step to make a parsing decision. No ambiguous or left-recursive grammar can be LL(1) A grammar is LL(1) iff for each set of A productions, where The following conditions hold: n A | ... | | 2 1 j i and n j 1 and n i 1 when {}, ) ( ) ( = j i First First j. i when {}, Follow(A) ) First( (b) j i when e, no, (a) the , if j = j i n...
View Full Document

Page1 / 3

review_lect9 - Make each undefined entry of M error. LL(1)...

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online