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

/ operator only allows single terms #49

Closed
eevee opened this issue Jul 13, 2014 · 1 comment
Closed

/ operator only allows single terms #49

eevee opened this issue Jul 13, 2014 · 1 comment

Comments

@eevee
Copy link

eevee commented Jul 13, 2014

Based on experience with other PEG pargens, I'd think this should work:

>>> from parsimonious import Grammar
>>> Grammar("a = b c / d")
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/eevee/.local/lib/python3.4/site-packages/parsimonious/grammar.py", line 63, in __init__
    exprs, first = self._expressions_from_rules(rules)
  File "/home/eevee/.local/lib/python3.4/site-packages/parsimonious/grammar.py", line 78, in _expressions_from_rules
    tree = rule_grammar.parse(rules)
  File "/home/eevee/.local/lib/python3.4/site-packages/parsimonious/grammar.py", line 83, in parse
    return self.default_rule.parse(text, pos=pos)
  File "/home/eevee/.local/lib/python3.4/site-packages/parsimonious/expressions.py", line 42, in parse
    raise IncompleteParseError(text, node.end, self)
parsimonious.exceptions.IncompleteParseError: Rule 'rules' matched in its entirety, but it didn't consume all the text. The non-matching portion of the text begins with '/ d' (line 1, column 9).

But / is defined with:

or_term = "/" _ term
ored = term or_term+

Wrapping everything in parentheses works, but is a little inconvenient when e.g. parsing a language with operators and trying to consume the whitespace after all of them :)

@erikrose
Copy link
Owner

I agree with you. I'll take care of this as #43. Thanks for the feedback!

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