[comp.lang.c] K&R II YACC grammar

scs@adam.pika.mit.edu (Steve Summit) (07/02/89)

In article <UYbhqrq00Vsn43xmA3@andrew.cmu.edu> bobg+@andrew.cmu.edu (Robert Steven Glickstein) writes:
>I've written a parser for ANSI-C using YACC (adhering strictly to the
>grammar given in K&R, second edition) that doesn't work.  Despite the
>claim in section A13 that "this grammar is acceptable to the YACC
>parser-generator"...

Is anyone else worried about the ethical question here?  Section
A13 really seems to encourage you to type it in, feed it to YACC,
and use it in your compiler ("This grammar can be transformed
mechanically into input acceptable to an automatic parser-
generator.") yet the copyright page contains the usual "No part
of this publication may be... stored in a retrieval system... in
any form or by any means..." etc.  (No criticism of Robert; I'm
sure many others have done the same.)  Any comments?

                                            Steve Summit
                                            scs@adam.pika.mit.edu

shankar@hpclscu.HP.COM (Shankar Unni) (07/06/89)

> Is anyone else worried about the ethical question here?  Section
> A13 really seems to encourage you to type it in, feed it to YACC,
> and use it in your compiler ("This grammar can be transformed
> mechanically into input acceptable to an automatic parser-
> generator.") yet the copyright page contains the usual "No part
> of this publication may be... stored in a retrieval system... in
> any form or by any means..." etc.  (No criticism of Robert; I'm
> sure many others have done the same.)  Any comments?

No, I don't see this as an ethical problem.  This is where we draw the
distinction between "an idea" and "the expression of an idea". In my
opinion, a YACC grammar leans more towards an idea, rather than an
expression thereof (after all, a grammar is not just a matter of opinion).

If you feel uncomfortable with this, I'm sure you can type it in and then
inside vi, do ":%s/\<\([a-zA-Z]\)/my_&/g".
-----
Shankar.

diamond@diamond.csl.sony.junet (Norman Diamond) (07/08/89)

Some bright person asked:

-> Is anyone else worried about the ethical question here?  Section
-> A13 really seems to encourage you to type it in, feed it to YACC,
-> and use it in your compiler ("This grammar can be transformed
-> mechanically into input acceptable to an automatic parser-
-> generator.") yet the copyright page contains the usual "No part
-> of this publication may be... stored in a retrieval system... in
-> any form or by any means..." etc.  (No criticism of Robert; I'm
-> sure many others have done the same.)  Any comments?

In article <660041@hpclscu.HP.COM> shankar@hpclscu.HP.COM (Shankar Unni) writes:

>No, I don't see this as an ethical problem.  This is where we draw the
>distinction between "an idea" and "the expression of an idea". In my
>opinion, a YACC grammar leans more towards an idea, rather than an
>expression thereof (after all, a grammar is not just a matter of opinion).

In fact a grammar is an expression of an idea.  A language is an idea.
Given a language, there are an infinite number of grammars generating
the language (assuming that the language is of Type 0 or better).
Some grammars are better than others.  Books generally give grammars
that are reasonably clear intuitively, to provide information in an
unambiguous manner, but these grammars are not especially good for
implementations (too slow, etc.).  So the book here really should have
allowed the grammar in A13 to be typed in and used, because it assists
in teaching the reader.  Write to the authors and ask for permission.
Maybe they'll give their grammar to the public domain.

--
Norman Diamond, Sony Computer Science Lab (diamond%csl.sony.jp@relay.cs.net)
 The above opinions are claimed by your machine's init process (pid 1), after
 being disowned and orphaned.  However, if you see this at Waterloo, Stanford,
 or Anterior, then their administrators must have approved of these opinions.