From ca79012fce104827e80a3ba2d9cb5fb1d8058914 Mon Sep 17 00:00:00 2001 From: ptmcg Date: Thu, 24 Jun 2010 11:08:54 +0000 Subject: Add fix to originalTextFor to not include any trailing comments or ignorable text git-svn-id: svn://svn.code.sf.net/p/pyparsing/code/src@200 9bf210a0-9d2d-494c-87cf-cfb32e7dff7b --- pyparsing.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'pyparsing.py') diff --git a/pyparsing.py b/pyparsing.py index cf49b36..b97c5ec 100644 --- a/pyparsing.py +++ b/pyparsing.py @@ -59,7 +59,7 @@ The pyparsing module handles some of the problems that are typically vexing when """ __version__ = "1.5.3" -__versionTime__ = "15 Jun 2010 02:21" +__versionTime__ = "24 Jun 2010 06:06" __author__ = "Paul McGuire " import string @@ -3332,8 +3332,10 @@ def originalTextFor(expr, asString=True): the expression passed to originalTextFor contains expressions with defined results names, you must set asString to False if you want to preserve those results name values.""" - locMarker = Empty().setParseAction(lambda s,loc,t: loc).leaveWhitespace() - matchExpr = locMarker("_original_start") + expr + locMarker("_original_end") + locMarker = Empty().setParseAction(lambda s,loc,t: loc) + endlocMarker = locMarker.copy() + endlocMarker.callPreparse = False + matchExpr = locMarker("_original_start") + expr + endlocMarker("_original_end") if asString: extractText = lambda s,l,t: s[t._original_start:t._original_end] else: -- cgit v1.2.1