diff options
author | bgoetzmann <devnull@localhost> | 2011-06-16 23:01:52 +0200 |
---|---|---|
committer | bgoetzmann <devnull@localhost> | 2011-06-16 23:01:52 +0200 |
commit | a87ba9a6f3f71c3e6cd969536704d8cf6e384ded (patch) | |
tree | 8e149b5a62ca69d838dca18e963899f971a4532b | |
parent | 95da6a811218abdf848f60e6ed894a49e5cfb68d (diff) | |
download | pygments-a87ba9a6f3f71c3e6cd969536704d8cf6e384ded.tar.gz |
Adding of the Groovy lexer.
-rw-r--r-- | pygments/lexers/agile.py | 62 |
1 files changed, 62 insertions, 0 deletions
diff --git a/pygments/lexers/agile.py b/pygments/lexers/agile.py index e7438158..662f8b7e 100644 --- a/pygments/lexers/agile.py +++ b/pygments/lexers/agile.py @@ -2041,3 +2041,65 @@ class FancyLexer(RegexLexer): (r'\d+', Number.Integer) ] } + + +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 + """ + + name = 'Groovy' + aliases = ['groovy'] + filenames = ['*.groovy'] + mimetypes = ['text/x-groovy'] + + flags = re.MULTILINE | re.DOTALL + + #: optional Comment or Whitespace + _ws = r'(?:\s|//.*?\n|/[*].*?[*]/)+' + + tokens = { + 'root': [ + # method names + (r'^(\s*(?:[a-zA-Z_][a-zA-Z0-9_\.\[\]]*\s+)+?)' # return arguments + r'([a-zA-Z_][a-zA-Z0-9_]*)' # method name + r'(\s*)(\()', # signature start + bygroups(using(this), Name.Function, Text, Operator)), + (r'[^\S\n]+', Text), + (r'//.*?\n', Comment.Single), + (r'/\*.*?\*/', Comment.Multiline), + (r'@[a-zA-Z_][a-zA-Z0-9_\.]*', Name.Decorator), + (r'(assert|break|case|catch|continue|default|do|else|finally|for|' + r'if|goto|instanceof|new|return|switch|this|throw|try|while|in|as)\b', + Keyword), + (r'(abstract|const|enum|extends|final|implements|native|private|' + r'protected|public|static|strictfp|super|synchronized|throws|' + r'transient|volatile)\b', Keyword.Declaration), + (r'(def|boolean|byte|char|double|float|int|long|short|void)\b', + Keyword.Type), + (r'(package)(\s+)', bygroups(Keyword.Namespace, Text)), + (r'(true|false|null)\b', Keyword.Constant), + (r'(class|interface)(\s+)', bygroups(Keyword.Declaration, Text), 'class'), + (r'(import)(\s+)', bygroups(Keyword.Namespace, Text), 'import'), + (r'"(\\\\|\\"|[^"])*"', String.Double), + (r"'(\\\\|\\'|[^'])*'", String.Single), + (r'\$/((?!/\$).)*/\$', String), + (r'/(\\\\|\\"|[^/])*/', String), + (r"'\\.'|'[^\\]'|'\\u[0-9a-f]{4}'", String.Char), + (r'(\.)([a-zA-Z_][a-zA-Z0-9_]*)', bygroups(Operator, Name.Attribute)), + (r'[a-zA-Z_][a-zA-Z0-9_]*:', Name.Label), + (r'[a-zA-Z_\$][a-zA-Z0-9_]*', Name), + (r'[~\^\*!%&\[\]\(\)\{\}<>\|+=:;,./?-]', Operator), + (r'[0-9][0-9]*\.[0-9]+([eE][0-9]+)?[fd]?', Number.Float), + (r'0x[0-9a-f]+', Number.Hex), + (r'[0-9]+L?', Number.Integer), + (r'\n', Text) + ], + 'class': [ + (r'[a-zA-Z_][a-zA-Z0-9_]*', Name.Class, '#pop') + ], + 'import': [ + (r'[a-zA-Z0-9_.]+\*?', Name.Namespace, '#pop') + ], + } |