summaryrefslogtreecommitdiff
path: root/pygments/lexers/perl.py
diff options
context:
space:
mode:
authorGeorg Brandl <georg@python.org>2014-11-06 12:10:16 +0100
committerGeorg Brandl <georg@python.org>2014-11-06 12:10:16 +0100
commit272429a2c5fc178f256a347c9d7642c6667b9a67 (patch)
tree470639542d3fdf82e1f1338cac5b8e0f1a617635 /pygments/lexers/perl.py
parent8b85d2a63069f341498a5feeb1874c11641b8dbc (diff)
downloadpygments-272429a2c5fc178f256a347c9d7642c6667b9a67.tar.gz
Simplify charclasses in a few more modules
Diffstat (limited to 'pygments/lexers/perl.py')
-rw-r--r--pygments/lexers/perl.py36
1 files changed, 18 insertions, 18 deletions
diff --git a/pygments/lexers/perl.py b/pygments/lexers/perl.py
index 728506cb..37ad4cfa 100644
--- a/pygments/lexers/perl.py
+++ b/pygments/lexers/perl.py
@@ -40,10 +40,10 @@ class PerlLexer(RegexLexer):
(r'\{(\\\\|\\[^\\]|[^\\}])*\}[egimosx]*', String.Regex, '#pop'),
(r'<(\\\\|\\[^\\]|[^\\>])*>[egimosx]*', String.Regex, '#pop'),
(r'\[(\\\\|\\[^\\]|[^\\\]])*\][egimosx]*', String.Regex, '#pop'),
- (r'\((\\\\|\\[^\\]|[^\\\)])*\)[egimosx]*', String.Regex, '#pop'),
- (r'@(\\\\|\\[^\\]|[^\\\@])*@[egimosx]*', String.Regex, '#pop'),
- (r'%(\\\\|\\[^\\]|[^\\\%])*%[egimosx]*', String.Regex, '#pop'),
- (r'\$(\\\\|\\[^\\]|[^\\\$])*\$[egimosx]*', String.Regex, '#pop'),
+ (r'\((\\\\|\\[^\\]|[^\\)])*\)[egimosx]*', String.Regex, '#pop'),
+ (r'@(\\\\|\\[^\\]|[^\\@])*@[egimosx]*', String.Regex, '#pop'),
+ (r'%(\\\\|\\[^\\]|[^\\%])*%[egimosx]*', String.Regex, '#pop'),
+ (r'\$(\\\\|\\[^\\]|[^\\$])*\$[egimosx]*', String.Regex, '#pop'),
],
'root': [
(r'\#.*?$', Comment.Single),
@@ -71,11 +71,11 @@ class PerlLexer(RegexLexer):
(r's<(\\\\|\\[^\\]|[^\\>])*>\s*', String.Regex, 'balanced-regex'),
(r's\[(\\\\|\\[^\\]|[^\\\]])*\]\s*', String.Regex,
'balanced-regex'),
- (r's\((\\\\|\\[^\\]|[^\\\)])*\)\s*', String.Regex,
+ (r's\((\\\\|\\[^\\]|[^\\)])*\)\s*', String.Regex,
'balanced-regex'),
(r'm?/(\\\\|\\[^\\]|[^\\/\n])*/[gcimosx]*', String.Regex),
- (r'm(?=[/!\\{<\[\(@%\$])', String.Regex, 'balanced-regex'),
+ (r'm(?=[/!\\{<\[(@%$])', String.Regex, 'balanced-regex'),
(r'((?<==~)|(?<=\())\s*/(\\\\|\\[^\\]|[^\\/])*/[gcimosx]*',
String.Regex),
(r'\s+', Text),
@@ -128,14 +128,14 @@ class PerlLexer(RegexLexer):
(r'(q|qq|qw|qr|qx)\(', String.Other, 'rb-string'),
(r'(q|qq|qw|qr|qx)\[', String.Other, 'sb-string'),
(r'(q|qq|qw|qr|qx)\<', String.Other, 'lt-string'),
- (r'(q|qq|qw|qr|qx)([^a-zA-Z0-9])(.|\n)*?\2', String.Other),
+ (r'(q|qq|qw|qr|qx)([\W_])(.|\n)*?\2', String.Other),
(r'package\s+', Keyword, 'modulename'),
(r'sub\s+', Keyword, 'funcname'),
(r'(\[\]|\*\*|::|<<|>>|>=|<=>|<=|={3}|!=|=~|'
r'!~|&&?|\|\||\.{1,3})', Operator),
(r'[-+/*%=<>&^|!\\~]=?', Operator),
- (r'[\(\)\[\]:;,<>/\?\{\}]', Punctuation), # yes, there's no shortage
- # of punctuation in Perl!
+ (r'[()\[\]:;,<>/?{}]', Punctuation), # yes, there's no shortage
+ # of punctuation in Perl!
(r'(?=\w)', Name, 'name'),
],
'format': [
@@ -159,7 +159,7 @@ class PerlLexer(RegexLexer):
(r'[a-zA-Z_]\w*', Name.Namespace, '#pop')
],
'funcname': [
- (r'[a-zA-Z_]\w*[\!\?]?', Name.Function),
+ (r'[a-zA-Z_]\w*[!?]?', Name.Function),
(r'\s+', Text),
# argument declaration
(r'(\([$@%]*\))(\s*)', bygroups(Punctuation, Text)),
@@ -167,18 +167,18 @@ class PerlLexer(RegexLexer):
(r'.*?\{', Punctuation, '#pop'),
],
'cb-string': [
- (r'\\[\{\}\\]', String.Other),
+ (r'\\[{}\\]', String.Other),
(r'\\', String.Other),
(r'\{', String.Other, 'cb-string'),
(r'\}', String.Other, '#pop'),
- (r'[^\{\}\\]+', String.Other)
+ (r'[^{}\\]+', String.Other)
],
'rb-string': [
- (r'\\[\(\)\\]', String.Other),
+ (r'\\[()\\]', String.Other),
(r'\\', String.Other),
(r'\(', String.Other, 'rb-string'),
(r'\)', String.Other, '#pop'),
- (r'[^\(\)]+', String.Other)
+ (r'[^()]+', String.Other)
],
'sb-string': [
(r'\\[\[\]\\]', String.Other),
@@ -188,11 +188,11 @@ class PerlLexer(RegexLexer):
(r'[^\[\]]+', String.Other)
],
'lt-string': [
- (r'\\[\<\>\\]', String.Other),
+ (r'\\[<>\\]', String.Other),
(r'\\', String.Other),
(r'\<', String.Other, 'lt-string'),
(r'\>', String.Other, '#pop'),
- (r'[^\<\>]+', String.Other)
+ (r'[^<>]+', String.Other)
],
'end-part': [
(r'.+', Comment.Preproc, '#pop')
@@ -518,13 +518,13 @@ class Perl6Lexer(ExtendedRegexLexer):
(r'(?<=~~)\s*/(?:\\\\|\\/|.)*?/', String.Regex),
(r'(?<=[=(,])\s*/(?:\\\\|\\/|.)*?/', String.Regex),
(r'm\w+(?=\()', Name),
- (r'(?:m|ms|rx)\s*(?P<adverbs>:[\w\s:]+)?\s*(?P<delimiter>(?P<first_char>[^0-9a-zA-Z_:\s])'
+ (r'(?:m|ms|rx)\s*(?P<adverbs>:[\w\s:]+)?\s*(?P<delimiter>(?P<first_char>[^\w:\s])'
r'(?P=first_char)*)', brackets_callback(String.Regex)),
(r'(?:s|ss|tr)\s*(?::[\w\s:]+)?\s*/(?:\\\\|\\/|.)*?/(?:\\\\|\\/|.)*?/',
String.Regex),
(r'<[^\s=].*?\S>', String),
(_build_word_match(PERL6_OPERATORS), Operator),
- (r'[0-9a-zA-Z_]' + PERL6_IDENTIFIER_RANGE + '*', Name),
+ (r'\w' + PERL6_IDENTIFIER_RANGE + '*', Name),
(r"'(\\\\|\\[^\\]|[^'\\])*'", String),
(r'"(\\\\|\\[^\\]|[^"\\])*"', String),
],