Saving/restoring bison parse state

tim@wagner.Princeton.EDU (Tim Hollebeek)
14 Oct 1997 00:37:36 -0400

          From comp.compilers

Related articles
Saving/restoring bison parse state tim@wagner.Princeton.EDU (1997-10-14)
Re: Saving/restoring bison parse state (1997-10-26)
Saving/restoring bison parse state ssome@csi.UOttawa.CA (Stephane Some) (1997-10-29)
| List of all articles for this month |

From: tim@wagner.Princeton.EDU (Tim Hollebeek)
Newsgroups: comp.compilers
Date: 14 Oct 1997 00:37:36 -0400
Organization: Chemistry Department, Princeton University
Keywords: yacc, question, comment

I'm writing a C documentation tool based on a bison grammar for C. One of
the things I want to do is handle BOTH blocks of #ifdef/#else/#endif

I have the practical aspects down as far as my program is concerned, so
I just need to get bison to cooperate. I.e.:

/* some C code */
/***** save all bison state info here *****/
#ifdef FOO
/* branch 1 */
/***** restore bison state info here *****/
/* branch 2 */

Has anyone tried something like this before? A quick look at the bison
output suggests it should work fine if I simply save the globals in the
YYPURE ifdef, as well as all the local variables in yyparse (probably using
a hacked version of bison.simple).

Are there any disadvantages to this approach I have missed? Any better
ways of accomplishing the same thing?

Tim Hollebeek
[There was discussion a year or so ago about backtracking versions of yacc.
The grammar of C++ is so awful that you need them to parse C++ reasonably.

Post a followup to this message

Return to the comp.compilers page.
Search the comp.compilers archives again.