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

mutual left recursion not supported #57

Open
rbtcollins opened this issue Nov 17, 2015 · 0 comments
Open

mutual left recursion not supported #57

rbtcollins opened this issue Nov 17, 2015 · 0 comments

Comments

@rbtcollins
Copy link

The OMeta paper describes mutual left recursion as a supported feature, but it appears broken in parsley.

Consider a simple left recursive grammar (this works):

exp = """\
num = <digit+>:n -> int(n)
expr = expr:e "-" num:n -> e - n
     | num
"""
compiled = makeGrammar(exp, {})
print(compiled("4-3").expr())

->

1

Now lets modify the grammar precisely as done in the paper: replacing expr in the expr recursion with another rule x that calls into expr:

exp = """\
num = <digit+>:n -> int(n)
x = expr
expr = x:e "-" num:n -> e - n
     | num
"""
compiled = makeGrammar(exp, {})
print(compiled("4-3").x())

->

Traceback (most recent call last):
  File "./t.py", line 36, in <module>
    print(compiled("4-3").x())
  File "/home/robertc/.virtualenvs/scratch/local/lib/python2.7/site-packages/parsley.py", line 98, in invokeRule
    raise err
ometa.runtime.ParseError: 
4-3
  ^
Parse error at line 1, column 2: expected EOF. trail: [digit]

If run with expr rather than x, the result is the same.

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