summaryrefslogtreecommitdiff
path: root/pyparsing/core.py
diff options
context:
space:
mode:
authorptmcg <ptmcg@austin.rr.com>2022-11-06 17:14:59 -0600
committerptmcg <ptmcg@austin.rr.com>2022-11-06 17:14:59 -0600
commit764dbdc1970e522f5ffe3bd03a0ddb5d1cfcb798 (patch)
tree7f52795bf2da70d68bc7889c2170e3a8b96bf0c6 /pyparsing/core.py
parent6aef782b6d347db134bafa66004c60b42e42e427 (diff)
downloadpyparsing-git-764dbdc1970e522f5ffe3bd03a0ddb5d1cfcb798.tar.gz
Added new class method `ParserElement.using_each`
Diffstat (limited to 'pyparsing/core.py')
-rw-r--r--pyparsing/core.py12
1 files changed, 12 insertions, 0 deletions
diff --git a/pyparsing/core.py b/pyparsing/core.py
index c466dbc..a6858bd 100644
--- a/pyparsing/core.py
+++ b/pyparsing/core.py
@@ -440,6 +440,18 @@ class ParserElement(ABC):
"""
ParserElement._literalStringClass = cls
+ @classmethod
+ def using_each(cls, seq, **class_kwargs):
+ """
+ Yields a sequence of class(obj, **class_kwargs) for obj in seq.
+
+ Example::
+
+ LPAR, RPAR, LBRACE, RBRACE, SEMI = Suppress.using_each("(){};")
+
+ """
+ yield from (cls(obj, **class_kwargs) for obj in seq)
+
class DebugActions(NamedTuple):
debug_try: typing.Optional[DebugStartAction]
debug_match: typing.Optional[DebugSuccessAction]