Commits

Rob Hoelz committed a68efa8

Perl 6: Pick up on Perl 6-style class declarations

We recognize them as Perl 6 style if we've seen a Perl-style variable
declaration or if it's preceded with a Perl-style scope modifier

Comments (0)

Files changed (1)

pygments/lexers/agile.py

             if re.match('^\s*(?:use\s+)?v6(?:\.\d(?:\.\d)?)?;', line):
                 return True
             # match class, module, role, enum, grammar declarations
-            if saw_perl_decl and re.match('^\s*(?:(?:my|our)\s+)?(?:module|class|role|enum|grammar)', line):
+            class_decl = re.match('^\s*(?:(?P<scope>my|our)\s+)?(?:module|class|role|enum|grammar)', line)
+            if class_decl and (saw_perl_decl or class_decl.group('scope') is not None):
                 return True
             break