-
-
Notifications
You must be signed in to change notification settings - Fork 264
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
one or more
rules consume trailing whitespace when exactly matched once
#396
Comments
one or more
rules consume trailing whitespaceone or more
rules consume trailing whitespace when exactly matched once
After looking through the code, I'd say this is because E.g. for pest, |
Proposed fix in #397. |
Ah, finally. I knew this day was going to come. Unfortunately, this implementation bug is probably something that people make use of in their logic. Fixing this might actually break them, but I'm happy to give it a try regardless maybe there's no actual dependee that uses it. I have a fix for 3.0, but I haven't had that much time to work on it. |
the end of rule whitespace handling is weird and inconsistent, see pest-parser/pest#396 and pest-parser/pest#519
This just bit us. Are there still plans to resolve this? Is there evidence that people rely on this bug? And lastly, is there a good workaround? The obvious idea would be to strip the white space off of everything pest returns, but I suspect there is a more elegant way, since otherwise there probably would be more people commenting here. In our case we are having trouble to parse data in the format "x <- foo" (see this page). Also, otherwise we are having a great time using pest, thank you! Update: I found a satisfying workaround, documented here for future visitors. Instead of
I now use
where |
the fix was feature-guarded with "grammar-extras" in order to keep the semver compatibility. plus a test was added. Closes pest-parser#396 Co-authored-by: Emanuel Joebstl <[email protected]>
Given the following grammar:
Then, parsing the following text:
Will associate the trailing newline after
b
with the rule fora
, instead of the the rule forroot
.That seems to work properly with
zero-or-more
expressions, where the whitespace will be associated with theroot
rule.Also, it works properly for more than one
b
. The following example:Puts the whitespace correctly inside root.
The text was updated successfully, but these errors were encountered: