Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!tut.cis.ohio-state.edu!ucbvax!ucsd!rutgers!okstate!norman From: norman@a.cs.okstate.edu (Norman Graham) Newsgroups: comp.lang.misc Subject: Re: Language Design Message-ID: <4526@okstate.UUCP> Date: 24 Mar 89 22:58:42 GMT References: <9861@megaron.arizona.edu> Organization: Oklahoma State Univ., Stillwater Lines: 25 From article <9861@megaron.arizona.edu>, by gudeman@arizona.edu (David Gudeman): > [stuff deleted about how the grammar specifies that > any identifier can serve as a type-specifier] > > So both claims made in this argument are correct: > > (1) the grammar of C is not context free > and > (2) the grammar given in K&R is context free This is an interesting point (ie. one I hadn't thought of before :-). In theory, a grammar is a generator for strings in a language, not a recognizer for a language (eg. various forms of automata). So the grammar in K&R is context-free, but it doesn't generate the C language--in addition to valid C programs it also generates invalid C programs. Of course, when this grammar is used as the basis of a compiler, the semantic analyzer should detect these invalid programs. This makes sense to me... how about anyone else out there? -- Norman Graham Oklahoma State University Internet: norman@a.cs.okstate.edu Computing and Information Sciences UUCP: {cbosgd, ihnp4, 219 Mathematical Sciences Building rutgers}!okstate!norman Stillwater, OK 74078-0599