next up previous contents index
Next: Math Functions Up: The Xic Scripting Language Previous: goto, label   Contents   Index


``Preprocessor'' Directives

The script parser interprets C-like ``preprocessor'' keywords. Unlike C, there is only a single pass through the text, so ``preprocessor'' is a misnomer.

The script preprocessor utilizes the generic macro preprocessor (see 18.1) used in various places within Xic. In the present context, the keywords start with the comment `#' character.

In addition to the predefined macros of the generic macro preprocessor, the following predefined macro is used in scripts.

THIS_SCRIPT
For any script which is read from a file (not counting the technology file) the token THIS_SCRIPT is effectively defined to be the name of the script (for scripts launched from the User Menu) or a path to the file. Thus, in the script, the token THIS_SCRIPT is replaced by the file or script name. For example, to print the script name in the console window, one could add a line
Print("The name of this script is THIS_SCRIPT")

The following ``preprocessor'' keywords are understood in scripts. These pretty much follow the C/C++ standards and behave similarly, and correspond to the generalized keywords described for the macro preprocessor. These are:

Keyword Function
#define Define a macro.
#if Conditional evaluated test.
#ifdef Conditional definition test.
#ifndef Conditional non-definition test.
#else Conditional else clause.
#endif Conditional end clause.

In addition, the following keyword, which has no counterpart in the generic macro preprocessor, is recognized in scripts:

#macro
The #macro directive, which has no counterpart in C, is assumed to be followed by macro statements in the format used in the .xicmacros file, followed by #end or #endif. If the #macro sequence appears in a script file, the macro is defined at that point.

Throughout the script, each line is macro expanded. The actual arguments replace the formal arguments (if any) in the substitution text, which replaces the macro reference. The macro is recognized as a text token, i.e., it must be surrounded by punctuation or white space.


next up previous contents index
Next: Math Functions Up: The Xic Scripting Language Previous: goto, label   Contents   Index
Stephen R. Whiteley 2022-05-28