Skip to content
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

pp.White skips preceding whitespace characters even if characters removed from default (from issue #350 resolution) #359

Open
cgevans opened this issue Jan 26, 2022 · 2 comments

Comments

@cgevans
Copy link

cgevans commented Jan 26, 2022

From revision 1ccf846 onward (the fix to #350), if the default whitespace characters are removed, for example, if there are no default whitespace characters, pp.White(ws) appears to skip over characters in " \t\n\r" to consume ws even if those characters are not in ws and not in the default whitespace characters.

import pyparsing as pp
pp.ParserElement.setDefaultWhitespaceChars("")

("a" + pp.White(" ") + "c").parseString("a\n c")  # Matches, should not.
#[Out]# ParseResults(['a', ' ', 'c'], {})

("a" + pp.White("\n") + "c").parseString("a\nc")  # Matches, should.
#[Out]# ParseResults(['a', '\n', 'c'], {})

("a" + pp.White("\n") + "c").parseString("a \nc")  # Matches, should not.
#[Out]# ParseResults(['a', '\n', 'c'], {})

("a" + pp.White("\n") + "c").parseString("a \n c")  # Does not match, should not.

("a" + pp.White("\n") + "c").parseString("a\n c")  # Does not match, should not.

(This is with Python 3.10.2, pyparsing 1ccf846 up to 938f59d)

@cgevans cgevans changed the title pp.White skips preceding whitespace characters even if characters removed from default (from issue #350 resolution) pp.White skips preceding whitespace characters even if characters removed from default, matches only some characters (from issue #350 resolution) Jan 26, 2022
cgevans added a commit to cgevans/qslib that referenced this issue Jan 26, 2022
@cgevans cgevans changed the title pp.White skips preceding whitespace characters even if characters removed from default, matches only some characters (from issue #350 resolution) pp.White skips preceding whitespace characters even if characters removed from default (from issue #350 resolution) Jan 26, 2022
@ptmcg
Copy link
Member

ptmcg commented Jan 31, 2022

Thanks for posting, will take me a bit to sift through. The White class has always been an oddity in pyparsing, given that it has to look for spaces that are ignored by most of the rest of the package.

@SamZhangQingChuan
Copy link

Hi @ptmcg. I am wondering if there is any update on this issue? This has cause issues in the pyhocon package. Many thanks!

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

No branches or pull requests

3 participants