[comp.compilers] yacc first and follow set generator wanted

slv@seg.npl.co.uk (S Voogd) (11/09/90)

'allo, 'allo,

I require a program that, given the syntax of a language written in YACC,
will give a list of all tokens that can appear immediately to the right of
some given non_terminal and a list of all tokens that can appear as the
first token of that non-terminal. (The so-called FIRST and FOLLOW sets)

Maybe it is possible to derive those sets from YACC (YACC uses those sets
to fill the parse-table) but I could not find anything about it in the
manual or other books (e.g. Aho, Sethi, Ullman).

Maybe FIRST and FOLLOW sets are called otherwise elsewhere therefore I'll
explain what I mean with it.

Given the following grammar:

A :  B  'c'  D;
B : 'e' 'f'
  | 'g' 'h';
C :  B  'i';
 
The First set of A is First(A) = First(B) = {'e', 'g'}
The FOLLOW set of B is Follow(B) = {'c', 'i'}


			Many thanx in advance
			       SIMON

please send replies to : slv@seg.npl.co.uk
			 S. L. Voogd
			 NPL London UK
			 +81 - 943 7009
				   6994
[I'd think one would be able to extract the info from the y.output listing,
or else directly from the generated parse tables. -John]
-- 
Send compilers articles to compilers@iecc.cambridge.ma.us or
{ima | spdcc | world}!esegue!compilers.  Meta-mail to compilers-request.