summaryrefslogtreecommitdiff
path: root/pygments/lexer.py
diff options
context:
space:
mode:
authorGeorg Brandl <georg@python.org>2020-09-06 14:35:14 +0200
committerGitHub <noreply@github.com>2020-09-06 14:35:14 +0200
commit40baa94a6bf0c62be8c8b03a942116869ce80128 (patch)
tree50eca3f33e60a4bbadd29bf566b294052e509259 /pygments/lexer.py
parented93a2758bdfbeaafc43ac59a611bf2cff92b55c (diff)
downloadpygments-git-40baa94a6bf0c62be8c8b03a942116869ce80128.tar.gz
all: use yield from (#1537)
Diffstat (limited to 'pygments/lexer.py')
-rw-r--r--pygments/lexer.py12
1 files changed, 4 insertions, 8 deletions
diff --git a/pygments/lexer.py b/pygments/lexer.py
index 2f8b2e82..3f0df88e 100644
--- a/pygments/lexer.py
+++ b/pygments/lexer.py
@@ -628,8 +628,7 @@ class RegexLexer(Lexer, metaclass=RegexLexerMeta):
if type(action) is _TokenType:
yield pos, action, m.group()
else:
- for item in action(self, m):
- yield item
+ yield from action(self, m)
pos = m.end()
if new_state is not None:
# state transition
@@ -716,8 +715,7 @@ class ExtendedRegexLexer(RegexLexer):
yield ctx.pos, action, m.group()
ctx.pos = m.end()
else:
- for item in action(self, m, ctx):
- yield item
+ yield from action(self, m, ctx)
if not new_state:
# altered the state stack?
statetokens = tokendefs[ctx.stack[-1]]
@@ -781,8 +779,7 @@ def do_insertions(insertions, tokens):
index, itokens = next(insertions)
except StopIteration:
# no insertions
- for item in tokens:
- yield item
+ yield from tokens
return
realpos = None
@@ -856,8 +853,7 @@ class ProfilingRegexLexer(RegexLexer, metaclass=ProfilingRegexLexerMeta):
def get_tokens_unprocessed(self, text, stack=('root',)):
# this needs to be a stack, since using(this) will produce nested calls
self.__class__._prof_data.append({})
- for tok in RegexLexer.get_tokens_unprocessed(self, text, stack):
- yield tok
+ yield from RegexLexer.get_tokens_unprocessed(self, text, stack)
rawdata = self.__class__._prof_data.pop()
data = sorted(((s, repr(r).strip('u\'').replace('\\\\', '\\')[:65],
n, 1000 * t, 1000 * t / n)