summaryrefslogtreecommitdiff
path: root/pygments/lexers/agile.py
diff options
context:
space:
mode:
authorRob Hoelz <rob@hoelz.ro>2012-12-23 00:45:47 +0100
committerRob Hoelz <rob@hoelz.ro>2012-12-23 00:45:47 +0100
commit0e8dcebae2a71128a47f6e3ce061a3e3fab49a75 (patch)
tree850984f4f94560a6067c3ad5b7818211627b9cbb /pygments/lexers/agile.py
parente148dda6a6a824379a53f3f380d458816c201485 (diff)
downloadpygments-0e8dcebae2a71128a47f6e3ce061a3e3fab49a75.tar.gz
Use str.find to locate end of comment/bracketed string
Diffstat (limited to 'pygments/lexers/agile.py')
-rw-r--r--pygments/lexers/agile.py22
1 files changed, 10 insertions, 12 deletions
diff --git a/pygments/lexers/agile.py b/pygments/lexers/agile.py
index b4713748..505c7df6 100644
--- a/pygments/lexers/agile.py
+++ b/pygments/lexers/agile.py
@@ -2027,29 +2027,27 @@ class Perl6Lexer(ExtendedRegexLexer):
# XXX this could be more efficient, but is fine for now
index = Perl6Lexer.PERL6_OPEN_BRACKET_CHARS.index(match.group(1))
closing_char = Perl6Lexer.PERL6_CLOSE_BRACKET_CHARS[index]
- pos = match.start()
text = context.text
- text_length = len(text)
+ end_pos = text.find(closing_char, match.start() + len(match.group(1)))
- while pos < text_length and text[pos] != closing_char:
- pos += 1
+ if end_pos == -1:
+ end_pos = len(text)
- yield match.start(), Comment.Multiline, text[match.start() : pos + 1]
- context.pos = pos + 1
+ yield match.start(), Comment.Multiline, text[match.start() : end_pos + 1]
+ context.pos = end_pos + 1
def bracketed_string_callback(lexer, match, context):
# XXX this could be more efficient, but is fine for now
index = Perl6Lexer.PERL6_OPEN_BRACKET_CHARS.index(match.group(1))
closing_char = Perl6Lexer.PERL6_CLOSE_BRACKET_CHARS[index]
- pos = match.start()
text = context.text
- text_length = len(text)
+ end_pos = text.find(closing_char, match.start() + len(match.group(1)))
- while pos < text_length and text[pos] != closing_char:
- pos += 1
+ if end_pos == -1:
+ end_pos = len(text)
- yield match.start(), String, text[match.start() : pos + 1]
- context.pos = pos + 1
+ yield match.start(), String, text[match.start() : end_pos + 1]
+ context.pos = end_pos + 1
tokens = {
'root' : [