0
$\begingroup$

I have this grammar:

E -> E + T
E -> T
T -> T * F
T -> F
F -> ( E )
F -> id

And this is the state diagram for it:

enter image description here

I tried to construct a parse table and I am getting shift/reduce conflict. More specifically in state 2 I can shift *. Also, FOLLOW(LHS) = FOLLOW(T) contains * so I can also reduce using rule 2. Hence shift/reduce conflict.

enter image description here

Am I right?

$\endgroup$
1
  • $\begingroup$ We discourage "please check whether my answer is correct" questions, as only "yes/no" answers are possible, which won't help you or future visitors. See here and here. Can you edit your post to ask about a specific conceptual issue you're uncertain about? As a rule of thumb, a good conceptual question should be useful even to someone who isn't looking at the problem you happen to be working on. If you just need someone to check your work, you might seek out a friend, classmate, or teacher. $\endgroup$
    – D.W.
    Jan 8 at 2:08

1 Answer 1

1
$\begingroup$

No, you're not right.

State 4 contains the item $E\to\cdot T$. After a GOTO on T, that should produce a state with item $E\to T\cdot$. But the destination state (S2) contains the item $T\to T\cdot$. That's a simple transcription error.

Now, * is in FOLLOW(T), but it's not in FOLLOW(E), which is what the item should have included. So the conflict is also a result of the same transcription error.

$\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.