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

White couldn't combine with set_results_name() #350

Closed
hfudev opened this issue Dec 24, 2021 · 4 comments
Closed

White couldn't combine with set_results_name() #350

hfudev opened this issue Dec 24, 2021 · 4 comments

Comments

@hfudev
Copy link

hfudev commented Dec 24, 2021

from pyparsing import White, alphas, Word

parser = White(' \t').set_results_name('indent') + Word(alphas).set_results_name('word')
print(parser.parse_string('    test'))

would raise:

pyparsing.exceptions.ParseException: Expected <SP><TAB>, found 'test'  (at char 4), (line:1, col:5)

but

from pyparsing import White, alphas, Word

parser = White(' \t') + Word(alphas).set_results_name('word')
print(parser.parse_string('    test'))

would return [' ', 'test']

@hfudev hfudev changed the title White couldn't combine with set_results_name White couldn't combine with set_results_name() Dec 24, 2021
@hfudev
Copy link
Author

hfudev commented Dec 24, 2021

pyparsing version 3.0.6 + python 3.10.1

@ptmcg
Copy link
Member

ptmcg commented Jan 2, 2022

Thanks for reporting this - looks like a bug. Though the whitespace-skipping logic around White expressions is not always intuitive.

@ptmcg
Copy link
Member

ptmcg commented Jan 2, 2022

I think this latest change addresses this issue - thanks for reporting it (It actually turned up a deeper problem with whitespace-skipping around White expressions, so this was a big help)!

@hfudev
Copy link
Author

hfudev commented Jan 4, 2022

@ptmcg 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

2 participants