O'Reilly logo

Compilers: Principles and Practice by Himanshu B. Dave, Parag H. Dave

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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:

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

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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required