summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorptmcg <ptmcg@9bf210a0-9d2d-494c-87cf-cfb32e7dff7b>2008-10-01 00:07:18 +0000
committerptmcg <ptmcg@9bf210a0-9d2d-494c-87cf-cfb32e7dff7b>2008-10-01 00:07:18 +0000
commitf8564e0b077a21fc7f5469bd72ac87f484b67d5c (patch)
tree0ad8484de13dc1f9223fab2fbc9c9e12287dcd67
parent2b0887193fc9d87431b7d1630fc5323c040d5f32 (diff)
downloadpyparsing-f8564e0b077a21fc7f5469bd72ac87f484b67d5c.tar.gz
Fix nestedExpr behavior if multi-character expression delimiters are used.
git-svn-id: svn://svn.code.sf.net/p/pyparsing/code/src@165 9bf210a0-9d2d-494c-87cf-cfb32e7dff7b
-rw-r--r--CHANGES6
-rw-r--r--pyparsing.py13
2 files changed, 13 insertions, 6 deletions
diff --git a/CHANGES b/CHANGES
index 67f3aac..731a37c 100644
--- a/CHANGES
+++ b/CHANGES
@@ -27,7 +27,11 @@ Version 1.5.1 - September, 2008
skipped text, will cause SkipTo to fail. Useful to prevent
SkipTo from reading past terminating expression. Instigated by
question posed by Aki Niimura on the pyparsing wiki.
-
+
+- Fixed bug in nestedExpr if multi-character expressions are given
+ for nesting delimiters. Patch provided by new pyparsing user,
+ Hans-Martin Gaudecker - thanks, H-M!
+
- Removed dependency on xml.sax.saxutils.escape, and included
internal implementation instead - proposed by Mike Droettboom on
the pyparsing mailing list, thanks Mike! Also fixed erroneous
diff --git a/pyparsing.py b/pyparsing.py
index 849d6e0..5df7326 100644
--- a/pyparsing.py
+++ b/pyparsing.py
@@ -59,12 +59,13 @@ The pyparsing module handles some of the problems that are typically vexing when
"""
__version__ = "1.5.1"
-__versionTime__ = "3 September 2008 08:23"
+__versionTime__ = "30 September 2008 19:03"
__author__ = "Paul McGuire <ptmcg@users.sourceforge.net>"
import string
from weakref import ref as wkref
-import copy,sys
+import copy
+import sys
import warnings
import re
import sre_constants
@@ -3522,11 +3523,13 @@ def nestedExpr(opener="(", closer=")", content=None, ignoreExpr=quotedString):
if content is None:
if isinstance(opener,basestring) and isinstance(closer,basestring):
if ignoreExpr is not None:
- content = (Combine(OneOrMore(~ignoreExpr +
- CharsNotIn(opener+closer+ParserElement.DEFAULT_WHITE_CHARS,exact=1))
+ content = (Combine(OneOrMore(~ignoreExpr + ~Literal(opener) + ~Literal(closer) +
+ CharsNotIn(ParserElement.DEFAULT_WHITE_CHARS,exact=1))
).setParseAction(lambda t:t[0].strip()))
else:
- content = (empty+CharsNotIn(opener+closer+ParserElement.DEFAULT_WHITE_CHARS).setParseAction(lambda t:t[0].strip()))
+ content = (empty + ~Literal(opener) + ~Literal(closer) +
+ CharsNotIn(ParserElement.DEFAULT_WHITE_CHARS)
+ ).setParseAction(lambda t:t[0].strip())
else:
raise ValueError("opening and closing arguments must be strings if no content expression is given")
ret = Forward()