I am writing a parser to parse mathematical expressions, which contain variables among other things. I want a list of all the captured variables. But I am only getting the last captured variable. Below is a minimal example to show the problem.
>>> from pyparsing import *
>>> var = Word(alphas)
>>> expr = Forward()
>>> expr << var('var') + ZeroOrMore(Literal('+') + expr)
>>> foo = expr.parseString("x + y + z")
>>> foo
(['x', '+', 'y', '+', 'z'], {'var': [('x', 0), ('y', 2), ('z', 4)]})
>>> foo['var']
'z'
I was expecting ['x', 'y', 'z']. I am using pyparsing version 2.1.