Open
Description
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.
Metadata
Metadata
Assignees
Labels
No labels