diff options
author | Rob Hoelz <rob@hoelz.ro> | 2013-04-10 18:40:58 +0200 |
---|---|---|
committer | Rob Hoelz <rob@hoelz.ro> | 2013-04-10 18:40:58 +0200 |
commit | 73457e391cd9a84435bf5d9bae756307b7f96d92 (patch) | |
tree | 4aae210ba919d0cc4b7a5099f31d1c69fae48551 /pygments/lexers/agile.py | |
parent | b313b3efabcc4726cc58902a29eef0f32bf14fcf (diff) | |
download | pygments-73457e391cd9a84435bf5d9bae756307b7f96d92.tar.gz |
Automatically escape arguments to _build_word_match
Diffstat (limited to 'pygments/lexers/agile.py')
-rw-r--r-- | pygments/lexers/agile.py | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/pygments/lexers/agile.py b/pygments/lexers/agile.py index 12a3ec5a..143ea919 100644 --- a/pygments/lexers/agile.py +++ b/pygments/lexers/agile.py @@ -2071,10 +2071,10 @@ class Perl6Lexer(ExtendedRegexLexer): def _build_word_match(words, boundary_regex_fragment = None, prefix = '', suffix = ''): if boundary_regex_fragment is None: - return r'\b(' + prefix + r'|'.join(words) + suffix + r')\b' + return r'\b(' + prefix + r'|'.join([ re.escape(x) for x in words]) + suffix + r')\b' else: return r'(?<!' + boundary_regex_fragment + ')' + prefix + '(' + \ - r'|'.join(words) + r')' + suffix + '(?!' + boundary_regex_fragment + ')' + r'|'.join([ re.escape(x) for x in words]) + r')' + suffix + '(?!' + boundary_regex_fragment + ')' def brackets_callback(token_class): def callback(lexer, match, context): @@ -2192,7 +2192,7 @@ class Perl6Lexer(ExtendedRegexLexer): ( r'(?:m|ms|rx)\s*(?P<adverbs>:[\w\s:]+)?\s*(?P<delimiter>(?P<first_char>[^0-9a-zA-Z:\s])(?P=first_char)*)', brackets_callback(String.Regex) ), ( r'(?:s|ss|tr)\s*(?::[\w\s:]+)?\s*/(?:\\\\|\\/|.)*?/(?:\\\\|\\/|.)*?/', String.Regex ), ( r'<[^\s=].*?\S>', String ), - ( _build_word_match([ re.escape(x) for x in PERL6_OPERATORS]), Operator ), + ( _build_word_match(PERL6_OPERATORS), Operator ), ( r'[0-9a-zA-Z_]' + PERL6_IDENTIFIER_RANGE + '*', Name ), ( r"'(\\\\|\\[^\\]|[^'\\])*'", String ), ( r'"(\\\\|\\[^\\]|[^"\\])*"', String ), |