Skip to content

Anchor BNGL action-name detection to start-of-line#84

Open
wshlavacek wants to merge 1 commit intoRuleWorld:mainfrom
wshlavacek:modelapi-b4-anchor-action-detection
Open

Anchor BNGL action-name detection to start-of-line#84
wshlavacek wants to merge 1 commit intoRuleWorld:mainfrom
wshlavacek:modelapi-b4-anchor-action-detection

Conversation

@wshlavacek
Copy link
Copy Markdown

Summary

`BNGFile._not_action` does an unanchored substring search of action names against each line, so any line that contains an action name as a substring gets pulled out of its block and pushed into the action list. The repeated repro is `conversion()=...` inside a `begin functions` block — the substring `version(` matches the `version` action prefix and the line gets misclassified.

Same pitfall exists for `bifurcate` (any identifier ending in `...ifurcate`), `simulate_ssa` / `simulate_nf` / `simulate_pla` / `simulate_ode` (any expression that mentions one of these names), and `readFile` / `writeFile` (any path or function with the substring).

Fix

Anchor the match to the start of the left-stripped line so user identifiers that look like an action name in the middle of an expression are no longer misclassified. Indentation is still allowed before the action name to match existing behavior.

Test plan

  • Existing CI passes
  • A model containing `conversion()=...` inside `begin functions` parses without losing the function

`BNGFile._not_action` does an unanchored substring search of action
names against each line, so any line that *contains* an action name as
a substring gets pulled out of its block and pushed into the action
list. The repeated repro is `conversion()=...` inside a `begin
functions` block — the substring `version(` matches the `version`
action prefix and the line gets misclassified.

Same pitfall exists for `bifurcate` (any identifier ending in
`...ifurcate`), `simulate_ssa` / `simulate_nf` / `simulate_pla` /
`simulate_ode` (any expression that mentions one of these names), and
`readFile` / `writeFile` (any path or function with the substring).

Fix: anchor the match to the start of the left-stripped line so user
identifiers that look like an action name in the middle of an
expression are no longer misclassified. Indentation is allowed before
the action name to match the existing behavior.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant