Re: What is the semantics of a language?

gah4 <gah4@u.washington.edu>
Tue, 25 Jan 2022 01:19:56 -0800 (PST)

          From comp.compilers

Related articles
What is the semantics of a language? costello@mitre.org (Roger L Costello) (2022-01-22)
Re: What is the semantics of a language? luser.droog@gmail.com (luser droog) (2022-01-24)
Re: What is the semantics of a language? gah4@u.washington.edu (gah4) (2022-01-25)
Re: What is the semantics of a language? gneuner2@comcast.net (George Neuner) (2022-01-26)
Re: What is the semantics of a language? gah4@u.washington.edu (gah4) (2022-01-26)
Re: What is the semantics of a language? lkrupp@invalid.pssw.com.invalid (Louis Krupp) (2022-02-18)
| List of all articles for this month |
From: gah4 <gah4@u.washington.edu>
Newsgroups: comp.compilers
Date: Tue, 25 Jan 2022 01:19:56 -0800 (PST)
Organization: Compilers Central
References: 22-01-081
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
In-Reply-To: 22-01-081

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]



Post a followup to this message

Return to the comp.compilers page.
Search the comp.compilers archives again.