1
$\begingroup$

A bit confused about whether this grammar is ambiguous or not

C' -> C
C -> d C u C
C -> d C
C -> ε

I tried building the DFA for this but I get this in one of the states:

C -> d C DOT u C, $
    C -> d C DOT, $

Isn't this a shift-reduce conflict, so surely it means the grammar is not LR(1)? Or does it reduce regardless since $ and u are both in the follow set of C? Is this not a reduce-reduce conflict since it goes to C regardless?

$\endgroup$
1
  • 2
    $\begingroup$ Is your question about being LR(1) or about being ambiguous. A CF grammar may be unambiguous, but not LR(1). $\endgroup$
    – babou
    Mar 28, 2015 at 13:41

1 Answer 1

1
$\begingroup$

This grammar (which isn't ambiguous) isn't LR(k) due to the right-recursion, thus it isn't LR(1).

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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