[Top][All Lists]

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

Re: push parser

From: Bob Rossi
Subject: Re: push parser
Date: Fri, 29 Sep 2006 10:57:15 -0400
User-agent: Mutt/1.5.11

On Fri, Sep 29, 2006 at 09:42:37AM -0400, Bob Rossi wrote:
> On Wed, Sep 27, 2006 at 04:30:43PM -0700, Paul Eggert wrote:
> > Bob Rossi <address@hidden> writes:
> > 
> > > There are no need for global variables, you are correct. The patch I
> > > originally made simply did not do away with the 4 global variables that
> > > the user traditionally used. I was a afraid this would break backwards
> > > compatibility for many users.
> > 
> > OK, but we shouldn't need to worry about doing away with global
> > variables in push parsers, since they're supposed to be pure.  We need
> > to keep globals only for traditional, impure parsers.
> OK, agreed. There are 4 globals of interest. 
>   int yychar;
>   YYSTYPE yylval;
>   int yynerrs;
>   YYLTYPE yylloc;
> I know what to do with yylval and yylloc. That's because we have the
> user declare them and pass them into the parser. I also know what to
> do with yychar, because the user also passes that data into the parser.
> What should I do with yynerrs?

Still wondering what to do with yynerrs. I simply made it a local
variable for now, and do not have the user pass it in. What do you think
of this patch for the other 3 variables?

One issue I had is, now the yyparse function (which calls yypushparse) 
depends on yylex to take 2 parameters. This breaks the small test I have
that is not in the test suite because my yylex takes nothing. Should we
force the user to have yylex take these parameters? or should we somehow
modify yyparse ()?

Now that I have run into this problem, I see this would have been a
problem in the reverse direction also. That is, it currently calls
yylex() and the user could have a different parameter profile for there
yylex ().

Bob Rossi

2006-09-29  Bob Rossi  <address@hidden>

        * data/push.c (yychar_set, yylval_set, yylloc_set): Delete.
        (yypushparse): Add yynchar, yynlval, yynlloc parameters.
        (struct yypvars): Remove b4_declare_parser_variables.
        (yypvarsinit): Remove init code for removed variables.
        (global scope): Do not declare b4_declare_parser_variables if
        push or pure mode.
        (yypushparse): Add b4_declare_parser_variables.
        Init new local variables, and remove init code for removed
        yypvars variables.
        (yyparse): Add local variables to pass to yypushparse.
        * tests/ (AT_PURE_IF): Rename to AT_PURE_OR_PUSH_IF and
        modify accordingly.
        (AT_PURE_AND_LOC_IF): Rename to AT_PURE_OR_PUSH_AND_LOC_IF and
        modify accordingly.

Attachment: push.c.diff
Description: Text document

reply via email to

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