more on FOLLOW sets (Debora Weber-Wulff)
Fri, 26 Jun 1992 08:12:56 GMT

          From comp.compilers

Related articles
more on FOLLOW sets (1992-06-26)
Re: more on FOLLOW sets (1992-06-26)
| List of all articles for this month |

Newsgroups: comp.compilers
From: (Debora Weber-Wulff)
Organization: Free University of Berlin
Date: Fri, 26 Jun 1992 08:12:56 GMT
Keywords: LR(1), parse

I've been thinking a lot about follow sets since the recent posting (and
since I'm trying to build a parser generator myself :-) and I am puzzled
by a question. Just to recaptitulate (and to see if I have really
understood why follow sets are needed):

Let's say we have the following item set in the set of LR(0) items:

    Ii: A -> B.T
            A -> B. where A is a nonterminal, T a terminal, B either.

We could just happily reduce A -> B here and continue parsing. But the
construction of the follow set for A can give rise to the following - if T
is in the follow for A, then we have a shift-reduce conflict: we could
either shift the T, or reduce A -> B. So the grammar is not SLR(1), and we
either use other methods or fiddle with the grammar.

My question: Why bother? Why not define the action at this point to be the
reduction and ignore the shift possibility? What goes wrong? One objection
might be when the lookahead is neither in the follow of A nor equal to T,
we can generate an error here instead of at the next step, after reduction
and upon finding no shift that is defined. But this doesn't seem to be all
that important.

So those of you who are "in the know": why follow?
Debora Weber-Wulff
Institut fuer Informatik +49 30 89691 124
Nestorstr. 8-9
D-W-1000 Berlin 31

Post a followup to this message

Return to the comp.compilers page.
Search the comp.compilers archives again.