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.
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.
It would be nice if your compiler enforced the following rules, which help prevent programming errors:
Each procedure call must use a procedure name that was previously either declared or defined, and the number of arguments must match the declaration or definition.
No procedure name may be defined more than once. (Remember, this applies only to definitions, not declarations.)
If the total number of declarations and definitions for a particular procedure name is greater than one, then all those declarations and definitions must be in agreement regarding the number of arguments.
Upload to moodle a zip file of your project.