|
|
|
|
|
by Zickzack
1375 days ago
|
|
As always, the off topic invitation cannot be passed. The two-level grammar of Algol 68 gave the semantics of Algol 68 in a denotational language, the second level. As such, it is not more complicated as other languages with defined semantics, such as in the ML family. To my knowledge, people used that second level to implement a real virtual (ho hum) machine, resulting in a working interpreter. However, the ML aficionados can be surprised with the information that their language was not first one with fully defined semantics. Algol 68 was ahead of its time. As for Pascal, history as I know says that Wirth invented Pascal as a training language for a course in which a one pass compiler was to be built. Only later, when the Algol 68 project became complicated, Wirth started to market it as a superior design - something which it never has been. And yes, I enjoyed Turbo Pascal. |
|
In any case, there’s something to be said for defining a language in a series of layers: tokens, then trees, then perhaps elaboration / desugaring, then one or more layers of semantics (typing, binding, execution). In an actual frontend, you probably even want a looser tree syntax followed by a layer of “semantic” checks that could technically be folded into the syntax, in order to be able to tell the user things like “you can’t use an array type like that” rather than “unexpected bracket”. Compare Lisp s-expressions, the Dylan idea of skeleton syntax trees, and the class of visibly pushdown languages as used in one recent structural editor[1]. Contrast the refusal of the Glasgow Haskell Compiler to desugar before typechecking[2].
[1] https://news.ycombinator.com/item?id=31384528
[2] https://www.aosabook.org/en/ghc.html