garry@batcomputer.tn.cornell.edu (Garry Wiegand as guest) (04/10/89)
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!)
lee@uhccux.uhcc.hawaii.edu (Greg Lee) (04/10/89)
From article <7708@batcomputer.tn.cornell.edu>, by garry@batcomputer.tn.cornell.edu (Garry Wiegand as guest): " ... " I'm not even real sure of the *informal* English distinction between ""syntax" and "semantics". " " How do you linguistics people use these words? We are no less confused than anyone. Semantics concerns reference, but in common usage in linguistics and logic, cross-reference doesn't make a thing semantic. In the typedef affair, I take it we're talking about a sort of cross-referencing. For instance, in predicate logic, in the most commonly used notation, arguments are cross-referenced by re-using variable names within the scope of a single quantifier for that name. Yet one can still give a logical syntax for predicate logic. Perhaps that is justified in logic, because variables can be regarded as notational conveniences. In a variant of ordinary logical notation, combinatory logic, there need be no variables. [Ref. W.V.O Quine, "Variables explained away", in Proc. Nat. Acad. of Sciences, late '40's.] A kind of cross-referencing in natural language similar to typedef's is grammatical agreement, which is usually taken to be syntactic in nature. It can be argued that agreement in natural language does not prevent it from being context-free, but the argument depends on the fact that the number of agreement categories (singular/plural, masculine/feminine, Bantu noun class, ...) is finite (and small). This is not the case with typedef's, so I would say that C is not context-free. Greg, lee@uhccux.uhcc.hawaii.edu
' Sabatella) (04/11/89)
>I'm not even real sure of the *informal* English distinction between >"syntax" and "semantics". > >How do you linguistics people use these words? One of my pet peeves is when two people are arguing over some fine distinction is the the exact meaning of a word, and one will exclaim, "That's just semantics". I always wondered what it is that this person thinks is more high-level than semantics, and what he would call it.
gudeman@arizona.edu (David Gudeman) (04/13/89)
In article <5160016@hpfcdc.HP.COM> marc@hpfcdc.HP.COM (Marc `Play Ball!' Sabatella) writes: > >One of my pet peeves is when two people are arguing over some fine distinction >is the the exact meaning of a word, and one will exclaim, "That's just >semantics". I always wondered what it is that this person thinks is more >high-level than semantics, and what he would call it. When someone says "That's just semantics" he probably means that the argument is based on misunderstanding. Example: A: This grammar generates this set of strings. B: No, it doesn't They think they are disagreeing about what set of strings a grammar generates, but a little more discussion may reveal that to B the word "generates" means "generates all and only this set of strings" and to A it means "generates at least all the strings in this set". Their disagreement then is one of the semantics of their medium of communication, they are not disagreeing about what they thought they were.
rjh@cs.purdue.EDU (Bob Hathaway) (04/13/89)
In article <5160016@hpfcdc.HP.COM> marc@hpfcdc.HP.COM (Marc `Play Ball!' Sabatella) writes: >>I'm not even real sure of the *informal* English distinction between >>"syntax" and "semantics". >> >>How do you linguistics people use these words? > >One of my pet peeves is when two people are arguing over some fine distinction >is the the exact meaning of a word, and one will exclaim, "That's just >semantics". I always wondered what it is that this person thinks is more >high-level than semantics, and what he would call it. I can remember an interesting set of linguistic definitions: Syntax Specifies the correct form for objects Semantics Specifies what the objects mean Pragmatics Specifies relationships among the objects I've also seen pragmatics defined as the use, history, and style of programming. Syntax is specified by grammars and semantics specify the meanings of syntactic entities but I've found a common confusion exists between syntax directed translation and semantics. English can be specified by a grammar but a grammar alone cannot recognize valid English sentences; semantics must be used to understand the syntactic entities. In other words, I can build parse trees for the correct translation of valid English sentences but the translation process resulting in these parse trees should not be performed through simple syntax directed translation, semantics and pragmatics are used to distinguish syntactic entities. In classical synthetic languages, syntax directed translation is sufficient to parse correct programs but they also recognize syntactically correct but semantically incorrect programs such as the inconsistent declaration and use of definitional objects and the incorrect use of context sensitive constructs such as break statements not contained within loops. So, my understanding of these terms are: syntax specifies correct forms, semantics specifies their meanings and pragmatics can specify additional information for understanding the context of usage. Bob Hathaway rjh@purdue.edu
smryan@garth.UUCP (s m ryan) (04/23/89)
>So: is there any *formal* definition and distinction between >"syntax" and "semantics", as applied in computer science? There is, sort of. This is also sort of a test. (oops!) -- But even this was lost to need -s m ryan to fill the gods's and Hreithmar's greed. -- Andwari's Gem, 1/15 Then Andwari in anger bold `Will the real doctor Henderson please declared a curse on stolen gold. report to neurosurgery immediately.'