Skip to content

Commit

Permalink
Fixed bug #31 in many() backtracking
Browse files Browse the repository at this point in the history
  • Loading branch information
vlasovskikh committed Nov 17, 2011
1 parent a17117c commit f955c70
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/funcparserlib/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,7 @@ def __call__(self, tokens, s):
v, s = self.p(tokens, s)
res.append(v)
except _NoParseError, e:
return res, e.state
return res, _State(s.pos, e.state.max)

def ebnf(self):
return u'{ %s }' % self.p
Expand Down
10 changes: 10 additions & 0 deletions tests/test_parsing.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
from nose.tools import eq_
from funcparserlib.parser import a, many

# Issue 31
def test_many_backtracking():
x = a('x')
y = a('y')
expr = many(x + y) + x + x
eq_(expr.parse('xyxyxx'), ([('x', 'y'), ('x', 'y')], 'x', 'x'))

0 comments on commit f955c70

Please sign in to comment.