Chapter 8. Preprocessor

Before the contents of the source file is handed to the main parser, it goes through the preprocessor. The preprocessor knows nothing of mnemonics or the script language. It's a simple mechanism that enables you to select pieces of the source to be discarded or included in what the main parser sees. This chapter explains how. (NOTE: The preprocessor is made like the one used in C# with the addition of #import, #importif and #importonce so you might find this familiar)

8.1. Defining preprocessor symbols

The preprocessor uses symbols do determine if it should discard or include portions of the source file. There are two methods to define a symbol. The first is from the command line. This defines a symbol called 'TEST':

java -jar KickAss.jar -define TEST

A symbol is either defined or not defined. It has no assigned value.

The other way is using the #define directive:

#define TEST

You can recognize a preprocessor directive on the '#'. If the first non-whitespace character on a line is a '#' then the line is a call to the preprocessor. If you want to remove the definition of a symbol you use the #undef directive.

#undef TEST