escape of the memo'd argument
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
PyMeta |
Fix Released
|
Undecided
|
Allen Short |
Bug Description
Hi there,
Been playing with pymeta, think it's great. I have encountered a bug that took me some time to track down:
---
from pymeta.grammar import OMeta
TestGrammar = OMeta.makeGrammar(
r'''
memo_arg :arg ::= <anything> ?(False)
trick ::= <letter> <memo_arg 'c'>
broken ::= <trick> | <anything>*
''', {}, name="TestGrammar")
assert TestGrammar(
---
Because arguments are passed on the same stack as input and the 'anything' rule is used to pop them, arguments can get memoized for 'anything' at the previous position and then find their way back into the input at some later application of 'anything'. One simple fix is to not memoize the anything rule - but I wonder why arguments are passed in this way?
kmh
The new input stream implementation fixes this -- I've added your test case to the test suite.