[net.lang.c] LALR

stephen@datacube.UUCP (10/21/85)

[out, out damned line!]

I have recently been engaged in implementing a yacc grammar based
on the one provided in Harbison and Steele's _C: A Reference Manual_ and
have encountered a bug. On page 337 the following productions have been
provided:

<key_dcltr> ::= <identifier>
...
<0008> ::= <key_dcltr>
<0008> ::= <key_dcltr> , <key_dcltr>
...

Neither <key_dcltr> nor <0008> are otherwise referenced in the grammar.

If anyone has solved this bug, or if it has been fixed in subsequent
editions, could they please post it to the net?

Thanks,

Stephen Watkins                    UUCP: ihnp4!datacube!stephen
Datacube Inc.; 4 Dearborn Rd.; Peabody, Ma. 01960; 617-535-6644

gwyn@BRL.ARPA (VLD/VMB) (10/23/85)

In the Harbison & Steele LALR(1) C grammar, delete
	<key_dcltr> ::= <identifier>
and
	<0008> ::= <key_dcltr>
	<0008> ::= <0008> , <key_dcltr>

On the same page change all occurrences of
	<enum_ctype>
to
	<enum_type>

On the preceding page change one occurrence of
	<struct_ctype>
to
	<struct_type>
and change three occurrences of
	<union_ctype>
to
	<union_type>

Be aware that this grammar is for an obsolete
definition of C.

roger@ll-sst (Roger Hale) (10/23/85)

[From: datacube!stephen; Date: 21 Oct 85 15:12:00 GMT]
> I have recently been engaged in implementing a yacc grammar based
> on the one provided in Harbison and Steele's _C: A Reference Manual_ and
> have encountered a bug. On page 337 the following productions have been
> provided:
> 
> <key_dcltr> ::= <identifier>
> ...
> <0008> ::= <key_dcltr>
> <0008> ::= <key_dcltr> , <key_dcltr>
> ...
> 
> Neither <key_dcltr> nor <0008> are otherwise referenced in the grammar.

I saw these orphans a while ago, too; here's what they suggest to me:

[enter just so story]

The line
	<p2_dcltr> ::= <p2_dcltr> ( <formals_declaration> )
used to have <keys_dcltr> (or some such name) in place of <formals_declaration>,
and a line group

	<keys_dcltr> ::=
	<keys_dcltr> ::= <0008>
followed the group defining <0008>.  [This being the output of their parser
generator.]  This gives function declarators like
	main(argc, argv) .
To accommodate the new style
	main(int argc, char **argv)
<formals_declaration> was defined and plugged into <p2_dcltr>, and <keys_dcltr>
was garbage collected, but not <0008> or <key_dcltr> (perhaps because <0008>
refers to itself).

[leave just so story]

FIX:	Just flush <key_dcltr> and <0008>.

Anyway, that's my opinion, just going by the text in front of me.
[Standard cover-everything disclaimer]
Flames to me, not the net; I'll warm up some chicken soup with them
if they're nice and toasty.

Yours,			Roger Hale
		Arpa:	roger@ll-sst.arpa
		Uucp:	{ucbvax,...}!roger%ll-sst.arpa might work

unilog@g.cs.cmu.edu (Unilogic) (10/24/85)

I can't remember where I saw them, but I have a bunch of corrections to the
grammar in Harbison and Steele.

	1. page 336: change occurrances of <struct_ctype> and <union_ctype>
		     to <struct_type> and <union_type>
	2. page 337: eliminate the production <key_dcltr> and both productions
		     <0008>
	3. page 341: change
			<cast_exp> ::= ( <typename_declaration> ) <prefix_exp>
		     to
			<cast_exp> ::= ( <typename_declaration> ) <cast_exp>

And that's all.  I've never tested the fixes and take no responsibility for
their accuracy.

						David Gentzel
----------------
ARPA:	unilog@cmu-cs-g
UUCP:	seismo!cmu-cs-g!unilog

richw@ada-uts.UUCP (10/31/85)

Someone mentioned that the Harbison & Steele grammar is for an
"obsolete" version of C.  Can anyone tell me where I can get
THE grammar?

Thanks,
Rich Wagner

guy@sun.uucp (Guy Harris) (11/11/85)

> Someone mentioned that the Harbison & Steele grammar is for an
> "obsolete" version of C.  Can anyone tell me where I can get
> THE grammar?

If the person in question (I think it was Doug Gwyn) meant that H&S's
grammar wasn't for ANSI C, he was jumping the gun.  The ANSI C standard
hasn't even been distributed for comment yet; I suspect it's called
something like a "draft proposed standard", meaning it's only a proposed
standard, and only a draft for one at that.  Wait until the final ANSI
standard comes out, and there'll be plenty of grammars available.

	Guy Harris

lcc.rich-wiz@locus.ucla.edu (Richard Mathews) (11/16/85)

> I suspect it's called something like a "draft proposed standard",
> meaning it's only a proposed standard, and only a draft for one at
> that.

>        Guy Harris

Actually, it is worse than that.  It is called a "PRELIMINARY draft
proposed" standard.  (quoted from the April 30th draft, section A.1,
emphasis theirs)

Richard M. Mathews
Locus Computing Corporation                    lcc.richard@LOCUS.UCLA.EDU
					       lcc.richard@UCLA-CS
			  {ihnp4,ucivax,trwrb}!lcc!richard
       {randvax,sdcrdcf,ucbvax,trwspp}!ucla-cs!lcc!richard