Toy Language '07 Compiler

The TL07 language is based on a very small subset of the Pascal language. It provides a good basis for a simple compiler. The main components of the compiler are:

Here is a really simple TL07 program that reads a number and prints double that number.

TL07 Source program:
PROGRAM simple
    VAR x AS INT ;
    x := READINT ;
    WRITEINT 2 * x ;
Syntax Tree (click to expand):
Semantic Tree (green means Integer):
Internal Representation:
General MIPS Assembly Code:
r1: .word 0
r2: .word 0
r3: .word 0
r4: .word 0
x:  .word 0

    li $v0, 5            # READINT
    syscall              # code 5 = read_int
    sw $v0, r1
    lw $a0, r1           # store x
    sw $a0, x
    li $a0, 2            # 2
    sw $a0, r2
    lw $a0, x            # load x
    sw $a0, r3
    lw $a0, r2           # 2 * x
    lw $a1, r3
    mul $a2, $a0, $a1
    sw $a2, r4
    li $v0, 1            # WRITEINT
    lw $a0, r4
    syscall              # code 1 = print_int

    li $v0, 10           # System code for exit
    syscall              #

Here is a robust TL07 program to calculate E = 2.71828+ to 500 digits: e.tl07
And here is the generated MIPS code for it: e.s and it's output: e.out -- Main