Commits

Rob Hoelz committed c0cba73

Perl 6: Use my/our/has as a hint

  • Participants
  • Parent commits aea6d85

Comments (0)

Files changed (1)

pygments/lexers/agile.py

         # XXX handle block comments
         lines = text.splitlines()
         lines = strip_pod(lines)
+        text  = '\n'.join(lines)
 
         if shebang_matches(text, r'perl6|rakudo|niecza|pugs'):
             return True
 
+        saw_perl_decl = False
+        # check for my/our/has declarations
+        # copied PERL6_IDENTIFIER_RANGE from above; not happy about that
+        if re.search("(?:my|our|has)\s+(?:['a-zA-Z0-9_:-]+\s+)?[$@%&(]", text):
+            saw_perl_decl = True
+
         for line in lines:
             line = re.sub('#.*', '', line)
             if re.match('^\s*$', line):
             if re.match('^\s*(?:use\s+)?v6(?:\.\d(?:\.\d)?)?;', line):
                 return True
             # match class, module, role, enum, grammar declarations
-            if re.match('^\s*(?:(?:my|our)\s+)?(?:module|class|role|enum|grammar)', line):
+            if saw_perl_decl and re.match('^\s*(?:(?:my|our)\s+)?(?:module|class|role|enum|grammar)', line):
                 return True
             break