diff options
Diffstat (limited to 'pygments/lexers/agile.py')
-rw-r--r-- | pygments/lexers/agile.py | 30 |
1 files changed, 14 insertions, 16 deletions
diff --git a/pygments/lexers/agile.py b/pygments/lexers/agile.py index 662f8b7e..22fd2dbc 100644 --- a/pygments/lexers/agile.py +++ b/pygments/lexers/agile.py @@ -12,7 +12,7 @@ import re from pygments.lexer import Lexer, RegexLexer, ExtendedRegexLexer, \ - LexerContext, include, combined, do_insertions, bygroups, using + LexerContext, include, combined, do_insertions, bygroups, using, this from pygments.token import Error, Text, Other, \ Comment, Operator, Keyword, Name, String, Number, Generic, Punctuation from pygments.util import get_bool_opt, get_list_opt, shebang_matches @@ -174,7 +174,7 @@ class PythonLexer(RegexLexer): } def analyse_text(text): - return shebang_matches(text, r'pythonw?(2\.\d)?') + return shebang_matches(text, r'pythonw?(2(\.\d)?)?') class Python3Lexer(RegexLexer): @@ -484,11 +484,11 @@ class RubyLexer(ExtendedRegexLexer): def gen_rubystrings_rules(): def intp_regex_callback(self, match, ctx): - yield match.start(1), String.Regex, match.group(1) # begin + yield match.start(1), String.Regex, match.group(1) # begin nctx = LexerContext(match.group(3), 0, ['interpolated-regex']) for i, t, v in self.get_tokens_unprocessed(context=nctx): yield match.start(3)+i, t, v - yield match.start(4), String.Regex, match.group(4) # end[mixounse]* + yield match.start(4), String.Regex, match.group(4) # end[mixounse]* ctx.pos = match.end() def intp_string_callback(self, match, ctx): @@ -496,13 +496,13 @@ class RubyLexer(ExtendedRegexLexer): nctx = LexerContext(match.group(3), 0, ['interpolated-string']) for i, t, v in self.get_tokens_unprocessed(context=nctx): yield match.start(3)+i, t, v - yield match.start(4), String.Other, match.group(4) # end + yield match.start(4), String.Other, match.group(4) # end ctx.pos = match.end() states = {} states['strings'] = [ # easy ones - (r'\:([a-zA-Z_][\w_]*[\!\?]?|\*\*?|[-+]@?|' + (r'\:@{0,2}([a-zA-Z_][\w_]*[\!\?]?|\*\*?|[-+]@?|' r'[/%&|^`~]|\[\]=?|<<|>>|<=?>|>=?|===?)', String.Symbol), (r":'(\\\\|\\'|[^'])*'", String.Symbol), (r"'(\\\\|\\'|[^'])*'", String.Single), @@ -661,7 +661,8 @@ class RubyLexer(ExtendedRegexLexer): # multiline regex (in method calls) (r'(?<=\(|,)/', String.Regex, 'multiline-regex'), # multiline regex (this time the funny no whitespace rule) - (r'(\s+)(/[^\s=])', String.Regex, 'multiline-regex'), + (r'(\s+)(/)(?![\s=])', bygroups(Text, String.Regex), + 'multiline-regex'), # lex numbers and ignore following regular expressions which # are division operators in fact (grrrr. i hate that. any # better ideas?) @@ -1044,7 +1045,6 @@ class LuaLexer(RegexLexer): (r'(true|false|nil)\b', Keyword.Constant), (r'(function)(\s+)', bygroups(Keyword, Text), 'funcname'), - (r'(class)(\s+)', bygroups(Keyword, Text), 'classname'), (r'[A-Za-z_][A-Za-z0-9_]*(\.[A-Za-z_][A-Za-z0-9_]*)?', Name), @@ -1059,10 +1059,6 @@ class LuaLexer(RegexLexer): ('\(', Punctuation, '#pop'), ], - 'classname': [ - ('[A-Za-z_][A-Za-z0-9_]*', Name.Class, '#pop') - ], - # if I understand correctly, every character is valid in a lua string, # so this state is only for later corrections 'string': [ @@ -1155,7 +1151,7 @@ class MiniDLexer(RegexLexer): ), # StringLiteral # -- WysiwygString - (r'@"(""|.)*"', String), + (r'@"(""|[^"])*"', String), # -- AlternateWysiwygString (r'`(``|.)*`', String), # -- DoubleQuotedString @@ -2003,7 +1999,7 @@ class FancyLexer(RegexLexer): # Comments (r'#(.*?)\n', Comment.Single), # Symbols - (r'\'[^\'\s]+', String.Symbol), + (r'\'([^\'\s\[\]\(\)\{\}]+|\[\])', String.Symbol), # Multi-line DoubleQuotedString (r'"""(\\\\|\\"|[^"])*"""', String), # DoubleQuotedString @@ -2026,6 +2022,7 @@ class FancyLexer(RegexLexer): ('[A-Z][a-zA-Z0-9_]*', Name.Constant), ('@[a-zA-Z_][a-zA-Z0-9_]*', Name.Variable.Instance), ('@@[a-zA-Z_][a-zA-Z0-9_]*', Name.Variable.Class), + ('(@|@@)', Operator), ('[a-zA-Z_][a-zA-Z0-9_]*', Name), # numbers - / checks are necessary to avoid mismarking regexes, # see comment in RubyLexer @@ -2046,14 +2043,15 @@ class FancyLexer(RegexLexer): class GroovyLexer(RegexLexer): """ For `Groovy <http://groovy.codehaus.org/>`_ source code. - Syntax can be found at http://svn.codehaus.org/groovy/trunk/groovy/groovy-core/src/main/org/codehaus/groovy/antlr/groovy.g + + *New in Pygments 1.5.* """ name = 'Groovy' aliases = ['groovy'] filenames = ['*.groovy'] mimetypes = ['text/x-groovy'] - + flags = re.MULTILINE | re.DOTALL #: optional Comment or Whitespace |