40 views | 40 views
0

If the conflicts are resolved in ABOVE manner...

show the above manner?

0

https://gateoverflow.in/87037/gate2005-83b

But i didn't get can u explain

0
E -> id | E+E | E * E ===> + and * in same level ===> equal precedence

But doubt at associativity due to + has left side and right side E

then it is Bottom-Up parsers ===> Right Most Derivation ===> + and * have right associativity

Given grammar :

E→num

EE+E / EE + x num $E I0 I2 I1 I1 I3 I4 ACCEPT I2 R3 R3 R3 I3 I2 I5 I4 I2 I6 I5 I3, R1 I4, R1 R1 I6 I3, R2 I4,R2 R2 Note: Shift-reduce conflict: Yacc’s default action in the case of a shift-reduce conflict is to choose the shift action. So when there is a situation to choose b/w shift and reduce (eg (I6,+)) we will choose shift. # In the below table E(i) is used just for identification purpose.  STACK INPUT ACTION OUTPUT I0 3x2+1$ (I0,num) : Shift I2 I03I2 x2+1$(I2,x) : Reduce by E->num E(1).val=num.val=3 I0E(1)I1 x2+1$ (I1,x) : Shift I4 I0E(1)I1xI4 2+1$(I4,num): Shift I2 I0E(1)I1xI42I2 +1$ (I2,+) : Reduce by E->num E(2).val=num.val=2 I0E(1)I1xI4E(2)I6 +1$(I6,+): Shift I3 I0E(1)I1xI4E(2)I6+I3 1$ (I3,num): Shift I2 I0E(1)I1xI4E(2)I6+I31I2 $(I2,$): Reduce by E->num E(3).val=num.val=1 I0E(1)I1xI4E(2)I6+I3E(3)I5 $(I5,$): Reduce by E->E+E E(4).val=E(2).val+E(3).val=2+1=3 I0E(1)I1xI4E(4)I6 $(I6,$): Reduce by E->ExE E(5).val=E(1).valxE(4).val=3x3=9 I0E(5)I1 $(I1,$): ACCEPT

by Boss (23.5k points)
0
really need to do this?
0

No but i wanted to give an elaboration..

The solution at https://gateoverflow.in/87037/gate2005-83b was not much clear to me..I understood the logic after building this table and all.. but the one Debashish Deka Sir added at https://gateoverflow.in/1405/gate2005-83a is also very detailed..

Deepalitrapti didn't get the solution in the first link..So i thought to give these details..

0
ok...