Skip to content

Accept trailing whitespace between \ and newline in line continuations#85

Merged
jrfaeder merged 4 commits into
RuleWorld:mainfrom
wshlavacek:modelapi-b4-trailing-whitespace-continuation
May 11, 2026
Merged

Accept trailing whitespace between \ and newline in line continuations#85
jrfaeder merged 4 commits into
RuleWorld:mainfrom
wshlavacek:modelapi-b4-trailing-whitespace-continuation

Conversation

@wshlavacek
Copy link
Copy Markdown
Contributor

Summary

`BNGFile.strip_actions` collapses `\` continuations before stripping action lines, but the regex `r"\\n"` rejects shapes like:

```
method=>"ode",<space>
```

which appear in real-world BNGL. BNG2.pl tolerates trailing whitespace between the `\` and the newline; the modelapi parser should too.

Fix

Loosen the regex to `r"\[ \t]*\n"`.

Note on conflict with #79

This PR and #79 ("Don't collapse `\` continuations inside commented BNGL lines") both modify the same line. Logically the two fixes compose — the combined regex would be `r"^([^#\n])\[ \t]\n"` with MULTILINE — but I've kept them as separate PRs per the audit's split guidance. Whichever lands first, the other can rebase trivially.

Test plan

  • Existing CI passes
  • A model with `...,\...` no longer drops the continuation line on the floor

wshlavacek and others added 4 commits May 10, 2026 17:17
`BNGFile.strip_actions` collapses `\<newline>` continuations before
stripping action lines, but the regex `r"\\\n"` rejects shapes like

    method=>"ode",\<space><newline>

which appear in real-world BNGL. BNG2.pl tolerates trailing whitespace
between the `\` and the newline; the modelapi parser should too.

Fix: loosen the regex to `r"\\[ \t]*\n"`.
Resolved conflict by combining:
- Comment-aware continuation handling from main (don't collapse backslashes in comments)
- Trailing whitespace tolerance from this PR
@jrfaeder jrfaeder merged commit 88ca3cf into RuleWorld:main May 11, 2026
17 checks passed
@wshlavacek wshlavacek deleted the modelapi-b4-trailing-whitespace-continuation branch May 11, 2026 17:07
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.

2 participants