Skip to content

expr1 | expr2 not working as expected #74

Open
@geuben

Description

@geuben

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.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions