2.1 A simple Language

We define a simple – but high enough level – language as an example. At present it contains just sufficient construct to write small programs, which can be compiled with the compiler we are going to discuss and executed on the virtual machine VM1. VM1 is a working computer; it is implemented only in software as a C program and not in silicon. As indicated in Chapter 1, a similar idea is actually used in programming languages such as Java, Perl and Python.

A typical program in simple looks like:

      int a ;
      let a = 10 ;
loop: print (a) ;
      let a = a – 1 ;
      if a goto loop ;

This program will print numbers 10 to 0, in descending order. Some of the language constructs are redundant at this stage (e.g. declaration of a ...

Get Compilers: Principles and Practice now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.