Mail Archives: djgpp/1997/06/06/09:47:48

Date: Fri, 6 Jun 1997 09:43:31 -0400 (EDT)
From: "Art S. Kagel" <kagel AT ns1 DOT bloomberg DOT com>
To: Tron Thomas <tron DOT thomas AT sierra DOT com>
Cc: djgpp AT delorie DOT com
Subject: Re: Can't get YACC parser to run
In-Reply-To: <>
Message-Id: <Pine.D-G.3.91.970606093947.12912D-100000@dg1>
Mime-Version: 1.0

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 )
  int main( int argc, char **argv )

> {

You need to initialize yyin to some file either:
        yyin = stdin;
        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

- Raw text -

  webmaster     delorie software   privacy  
  Copyright 2019   by DJ Delorie     Updated Jul 2019