COSC48 Implementation of Programming Languages

Course Content

COSC48 consists of the technology of describing and implementing modern programming languages.

This course is similar to a course I have taught at Harvard and earlier at Santa Cruz and now at Dartmouth since the year 2000. The focus is on xcom, a small conventional compile-and-go system (scanner, parser, generator, emitter, runtime). Over the years xcom has migrated from Vax to Intel, and from C through C++ to MATLAB. An industrial short course and teaching materials can be downloaded from the MathWorks File Exchange. It runs on Intel X86 Windows, Linux and OSX. It is currently being ported to Intel A64 (64 bit extension of X86).

The idea is that as the academic material is presented, the student can be trying out changes in their personal copy of xcom.

What can be simple is simple. The target language, called X, is patterned after the Dijkstra if-fi constructs. Types logical, integer, and real are implemented. The scanner is hand written. The parser is either recursive descent or LR(1) (plug and play). The intermediate representation is the parse tree defined by the X grammar. There is a symbol table, and Intel x86 emitters. Running a program means filling an array with bits, then cheating the C type system to execute the bits in the array. Input and output, and some simple debugging, are handled by the runtime. All of this is open to the view of enquiring eyes.

A student should enjoy the formalisms of language translation (I won't say mathematics, because that scares the students away) and can do exercises (of which there are plenty in the pages of text-like material in the distribution).

Each student must do a project, presumably as one of a small group. A project usually means renaming X, then extending it into something you would be proud to present to the class (if we have time for in-class presentations by students).

What will not be taught: any serious optimization, or an industrial strength tools. For those who seriously get interested in the Intel code emitters, I have Intel 486 handbooks. There are also lots of compiler texts.


Created: May 17, 2001
Last modified: March 24, 2009