[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: |
Thu, 21 Sep 2006 07:05:07 -0400 |
User-agent: |
Mutt/1.5.11 |
On Thu, Sep 21, 2006 at 11:13:54AM +0000, Frans Englich wrote:
> On Saturday 16 September 2006 14:53, Bob Rossi wrote:
> > 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?
>
> How about using an enum? It would be a pity to use defines since they're
> evil,
> and there has been efforts to remove defines in favour of enums(yytokentype).
> Enums increases type safety.
Paul, what do you think of this idea? Either we could leave what you
installed last night, or we could make an enum that represents all the
return values yypushparse (and yyparse) could return, and have the user
compare the result to the enum.
Bob Rossi
- Re: push parser, (continued)
- 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, 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, Paul Eggert, 2006/09/29
- Re: push parser, Bob Rossi, 2006/09/29
Re: push parser, Frans Englich, 2006/09/21