On Mon, 2 Jul 2007, Bob Rossi wrote: > OK. I don't even know what push-pull-parser does. When I submitted the > patch, I only had support for push-parser and pure-parser didn't effect > it at all. You did some improvements to the patch, and we ended up > with push-pull-parser as well. My question is, is push-parser still > the same idea as what I committed? If so, what is push-pull-parser? > > With out knowing what it is, the name seems odd to me. You can have a > push parser, and you can have a pull parser, but what's a > push-pull-parser? :)
It's both. %push-parser defines yypush_parse. When combined with %pure-parser, it's close to your original form. %push-pull-parser adds yypull_parse, which is a wrapper around yypush_parse that invokes yylex in a loop. For example, one can yypush_parse tokens to select a subgrammar and then yypull_parse the rest of the input stream. %push-pull-parser also defines yyparse, which is a wrapper around yypull_parse. This yyparse has the same interface as the yyparse generated when neither %push-* directive is specified. yypull_parse and yyparse are not defined for %push-parser because that would require the user to define yylex even when he doesn't want to. To see some of these interfaces, you might try generating a few example parsers. It's probably easiest to look at the generated header file. Again, the following seems more intuitive to me now: %define push_pull "pull" // default %define push_pull "push" %define push_pull "both" > > You can use %pure-parser in combination with either %push-parser or > > %push-pull-parser. > > OK, I remember this. What was the benefit of providing this > functionality to the user? How would I describe the tradeoffs to the > user in the manual? My original patch only provided the pure version. The impure version is for compatibility with non-push mode. That is, when %push-pull-parser is declared, regardless of whether %pure-parser is declared, the yyparse and yylex interfaces are the same as when neither %push-* directive is declared. I found this very helpful so I could reuse existing tests in the test suite. I'm guessing some users might find it helpful as well when evolving old code. In general, I like the consistency. Nevertheless, as with non-push mode, the user should probably be encouraged to use the pure version for new parsers. _______________________________________________ [email protected] http://lists.gnu.org/mailman/listinfo/help-bison
