|more on FOLLOW sets firstname.lastname@example.org (1992-06-26)|
|Re: more on FOLLOW sets email@example.com (1992-06-26)|
|From:||firstname.lastname@example.org (Debora Weber-Wulff)|
|Organization:||Free University of Berlin|
|Date:||Fri, 26 Jun 1992 08:12:56 GMT|
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
So those of you who are "in the know": why follow?
Debora Weber-Wulff email@example.com
Institut fuer Informatik +49 30 89691 124
D-W-1000 Berlin 31
Return to the
Search the comp.compilers archives again.