Date: Fri, 6 Jun 1997 09:43:31 -0400 (EDT) From: "Art S. Kagel" To: Tron Thomas Cc: djgpp AT delorie DOT com Subject: Re: Can't get YACC parser to run In-Reply-To: <33970040.7AF0@sierra.com> Message-Id: Mime-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Precedence: bulk On Thu, 5 Jun 1997, Tron Thomas wrote: > I reading the book "Lex and Yacc" by John R. Levine, Tonay Mason, and > > I created the program in example 1-7 (a Yacc Parser) of chapter one, but > I'm not sure how I'm supposed to run it. When I just try to launch it, > extern FILE *yyin; > > main( ) Oh no another BAD example from some book! The function main() MUST ALWAYS return an int and if you do not use the standard argument list you should declare the list void. Hence either: int main( void ) OR int main( int argc, char **argv ) > { You need to initialize yyin to some file either: yyin = stdin; or: yyin = fopen( "mytestfile", "r" ); BTW you need to include stdio.h and should also include stdlib.h. > while(!feof(yyin)){ > yyparse( ); > } > } > > When I trace through this code yyin = 0 causing the program to crash on > the call to feof. > > Can somebody tell me what I need to do to get this program to run? > Art S. Kagel, kagel AT bloomberg DOT com