Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
dynare
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Camilo Marchesini
dynare
Commits
5994321c
Verified
Commit
5994321c
authored
Aug 19, 2019
by
Houtan Bastani
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
preprocessor: submodule update
parent
776792e1
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
30 additions
and
9 deletions
+30
-9
doc/manual/source/the-model-file.rst
doc/manual/source/the-model-file.rst
+14
-5
preprocessor
preprocessor
+1
-1
tests/example1_macro.mod
tests/example1_macro.mod
+15
-3
No files found.
doc/manual/source/the-model-file.rst
View file @
5994321c
...
...
@@ -10313,7 +10313,7 @@ directives are:
* ``@#includepath``, paths to search for files that are to be included,
* ``@#include``, for file inclusion,
* ``@#define``, for defining a macro processor variable,
*
``@#
if
,
@#
ifdef
,
@#
ifndef
,
@#
else
,
@#
endif
``
for
conditional
statements
,
* ``@#if, @#ifdef, @#ifndef, @#else
if, @#else
, @#endif`` for conditional statements,
* ``@#for, @#endfor`` for constructing loops.
The macro processor maintains its own list of variables (distinct from model
...
...
@@ -10629,20 +10629,29 @@ Macro directives
.. macrodir:: @#if MACRO_EXPRESSION
@#ifdef MACRO_VARIABLE
@#ifndef MACRO_VARIABLE
@#elseif MACRO_EXPRESSION
@#else
@#endif
|br| Conditional inclusion of some part of the ``.mod`` file. The lines
between
``@#
if
``,
``@#
ifdef
``,
or
``@#
ifndef
``
and
the
next
``@#
else
``
or
``@#
endif
``
is
executed
only
if
the
condition
evaluates
to
``
true
``.
The
``@#
else
``
branch
is
optional
and
,
if
present
,
is
only
evaluated
if
the
condition
evaluates
to
``
false
``.
between ``@#if``, ``@#ifdef``, or ``@#ifndef`` and the next ``@#elseif``,
``@#else`` or ``@#endif`` is executed only if the condition evaluates to
``true``. Following the ``@#if`` body, you can zero or more ``@#elseif``
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``
if the MACRO_VARIABLE has been previously defined, regardless of its
value. Conversely, ``@#ifndef`` will evaluate to true if the MACRO_VARIABLE
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
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
...
...
preprocessor
@
588896b5
Compare
75b000a0
...
588896b5
Subproject commit
75b000a0b5f36893e2d32d97abcfe17bc1a3f71
b
Subproject commit
588896b5091ddee650a9548088a2df164df5c22
b
tests/example1_macro.mod
View file @
5994321c
...
...
@@ -95,9 +95,9 @@ e = 0;
u = 0;
end;
@#define DEFINED=0
@#define DEFINED
var
=0
@#ifndef DEFINED
@#ifndef DEFINED
var
@#error "IFNDEF PROBLEM"
@#else
shocks;
...
...
@@ -107,12 +107,24 @@ var e, u = phi*0.009*0.009;
end;
@#endif
@#ifdef DEFINED
@#ifdef DEFINED
var
stoch_simul;
@#elseif true
@#error "ELSEIF PROBLEM"
@#else
@#error "IFDEF PROBLEM"
@#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 f(x) = x + a
@#define a = 2
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment