Example: Very-Simple-Programming-Language (VSPL)

We call this language the Very-Simple-Programming-Language (VSPL). It is based on Sebesta's Example 3.1. The following is the description of VSPL.

Syntax of VSPL:

Please note that the symbol <id> (identifier) is a token which should be recognized by the lexical analyzer.

Semantics of VSPL (informal definition):

As defined by the syntax, a program in this language consists of a list of assignment statements. To simplify this example, we ignore the generation of machine code for the assignment statement. Instead, we define the semantics of letting the compiler execute the assignment statements and print a summary of the assignment operations that have been performed. The value of an expression is defined, as discussed in class, by the usual mathematical conventions. (We ignore the problem of type checking, since we can assume that all values are of integer type).

To execute an assignment statement, the compiler uses a symbol table which contains for each identifier its current value. There are three predefined identifiers with the names zero, one and ten, which have the initial values 0, 1 and 10, respectively.

Note: Letting the compiler execute the statements of the program only makes sense when there are no loops in the program. As soon as there are loops, the execution cannot be performed during a single pass by the compiler from left to right. This is why, normally a compiler generates code (while reading the program from left to right), and this code is executed subsequently.