Mail Archives: djgpp/1997/06/05/22:22:18
Assigning some valid descriptor to yyin will help. For example:
yyin = stdin;
for reading from standard input
or
if ((yyin = fopen("infile", "r")) == NULL)
return -1;
for reading from the file "infile".
> -----Original Message-----
> From: Tron Thomas [SMTP:tron DOT thomas AT sierra DOT com]
> Sent: Thursday, June 05, 1997 8:07 PM
> To: djgpp AT delorie DOT com
> Subject: Can't get YACC parser to run
>
> I reading the book "Lex and Yacc" by John R. Levine, Tonay Mason, and
> Doug Brown. I am using Flex version 2.5.3 and Bison version 1.25 for
> MS-DOS to run their examples, and I'm compiling the programs using
> Visual C++ 4.2 on Windows '95.
>
> 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,
> the program crashes. This is because the main function in the file
> ch1-05.y is defined as follows:
>
> extern FILE *yyin;
>
> main( )
> {
> 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?
- Raw text -