Re: What is the semantics of a language?

George Neuner <gneuner2@comcast.net>
Wed, 26 Jan 2022 14:24:13 -0500

          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: George Neuner <gneuner2@comcast.net>
Newsgroups: comp.compilers
Date: Wed, 26 Jan 2022 14:24:13 -0500
Organization: A noiseless patient Spider
References: 22-01-081
Injection-Info: gal.iecc.com; posting-host="news.iecc.com:2001:470:1f07:1126:0:676f:7373:6970"; logging-data="6443"; mail-complaints-to="abuse@iecc.com"
Keywords: semantics
Posted-Date: 26 Jan 2022 14:48:25 EST

On Sat, 22 Jan 2022 00:08:35 +0000, Roger L Costello
<costello@mitre.org> wrote:


>Hello Compiler Experts!
>
>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, ...


This part of the statement is an example of circular reasoning and is
absolutely meaningless.


>... and by the actions taken when various groupings are recognized.


This part is valid - there may be distinction necessary between
actions taken at compile time vs actions taken at run time, but in any
case actions DO define semantics.




>Niklaus Wirth agrees with the Bison specification. In the introduction of his book, Compiler Construction, he says [2]:
>
>The translation process is now guided by the structure of the analysed
>text. The text is decomposed, parsed into its components according to
>the given syntax. For the most elementary components, their semantics
>is recognized, and the meaning (semantics) of the composite parts is
>the result of the semantics of their components. Naturally, the
>meaning of the source text must be preserved by the translation.
>
>Do you agree that that is the definition of the semantics of a language?


I agree that Wirth's statement is very similar to what is in the Bison
manual.




Not having either the Bison manual or Wirth's book handy, I will
comment only on the quoted statements above. I will (perhaps naively)
assume that in both cases there is further explanation in the
respective texts.




The problem with both statements is that neither defines what is meant
by "semantic value".


Bison assumes that the reader understands what is a token, what is the
"value" of a token, and what a token "value" means in context of a
given grouping of tokens.
[Of course, the developer /must/ know these things, but that statement
clearly was not written for a beginner.]


Wirth's statement makes an analogous mistake while also introducing a
distinction between "elementary" components whose semantics somehow
simply can be "recognized", and "composites" which somehow take their
semantics from some confluence of the semantics of their constituent
components (although that is not explicitly stated and so may be
unclear to the reader).


I learned addition in /elementary/ school - so is addition elementary?
Or is it composite? The reader has to know - or be told - that in the
context of compiling "2" should be considered elementary but "1 + 1"
should be considered composite.
[This leaves aside whether or not the the addition might be evaluated
at compile time and only the result inserted into the object code.]




For comparison, the Lisp manual explicitly defines what is literal
data and says that literal data is "self evaluating": e.g., "42" will
evaluate to the /integer/ value 42, and that the resulting value will
satisfy certain testing predicates such as integerp, rationalp, etc.
If, instead, you wanted a floating point value, you need to convert
the integer or write the literal in a different way.


Although somewhat blatantly obvious, Lisp makes clear that literals do
have semantics - ie. that they are self-evaluating, that the result of
evaluation is a value of a certain "type", and what it means to be a
value of a certain type.


Other languages also explicitly define these things in their manuals
and/or standards ... I'm simply picking on Lisp because, AFAIK, it was
the first to rigorously do so.




>/Roger
>
>[1] Section 3.4 of the Bison specification: https://www.gnu.org/software/bison/manual/bison.html#Semantics
>
>[2] See page 6, fourth paragraph in Compiler Construction by Niklaus Wirth: https://people.inf.ethz.ch/wirth/CompilerConstruction/CompilerConstruction1.pdf
>[That's one definition. But I suspect we will hear it's far from the only one. -John]


YMMV,
George


Post a followup to this message

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