Preprocessor

Preprocesor can include files and define simple macros. All these constructs are processed at the scanner layer, the parser receives generated tokens instead of include or define command.

include("filename");
define("name", "value");

Position in the source files can be passed to the script using predefined constants.

__FILE__
__LINE__
__FUNCTION__

There are two possible versions of comments. Multiline comment couldn't contain another multiline comment.

// This is a single line comment

/*
This is a multiline comment
*/

Examples

The following source code contains a comment, defines new tverify macro and uses symbolic constant __FUNCTION__.

// From samples/tests.txt
define("tverify", "result = result && verify");

function testFactorial()
{
	result = true;

	tverify(factorial(1) == 1);
	tverify(factorial(2) == 2);
	tverify(factorial(3) == 6);

	return testResult(__FUNCTION__, result);
}

All these preprocessor constructs are processed inside the scanner, the parser receives tokens that represent the following code (compare the bold parts).

function testFactorial()
{
	result = true;

	result = result && verify(factorial(1) == 1);
	result = result && verify(factorial(2) == 2);
	result = result && verify(factorial(3) == 6);

	return testResult("testFactorial", result);
}