diff options
author | ptmcg <ptmcg@austin.rr.com> | 2022-11-06 17:14:59 -0600 |
---|---|---|
committer | ptmcg <ptmcg@austin.rr.com> | 2022-11-06 17:14:59 -0600 |
commit | 764dbdc1970e522f5ffe3bd03a0ddb5d1cfcb798 (patch) | |
tree | 7f52795bf2da70d68bc7889c2170e3a8b96bf0c6 /pyparsing/core.py | |
parent | 6aef782b6d347db134bafa66004c60b42e42e427 (diff) | |
download | pyparsing-git-764dbdc1970e522f5ffe3bd03a0ddb5d1cfcb798.tar.gz |
Added new class method `ParserElement.using_each`
Diffstat (limited to 'pyparsing/core.py')
-rw-r--r-- | pyparsing/core.py | 12 |
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] |