diff options
author | Georg Brandl <georg@python.org> | 2012-08-19 09:57:11 +0200 |
---|---|---|
committer | Georg Brandl <georg@python.org> | 2012-08-19 09:57:11 +0200 |
commit | aa08632af3e5ec6dfde0b4f3a4d50880213b6072 (patch) | |
tree | 6b6cbef30e39b038ebf1baf51d3066e1aa832012 /pygments/lexers/jvm.py | |
parent | 49d0922ba75a209771ad57d5b9f26ae83896bf89 (diff) | |
parent | 93fdb964a94880d7439fd3fe68926bed463dc0c2 (diff) | |
download | pygments-aa08632af3e5ec6dfde0b4f3a4d50880213b6072.tar.gz |
Merged in svenefftinge/pygments-main-xtend-support (pull request #68)
Diffstat (limited to 'pygments/lexers/jvm.py')
-rw-r--r-- | pygments/lexers/jvm.py | 69 |
1 files changed, 68 insertions, 1 deletions
diff --git a/pygments/lexers/jvm.py b/pygments/lexers/jvm.py index 64338e46..a5c09e41 100644 --- a/pygments/lexers/jvm.py +++ b/pygments/lexers/jvm.py @@ -20,7 +20,8 @@ from pygments import unistring as uni __all__ = ['JavaLexer', 'ScalaLexer', 'GosuLexer', 'GosuTemplateLexer', - 'GroovyLexer', 'IokeLexer', 'ClojureLexer', 'KotlinLexer'] + 'GroovyLexer', 'IokeLexer', 'ClojureLexer', 'KotlinLexer', + 'XtendLexer'] class JavaLexer(RegexLexer): @@ -845,3 +846,69 @@ class KotlinLexer(RegexLexer): self._tokens = self._all_tokens[level] RegexLexer.__init__(self, **options) + +class XtendLexer(RegexLexer): + """ + For `Xtend <http://xtend-lang.org/>`_ source code. + + *New in Pygments 1.5.* + """ + + name = 'Xtend' + aliases = ['xtend'] + filenames = ['*.xtend'] + mimetypes = ['text/x-xtend'] + + 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|IF|' + r'ELSE|ELSEIF|ENDIF|FOR|ENDFOR|SEPARATOR|BEFORE|AFTER)\b', + Keyword), + (r'(def|abstract|const|enum|extends|final|implements|native|private|' + r'protected|public|static|strictfp|super|synchronized|throws|' + r'transient|volatile)\b', Keyword.Declaration), + (r'(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, 'template'), + (ur"(\u00BB)", String, 'template'), + (r'"(\\\\|\\"|[^"])*"', String), + (r"'(\\\\|\\'|[^'])*'", String), + (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') + ], + 'template': [ + (r"'''", String, '#pop'), + (ur"\u00AB", String, '#pop'), + (r'.', String) + ], + } |