LL(1) S -> ABS | BaA | f A -> aA | bB B -> dAA | g FIRST(S) = FIRST(ABS) u FIRST(BaA) u FIRST(f) = = FIRST(A) u FIRST(B) u {f} = FIRST S f AB | fabdg | fabdg A ab | ab | ab B dg | dg | dg a b d f g # S (ABS,1) (ABS,1) (BaA,2) (f,3) (BaA,2) A aA bB B dAA g (gabg#, S#, []) -> g/S: BaA,2 (gabg#, BaA#, [2]) -> g/B: g,7 (gabg#, gaA#, [2,7]) -> g/g: pop (abg#, aA#, [2,7]) -> a/a: pop (bg#, A#, [2,7]) -> b/A: bB,5 (bg#, bB#, [2,7,5]) -> b/b: pop (g#, B#, [2,7,5]) -> g/B: g,7 (g#, g#, [2,7,5,7]) -> g/g: pop (#, #, [2,7,5,7]) -> #/#: accept ---------------------------- általános LL(1) S -> DaB | BbD B -> eps | f D -> eps | d S -> ABD A -> epszilon | a B -> epszilon | b D -> epszilon | d el tud tunni: S, A, B, D FIRST(S) = FIRST(A) u FIRST(B) u FIRST(D) FIRST S ABD | abd A a | a B b | b D d | d FOLLOW S # | # | # A FIRST(B),FIRST(D) FOLLOW(S) | bd S | bd# B FIRST(D) FOLLOW(S) | d S | d# D FOLLOW(S) | S | # S -> ABD A -> epszilon | a B -> epszilon | b D -> epszilon | d a b d # S (ABD,1) (ABD,1) (ABD,1) ABD,1 A a,3 eps,2 eps,2 eps,2 B b,5 eps,4 eps,4 D d,7 eps,6 b# S -> DaB | BbD B -> eps | f D -> eps | d eltunik: B, D FIRST S ab DB | abdf B f | f D d | d FOLLOW S # | # B b S | #b D a S | #a a b d # f S DaB,1 BbD,2 DaB,1 BbD,2 B eps,3 eps,3 f,4 D eps,5 d,6 eps,5