Forward() and leaveWhitespace() do not work together
Brought to you by:
ptmcg
Try running the following test script:
from pyparsing import * x = OneOrMore( Regex(".") ) x.leaveWhitespace() print( x.parseString("x x") ) x = Forward() x << OneOrMore( Regex(".") ) x.leaveWhitespace() print( x.parseString("x x") ) x = Forward() x.leaveWhitespace() x << OneOrMore( Regex(".") ) print( x.parseString("x x") )
Expected behavior: ['x', ' ', 'x'] printed three times
Observed behavior: ['x', ' ', 'x'] printed once, ['x', 'x'] printed twice.
It appears that leaveWhitespace() has no effect when called on a Forward object.
Checking Google finds older code (from like 2006) where people where using leaveWhitespace on a Forward(), so apparently this worked at one time.
I should have mentioned, I saw this running 2.0.3, however I did an easy_install -U and upgraded to 2.0.6 and I still see the problem.