diff options
author | Unknown <catmiller@cat.local> | 2014-03-20 17:04:33 -0400 |
---|---|---|
committer | Unknown <catmiller@cat.local> | 2014-03-20 17:04:33 -0400 |
commit | c3d5f1f0cac8ea3d1c666375d6acaa2a896bbb15 (patch) | |
tree | dc1935f33c88f06848a162a41087c6d3ae8ad56a /pygments/lexers/jvm.py | |
parent | 8f8ed8cf3e577fb07cd95c66a65b1aac1fa285d2 (diff) | |
download | pygments-c3d5f1f0cac8ea3d1c666375d6acaa2a896bbb15.tar.gz |
Create PigLexer.
Diffstat (limited to 'pygments/lexers/jvm.py')
-rw-r--r-- | pygments/lexers/jvm.py | 52 |
1 files changed, 51 insertions, 1 deletions
diff --git a/pygments/lexers/jvm.py b/pygments/lexers/jvm.py index 5c535142..3360ced3 100644 --- a/pygments/lexers/jvm.py +++ b/pygments/lexers/jvm.py @@ -20,7 +20,7 @@ from pygments import unistring as uni __all__ = ['JavaLexer', 'ScalaLexer', 'GosuLexer', 'GosuTemplateLexer', 'GroovyLexer', 'IokeLexer', 'ClojureLexer', 'KotlinLexer', - 'XtendLexer', 'AspectJLexer', 'CeylonLexer'] + 'XtendLexer', 'AspectJLexer', 'CeylonLexer', 'PigLexer'] class JavaLexer(RegexLexer): @@ -1066,3 +1066,53 @@ class XtendLexer(RegexLexer): (r'.', String) ], } + +class PigLexer(RegexLexer): + name = 'Pig' + aliases = ['pig'] + filenames = ['*.pig'] + mimetypes = ['text/x-pig'] + + flags = re.MULTILINE|re.IGNORECASE + + tokens = { + 'root': [ + (r'\s+', Text), + (r'--.*', Comment), + (r'/\*\*([^*][^/]*)/', Comment.Multiline), + (r'/\*\*.*\*\*/$', Comment), + (r'\\\n', Text), + (r'\\', Text), + (r'\'[^\'^\n]+\'', String), + (r'\"[^\"^\n]+\"', String), + include('keywords'), + include('types'), + include('builtins'), + (r'[0-9][0-9]*\.[0-9]+([eE][0-9]+)?[fd]?', Number.Float), + (r'0x[0-9a-fA-F]+', Number.Hex), + (r'[0-9]+L?', Number.Integer), + (r'\n', Text), + (r'([a-zA-Z_][a-zA-Z0-9_]*)(\s*)(\()', + bygroups(Name.Function, Text, Punctuation)), + (r'[()#:]', Text), + (r'[^(:\n#\'\")\s]+', Text), + (r'\S+\s+', Text) + ], + 'keywords': [ + (r'(assert|and|any|all|arrange|as|asc|bag|by|cache|CASE|cat|cd|cp|' + r'%declare|%default|define|dense|desc|describe|distinct|du|dump|' + r'eval|exex|explain|filter|flatten|foreach|full|generate|group|help|' + r'if|illustrate|import|inner|input|into|is|join|kill|left|limit|load|' + r'ls|map|matches|mkdir|mv|not|null|onschema|or|order|outer|output|' + r'parallel|pig|pwd|quit|register|returns|right|rm|rmf|rollup|run|sample|' + r'set|ship|split|stderr|stdin|stdout|store|stream|through|union|using|void)\b', Keyword) + ], + 'builtins': [ + (r'(AVG|BinStorage|cogroup|CONCAT|copyFromLocal|copyToLocal|COUNT|' + r'cross|DIFF|MAX|MIN|PigDump|PigStorage|SIZE|SUM|TextLoader|TOKENIZE)\b', Name.Builtin) + ], + 'types':[ + (r'(bytearray|BIGINTEGER|BIGDECIMAL|chararray|datetime|double|float|' + r'int|long|tuple)\b', Keyword.Type) + ], + } |