[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: push parser implemenation
From: |
Paul Eggert |
Subject: |
Re: push parser implemenation |
Date: |
Thu, 07 Sep 2006 10:44:10 -0700 |
User-agent: |
Gnus/5.1008 (Gnus v5.10.8) Emacs/21.4 (gnu/linux) |
Bob Rossi <address@hidden> writes:
> Here is what the user will do in push-parser mode:
> struct yypvars *ctx = yypvarsinit ();
> do {
> set_yychar (ctx, yylex ());
> ctx->yylval = yylval;
> yyparse (ctx);
> } while (get_yyresult (ctx) != 0);
> free (ctx);
There may be some minor namespace issues here: in C, all symbols the
parser exports should start with yy or YY.
I don't quite follow this part:
> set_yychar (ctx, yylex ());
> ctx->yylval = yylval;
Why use one method to set yychar, and the other to set yylval?
Shouldn't the same method be used to set both?
> 1. I've Added the %push-parser option
> push.c works in both push and pull mode. If you set the %push-parser
> option, it will work in push mode, otherwise pull mode.
Is it easy to switch between push and pull mode at runtime? If so,
it should be a runtime switch. (If not, then not. :-)
> It was mentioned that the pull parser could be implemented be
> using the push mode. Should I do this?
Sorry, I don't know the technical issues here. Would it slow down
pull parsing to implement it in the push context? Would it change
the documented (or undocumented :-) API?
> 2. struct yypvars and yypvarsinit
> Adding the struct yypvars that contains all the data needed to do the
> parse. yypvarsinit is a user visible function that inits the struct.
> Should I add a yypvarsdestroy? or just let the user do a free ()?
Is there any reason a destroy op might want to do anything other than
a simple free any time in the foreseeable future? If not, then free
is fine.
Is there any reason struct yypvars should be opaque?
> 3. yychar, yylval, yynerrs, and yylloc (external parser variables)
> These variables remain external in the default parser. However, in
> the pure and push parser they go in the struct yypvars. So, I'm
> currently making accessor functions to access them. I currently only
> have:
> int get_yyresult (void *PVVOID);
> void set_yychar (void *PVVOID, int yychar);
> because they are the only 2 I need. However, should I just generate
> all 4 pairs of set/get functions for yychar, yylval, yynerrs, and
> yylloc?
I'd just generate the ones you need for now. However, their names
should start with yy to avoid namespace collision.
> 5. Test suite.
> What should I do to modify the test suite?
It'd be nice if we could try several tests in both push and pull mode.
> 6. Documentation
> New chapter?
You've saved the hardest part for last. :-)
I don't think it should be a new chapter; the text needs to be
interspersed when needed. You can start looking for areas by seeing
where the existing documentation talks about pure parsers.
- Re: push parser implemenation, Bob Rossi, 2006/09/07
- Re: push parser implemenation,
Paul Eggert <=
- Re: push parser implemenation, Bob Rossi, 2006/09/07
- Re: push parser implemenation, Paul Eggert, 2006/09/07
- Re: push parser implemenation, Bob Rossi, 2006/09/07
- Re: push parser implemenation, Paul Eggert, 2006/09/08
- Re: push parser implemenation, Bob Rossi, 2006/09/08
- Re: push parser implemenation, Paul Eggert, 2006/09/08
- Re: push parser implemenation, Bob Rossi, 2006/09/11
- Re: push parser implemenation, Paul Eggert, 2006/09/11
- Re: push parser implemenation, Bob Rossi, 2006/09/11
- Re: push parser implemenation, Paul Eggert, 2006/09/11