bison-patches
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: push parser implemenation


From: Bob Rossi
Subject: Re: push parser implemenation
Date: Sun, 2 Apr 2006 09:11:01 -0400
User-agent: Mutt/1.5.9i

> Here is what the interface looks like from the user's perspective
> 
> int
> main (void)
> {
>   void *ctx = yypvarsinit ();
>   FILE *fp;
>   int val = 1;
>   fp= fopen("1.dat", "r");
>   yyparse (ctx);
>   do {
>     if(val != 0)
>      set_yychar (ctx, yylex(fp));
>     yyparse(ctx);
>     val = get_yyresult (ctx);
>     if(val == 1)
>       fprintf(stderr,"\nSyntax error");
>   } while (val!=0);
>   fclose(fp);
> 
>   fprintf(stderr, "\n");
>   return 0;
> }
> 
> It's important to realize that yyparse needs to be called once to init
> the parser. 

Hmm, I think this isn't necessary. I just thought it was. The yyparse
(ctx) call is not necessary before the 'do {' line.

Bob Rossi




reply via email to

[Prev in Thread] Current Thread [Next in Thread]