summaryrefslogtreecommitdiff
path: root/pyparsing/helpers.py
diff options
context:
space:
mode:
authorMarcin Jaworski <mrjaworski@gmail.com>2020-05-03 19:15:23 +0200
committerGitHub <noreply@github.com>2020-05-03 12:15:23 -0500
commit827f615719ae83800e4252593da5b9d05a97e11a (patch)
treec43a0088378fb0bf2b0381788394f21461949701 /pyparsing/helpers.py
parent39934574db9796f27397b9f76a112c2466bd1a69 (diff)
downloadpyparsing-git-827f615719ae83800e4252593da5b9d05a97e11a.tar.gz
Pop counter token and return rest instead of dropping all tokens in countedArray (#209)
* Pop counter token and return rest instead of dropping all tokens * Include only named results from intExpr in countedArray results * Remove internal Group from countedArray * Fix operator precedence * Update countedArray tests
Diffstat (limited to 'pyparsing/helpers.py')
-rw-r--r--pyparsing/helpers.py5
1 files changed, 3 insertions, 2 deletions
diff --git a/pyparsing/helpers.py b/pyparsing/helpers.py
index d710d78..97e5943 100644
--- a/pyparsing/helpers.py
+++ b/pyparsing/helpers.py
@@ -55,8 +55,9 @@ def countedArray(expr, intExpr=None):
def countFieldParseAction(s, l, t):
n = t[0]
- arrayExpr << (n and Group(And([expr] * n)) or Group(empty))
- return []
+ arrayExpr << (And([expr] * n) if n else empty)
+ # clear list contents, but keep any named results
+ del t[:]
if intExpr is None:
intExpr = Word(nums).setParseAction(lambda t: int(t[0]))