Exercise 4 Name __________________ Score __/26
|
| S ® ABC
A ® a | Cb | є B ® c | dA | є C ® e | f |
FIRST(S)={a,c,d,e,f} FIRST(A)={a,e,f,є} FIRST(B)={c,d,є} FIRST(C)={e,f} |
FOLLOW(S)={$} Rule 1. FOLLOW(A)=FIRST(B)ÈFIRST(C)ÈFOLLOW(B)={c,d,e,f} Rule 2, 3 and 4. FOLLOW(B)=FIRST(C)={e,f} Rule 2 FOLLOW(C)=FIRST(b) ={b}ÈFOLLOW(S) = {b,$} Rule 2 and 4 |
Blank entries are error conditions. Rules for typical
production X ® b are:
|
| a | b | c | d | e | f | $ | |
| S | S ® ABC | S ® ABC | S ® ABC | S ® ABC | S ® ABC | ||
| A | A ® a | A ®є |
A ®є |
A ® Cb A ®є |
A ® Cb A ®є |
||
| B | B ® c | B ® dA | B ® є | B ® є | |||
| C | C ® e | C ® f |


x:=a+3 Stack Input Action row,column entry 1 x:=a+3$ shift 1,id s4 1id4 :=a+3$ shift 4,:= s6 1id4:=6 a+3$ shift 6,id s20 1id4:=6id20 +3$ reduce E ® id 20,+ r4 6,E g11 1id4:=6E11 +3$ shift 11,+ s16 1id4:=6E11+16 3$ shift 16,num s10 1id4:=6E11+16num10 $ reduce E ® num 10,$ r5 16,E g17 1id4:=6E11+16E17 $ reduce E ® E+E 17,$ r6 6,E g11 1id4:=6E11 $ reduce S ® id:=E 11,$ r2 1S $ 1,S g2 1S $ accept 2,$