bison-patches
[Top][All Lists]
Advanced

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

Re: push parser


From: Paul Eggert
Subject: Re: push parser
Date: Wed, 27 Sep 2006 09:50:46 -0700
User-agent: Gnus/5.1008 (Gnus v5.10.8) Emacs/21.4 (gnu/linux)

Bob Rossi <address@hidden> writes:

> How is the interface coming along? Do you see any other
> modifications that should take place?

Sorry, I'm not sure what you mean here.  The interface is improving,
yes.

> {
>   struct yypvars *ctx = yypvarsinit ();
>   int status, ch;
>   do {
>     ch = yylex ();
>     status = yypushparse (ctx, ch, &yylval, &yylloc);
>   } while (status == YYPUSH_MORE);
>   free (ctx);
>   return status;
> }
>
> One potential problem that I can think of is that the push parser still 
> allows the user to use the global variables yylval and yylloc.

It doesn't _require_ that, does it?  It merely _allows_ it.  One could
use code like this instead:

 {
   struct yypvars *ctx = yypvarsinit ();
   YYSTYPE my_lval;
   YYLTYPE my_lloc;
   int status, ch;
   do {
     ch = my_lex (&my_lval, &my_lloc);
     status = yypushparse (ctx, ch, &my_lval, &my_lloc);
   } while (status == YYPUSH_MORE);
   free (ctx);
   return status;
 }

This would be more reentrant, etc.  We should use it as an example,
rather than the nonreentrant version.

> The push parser also has it's own version of these variables in the
> yypvars struct. I don't know if it's a good thing or a bad thing
> that we still use the global variables. At a minimum, it will allow
> users to not have to modify there lexers. What do you think?

I didn't remember that the push parser has its own copy.  If the push
parser must have its own version of these variables *ctx, perhaps we
should make them visible to the user.  E.g.,

 {
   struct yypvars *ctx = yypvarsinit ();
   YYSTYPE *my_lval = yypv_lval (ctx);
   YYLTYPE *my_loc = yypv_loc (ctx);
   int status;
   do {
     status = yypushparse (ctx, my_lex (my_lval, my_loc));
   } while (status == YYPUSH_MORE);
   free (ctx);
   return status;
 }

or even this, assuming the lexer is changed to use yypv_lval,
yypv_loc:

 {
   struct yypvars *ctx = yypvarsinit ();
   int status;
   do
     status = yypushparse (ctx, my_lex (ctx));
   while (status == YYPUSH_MORE);
   free (ctx);
   return status;
 }

> The push parser should also work under multiple contexts (ie
> aapushparse, bbpushparse). Can you think of a reason it currently
> wouldn't?

I don't see offhand, no.




reply via email to

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