summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormitsuhiko <devnull@localhost>2008-12-12 17:21:16 +0100
committermitsuhiko <devnull@localhost>2008-12-12 17:21:16 +0100
commitda7aa55d735be6825d36f73ee0e1155b0a8c002c (patch)
treec8e7f0c1ab3c785b9e27672cce0c126aa20252b5
parent93c82907d3684fda2555ca050e77c940565b2f1e (diff)
downloadpygments-da7aa55d735be6825d36f73ee0e1155b0a8c002c.tar.gz
Fixed a bug with ruby strings like this:
%Q_foo\_bar#{"hello".monkeypatched_method(:foo, :bar, "blah #{bleh}")}\_baz_.upcase! This is an experimental checkin because it slows down the string lexing. If it's too slow i'll revert this changeset.
-rw-r--r--pygments/lexers/agile.py20
1 files changed, 10 insertions, 10 deletions
diff --git a/pygments/lexers/agile.py b/pygments/lexers/agile.py
index f235d8cf..0ca1139f 100644
--- a/pygments/lexers/agile.py
+++ b/pygments/lexers/agile.py
@@ -509,8 +509,8 @@ class RubyLexer(ExtendedRegexLexer):
(r'"', String.Double, 'simple-string'),
(r'(?<!\.)`', String.Backtick, 'simple-backtick'),
]
- # double-quoted string and symbol
+ # double-quoted string and symbol
for name, ttype, end in ('string', String.Double, '"'), \
('sym', String.Symbol, '"'), \
('backtick', String.Backtick, '`'):
@@ -522,7 +522,6 @@ class RubyLexer(ExtendedRegexLexer):
]
# braced quoted strings
-
for lbrace, rbrace, name in ('\\{', '\\}', 'cb'), \
('\\[', '\\]', 'sb'), \
('\\(', '\\)', 'pa'), \
@@ -560,20 +559,21 @@ class RubyLexer(ExtendedRegexLexer):
# these must come after %<brace>!
states['strings'] += [
# %r regex
- (r'(%r(.))(.*?)(\2[mixounse]*)', intp_regex_callback),
- # regular fancy strings
- (r'%[qsw](.).*?\1', String.Other),
- (r'(%[QWx](.))(.*?)(\2)', intp_string_callback),
+ (r'(%r([^a-zA-Z0-9]))([^\2\\]*(?:\\.[^\2\\]*)*)(\2[mixounse]*)',
+ intp_regex_callback),
+ # regular fancy strings with qsw
+ (r'%[qsw]([^a-zA-Z0-9])([^\1\\]*(?:\\.[^\1\\]*)*)\1', String.Other),
+ (r'(%[QWx]([^a-zA-Z0-9]))([^\2\\]*(?:\\.[^\2\\]*)*)(\2)', intp_string_callback),
# special forms of fancy strings after operators or
# in method calls with braces
- (r'(?<=[-+/*%=<>&!^|~,(])(\s*)(%([\t ]).*?\3)',
+ (r'(?<=[-+/*%=<>&!^|~,(])(\s*)(%([\t ])(?:[^\3\\]*(?:\\.[^\3\\]*)*)\3)',
bygroups(Text, String.Other, None)),
# and because of fixed with lookbehinds the whole thing a
# second time for line startings...
- (r'^(\s*)(%([\t ]).*?\3)',
+ (r'^(\s*)(%([\t ])(?:[^\3\\]*(?:\\.[^\3\\]*)*)\3)',
bygroups(Text, String.Other, None)),
- # all regular fancy strings
- (r'(%([^a-zA-Z0-9\s]))(.*?)(\2)', intp_string_callback),
+ # all regular fancy strings without qsw
+ (r'(%([^a-zA-Z0-9\s]))([^\2\\]*(?:\\.[^\2\\]*)*)(\2)', intp_string_callback),
]
return states