-
Notifications
You must be signed in to change notification settings - Fork 54
Description
Introduce an include
statement that allows one NESTML file to be included into another.
For simplicity, this should be just a verbatim (C preprocessor #include
style) textual include. (Hence, we choose the name include
rather than import
.)
Example:
model_XYZ.nestml
:
parameters:
a mV = 42 mV
model_FOO.nestml
:
parameters:
b mV = -2 mV
model_full.nestml
:
model foo:
include "model_XYZ.nestml"
include "model_FOO.nestml"
state:
c mV = a + b
Use this to deduplicate/modularize code for postsynaptic response shapes and refractory mechanism in neurons.
The include
statement should be able to appear at any indentation level. For instance, you could do an include "root_finding.nestml"
inside the update
block of a model.
This means that the ModelParser has to be able to parse the included .nestml file at different points of the grammar: as a modelBody, or as an Expression, or as a Statement, etc. We could achieve this by trying to parse these different elements one by one and wrapping them in a series of try..except blocks. So there would be a (for example) ModelParser.parse_included_file(filename)
. The ASTNode returned from there should be plugged into the place in the parent where the include
statement appears.