Don't collapse \ continuations inside commented BNGL lines#79
Open
wshlavacek wants to merge 1 commit intoRuleWorld:mainfrom
Open
Don't collapse \ continuations inside commented BNGL lines#79wshlavacek wants to merge 1 commit intoRuleWorld:mainfrom
\ continuations inside commented BNGL lines#79wshlavacek wants to merge 1 commit intoRuleWorld:mainfrom
Conversation
`BNGFile.strip_actions` folds trailing-backslash line continuations before
the action parser sees them, but the previous regex didn't respect
comments: a commented-out
# foo()=if(t<42,0,\
immediately above a live
foo()=if(t<42,9.899,\
glued both into the comment, and the live definition silently
disappeared from the rendered `.bngl` (and from any `.net` BNG2.pl
generated downstream).
Fix: anchor the regex to start-of-line and require no `#` between that
and the trailing `\` — comment lines keep their continuation markers as
part of the comment body, which is what BNG2.pl itself does.
2 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
`BNGFile.strip_actions` folds trailing-backslash line continuations before the action parser sees them, but the regex doesn't currently respect comments. A commented-out
```
foo()=if(t<42,0,\
glues both into the comment, and the live definition silently disappears from the rendered `.bngl` (and from any `.net` BNG2.pl generates downstream).
Fix
Anchor the regex to start-of-line and require no `#` between that and the trailing `\` — comment lines keep their continuation markers as part of the comment body, which is what BNG2.pl itself does.
```python
mstr = re.sub(r"^([^#\n]*)\\n", r"\1", mstr, flags=re.MULTILINE)