From: Andrew Crabtree Message-Id: <199706061555.AA006622503@typhoon.rose.hp.com> Subject: Re: Can't get YACC parser to run To: tron DOT thomas AT sierra DOT com (Tron Thomas) Date: Fri, 06 Jun 1997 8:55:03 PDT Cc: djgpp AT delorie DOT com In-Reply-To: <33970040.7AF0@sierra.com>; from "Tron Thomas" at Jun 05, 97 11:06 am Precedence: bulk > I created the program in example 1-7 (a Yacc Parser) of chapter one, but That example is just bad. > main( ) > { > while(!feof(yyin)){ Normally, if you don't do anything else, yyin will be initialized to be stdin. This happens in the yylex function lex.yy.c YY_DECL prototype if (!yyin) yyin = stdin; which won't get called until you are in yyparse. So, you can just manually assign yyin=stdin first thing in main. I would probably be better though, to change to grammar file so that it accepts an infinite number of sentences, and then write a special rule for eof. sentence_list : sentence | sentence_list sentence sentence : subject VERB object Then maybe add a <> {return 0} in lex. Now you can just call yyparse directly in main. int main() { yyparse(); return 0; } HTH Andrew