Menu

Preprocessor

Marcel Schaible

Preprocessor

The compiler should provide an included preprocessor like e.g. C preprocessor. It is inspired by the pseudo-preprocessor of RTOS-UH.

Specification

#DEFINE <const> = <constexpr>;        Define a constant <const> with the value <constexpr>
#INCLUDE <filename>;                  Include the source file <filename>
#IF <constexpr>;                      Conditional compilation if <constexpr> = true
#IFUDEF <constexpr>;                  Conditional compilation if <constexpr> = false
#ELSE;                                Else 
#FIN;                                 End of #IF or #IFUDEF
#ERROR <message>                      Print <message> to the console and aborts compilation
#WARN <message>                       Print <message> to the console and continues compilation

#DEFINE

#INCLUDE

#IF

#IFUDEF

#ERROR

#WARN

Scope

Example

#INCLUDE "definitions.prl";

#DEFINE TEST = 1;
#DEFINE MYCONST1 = 0;
#DEFINE MYCONST2 = 42;


#IF TEST = 1;
DCL var FIXED(15) INIT(MYCONST1);
#ELSE;
DCL var FIXED(15) INIT(MYCONST2);
#FIN;:

Related

Wiki: Home