Computing FIRST(X) for a left recursive grammar

muzzetta@videobank.it (Alessandro Muzzetta)
6 Mar 2000 00:32:26 -0500

          From comp.compilers

Related articles
Computing FIRST(X) for a left recursive grammar muzzetta@videobank.it (2000-03-06)
Re: Computing FIRST(X) for a left recursive grammar vugluskr@unicorn.math.spbu.ru (2000-03-06)
Re: Computing FIRST(X) for a left recursive grammar torbenm@diku.dk (2000-03-06)
Re: Computing FIRST(X) for a left recursive grammar joachim.durchholz@halstenbach.com.or.de (Joachim Durchholz) (2000-03-06)
Re: Computing FIRST(X) for a left recursive grammar rsherry@home.com (Robert Sherry) (2000-03-07)
Re: Computing FIRST(X) for a left recursive grammar johnmce@texas.net (2000-03-07)
| List of all articles for this month |

From: muzzetta@videobank.it (Alessandro Muzzetta)
Newsgroups: comp.compilers
Date: 6 Mar 2000 00:32:26 -0500
Organization: Compilers Central
Keywords: LALR

Hello,


can some kind soul please answer this silly question of mine...


Assuming you have the following yacc rules


list: /* empty */
| list NEWLINE
| list expr NEWLINE
;
expr: ...
;


How do I calculate FIRST(list) for this left recursive grammar? I'm
working on an SLR parser generator, and I don't know how to handle
this case. What should FIRST(list) contain besides the empty string?
FIRST(NEWLINE) and FIRST(expr)??? Wouldn't that be the follow set of
list?


Another question: what are suitable data structures for representing
sets of arbitrary strings denoting the first/follow set of a symbol?
Fast insertions are necessary.


Thanks


Post a followup to this message

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