Slide 5.2: Inherited attributes
Slide 5.4: A translational-semantics example (cont.)
Home

A Translational-Semantics Example


According to the previous discussion, translational semantics is to express the meaning of a language by a translation schema which, for any program in the language, yields a program in a simpler and, it is hoped, better understood language. To better understand the meaning of translational semantics, the following slides give an example of translational semantics.

The Programming Language Wren
Wren is a small imperative language whose only control structures are the if command for selection and the while command for iteration. Variables are explicitly typed as integer or boolean, and the semantics of Wren follows a strong typing discipline when using expressions. The BNF of Wren is on the right:

A Virtual Machine
A Wren program will be translated to an assembly-language program of a virtual machine, which interprets the program by using a high-level language such as C/C++.
The complete instruction set of the machine is on the right and the differences between a real machine and virtual machine are given next.