BlueBrain / nmodl

Code Generation Framework For NEURON MODeling Language
https://bluebrain.github.io/nmodl/
Apache License 2.0
57 stars 15 forks source link

Refactor `set_token`. #1428

Open 1uc opened 2 months ago

1uc commented 2 months ago

Currently, one must call set_token in nmodl.yy to have information about where the token appears in the MOD file. Since, it's manual, it's rarely used, and many nodes of the initial AST don't have any token information associated with them.

For example FUNCTION and PROCEDURE blocks have their ModToken set, while NET_RECEIVE doesn't. https://github.com/BlueBrain/nmodl/blob/5abff4fb49b8d00b8903e0b745f805f8169ff6c0/src/parser/nmodl.yy#L1496-L1506

Instead of fixing all occurences using the current API, we could consider changing the ctors for AST nodes such that they expect the ModToken (describing the location) as their first argument, and then the additional arguments. This way the compiler will complain about any omissions.