Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!cornell!batcomputer!garry From: garry@batcomputer.tn.cornell.edu (Garry Wiegand as guest) Newsgroups: comp.lang.misc Subject: Syntax vs Semantics (silliness!) Message-ID: <7708@batcomputer.tn.cornell.edu> Date: 10 Apr 89 02:44:07 GMT Reply-To: garry@larch.cadif.cornell.edu Organization: Cornell Engineering && Ithaca Software Lines: 44 In a recent article dhesi@bsu-cs.bsu.edu (Rahul Dhesi) wrote: >In a recent article gudeman@arizona.edu (David Gudeman) writes: >>There is no context free grammar that recognises all valid C programs. > >Well...there is no context free grammar that recognizes all valid C >programs and *no others*. This is getting silly. I can write a very short grammar that successfully parses C. (As an offshoot, it can also parse all other past and future programming languages.) All it has is one rule: "String_Of_Tokens -> zero or more arbitrary tokens". This is a trivially legitimate grammar for C, I think. But interesting? well... My grammar unfortunately parses quite a few invalid programs. Nothing wrong with that, of course. There's always some errors that make it past parsing and have to be caught in the semantic phase. The "semantic phase", in this compiler, would just be a little hairier than usual. Which brings me to my point: is the syntax/parsing phase an *arbitrary* slice off the front end of a compiler, with the rest being "semantics"? Is there any *formal* distinction between "syntax" and "semantics" that someone can tell us about? If there's no formal definition of the minimum actions a "C parser" must perform, then I'm afraid there's no way to resolve this argument over the properties of the "correct grammar" for C. My grammar that just produces String_Of_Tokens as its only output is as formal as K&R's. Clearly context-free, yes? But boring to talk about, yes? Time to cool down the discussion. People are assuming very different things about the non-mathematical properties of grammars: things having to do with the purpose of devising grammars. So: is there any *formal* definition and distinction between "syntax" and "semantics", as applied in computer science? I'm not even real sure of the *informal* English distinction between "syntax" and "semantics". How do you linguistics people use these words? garry wiegand (garry@larch.cadif.cornell.edu - @tcgould won't work!)