A Quick Introduction to Virgil - Building VPC

This is part of a basic introduction to programming in Virgil and gives an overview of the language, its syntax, and its structures. This page gives a step-by step tutorial on building the compiler and interpreter.

Prerequisites

Virgil is a cross-platform, portable language, but this tutorial focuses on one particular microcontroller model and architecture. You will need the following prerequisites to try this tutorial:

  • Java - a working Java 5 installation that includes javac, the Java source compiler, to compile the Virgil compiler and interpreter, which are both written in Java.

Step 1 - Get Virgil

The first step is to download the source release of the Virgil compiler and demo applications on the releases page. Alternatively, you can also check out the latest version from CVS using the instructions on the CVS access page.

Step 2 - Compile VPC

The VPC compiler is written in Java, and the source code that you obtained in step 1 must be compiled by the java compiler before you can use VPC. The source release and CVS version contain a makefile in the compiler/ directory for building the VPC compiler. To compile the compiler, you simply need to go to that directory and run make:

% cd compiler/
% make
javac -source 1.5 -d bin `find src/vpc src/cck -name '*.java'`
Note: Some input files use unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
% _

Step 3 - Set Your ClassPath

Java uses an environment variable called $CLASSPATH to search for the classes of an application. In order to run the Virgil compiler, you will need to set this environment variable to point to the compiler/bin directory under the virgil directory. For example, in bash, you can use the following command to set your classpath:

% export CLASSPATH=(mydir)/virgil/compiler/bin
% _

After this step, you should be able to successfully run VPC using a command such as:

% java vpc.Compiler
Virgil Prototype Compiler [Release B-03]
Copyright (c) 2004-2007, Regents of the University of California
All rights reserved.

Usage: vpc [options] 
Usage: vpc -help [category]

OVERVIEW

    VPC is a prototype compiler for the Virgil programming language that
performs semantic checking on Virgil source code as well as optimizations, and
generates either a machine-independent intermediate code, or a
machine-dependent C code which is suitable for gcc. Additionally, VPC
implements a number of program analysis and verification tools for Virgil
programs. Each of these analysis and optimization tools can be accessed
through the compiler options that are described in the next section.
 . . . 
% _

Go back to the tutorial.