You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Dear community, thanks for the nice library. I am not very familiar with parser combinator libraries yet, but I sometimes encounter expressions that get stuck, such as this one:
>>>spaces=regex(r'[ \t]*')
>>>word=regex('[a-zA-Z0-9\-._:%]*')
>>>words=word.sep_by(spaces)
>>>words.parse('ak kjd l lksdjf')
Any guidance on what I'm doing wrong here? Thank you.
The text was updated successfully, but these errors were encountered:
Your example works if you replace the * with a + inside the regexes.
When you use a *, you're saying that an empty string is a valid spaces and also a valid word, and so word.sep_by(spaces) can have an infinite amount of empty words separated by empty spaces as a prefix.
My goodness! I had not thought about that. Thank you. Is there any caveat in leaving * in spaces but remove it from word (i.e. to allow zero or more spaces between them)?
Dear community, thanks for the nice library. I am not very familiar with parser combinator libraries yet, but I sometimes encounter expressions that get stuck, such as this one:
Any guidance on what I'm doing wrong here? Thank you.
The text was updated successfully, but these errors were encountered: