Path: csiph.com!weretis.net!feeder6.news.weretis.net!news.misty.com!news.iecc.com!.POSTED.news.iecc.com!nerds-end From: gah4 Newsgroups: comp.compilers Subject: Re: What is the semantics of a language? Date: Tue, 25 Jan 2022 01:19:56 -0800 (PST) Organization: Compilers Central Lines: 42 Sender: news@iecc.com Approved: comp.compilers@iecc.com Message-ID: <22-01-111@comp.compilers> References: <22-01-081@comp.compilers> Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Injection-Info: gal.iecc.com; posting-host="news.iecc.com:2001:470:1f07:1126:0:676f:7373:6970"; logging-data="38441"; mail-complaints-to="abuse@iecc.com" Keywords: semantics Posted-Date: 25 Jan 2022 11:09:34 EST X-submission-address: compilers@iecc.com X-moderator-address: compilers-request@iecc.com X-FAQ-and-archives: http://compilers.iecc.com In-Reply-To: <22-01-081@comp.compilers> Xref: csiph.com comp.compilers:2868 On Friday, January 21, 2022 at 7:24:11 PM UTC-8, Roger L Costello wrote: > Ah! I found the answer to the question: > What is the semantics of a language? > Section 3.4 of the Bison specification [1] has the answer: > 3.4 Defining Language Semantics > The grammar rules for a language determine only the syntax. The > semantics are determined by the semantic values associated with > various tokens and groupings, and by the actions taken when various > groupings are recognized. It seems to me that the distinction is less important than it used to be. There is a story (possibly fictional) of a compiler with only one error message: "SYNTAX ERROR" (You were lucky to get the line number.) For most languages, there are many programs that satisfy the syntax rules, but not the semantics. If, for example you have: J = 1.2 and J has the wrong type, this is a semantic error, not a syntax error. This used to be more important, as compilers generated the error messages in a different way, and possibly at a different time. Syntax errors might be generated line by line, but semantics errors not until the whole program has been processed. When memories were small, tricks were used to fit compilers into the available memory. Reminds me, in the days of punched cards there were stories about debugging compilers by feeding in cards from the recycling bin. Most likely, that includes many statements that are almost correct, and that one would like the compiler to properly report the error. [The line between syntax and semantics is quite fuzzy. There have been languages that put the types into the syntax so your example would have been a syntax error. Experience has shown that's not a great idea since it's much harder to produce useful error messages that way. -John]