1
$\begingroup$

when constructing the SLR(1) table for some grammar I need to compute the FOLLOW set for all terminals in order to decide where and when to reduce.

Do I compute theme for the augmented grammar or the original one?
Is there even a difference?

$\endgroup$

2 Answers 2

0
$\begingroup$

In SLR(1) parser you need to compute only the follows of non-terminal symbols. When you have to put a reduce in the table, you look at the follows of the head of the production, and then put the production only in columns(correspond to terminals) that are in the follows.

$\endgroup$
0
$\begingroup$

by augmented grammar I am assuming the production rule S'->S. The purpose of augmented grammar is just to make the process of computing the go-to graph homogeneous for all nodes, it actually isn't a part of the grammar, so you dont need to compute its follows. Even if you did, it won't matter unless you are taking it as a part of the grammar, which in case changes the grammar itself.

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