Commits

Rob Hoelz  committed 48a6fde

Reapply: Add a Perl 6 detection heuristic: my TYPE VAR

  • Participants
  • Parent commits bec3eb9

Comments (0)

Files changed (1)

File pygments/lexers/agile.py

     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',
             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