From emoryu1!arnold Tue Dec 16 10:42:42 1986
Received: by mirror.TMC.COM (4.12/UUCP-Project/rel-1.0/08-20-86)
	id AA27208; Tue, 16 Dec 86 10:42:32 est
Received: by emoryu1.eu (5.51/5.6)
	id AA29446; Mon, 15 Dec 86 11:02:20 EST
Date: Mon, 15 Dec 86 11:02:20 EST
From: emoryu1!arnold (Arnold D. Robbins)
Message-Id: <8612151602.AA29446@emoryu1.eu>
To: ejp@ausmelb.oz
Subject: Re:  fyi (restarting yacc)
Cc: arnold, mirror!rs
Status: R

Mr. Pitt,
	Rich Salz forwarded me a copy of your note, apparently in the
spirit of technical correspondence where authors usually reply to questions
on their published works.

	You raise some very valid points which I will address below. However,
I should state that the posting was made with no surrounding context, largely
due to the backlog in mod.sources -- the yacc stuff was sent to Rich several
*months* ago. Had such context been available, many of your objections would
have been answered.

	A while back on mod.compilers there was a discussion about restarting
yacc; I volunteered to post the code that I had to do so, and to send it to
mod.sources, which is the appropriate place to post sources; the posting just
now made it out.

> Date: Fri, 12 Dec 86 11:22:56 est
> From: Esmond Pitt <ejp@ausmelb.OZ>
> To: mirror!sources-request
> Subject: Re: v07i086:  Tools to restart YACC parses
> 
> In article <770@mirror.TMC.COM> you write:
> >Submitted by: linus!gatech!emory!arnold (Arnold D. Robbins {EUCC})
> >Mod.sources: Volume 7, Issue 86
> >Archive-name: yacchacks
> >
> >
> >[  The tools here provide a way to restart YACC parses to handle
> >   conditional-compilation directives, include directives, and
> >   from error states.  Good luck.  The "kclose" routine herein
> >   can probably be more portable written with a dup()/fclose/fdopen
> >   set of calls.  --r$  ]
> >
> >Arnold Robbins
> >CSNET:	arnold@emory	BITNET:	arnold@emoryu1
> >ARPA:	arnold%emory.csnet@csnet-relay.arpa
> >UUCP:	{ akgua, decvax, gatech, sb1, sb6, sunatl }!emory!arnold

Note that nothing of any mail that I sent to Rich was actually published,
just his comments and my signature. That's probably ok, as I don't remember
verbatim what I had sent him.

> I am puzzled by this posting.
> Why on earth interrupt and restart a parser?
> It is all most unnecessary.
> 
> Compiler-writers without such baroque minds have the lexical analyser
				^^^^^^^
No real need to be insulting. See my reasons, below.

> recognize and process include directives and conditional-compilation directives,
> the latter by simply continuing to read through conditioned-out bits.
> There is no need to consult, interrupt or deceive the parser at all.

There is indeed at least one quite valid reason: a cross referencer. I wrote
a yacc-based cross referencer for a very extended version of Pascal that had
conditional compilation; clearly the use of an identifier inside both halves
of a conditional must be noted. In this case, the parse must be restarted
when the other half of the condtional is seen.

I agree that for a real compiler it should indeed be done by the lexer, and
the parser should never know about it.

> The only advantage of Robbins' scheme is that conditioned-out code
> still gets parsed, so any errors are reported.
> This is not stated anywhere in the posting,
> nor the consequence that each grammar action, or the rest of the compiler,
> needs to somehow ignore conditioned-out code.
> Nothing in the posting implements such a control.

Again, the original code was not part of a real compiler; it grew out of
a discussion in an entirely different newsgroup. All that was asked for
was a way to restart a yacc parser; the unspoken assumption is that a compiler
writer who is playing such a trick knows the consequences of what he's doing.
Your point is valid; but I never claimed to be providing tools to do a whole
job, just a certain, *specialized* piece of code.

> [ further discussion of the consequences if not done right ]
> 
> Robbins also does not sufficiently indicate the control syntax which
> is implemented by his scheme.

Sorry; the syntax is in the lex code if you study it. It was:

{$ifc <conditon> then}
	<pascal code>
[ {$else}
	<pascal code> ]		(* else part optional, of course *)
{$endc}

> The whole thing is most unimpressive.
> I thought moderators were supposed to moderate.

Again, really no need to be insulting; it is just a posting that was
out of context and not a complete tool. I am sorry you weren't impressed,
but I post source code to help out others who may find it useful, not
to impress people with my wizardliness (or possible lack thereof).

> Esmond Pitt,				ACSnet: ejp@ausmelb.oz
> Austec International Ltd,		UUCP: ...!seismo!munnari!ausmelb.oz!ejp
> 344 St Kilda Rd,			ARPA: ejp%ausmelb.oz@SEISMO.CSS.GOV
> Melbourne, 3004, AUSTRALIA.		Phone: +61 3 699 4511; Telex: AA38559

Arnold Robbins
Emory University Computing Center
UUCP:	seismo!akgua!emoryu1!arnold
ARPA:	arnold%emoryu1@relay.cs.net
Phone:	+1 404 727 4785

