MCS-388 Lab 6: Procedures – Further Features (Spring 2014)

Due: May 14, 2014

Allowing procedure declarations, not just definitions

Languages like C conventionally provide procedure declarations, such as

int putchar(int c);

as well as procure definitions, such as

int square(int n){return n*n;}

By making your compiler accept any list of zero or more items, each of which is either a procedure declaration or a procedure definition, you'll be able to totally eliminate LibraryDeclarations. If someone wants to use putchar, they can jolly well declare it themself.

In the LLVM output, you'll need to follow LLVM's rules, which are somewhat different: only output an LLVM declaration for a procedure if there is no definition and only once for each procedure.

Allowing more or fewer arguments

Change procedure calls, procedure definitions, and procedure declarations to allow any number of arguments. In addition to allowing you to write more interesting procedures yourself, this opens up more of the standard C library for your use. If you find yourself wanting to use a test program that reads input, you'll need to modify build.xml. If you don't find ant's documentation readable, I can give you a hand with this.

Checking calls, declarations, and definitions

It would be nice if your compiler enforced the following rules, which help prevent programming errors:


Upload to moodle a zip file of your project.

Course web site:
Instructor: Max Hailperin <>