0
$\begingroup$

Consider this example:

stmt => if (expr) stmt | if (expr) stmt else stmt | other

Why can't we use shift-reduce on this?

This is a compiler homework and I really need to answer it.

$\endgroup$
0
$\begingroup$

The grammar is ambiguous, so no deterministic parsing technique will be able to handle it. The parsing techniques called "shift-reduce" are all deterministic.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.