escape of the memo'd argument

Bug #239344 reported by kmh
2
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('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

Revision history for this message
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  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.