How to describe the semantics of a language?

263 views Asked by At

For syntax there is the EBNF ISO 14977 standard.

for runtime we have CLI ISO 23271 standard
see also Simple definition of "semantics" as it is commonly used in relation to programming languages/APIs?

but how to describe the transition from EBNF to CLI specs in declarative way? i.e. is it enough to use the S-attributed grammar? Which standard define the syntax of such grammar?

1

There are 1 answers

3
Ira Baxter On BEST ANSWER

There are many ways to define the semantics of a language. All of them have to express somehow the relationship between the program text and "what it computes".

A short but incomplete list of basic techniques:

  • Define an interpreter ("operational semantics")
  • Define a map from the source code to an enriched lambda calculus ("denotational semantics")
  • Define a map from the source code to another well-defined language ("transformational semantics")

Essentially, these are computations defined over the source text of a program instance.

You can implement these computations in many different ways. One way to implement them might be "S-attributed" grammars, although why you would want to restrict yourself to only S-attributes rather than a standard attributed grammar with inherited attributes is beyond me.

Given that there are so many ways to do this, I doubt you are going to find a standard. Certainly the programming langauge committees aren't using one. Heck, they won't even use a standard for BNF.