diff options
author | Rob Hoelz <rob@hoelz.ro> | 2014-01-20 18:15:50 +0100 |
---|---|---|
committer | Rob Hoelz <rob@hoelz.ro> | 2014-01-20 18:15:50 +0100 |
commit | dfdc916106cfdf79624adbe9687642145c101356 (patch) | |
tree | 01c5ca424f64a798dec882c68c1ca1de5550f8c2 | |
parent | 58c8c64ec9444d7929460cc5a9c34b78f1739ec7 (diff) | |
parent | 530a95d43b9249585e7ce8b1512fe475ebee8e62 (diff) | |
download | pygments-dfdc916106cfdf79624adbe9687642145c101356.tar.gz |
Merged birkenfeld/pygments-main into default
-rw-r--r-- | pygments/lexers/agile.py | 38 |
1 files changed, 16 insertions, 22 deletions
diff --git a/pygments/lexers/agile.py b/pygments/lexers/agile.py index 89b2d2da..721586a1 100644 --- a/pygments/lexers/agile.py +++ b/pygments/lexers/agile.py @@ -1940,7 +1940,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', @@ -2245,9 +2245,6 @@ class Perl6Lexer(ExtendedRegexLexer): } def analyse_text(text): - # disabled for now; the lexer is not bug-free and will loop sometimes, - # so let's be sure to use it only for "real" Perl 6 code. - return False def strip_pod(lines): in_pod = False stripped_lines = [] @@ -2262,29 +2259,26 @@ class Perl6Lexer(ExtendedRegexLexer): return stripped_lines + # XXX handle block comments lines = text.splitlines() lines = strip_pod(lines) - text = '\n'.join(lines) - if shebang_matches(text, r'perl6|rakudo|niecza'): + if shebang_matches(text, r'perl6|rakudo|niecza|pugs'): return True - if 'use v6' in text: - return 0.91 # 0.01 greater than Perl says for 'my $' - if re.search(r'[$@%]\*[A-Z]+', text): # Perl 6-style globals ($*OS) - return 0.91 - if re.search(r'[$@%]\?[A-Z]+', text): # Perl 6 compiler variables ($?PACKAGE) - return 0.91 - if re.search(r'[$@%][!.][A-Za-z0-9_-]+', text): # Perl 6 member variables - return 0.91 - - for line in text.splitlines(): - if re.match(r'\s*(?:my|our)?\s*module', line): # module declarations - return 0.91 - if re.match(r'\s*(?:my|our)?\s*role', line): # role declarations - return 0.91 - if re.match(r'\s*(?:my|our)?\s*class\b', line): # class declarations - return 0.91 + for line in lines: + line = re.sub('#.*', '', line) + if re.match('^\s*$', line): + continue + + # match v6; use v6; use v6.0; use v6.0.0; + 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): + return True + break + return False def __init__(self, **options): |