vlasovskikh / funcparserlib

Recursive descent parsing library for Python based on functional combinators
https://funcparserlib.pirx.ru
MIT License
338 stars 38 forks source link

Tutorial not working #49

Closed sofianito closed 4 years ago

sofianito commented 7 years ago

Hi!

I'm getting an error at line 47: return reduce(lambda s, (f, x): f(s, x), list, z)

It complains about the ( before f

patrickmesana commented 6 years ago

Anyone using this project?

infectious commented 6 years ago

I asked someone smarter than me and he said to change that line to:

return reduce(lambda x, y: y[0](x, y[1]), list, z)

escalonn commented 6 years ago

The line as written here works in Python 2.x. But parameter tuple unpacking was removed in Python 3. The version here is the equivalent way to write it in Python 3 and also works in Python 2.

The lambda could be written like this to make the comparison clearer lambda s, f_x: f_x[0](s, f_x[1])