Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!watmath!clyde!burl!ulysses!cbosgd!ihnp4!ima!johnl From: johnl@ima.UUCP (Compilers mailing list) Newsgroups: mod.compilers Subject: Re: incremental compilers (restarting yacc) Message-ID: <144@ima.UUCP> Date: Tue, 1-Jul-86 10:49:46 EDT Article-I.D.: ima.144 Posted: Tue Jul 1 10:49:46 1986 Date-Received: Thu, 3-Jul-86 00:22:33 EDT References: <139@ima.UUCP> Reply-To: harvard!seismo!gatech!emory!arnold (Arnold D. Robbins {EUCC}) Organization: Math & Computer Science, Emory University, Atlanta Lines: 34 Approved: Posted-Date: Mon, 30 Jun 86 16:28:30 edt >[I have seen some papers on things like tricking yacc into restarting a parse, >but little formal stuff on issues like symbol tables for incremental compilers. >-John] Getting Yacc to restart a parse is not terribly hard. I did it a few years ago, this way (to produce a Pascal cross referencer for a pascal that had conditional compilation): First, run yacc on the grammar to produce the y.tab.c file. Next, some of the variables internal to the yyparse() routine have to be made external. I did this with an ed script via the makefile. Then, the scanner, when it sees the (equivalent of) #ifdef, saves those particular variables on a stack. At a #else (if there is one), it restores the variables. On seeing the #endif, it pops the stack. This handles nested conditionals quite nicely. (I think I described it right... it has to be over three years ago that I did this). If there is enough mail coming in to me, I guess I'll dig up the relevant code and post it. It was a wonderful kludge, but it worked. (Of course, I had help from an LALR wizard to tell me which yacc variables needed to be saved, I'm not that much of a grammar/parser jock to know.) -- Arnold Robbins CSNET: arnold@emory BITNET: arnold@emoryu1 ARPA: arnold%emory.csnet@csnet-relay.arpa UUCP: { akgua, decvax, gatech, sb1, sb6, sunatl }!emory!arnold "All this digital stuff is just a fad. Analog is the way to go." -- William M. Robbins, 1984 -- Send compilers mail to ima!compilers or, in a pinch to Levine@YALE.EDU Plausible paths are { ihnp4 | decvax | cbosgd | harvard | yale | bbncca}!ima Please send responses to the originator of the message -- I cannot forward mail accidentally sent back to compilers. Meta-mail to ima!compilers-request