summaryrefslogtreecommitdiff
path: root/pygments/lexers/jvm.py
diff options
context:
space:
mode:
authorBrian R. Jackson <brian@jaxzin.com>2012-02-25 00:45:06 -0500
committerBrian R. Jackson <brian@jaxzin.com>2012-02-25 00:45:06 -0500
commita8791bedb48bb00c6775fb31533b72fc9668734e (patch)
treea8e62ca415879594db4be008d3c2e83360d81aa6 /pygments/lexers/jvm.py
parent5558d3ba11cc7b2d1e16228ce3c5402b7d48072c (diff)
downloadpygments-a8791bedb48bb00c6775fb31533b72fc9668734e.tar.gz
Added support for Tea. http://teatrove.org
Diffstat (limited to 'pygments/lexers/jvm.py')
-rw-r--r--pygments/lexers/jvm.py47
1 files changed, 47 insertions, 0 deletions
diff --git a/pygments/lexers/jvm.py b/pygments/lexers/jvm.py
index 83b45613..fbd2b9ed 100644
--- a/pygments/lexers/jvm.py
+++ b/pygments/lexers/jvm.py
@@ -676,3 +676,50 @@ class ClojureLexer(RegexLexer):
(r'(\(|\))', Punctuation),
],
}
+
+class TeaLangLexer(RegexLexer):
+ """
+ For `Tea <http://teatrove.org/>`_ source code. Only used within a TeaTemplateLexer.
+ """
+
+ 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'(and|break|else|foreach|if|in|not|or|reverse)\b',
+ Keyword),
+ (r'(as|call|define)\b', Keyword.Declaration),
+ (r'(true|false|null)\b', Keyword.Constant),
+ (r'(template)(\s+)', bygroups(Keyword.Declaration, Text), 'template'),
+ (r'(import)(\s+)', bygroups(Keyword.Namespace, Text), 'import'),
+ (r'"(\\\\|\\"|[^"])*"', String),
+ (r'\'(\\\\|\\\'|[^\'])*\'', String),
+ (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'(isa|[.]{3}|[.]{2}|[=#!<>+-/%&;,.\*\\\(\)\[\]\{\}])', 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)
+ ],
+ 'template': [
+ (r'[a-zA-Z_][a-zA-Z0-9_]*', Name.Class, '#pop')
+ ],
+ 'import': [
+ (r'[a-zA-Z0-9_.]+\*?', Name.Namespace, '#pop')
+ ],
+ }
+