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

Parsing spaces in a string with Choices #57

Open
luzhengyang opened this issue Mar 26, 2022 · 1 comment
Open

Parsing spaces in a string with Choices #57

luzhengyang opened this issue Mar 26, 2022 · 1 comment

Comments

@luzhengyang
Copy link

Hi, I love your work and I have question about parse a string which has spaces using Choices.
For example, I have create a grammar

grammar Weather
      root  <-  'the weather is' ('good' / 'nice')

This will not correctly parse the sentence "the weather is good" because there is a space between "the weather is" and "good". I have to add a space after the weather is in the grammar in order to parse the sentence.

grammar Weather
      root  <-  'the weather is ' ('good' / 'nice')

I'm wondering if there is a better way of doing this.

@jcoglan
Copy link
Owner

jcoglan commented Mar 30, 2022

No, that's exactly how you're supposed to do this. Spaced aren't special, they need including in rules just as you would any other kind of character.

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