This module, [pre], realises a simple text processor. It supports the
usage of macros which will be expanded during processing - by the result
of the corresponding special replacement functions.
The following rules describes the source text format:
Text :: Literal
:: "&&"
:: "&" MacroName "&"
:: "&" "IF" FlagName "&" Text
["&" "ELSE" "&" Text]
"&" "FI" "&"
:: Text Text
Literal :: Each printable ASCII-character beside "&", additionally "\n" und "\f".
MacroName :: (Literal-"&"-" "-"\n"-"\f")+ .
Beside that the reserved words "IF","ELSE","FI" are not allowed.
FlagName :: like MacroName; MacroName and FlagName must be disjunct sets.
Now the interpretation can be specified as follows:
A literal identifies itself, i.e. will be taken as is.
'&&' will be expanded to '&'.
'&MacroName&' forces the call of the corresponding evaluation function to output
the replacement text for the macro. The left border is the column with the first "&".
With the IF-THEN-ELSE-FI construction conditional generation becomes possible.
FlagName refers to the corresponding boolean evaluation function. On true the text
after '&IF FlagName& will be processed, otherwise the optional '&ELSE&'-part.
Internally the following generalisation of the grammar will be used:
Text :: Literal
:: "&&"
:: "&" MacroName "&"
:: "&" KeyWord [FlagName] "&"
:: Text Text
void PRE_dfnMacro(c_string MacroName, void (* Macro)()) | defines macro with name 'MacroName' and meaning 'Macro' |
void PRE_dfnFlag(c_string FlagName, int (* Flag)()) | defines flag with name 'FlagName' and meaning 'Flag' |
void PRE_Process(c_string environ, c_string file, c_string ext, FILE *fileout) | preprocesses module [$'environ'/'file''ext'] to file 'fileout' |
void PRE_init(void) | enter the preprocessor module |
void PRE_quit(void) | leave the preprocessor module |
int PRE_tColumnNo(void) | column number of current token |