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

expr1 | expr2 not working as expected #74

Open
geuben opened this issue Sep 27, 2018 · 0 comments
Open

expr1 | expr2 not working as expected #74

geuben opened this issue Sep 27, 2018 · 0 comments

Comments

@geuben
Copy link

geuben commented Sep 27, 2018

I am experiencing some oddities with using or expressions. I have replicated it with a trivial example:

import parsley

x = parsley.makeGrammar(
    """
    away_we_go = ('away we go' | 'off and running') -> "away_we_go"
    back_underway = ('back underway' | 'back under way') -> "back_underway"
    all = (anything*) -> "all"
    foo = away_we_go | back_underway | all
    """,
    {}
)

print x("giorenagoirhger").foo()            # all
print x("giorena goirhger").foo()           # all
print x("away we go").foo()                 # away_we_go
print x("back underway").foo()              # back_underway
print x("go").foo()                         # all
print x("lets go").foo()                    # all
print x("we are back under way go").foo()   # all
print x("we are back under way").foo()      # all
print x("back under way go").foo()          # ERROR
Traceback (most recent call last):
  File "process/tests/parsley_test.py", line 21, in <module>
    print x("back under way go").foo()          # ERROR
  File "/Users/reuben/.virtualenvs/processor/lib/python2.7/site-packages/parsley.py", line 98, in invokeRule
    raise err
ometa.runtime.ParseError:
back under way go
 ^
Parse error at line 1, column 1: expected EOF. trail: []

unless I am mistaken "back under way go" should fail to match the away_we_go pattern and the back_underway pattern and then match the all pattern.

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

1 participant