escape of the memo'd argument

Bug #239344 reported by kmh on 2008-06-12
2
Affects Status Importance Assigned to Milestone
PyMeta
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('ab').apply('broken') == ['c', 'b']

---

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

Allen Short (washort) wrote :

The new input stream implementation fixes this -- I've added your test case to the test suite.

Changed in pymeta:
assignee: nobody → washort
status: New → Fix Released
To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers