preprocessor: submodule update
parent
776792e15c
commit
5994321cd7
|
@ -10313,7 +10313,7 @@ directives are:
|
||||||
* ``@#includepath``, paths to search for files that are to be included,
|
* ``@#includepath``, paths to search for files that are to be included,
|
||||||
* ``@#include``, for file inclusion,
|
* ``@#include``, for file inclusion,
|
||||||
* ``@#define``, for defining a macro processor variable,
|
* ``@#define``, for defining a macro processor variable,
|
||||||
* ``@#if, @#ifdef, @#ifndef, @#else, @#endif`` for conditional statements,
|
* ``@#if, @#ifdef, @#ifndef, @#elseif, @#else, @#endif`` for conditional statements,
|
||||||
* ``@#for, @#endfor`` for constructing loops.
|
* ``@#for, @#endfor`` for constructing loops.
|
||||||
|
|
||||||
The macro processor maintains its own list of variables (distinct from model
|
The macro processor maintains its own list of variables (distinct from model
|
||||||
|
@ -10629,20 +10629,29 @@ Macro directives
|
||||||
.. macrodir:: @#if MACRO_EXPRESSION
|
.. macrodir:: @#if MACRO_EXPRESSION
|
||||||
@#ifdef MACRO_VARIABLE
|
@#ifdef MACRO_VARIABLE
|
||||||
@#ifndef MACRO_VARIABLE
|
@#ifndef MACRO_VARIABLE
|
||||||
|
@#elseif MACRO_EXPRESSION
|
||||||
@#else
|
@#else
|
||||||
@#endif
|
@#endif
|
||||||
|
|
||||||
|br| Conditional inclusion of some part of the ``.mod`` file. The lines
|
|br| Conditional inclusion of some part of the ``.mod`` file. The lines
|
||||||
between ``@#if``, ``@#ifdef``, or ``@#ifndef`` and the next ``@#else`` or
|
between ``@#if``, ``@#ifdef``, or ``@#ifndef`` and the next ``@#elseif``,
|
||||||
``@#endif`` is executed only if the condition evaluates to ``true``. The
|
``@#else`` or ``@#endif`` is executed only if the condition evaluates to
|
||||||
``@#else`` branch is optional and, if present, is only evaluated if the
|
``true``. Following the ``@#if`` body, you can zero or more ``@#elseif``
|
||||||
condition evaluates to ``false``.
|
branches. An ``@#elseif`` condition is only evaluated if the preceding
|
||||||
|
``@#if`` or ``@#elseif`` condition evaluated to ``false``. The ``@#else``
|
||||||
|
branch is optional and is only evaluated if all ``@#if`` and ``@#elseif``
|
||||||
|
statements evaluate to false.
|
||||||
|
|
||||||
Note that when using ``@#ifdef``, the condition will evaluate to ``true``
|
Note that when using ``@#ifdef``, the condition will evaluate to ``true``
|
||||||
if the MACRO_VARIABLE has been previously defined, regardless of its
|
if the MACRO_VARIABLE has been previously defined, regardless of its
|
||||||
value. Conversely, ``@#ifndef`` will evaluate to true if the MACRO_VARIABLE
|
value. Conversely, ``@#ifndef`` will evaluate to true if the MACRO_VARIABLE
|
||||||
has not yet been defined.
|
has not yet been defined.
|
||||||
|
|
||||||
|
Note that when using ``@#elseif`` you can check whether or not a variable
|
||||||
|
has been defined by using the ``defined`` operator. Hence, to enter the
|
||||||
|
body of an ``@#elseif`` branch if the variable ``X`` has not been defined,
|
||||||
|
you would write: ``@#elseif !defined(X)``.
|
||||||
|
|
||||||
Note that if a real appears as the result of the MACRO_EXPRESSION, it
|
Note that if a real appears as the result of the MACRO_EXPRESSION, it
|
||||||
will be interpreted as a boolean; a value of ``0`` is interpreted as ``false``,
|
will be interpreted as a boolean; a value of ``0`` is interpreted as ``false``,
|
||||||
otherwise it is interpreted as ``true``. Further note that because of the
|
otherwise it is interpreted as ``true``. Further note that because of the
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
Subproject commit 75b000a0b5f36893e2d32d97abcfe17bc1a3f71b
|
Subproject commit 588896b5091ddee650a9548088a2df164df5c22b
|
|
@ -95,9 +95,9 @@ e = 0;
|
||||||
u = 0;
|
u = 0;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@#define DEFINED=0
|
@#define DEFINEDvar=0
|
||||||
|
|
||||||
@#ifndef DEFINED
|
@#ifndef DEFINEDvar
|
||||||
@#error "IFNDEF PROBLEM"
|
@#error "IFNDEF PROBLEM"
|
||||||
@#else
|
@#else
|
||||||
shocks;
|
shocks;
|
||||||
|
@ -107,12 +107,24 @@ var e, u = phi*0.009*0.009;
|
||||||
end;
|
end;
|
||||||
@#endif
|
@#endif
|
||||||
|
|
||||||
@#ifdef DEFINED
|
@#ifdef DEFINEDvar
|
||||||
stoch_simul;
|
stoch_simul;
|
||||||
|
@#elseif true
|
||||||
|
@#error "ELSEIF PROBLEM"
|
||||||
@#else
|
@#else
|
||||||
@#error "IFDEF PROBLEM"
|
@#error "IFDEF PROBLEM"
|
||||||
@#endif
|
@#endif
|
||||||
|
|
||||||
|
@#if false
|
||||||
|
@#error "IF ERROR"
|
||||||
|
@#elseif false
|
||||||
|
@#error "ELSEIF ERROR"
|
||||||
|
@#elseif defined(DEFINEDvar)
|
||||||
|
@#echo "Good"
|
||||||
|
@#else
|
||||||
|
@#error "ELSE ERROR"
|
||||||
|
@#endif
|
||||||
|
|
||||||
@#define a = 1
|
@#define a = 1
|
||||||
@#define f(x) = x + a
|
@#define f(x) = x + a
|
||||||
@#define a = 2
|
@#define a = 2
|
||||||
|
|
Loading…
Reference in New Issue