Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!ames!lll-lcc!lll-winken!uunet!kddlab!titcca!sragwa!wsgw!socslgw!diamond!diamond From: diamond@diamond.csl.sony.junet (Norman Diamond) Newsgroups: comp.lang.misc Subject: Re: Language Design, or: is C's Grammar Context Free Keywords: BNF, Grammars, Silliness Message-ID: <10151@socslgw.csl.sony.JUNET> Date: 10 Apr 89 02:14:27 GMT References: <5200040@m.cs.uiuc.edu> <12443@watdragon.waterloo.edu> <6541@bsu-cs.UUCP> <920@m10ux.ATT.COM> Sender: news@csl.sony.JUNET Reply-To: diamond@diamond. (Norman Diamond) Organization: /usr/lib/news/organization Lines: 36 In article <920@m10ux.ATT.COM> mnc@m10ux.ATT.COM (Michael Condict) writes: >Consider instead the one that someone else posted: > > { T * x; . . . } > >... One of the following two different parse trees >should be produced: > > * decl > / \ / \ > T x T * > | > x Those are not parse trees. Parse trees would resemble the following ones. Actually K&R's grammar would produce more complicated trees than these, but a more complicated grammar could produce these trees. expr decl / | \ / | \ T * x T * x And it really isn't difficult to unify these cases to allow an unambiguous grammar, leaving the resolution to the semantic stage. expr_or_decl / | \ T * x Of course, C is ugly because of the difficulty human readers have in reading such things, but compilers (C compilers anyway) have no sense of aesthetics. Norman Diamond, Sony Computer Science Lab (diamond%csl.sony.jp@relay.cs.net) The above opinions are my own. | Why are programmers criticized for If they're also your opinions, | re-inventing the wheel, when car you're infringing my copyright. | manufacturers are praised for it?