I found a question while studying compilers :-
Given a grammar E->E+E/E×E/number
The above grammar is fed to a YACC with semantic rules for parsing. What will be the action of the YACC.
1) it detects recursion and eliminates recursion.
2) it detects RR conflict and resolves
3) it detects SR conflict and resolves in favour of Shift over Reduce action
4) it detects SR conflict and resolves in favour of reduce over shift action
The answer given is option 3. But I have read that LALR parser cannot parse ambiguous grammar, while the above grammar is ambiguous.
A) So how can YACC(which is a LALR parser) parse the given grammar?
B) What about other ambiguous grammar, I.e. can YACC parse all the ambiguous grammars?