Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Introduce an include statement #884

Open
clinssen opened this issue Mar 22, 2023 · 0 comments · May be fixed by #1121
Open

Introduce an include statement #884

clinssen opened this issue Mar 22, 2023 · 0 comments · May be fixed by #1121

Comments

@clinssen
Copy link
Contributor

clinssen commented Mar 22, 2023

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.

@clinssen clinssen changed the title Introduce an import or include statement Introduce an include statement Oct 7, 2024
@pnbabu pnbabu linked a pull request Oct 7, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant