Path: csiph.com!weretis.net!feeder6.news.weretis.net!news.misty.com!news.iecc.com!.POSTED.news.iecc.com!nerds-end From: luser droog Newsgroups: comp.compilers Subject: Re: What is the semantics of a language? Date: Mon, 24 Jan 2022 11:39:11 -0800 (PST) Organization: Compilers Central Lines: 31 Sender: news@iecc.com Approved: comp.compilers@iecc.com Message-ID: <22-01-110@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="67370"; mail-complaints-to="abuse@iecc.com" Keywords: semantics Posted-Date: 24 Jan 2022 14:40:56 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:2867 On Friday, January 21, 2022 at 9:24:11 PM UTC-6, Roger L Costello wrote: > 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. > > 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 think those are both good. Another perspective is view syntax vs. semantics as the purview of different tools. A parser generator will handle the syntax but you have to provide the semantics in some other form. Adopting a common backend will handle semantics but you have to provide your own syntax analysis. So I'd say the syntax is directed by the grammar, but the semantics is directed by the resulting structure from a successful application of that syntax. What it looks like vs. What to do about it