[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: |
Mon, 18 Sep 2006 09:30:52 -0400 |
User-agent: |
Mutt/1.5.11 |
On Sat, Sep 16, 2006 at 04:03:35PM -0700, Paul Eggert wrote:
> Bob Rossi <address@hidden> writes:
>
> > Hi,
> >
> > The user interface to the push parser currently looks like this:
> >
> > int
> > yyparse (void)
> > {
> > struct yypvars *ctx = yypvarsinit ();
> > int status;
> > do {
> > yychar_set (ctx, yylex ());
> > yylval_set (ctx, yylval);
> > #ifdef YYLTYPE_IS_TRIVIAL
> > yylloc_set (ctx, yylloc);
> > #endif
> > yypushparse (ctx);
> > status = yyresult_get (ctx);
> > } while (status == 4);
> > free (ctx);
> > return status;
> > }
> >
> > In particular, I don't like this line:
> > } while (status == 4);
> >
> > The number 4 should be put in either a #define, or a function call.
> > Which one is preferable? The #define would probably be more efficient.
> > If so, what would be a good name?
>
> I'm not quite sure what 4 means, but how about YYPUSH_MORE? It could
> be defined in the equivalent of y.tab.h.
OK, I will do this.
> Why the #ifdef on YYLTYPE_IS_TRIVIAL? YYLTYPE_IS_TRIVIAL tells
> us whether yyltype is trivial (i.e., does not need attention by
> C++ storage managers), not whether it exists.
OK, I need to determine if YYLTYPE is exists. What's the best way
to do that?
> Looking at the interface, it strikes me that perhaps we could
> simplify it a bit. How about something like this?
>
> int
> yyparse (void)
> {
> struct yypvars *ctx = yypvarsinit ();
> int status;
> do {
> int ch = yylex ();
> status = yypushparse (ctx, ch, yylval, yylloc);
> } while (status == YYPUSH_MORE);
> free (ctx);
> return status;
> }
>
> where you omit the ", yylloc" if you are not using locations.
Well, I like that you are having yypushparse return the same value that
yyparse would have returned. I'll make that change also. With that
change, we no longer need yystatus_get ().
I'm not sure that I like passing all the values into yypushparse though.
The problem is, not everyone wants to pass all the values in. We would
force them to pass values in that they don't care about which could
be confusing. What do you think?
Bob Rossi
- push parser, Bob Rossi, 2006/09/16
- Re: push parser, Paul Eggert, 2006/09/16
- Re: push parser,
Bob Rossi <=
- Re: push parser, Paul Eggert, 2006/09/18
- Re: push parser, Bob Rossi, 2006/09/20
- Re: push parser, Paul Eggert, 2006/09/21
- Re: push parser, Bob Rossi, 2006/09/21
- Re: push parser, Bob Rossi, 2006/09/25
- Re: push parser, Bob Rossi, 2006/09/25
- Re: push parser, Paul Eggert, 2006/09/26
- Re: push parser, Bob Rossi, 2006/09/26
- Re: push parser, Paul Eggert, 2006/09/26
- Re: push parser, Bob Rossi, 2006/09/27