Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!csd4.milw.wisc.edu!lll-winken!uunet!mcvax!hp4nl!kunivv1!phoibos!ge From: ge@phoibos.UUCP (Ge Weijers) Newsgroups: comp.lang.misc Subject: Re: Language Design Message-ID: <540@phoibos.UUCP> Date: 23 Mar 89 12:12:59 GMT References: <9122@claris.com> Organization: University of Nijmegen, The Netherlands. Lines: 31 From article <9122@claris.com>, by hearn@claris.com (Bob Hearn): >>I'm looking in the back of K&R (first edition), and if I'm not mistaken I'm >>seeing context-sensitive stuff in the grammar. > Enough of this bullshit! How many times do I have to say it??? The grammar > in K&R is context-free. Do you know what a context-free grammar *is*? Yeah, here is my regular C grammar (a regular expression, really): c : | letter c | digit c | /* etc. */ ; Okay, it matches a lot more than C, but all legal C programs are acceptable. So are all programs in all other programming languages. Useful! The grammar in K&R is in the same category. It accepts all legal C programs, plus a lot more. Because of current compiler technology we use an artificial separation between syntax and static semantics. Static semantics can be expressed in more powerful grammar types (2-level van Wijngaarden grammars etc.) Your note is correct, but so is the observation that some context-sensitive features are suggested by using different names for the same terminal, nl. identifier. K&R use non-terminal names judiciously to suggest more than they are really telling. C can not be described exactly by a CFG, so C is not a context-free language. Usually this type of confusion starts because one party is talking about a grammar, whilst the other party is really talking about (an exact grammar of) the language. Ge' Weijers, KUN Nijmegen, the Netherlands ge@cs.kun.nl