Is this grammar LR(0) or SLR(1)

56 views Asked by At

I have a question related to a grammar:

S --> ( S ) S | S --> epsilon.

So is this grammar LR(0) or SLR(1)? I have provided the NFA and DFA of it but I am stuck on the parsing table.NFA and DFA of the grammar above mentioned

In my opinion this is a SLR(0) grammar because every state contains S --> . because of the epsilon, and so every state with this production has a Shift-Reduce conflict.

1

There are 1 answers

0
Michael Dyck On

The grammar is not LR(0) because (as you point out) there are shift-reduce conflicts in the LR(0) automaton.

It also isn't SLR(0) because that's the same as LR(0).

It looks to me like it's SLR(1), because FOLLOW(S) is ')' and the end-marker (which you omit from your analysis), and that would be enough to resolve the conflicts.