def locatedExpr(expr):
 locator = Empty().setParseAction((lambda s, l, t: l))
 return Group(((locator('locn_start') + expr('value')) + locator.copy().leaveWhitespace()('locn_end')))

def locatedExpr ( expr ) : locator = Empty ( ) . setParseAction ( ( lambda s , l , t : l ) ) return Group ( ( ( locator ( 'locn_start' ) + expr ( 'value' ) ) + locator . copy ( ) . leaveWhitespace ( ) ( 'locn_end' ) ) )
helper to decorate a returned token with its starting and ending locations in the input string .