diff options
author | ptmcg <ptmcg@9bf210a0-9d2d-494c-87cf-cfb32e7dff7b> | 2008-07-02 03:00:58 +0000 |
---|---|---|
committer | ptmcg <ptmcg@9bf210a0-9d2d-494c-87cf-cfb32e7dff7b> | 2008-07-02 03:00:58 +0000 |
commit | 94d112a1cc169e357e0dffeba8473e4491cc5ad5 (patch) | |
tree | 6354d186844f0d0bb4ec5a695ceb65026114c052 | |
parent | b53d5bcdf2fc30941806ba507c853a43e06a1600 (diff) | |
download | pyparsing-94d112a1cc169e357e0dffeba8473e4491cc5ad5.tar.gz |
Fixed bug in ParseResults.asXML()
git-svn-id: svn://svn.code.sf.net/p/pyparsing/code/src@160 9bf210a0-9d2d-494c-87cf-cfb32e7dff7b
-rw-r--r-- | CHANGES | 4 | ||||
-rw-r--r-- | pyparsing.py | 12 |
2 files changed, 10 insertions, 6 deletions
@@ -29,6 +29,10 @@ Version 1.5.1 - ???, 2008 the base set of attribute names, plus any results names that are
defined.
+- Fixed bug in ParseResults.asXML(), in which the first named
+ item within a ParseResults gets reported with an <ITEM> tag instead
+ of with the correct results name.
+
Version 1.5.0 - June, 2008
--------------------------
diff --git a/pyparsing.py b/pyparsing.py index 9a6f2f2..40959e1 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.1"
-__versionTime__ = "1 July 2008 16:48"
+__versionTime__ = "1 July 2008 21:54"
__author__ = "Paul McGuire <ptmcg@users.sourceforge.net>"
import string
@@ -256,6 +256,8 @@ class _ParseResultsWithOffset(object): return self.tup[i]
def __repr__(self):
return repr(self.tup)
+ def setOffset(self,i):
+ self.tup = (self.tup[0],i)
class ParseResults(object):
"""Structured parse results, to provide multiple means of access to the parsed data:
@@ -285,9 +287,6 @@ class ParseResults(object): self.__toklist = [toklist]
self.__tokdict = dict()
- # this line is related to debugging the asXML bug
- #~ asList = False
-
if name:
if not modal:
self.__accumNames[name] = 0
@@ -299,9 +298,9 @@ class ParseResults(object): toklist = [ toklist ]
if asList:
if isinstance(toklist,ParseResults):
- self[name] = _ParseResultsWithOffset(toklist.copy(),-1)
+ self[name] = _ParseResultsWithOffset(toklist.copy(),0)
else:
- self[name] = _ParseResultsWithOffset(ParseResults(toklist[0]),-1)
+ self[name] = _ParseResultsWithOffset(ParseResults(toklist[0]),0)
self[name].__name = name
else:
try:
@@ -424,6 +423,7 @@ class ParseResults(object): self[k] = v
if isinstance(v[0],ParseResults):
v[0].__parent = wkref(self)
+
self.__toklist += other.__toklist
self.__accumNames.update( other.__accumNames )
del other
|