[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 09:42:37 -0400 |
User-agent: |
Mutt/1.5.11 |
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?
> >> {
> >> struct yypvars *ctx = yypvarsinit ();
> >> int status;
> >> do {
> >> YYTOKTYPE token_info;
> >> status = yypushparse (ctx, my_lex (&token_info), &token_info);
> >> } while (status == YYPUSH_MORE);
> >> free (ctx);
> >> return status;
> >> }
> >
> > Be careful with the above examples, function parameters can be
> > evaluated in either direction, and in the case above, if the compiler
> > evaluates right to left, you will get undesired results.
>
> No, there's no problem here, since the example passes token_info's
> address to yypushparse, not its value.
Oops. I thought I had one up on you :).
Thanks,
Bob Rossi
- Re: push parser, (continued)
- Re: push parser, Bob Rossi, 2006/09/27
- Re: push parser, Paul Eggert, 2006/09/27
- Re: push parser, Bob Rossi, 2006/09/27
- Re: push parser, Paul Eggert, 2006/09/27
- Re: push parser, Bob Rossi, 2006/09/27
- Re: push parser, Paul Eggert, 2006/09/28
- Re: push parser,
Bob Rossi <=
- Re: push parser, Bob Rossi, 2006/09/29
- Re: push parser, Paul Eggert, 2006/09/29
- Re: push parser, Bob Rossi, 2006/09/29
- Re: push parser, Paul Eggert, 2006/09/29
- Re: push parser, Bob Rossi, 2006/09/29
Re: push parser, Frans Englich, 2006/09/21