summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRob Hoelz <rob@hoelz.ro>2014-01-12 18:31:39 +0100
committerRob Hoelz <rob@hoelz.ro>2014-01-12 18:31:39 +0100
commitfeb11916dec3048ee8e25f2f1127313d5ad63c3b (patch)
treeb4cee842a770e6551639f881b675b35bf4258b49
parente8591a3594e89e98be2890fd99d12e68a459a840 (diff)
downloadpygments-feb11916dec3048ee8e25f2f1127313d5ad63c3b.tar.gz
Reapply: Add a Perl 6 detection heuristic: my TYPE VAR
-rw-r--r--pygments/lexers/agile.py6
1 files changed, 5 insertions, 1 deletions
diff --git a/pygments/lexers/agile.py b/pygments/lexers/agile.py
index 21363d33..17a0d449 100644
--- a/pygments/lexers/agile.py
+++ b/pygments/lexers/agile.py
@@ -1939,7 +1939,7 @@ class Perl6Lexer(ExtendedRegexLexer):
mimetypes = ['text/x-perl6', 'application/x-perl6']
flags = re.MULTILINE | re.DOTALL | re.UNICODE
- PERL6_IDENTIFIER_RANGE = "['a-zA-Z0-9_:-]"
+ PERL6_IDENTIFIER_RANGE = "['a-zA-Z0-9_:-]" # if you alter this, search for a copy made of it below
PERL6_KEYWORDS = (
'BEGIN', 'CATCH', 'CHECK', 'CONTROL', 'END', 'ENTER', 'FIRST', 'INIT',
@@ -2283,6 +2283,10 @@ class Perl6Lexer(ExtendedRegexLexer):
return 0.91
if re.search(r'sub\s+\w+:\w*[^a-zA-Z0-9{(: ]', text): # Special sub/method syntax (ex. sub postcircumfix:<[ ]>)
return 0.91
+ # XXX I don't like the copy+pasting of PERL6_IDENTIFIER_RANGE from above, but I don't know how to access it
+ # otherwise
+ if re.search(r'my\s+[\'a-zA-Z0-9_:-]+\s+[$@%(]', text): # my TYPE [$scalar|@array|%hash|($list, $of, $vars)]
+ return 0.91
for line in text.splitlines():
if re.match(r'\s*(?:my|our)?\s*module', line): # module declarations