`                  `

## A simple interpreter

For simplicity's sake, we limit the scope of our first interpreter to the addition, subtraction, and multiplication of integers in a list of expressions. Here is the specification for our interpreter in words:

• The value of an integer is itself.
• The value of a binary expression is the result of a binary operator applied to the evaluation of the two descendents.
• The value of a unary expression is the result of a unary operator applied to the evaluation of its descendent.
• The value returned by a list of expressions is the value of the last expression.

We express these rules, using the notation of natural semantics, as follows:

The last two rules correspond to the fourth item in our specification and may be read:

If a list of expressions contains one expression, the value returned is the result of its evaluation. If a list contains more than one expression, evaluate the first expression and return the result of the evaluation of the rest of the list.
Using the true Typol syntax, we would write these rules as follows:

```
|- integer N : integer N ;

|- EXP1 : integer x1  &
|- EXP2 : integer x2  &
----------------
|- plus(EXP1, EXP2) : integer x ;

|- EXP1 : integer x1  &
|- EXP2 : integer x2  &
sub(x1, x2, x)
----------------
|- minus(EXP1, EXP2) : integer x ;

|- EXP1 : integer x1  &
|- EXP2 : integer x2  &
mult(x1, x2, x)
----------------
|- prod(EXP1, EXP2) : integer x ;```

```
|- EXP  : integer x1  &
neg(x1, x)
----------------
|- uminus(EXP) : integer x ;

|- EXP1 : v
----------------
|- exp_s[EXP1] : v ;

|- EXP1 : v1  &
|- EXPS : v
----------------
|- exp_s[EXP1.EXPS] : v ;```

Lists in Typol are designated using brackets, and list elements are distinguished using the period (.) notation.

These rules do not yet compose a complete Typol program, but they make up the purely semantic part. The rest of the program will address input and output issues.

Tutorial