retagged by
635 views
2 votes
2 votes

Image of shift reduce

In the above grammar,

1. how to determine the precedence of the operator?

2. If there is shift and reduce conflict, in who's favor to resolve?

3. Why are we not reducing E-->E+E, instead we are shifting. But incase of E-->id, we are reducing.

retagged by

1 Answer

0 votes
0 votes
when you can not derive any precedence out of the gramaar rules, use the general precedence of operators.

which is id > * > + > $

now if you know how the above algorithm works you will certainly know why i) has not been reduced and ii) also not reduced

Related questions

1 votes
1 votes
1 answer
1
shikharV asked Jan 14, 2016
1,747 views
Given solution:After reducing two 1's of expression to E, E*E should be reduced not the 3rd 1. So final output will be 112*311+2 instead of the given output. Please check...
0 votes
0 votes
1 answer
2
Sourabh Kumar asked Jan 14, 2016
351 views