ThirdParty/Pygments/pygments/lexers/agile.py

changeset 1705
b0fbc9300f2b
parent 808
8f85926125ef
child 2426
da76c71624de
equal deleted inserted replaced
1704:02ae6c55b35b 1705:b0fbc9300f2b
3 pygments.lexers.agile 3 pygments.lexers.agile
4 ~~~~~~~~~~~~~~~~~~~~~ 4 ~~~~~~~~~~~~~~~~~~~~~
5 5
6 Lexers for agile languages. 6 Lexers for agile languages.
7 7
8 :copyright: Copyright 2006-2010 by the Pygments team, see AUTHORS. 8 :copyright: Copyright 2006-2012 by the Pygments team, see AUTHORS.
9 :license: BSD, see LICENSE for details. 9 :license: BSD, see LICENSE for details.
10 """ 10 """
11 11
12 import re 12 import re
13 13
18 from pygments.util import get_bool_opt, get_list_opt, shebang_matches 18 from pygments.util import get_bool_opt, get_list_opt, shebang_matches
19 from pygments import unistring as uni 19 from pygments import unistring as uni
20 20
21 21
22 __all__ = ['PythonLexer', 'PythonConsoleLexer', 'PythonTracebackLexer', 22 __all__ = ['PythonLexer', 'PythonConsoleLexer', 'PythonTracebackLexer',
23 'RubyLexer', 'RubyConsoleLexer', 'PerlLexer', 'LuaLexer', 23 'Python3Lexer', 'Python3TracebackLexer', 'RubyLexer',
24 'MiniDLexer', 'IoLexer', 'TclLexer', 'ClojureLexer', 24 'RubyConsoleLexer', 'PerlLexer', 'LuaLexer', 'MoonScriptLexer',
25 'Python3Lexer', 'Python3TracebackLexer', 'FactorLexer', 'IokeLexer'] 25 'MiniDLexer', 'IoLexer', 'TclLexer', 'FactorLexer', 'FancyLexer']
26 26
27 # b/w compatibility 27 # b/w compatibility
28 from pygments.lexers.functional import SchemeLexer 28 from pygments.lexers.functional import SchemeLexer
29 from pygments.lexers.jvm import IokeLexer, ClojureLexer
29 30
30 line_re = re.compile('.*?\n') 31 line_re = re.compile('.*?\n')
31 32
32 33
33 class PythonLexer(RegexLexer): 34 class PythonLexer(RegexLexer):
53 (r'(in|is|and|or|not)\b', Operator.Word), 54 (r'(in|is|and|or|not)\b', Operator.Word),
54 (r'!=|==|<<|>>|[-~+/*%=<>&^|.]', Operator), 55 (r'!=|==|<<|>>|[-~+/*%=<>&^|.]', Operator),
55 include('keywords'), 56 include('keywords'),
56 (r'(def)((?:\s|\\\s)+)', bygroups(Keyword, Text), 'funcname'), 57 (r'(def)((?:\s|\\\s)+)', bygroups(Keyword, Text), 'funcname'),
57 (r'(class)((?:\s|\\\s)+)', bygroups(Keyword, Text), 'classname'), 58 (r'(class)((?:\s|\\\s)+)', bygroups(Keyword, Text), 'classname'),
58 (r'(from)((?:\s|\\\s)+)', bygroups(Keyword.Namespace, Text), 'fromimport'), 59 (r'(from)((?:\s|\\\s)+)', bygroups(Keyword.Namespace, Text),
59 (r'(import)((?:\s|\\\s)+)', bygroups(Keyword.Namespace, Text), 'import'), 60 'fromimport'),
61 (r'(import)((?:\s|\\\s)+)', bygroups(Keyword.Namespace, Text),
62 'import'),
60 include('builtins'), 63 include('builtins'),
61 include('backtick'), 64 include('backtick'),
62 ('(?:[rR]|[uU][rR]|[rR][uU])"""', String, 'tdqs'), 65 ('(?:[rR]|[uU][rR]|[rR][uU])"""', String, 'tdqs'),
63 ("(?:[rR]|[uU][rR]|[rR][uU])'''", String, 'tsqs'), 66 ("(?:[rR]|[uU][rR]|[rR][uU])'''", String, 'tsqs'),
64 ('(?:[rR]|[uU][rR]|[rR][uU])"', String, 'dqs'), 67 ('(?:[rR]|[uU][rR]|[rR][uU])"', String, 'dqs'),
100 r'UnicodeEncodeError|UnicodeError|UnicodeTranslateError|' 103 r'UnicodeEncodeError|UnicodeError|UnicodeTranslateError|'
101 r'UnicodeWarning|UserWarning|ValueError|VMSError|Warning|' 104 r'UnicodeWarning|UserWarning|ValueError|VMSError|Warning|'
102 r'WindowsError|ZeroDivisionError)\b', Name.Exception), 105 r'WindowsError|ZeroDivisionError)\b', Name.Exception),
103 ], 106 ],
104 'numbers': [ 107 'numbers': [
105 (r'(\d+\.\d*|\d*\.\d+)([eE][+-]?[0-9]+)?', Number.Float), 108 (r'(\d+\.\d*|\d*\.\d+)([eE][+-]?[0-9]+)?j?', Number.Float),
106 (r'\d+[eE][+-]?[0-9]+', Number.Float), 109 (r'\d+[eE][+-]?[0-9]+j?', Number.Float),
107 (r'0[0-7]+', Number.Oct), 110 (r'0[0-7]+j?', Number.Oct),
108 (r'0[xX][a-fA-F0-9]+', Number.Hex), 111 (r'0[xX][a-fA-F0-9]+', Number.Hex),
109 (r'\d+L', Number.Integer.Long), 112 (r'\d+L', Number.Integer.Long),
110 (r'\d+', Number.Integer) 113 (r'\d+j?', Number.Integer)
111 ], 114 ],
112 'backtick': [ 115 'backtick': [
113 ('`.*?`', String.Backtick), 116 ('`.*?`', String.Backtick),
114 ], 117 ],
115 'name': [ 118 'name': [
121 ], 124 ],
122 'classname': [ 125 'classname': [
123 ('[a-zA-Z_][a-zA-Z0-9_]*', Name.Class, '#pop') 126 ('[a-zA-Z_][a-zA-Z0-9_]*', Name.Class, '#pop')
124 ], 127 ],
125 'import': [ 128 'import': [
126 (r'((?:\s|\\\s)+)(as)((?:\s|\\\s)+)', 129 (r'(?:[ \t]|\\\n)+', Text),
127 bygroups(Text, Keyword.Namespace, Text)), 130 (r'as\b', Keyword.Namespace),
131 (r',', Operator),
128 (r'[a-zA-Z_][a-zA-Z0-9_.]*', Name.Namespace), 132 (r'[a-zA-Z_][a-zA-Z0-9_.]*', Name.Namespace),
129 (r'(\s*)(,)(\s*)', bygroups(Text, Operator, Text)),
130 (r'', Text, '#pop') # all else: go back 133 (r'', Text, '#pop') # all else: go back
131 ], 134 ],
132 'fromimport': [ 135 'fromimport': [
133 (r'((?:\s|\\\s)+)(import)\b', bygroups(Text, Keyword.Namespace), '#pop'), 136 (r'(?:[ \t]|\\\n)+', Text),
137 (r'import\b', Keyword.Namespace, '#pop'),
134 (r'[a-zA-Z_.][a-zA-Z0-9_.]*', Name.Namespace), 138 (r'[a-zA-Z_.][a-zA-Z0-9_.]*', Name.Namespace),
135 ], 139 ],
136 'stringescape': [ 140 'stringescape': [
137 (r'\\([\\abfnrtv"\']|\n|N{.*?}|u[a-fA-F0-9]{4}|' 141 (r'\\([\\abfnrtv"\']|\n|N{.*?}|u[a-fA-F0-9]{4}|'
138 r'U[a-fA-F0-9]{8}|x[a-fA-F0-9]{2}|[0-7]{1,3})', String.Escape) 142 r'U[a-fA-F0-9]{8}|x[a-fA-F0-9]{2}|[0-7]{1,3})', String.Escape)
150 'nl': [ 154 'nl': [
151 (r'\n', String) 155 (r'\n', String)
152 ], 156 ],
153 'dqs': [ 157 'dqs': [
154 (r'"', String, '#pop'), 158 (r'"', String, '#pop'),
155 (r'\\\\|\\"|\\\n', String.Escape), # included here again for raw strings 159 (r'\\\\|\\"|\\\n', String.Escape), # included here for raw strings
156 include('strings') 160 include('strings')
157 ], 161 ],
158 'sqs': [ 162 'sqs': [
159 (r"'", String, '#pop'), 163 (r"'", String, '#pop'),
160 (r"\\\\|\\'|\\\n", String.Escape), # included here again for raw strings 164 (r"\\\\|\\'|\\\n", String.Escape), # included here for raw strings
161 include('strings') 165 include('strings')
162 ], 166 ],
163 'tdqs': [ 167 'tdqs': [
164 (r'"""', String, '#pop'), 168 (r'"""', String, '#pop'),
165 include('strings'), 169 include('strings'),
171 include('nl') 175 include('nl')
172 ], 176 ],
173 } 177 }
174 178
175 def analyse_text(text): 179 def analyse_text(text):
176 return shebang_matches(text, r'pythonw?(2\.\d)?') 180 return shebang_matches(text, r'pythonw?(2(\.\d)?)?')
177 181
178 182
179 class Python3Lexer(RegexLexer): 183 class Python3Lexer(RegexLexer):
180 """ 184 """
181 For `Python <http://www.python.org>`_ source code (version 3.0). 185 For `Python <http://www.python.org>`_ source code (version 3.0).
193 uni_name = "[%s][%s]*" % (uni.xid_start, uni.xid_continue) 197 uni_name = "[%s][%s]*" % (uni.xid_start, uni.xid_continue)
194 198
195 tokens = PythonLexer.tokens.copy() 199 tokens = PythonLexer.tokens.copy()
196 tokens['keywords'] = [ 200 tokens['keywords'] = [
197 (r'(assert|break|continue|del|elif|else|except|' 201 (r'(assert|break|continue|del|elif|else|except|'
198 r'finally|for|global|if|lambda|pass|raise|' 202 r'finally|for|global|if|lambda|pass|raise|nonlocal|'
199 r'return|try|while|yield|as|with|True|False|None)\b', Keyword), 203 r'return|try|while|yield|as|with|True|False|None)\b', Keyword),
200 ] 204 ]
201 tokens['builtins'] = [ 205 tokens['builtins'] = [
202 (r'(?<!\.)(__import__|abs|all|any|bin|bool|bytearray|bytes|' 206 (r'(?<!\.)(__import__|abs|all|any|bin|bool|bytearray|bytes|'
203 r'chr|classmethod|cmp|compile|complex|delattr|dict|dir|' 207 r'chr|classmethod|cmp|compile|complex|delattr|dict|dir|'
362 filenames = ['*.pytb'] 366 filenames = ['*.pytb']
363 mimetypes = ['text/x-python-traceback'] 367 mimetypes = ['text/x-python-traceback']
364 368
365 tokens = { 369 tokens = {
366 'root': [ 370 'root': [
367 (r'^Traceback \(most recent call last\):\n', Generic.Traceback, 'intb'), 371 (r'^Traceback \(most recent call last\):\n',
372 Generic.Traceback, 'intb'),
368 # SyntaxError starts with this. 373 # SyntaxError starts with this.
369 (r'^(?= File "[^"]+", line \d+)', Generic.Traceback, 'intb'), 374 (r'^(?= File "[^"]+", line \d+)', Generic.Traceback, 'intb'),
370 (r'^.*\n', Other), 375 (r'^.*\n', Other),
371 ], 376 ],
372 'intb': [ 377 'intb': [
374 bygroups(Text, Name.Builtin, Text, Number, Text, Name, Text)), 379 bygroups(Text, Name.Builtin, Text, Number, Text, Name, Text)),
375 (r'^( File )("[^"]+")(, line )(\d+)(\n)', 380 (r'^( File )("[^"]+")(, line )(\d+)(\n)',
376 bygroups(Text, Name.Builtin, Text, Number, Text)), 381 bygroups(Text, Name.Builtin, Text, Number, Text)),
377 (r'^( )(.+)(\n)', 382 (r'^( )(.+)(\n)',
378 bygroups(Text, using(PythonLexer), Text)), 383 bygroups(Text, using(PythonLexer), Text)),
379 (r'^([ \t]*)(...)(\n)', 384 (r'^([ \t]*)(\.\.\.)(\n)',
380 bygroups(Text, Comment, Text)), # for doctests... 385 bygroups(Text, Comment, Text)), # for doctests...
381 (r'^(.+)(: )(.+)(\n)', 386 (r'^(.+)(: )(.+)(\n)',
382 bygroups(Generic.Error, Text, Name, Text), '#pop'), 387 bygroups(Generic.Error, Text, Name, Text), '#pop'),
383 (r'^([a-zA-Z_][a-zA-Z0-9_]*)(:?\n)', 388 (r'^([a-zA-Z_][a-zA-Z0-9_]*)(:?\n)',
384 bygroups(Generic.Error, Text), '#pop') 389 bygroups(Generic.Error, Text), '#pop')
410 'intb': [ 415 'intb': [
411 (r'^( File )("[^"]+")(, line )(\d+)(, in )(.+)(\n)', 416 (r'^( File )("[^"]+")(, line )(\d+)(, in )(.+)(\n)',
412 bygroups(Text, Name.Builtin, Text, Number, Text, Name, Text)), 417 bygroups(Text, Name.Builtin, Text, Number, Text, Name, Text)),
413 (r'^( )(.+)(\n)', 418 (r'^( )(.+)(\n)',
414 bygroups(Text, using(Python3Lexer), Text)), 419 bygroups(Text, using(Python3Lexer), Text)),
415 (r'^([ \t]*)(...)(\n)', 420 (r'^([ \t]*)(\.\.\.)(\n)',
416 bygroups(Text, Comment, Text)), # for doctests... 421 bygroups(Text, Comment, Text)), # for doctests...
417 (r'^(.+)(: )(.+)(\n)', 422 (r'^(.+)(: )(.+)(\n)',
418 bygroups(Generic.Error, Text, Name, Text), '#pop'), 423 bygroups(Generic.Error, Text, Name, Text), '#pop'),
419 (r'^([a-zA-Z_][a-zA-Z0-9_]*)(:?\n)', 424 (r'^([a-zA-Z_][a-zA-Z0-9_]*)(:?\n)',
420 bygroups(Generic.Error, Text), '#pop') 425 bygroups(Generic.Error, Text), '#pop')
481 del heredocstack[:] 486 del heredocstack[:]
482 487
483 488
484 def gen_rubystrings_rules(): 489 def gen_rubystrings_rules():
485 def intp_regex_callback(self, match, ctx): 490 def intp_regex_callback(self, match, ctx):
486 yield match.start(1), String.Regex, match.group(1) # begin 491 yield match.start(1), String.Regex, match.group(1) # begin
487 nctx = LexerContext(match.group(3), 0, ['interpolated-regex']) 492 nctx = LexerContext(match.group(3), 0, ['interpolated-regex'])
488 for i, t, v in self.get_tokens_unprocessed(context=nctx): 493 for i, t, v in self.get_tokens_unprocessed(context=nctx):
489 yield match.start(3)+i, t, v 494 yield match.start(3)+i, t, v
490 yield match.start(4), String.Regex, match.group(4) # end[mixounse]* 495 yield match.start(4), String.Regex, match.group(4) # end[mixounse]*
491 ctx.pos = match.end() 496 ctx.pos = match.end()
492 497
493 def intp_string_callback(self, match, ctx): 498 def intp_string_callback(self, match, ctx):
494 yield match.start(1), String.Other, match.group(1) 499 yield match.start(1), String.Other, match.group(1)
495 nctx = LexerContext(match.group(3), 0, ['interpolated-string']) 500 nctx = LexerContext(match.group(3), 0, ['interpolated-string'])
496 for i, t, v in self.get_tokens_unprocessed(context=nctx): 501 for i, t, v in self.get_tokens_unprocessed(context=nctx):
497 yield match.start(3)+i, t, v 502 yield match.start(3)+i, t, v
498 yield match.start(4), String.Other, match.group(4) # end 503 yield match.start(4), String.Other, match.group(4) # end
499 ctx.pos = match.end() 504 ctx.pos = match.end()
500 505
501 states = {} 506 states = {}
502 states['strings'] = [ 507 states['strings'] = [
503 # easy ones 508 # easy ones
504 (r'\:([a-zA-Z_][\w_]*[\!\?]?|\*\*?|[-+]@?|' 509 (r'\:@{0,2}([a-zA-Z_]\w*[\!\?]?|\*\*?|[-+]@?|'
505 r'[/%&|^`~]|\[\]=?|<<|>>|<=?>|>=?|===?)', String.Symbol), 510 r'[/%&|^`~]|\[\]=?|<<|>>|<=?>|>=?|===?)', String.Symbol),
506 (r":'(\\\\|\\'|[^'])*'", String.Symbol), 511 (r":'(\\\\|\\'|[^'])*'", String.Symbol),
507 (r"'(\\\\|\\'|[^'])*'", String.Single), 512 (r"'(\\\\|\\'|[^'])*'", String.Single),
508 (r':"', String.Symbol, 'simple-sym'), 513 (r':"', String.Symbol, 'simple-sym'),
509 (r'"', String.Double, 'simple-string'), 514 (r'"', String.Double, 'simple-string'),
581 return states 586 return states
582 587
583 tokens = { 588 tokens = {
584 'root': [ 589 'root': [
585 (r'#.*?$', Comment.Single), 590 (r'#.*?$', Comment.Single),
586 (r'=begin\s.*?\n=end', Comment.Multiline), 591 (r'=begin\s.*?\n=end.*?$', Comment.Multiline),
587 # keywords 592 # keywords
588 (r'(BEGIN|END|alias|begin|break|case|defined\?|' 593 (r'(BEGIN|END|alias|begin|break|case|defined\?|'
589 r'do|else|elsif|end|ensure|for|if|in|next|redo|' 594 r'do|else|elsif|end|ensure|for|if|in|next|redo|'
590 r'rescue|raise|retry|return|super|then|undef|unless|until|when|' 595 r'rescue|raise|retry|return|super|then|undef|unless|until|when|'
591 r'while|yield)\b', Keyword), 596 r'while|yield)\b', Keyword),
596 (r'def(?=[*%&^`~+-/\[<>=])', Keyword, 'funcname'), 601 (r'def(?=[*%&^`~+-/\[<>=])', Keyword, 'funcname'),
597 (r'(class)(\s+)', bygroups(Keyword, Text), 'classname'), 602 (r'(class)(\s+)', bygroups(Keyword, Text), 'classname'),
598 # special methods 603 # special methods
599 (r'(initialize|new|loop|include|extend|raise|attr_reader|' 604 (r'(initialize|new|loop|include|extend|raise|attr_reader|'
600 r'attr_writer|attr_accessor|attr|catch|throw|private|' 605 r'attr_writer|attr_accessor|attr|catch|throw|private|'
601 r'module_function|public|protected|true|false|nil)\b', Keyword.Pseudo), 606 r'module_function|public|protected|true|false|nil)\b',
607 Keyword.Pseudo),
602 (r'(not|and|or)\b', Operator.Word), 608 (r'(not|and|or)\b', Operator.Word),
603 (r'(autoload|block_given|const_defined|eql|equal|frozen|include|' 609 (r'(autoload|block_given|const_defined|eql|equal|frozen|include|'
604 r'instance_of|is_a|iterator|kind_of|method_defined|nil|' 610 r'instance_of|is_a|iterator|kind_of|method_defined|nil|'
605 r'private_method_defined|protected_method_defined|' 611 r'private_method_defined|protected_method_defined|'
606 r'public_method_defined|respond_to|tainted)\?', Name.Builtin), 612 r'public_method_defined|respond_to|tainted)\?', Name.Builtin),
607 (r'(chomp|chop|exit|gsub|sub)!', Name.Builtin), 613 (r'(chomp|chop|exit|gsub|sub)!', Name.Builtin),
608 (r'(?<!\.)(Array|Float|Integer|String|__id__|__send__|abort|ancestors|' 614 (r'(?<!\.)(Array|Float|Integer|String|__id__|__send__|abort|'
609 r'at_exit|autoload|binding|callcc|caller|' 615 r'ancestors|at_exit|autoload|binding|callcc|caller|'
610 r'catch|chomp|chop|class_eval|class_variables|' 616 r'catch|chomp|chop|class_eval|class_variables|'
611 r'clone|const_defined\?|const_get|const_missing|const_set|constants|' 617 r'clone|const_defined\?|const_get|const_missing|const_set|'
612 r'display|dup|eval|exec|exit|extend|fail|fork|' 618 r'constants|display|dup|eval|exec|exit|extend|fail|fork|'
613 r'format|freeze|getc|gets|global_variables|gsub|' 619 r'format|freeze|getc|gets|global_variables|gsub|'
614 r'hash|id|included_modules|inspect|instance_eval|' 620 r'hash|id|included_modules|inspect|instance_eval|'
615 r'instance_method|instance_methods|' 621 r'instance_method|instance_methods|'
616 r'instance_variable_get|instance_variable_set|instance_variables|' 622 r'instance_variable_get|instance_variable_set|instance_variables|'
617 r'lambda|load|local_variables|loop|' 623 r'lambda|load|local_variables|loop|'
626 r'split|sprintf|srand|sub|syscall|system|taint|' 632 r'split|sprintf|srand|sub|syscall|system|taint|'
627 r'test|throw|to_a|to_s|trace_var|trap|untaint|untrace_var|' 633 r'test|throw|to_a|to_s|trace_var|trap|untaint|untrace_var|'
628 r'warn)\b', Name.Builtin), 634 r'warn)\b', Name.Builtin),
629 (r'__(FILE|LINE)__\b', Name.Builtin.Pseudo), 635 (r'__(FILE|LINE)__\b', Name.Builtin.Pseudo),
630 # normal heredocs 636 # normal heredocs
631 (r'(?<!\w)(<<-?)(["`\']?)([a-zA-Z_]\w*)(\2)(.*?\n)', heredoc_callback), 637 (r'(?<!\w)(<<-?)(["`\']?)([a-zA-Z_]\w*)(\2)(.*?\n)',
638 heredoc_callback),
632 # empty string heredocs 639 # empty string heredocs
633 (r'(<<-?)("|\')()(\2)(.*?\n)', heredoc_callback), 640 (r'(<<-?)("|\')()(\2)(.*?\n)', heredoc_callback),
634 (r'__END__', Comment.Preproc, 'end-part'), 641 (r'__END__', Comment.Preproc, 'end-part'),
635 # multiline regex (after keywords or assignments) 642 # multiline regex (after keywords or assignments)
636 (r'(?:^|(?<=[=<>~!])|' 643 (r'(?:^|(?<=[=<>~!])|'
655 r'(?<=^gsub!\s)|' 662 r'(?<=^gsub!\s)|'
656 r'(?<=^match\s)|' 663 r'(?<=^match\s)|'
657 r'(?<=^if\s)|' 664 r'(?<=^if\s)|'
658 r'(?<=^elsif\s)' 665 r'(?<=^elsif\s)'
659 r')(\s*)(/)', bygroups(Text, String.Regex), 'multiline-regex'), 666 r')(\s*)(/)', bygroups(Text, String.Regex), 'multiline-regex'),
660 # multiline regex (in method calls) 667 # multiline regex (in method calls or subscripts)
661 (r'(?<=\(|,)/', String.Regex, 'multiline-regex'), 668 (r'(?<=\(|,|\[)/', String.Regex, 'multiline-regex'),
662 # multiline regex (this time the funny no whitespace rule) 669 # multiline regex (this time the funny no whitespace rule)
663 (r'(\s+)(/[^\s=])', String.Regex, 'multiline-regex'), 670 (r'(\s+)(/)(?![\s=])', bygroups(Text, String.Regex),
671 'multiline-regex'),
664 # lex numbers and ignore following regular expressions which 672 # lex numbers and ignore following regular expressions which
665 # are division operators in fact (grrrr. i hate that. any 673 # are division operators in fact (grrrr. i hate that. any
666 # better ideas?) 674 # better ideas?)
667 # since pygments 0.7 we also eat a "?" operator after numbers 675 # since pygments 0.7 we also eat a "?" operator after numbers
668 # so that the char operator does not work. Chars are not allowed 676 # so that the char operator does not work. Chars are not allowed
693 (r'[A-Z][a-zA-Z0-9_]+', Name.Constant), 701 (r'[A-Z][a-zA-Z0-9_]+', Name.Constant),
694 # this is needed because ruby attributes can look 702 # this is needed because ruby attributes can look
695 # like keywords (class) or like this: ` ?!? 703 # like keywords (class) or like this: ` ?!?
696 (r'(\.|::)([a-zA-Z_]\w*[\!\?]?|[*%&^`~+-/\[<>=])', 704 (r'(\.|::)([a-zA-Z_]\w*[\!\?]?|[*%&^`~+-/\[<>=])',
697 bygroups(Operator, Name)), 705 bygroups(Operator, Name)),
698 (r'[a-zA-Z_][\w_]*[\!\?]?', Name), 706 (r'[a-zA-Z_]\w*[\!\?]?', Name),
699 (r'(\[|\]|\*\*|<<?|>>?|>=|<=|<=>|=~|={3}|' 707 (r'(\[|\]|\*\*|<<?|>>?|>=|<=|<=>|=~|={3}|'
700 r'!~|&&?|\|\||\.{1,3})', Operator), 708 r'!~|&&?|\|\||\.{1,3})', Operator),
701 (r'[-+/*%=<>&!^|~]=?', Operator), 709 (r'[-+/*%=<>&!^|~]=?', Operator),
702 (r'[(){};,/?:\\]', Punctuation), 710 (r'[(){};,/?:\\]', Punctuation),
703 (r'\s+', Text) 711 (r'\s+', Text)
704 ], 712 ],
705 'funcname': [ 713 'funcname': [
706 (r'\(', Punctuation, 'defexpr'), 714 (r'\(', Punctuation, 'defexpr'),
707 (r'(?:([a-zA-Z_][a-zA-Z0-9_]*)(\.))?' 715 (r'(?:([a-zA-Z_][a-zA-Z0-9_]*)(\.))?'
708 r'([a-zA-Z_][\w_]*[\!\?]?|\*\*?|[-+]@?|' 716 r'([a-zA-Z_]\w*[\!\?]?|\*\*?|[-+]@?|'
709 r'[/%&|^`~]|\[\]=?|<<|>>|<=?>|>=?|===?)', 717 r'[/%&|^`~]|\[\]=?|<<|>>|<=?>|>=?|===?)',
710 bygroups(Name.Class, Operator, Name.Function), '#pop'), 718 bygroups(Name.Class, Operator, Name.Function), '#pop'),
711 (r'', Text, '#pop') 719 (r'', Text, '#pop')
712 ], 720 ],
713 'classname': [ 721 'classname': [
714 (r'\(', Punctuation, 'defexpr'), 722 (r'\(', Punctuation, 'defexpr'),
715 (r'<<', Operator, '#pop'), 723 (r'<<', Operator, '#pop'),
716 (r'[A-Z_][\w_]*', Name.Class, '#pop'), 724 (r'[A-Z_]\w*', Name.Class, '#pop'),
717 (r'', Text, '#pop') 725 (r'', Text, '#pop')
718 ], 726 ],
719 'defexpr': [ 727 'defexpr': [
720 (r'(\))(\.|::)?', bygroups(Punctuation, Operator), '#pop'), 728 (r'(\))(\.|::)?', bygroups(Punctuation, Operator), '#pop'),
721 (r'\(', Operator, '#push'), 729 (r'\(', Operator, '#push'),
730 (r'#@@?[a-zA-Z_][a-zA-Z0-9_]*', String.Interpol), 738 (r'#@@?[a-zA-Z_][a-zA-Z0-9_]*', String.Interpol),
731 (r'#\$[a-zA-Z_][a-zA-Z0-9_]*', String.Interpol) 739 (r'#\$[a-zA-Z_][a-zA-Z0-9_]*', String.Interpol)
732 ], 740 ],
733 'string-intp-escaped': [ 741 'string-intp-escaped': [
734 include('string-intp'), 742 include('string-intp'),
735 (r'\\([\\abefnrstv#"\']|x[a-fA-F0-9]{1,2}|[0-7]{1,3})', String.Escape) 743 (r'\\([\\abefnrstv#"\']|x[a-fA-F0-9]{1,2}|[0-7]{1,3})',
744 String.Escape)
736 ], 745 ],
737 'interpolated-regex': [ 746 'interpolated-regex': [
738 include('string-intp'), 747 include('string-intp'),
739 (r'[\\#]', String.Regex), 748 (r'[\\#]', String.Regex),
740 (r'[^\\#]+', String.Regex), 749 (r'[^\\#]+', String.Regex),
817 aliases = ['perl', 'pl'] 826 aliases = ['perl', 'pl']
818 filenames = ['*.pl', '*.pm'] 827 filenames = ['*.pl', '*.pm']
819 mimetypes = ['text/x-perl', 'application/x-perl'] 828 mimetypes = ['text/x-perl', 'application/x-perl']
820 829
821 flags = re.DOTALL | re.MULTILINE 830 flags = re.DOTALL | re.MULTILINE
822 # TODO: give this a perl guy who knows how to parse perl... 831 # TODO: give this to a perl guy who knows how to parse perl...
823 tokens = { 832 tokens = {
824 'balanced-regex': [ 833 'balanced-regex': [
825 (r'/(\\\\|\\/|[^/])*/[egimosx]*', String.Regex, '#pop'), 834 (r'/(\\\\|\\[^\\]|[^\\/])*/[egimosx]*', String.Regex, '#pop'),
826 (r'!(\\\\|\\!|[^!])*![egimosx]*', String.Regex, '#pop'), 835 (r'!(\\\\|\\[^\\]|[^\\!])*![egimosx]*', String.Regex, '#pop'),
827 (r'\\(\\\\|[^\\])*\\[egimosx]*', String.Regex, '#pop'), 836 (r'\\(\\\\|[^\\])*\\[egimosx]*', String.Regex, '#pop'),
828 (r'{(\\\\|\\}|[^}])*}[egimosx]*', String.Regex, '#pop'), 837 (r'{(\\\\|\\[^\\]|[^\\}])*}[egimosx]*', String.Regex, '#pop'),
829 (r'<(\\\\|\\>|[^>])*>[egimosx]*', String.Regex, '#pop'), 838 (r'<(\\\\|\\[^\\]|[^\\>])*>[egimosx]*', String.Regex, '#pop'),
830 (r'\[(\\\\|\\\]|[^\]])*\][egimosx]*', String.Regex, '#pop'), 839 (r'\[(\\\\|\\[^\\]|[^\\\]])*\][egimosx]*', String.Regex, '#pop'),
831 (r'\((\\\\|\\\)|[^\)])*\)[egimosx]*', String.Regex, '#pop'), 840 (r'\((\\\\|\\[^\\]|[^\\\)])*\)[egimosx]*', String.Regex, '#pop'),
832 (r'@(\\\\|\\\@|[^\@])*@[egimosx]*', String.Regex, '#pop'), 841 (r'@(\\\\|\\[^\\]|[^\\\@])*@[egimosx]*', String.Regex, '#pop'),
833 (r'%(\\\\|\\\%|[^\%])*%[egimosx]*', String.Regex, '#pop'), 842 (r'%(\\\\|\\[^\\]|[^\\\%])*%[egimosx]*', String.Regex, '#pop'),
834 (r'\$(\\\\|\\\$|[^\$])*\$[egimosx]*', String.Regex, '#pop'), 843 (r'\$(\\\\|\\[^\\]|[^\\\$])*\$[egimosx]*', String.Regex, '#pop'),
835 ], 844 ],
836 'root': [ 845 'root': [
837 (r'\#.*?$', Comment.Single), 846 (r'\#.*?$', Comment.Single),
838 (r'^=[a-zA-Z0-9]+\s+.*?\n=cut', Comment.Multiline), 847 (r'^=[a-zA-Z0-9]+\s+.*?\n=cut', Comment.Multiline),
839 (r'(case|continue|do|else|elsif|for|foreach|if|last|my|' 848 (r'(case|continue|do|else|elsif|for|foreach|if|last|my|'
841 r'print|new|BEGIN|CHECK|INIT|END|return)\b', Keyword), 850 r'print|new|BEGIN|CHECK|INIT|END|return)\b', Keyword),
842 (r'(format)(\s+)([a-zA-Z0-9_]+)(\s*)(=)(\s*\n)', 851 (r'(format)(\s+)([a-zA-Z0-9_]+)(\s*)(=)(\s*\n)',
843 bygroups(Keyword, Text, Name, Text, Punctuation, Text), 'format'), 852 bygroups(Keyword, Text, Name, Text, Punctuation, Text), 'format'),
844 (r'(eq|lt|gt|le|ge|ne|not|and|or|cmp)\b', Operator.Word), 853 (r'(eq|lt|gt|le|ge|ne|not|and|or|cmp)\b', Operator.Word),
845 # common delimiters 854 # common delimiters
846 (r's/(\\\\|\\/|[^/])*/(\\\\|\\/|[^/])*/[egimosx]*', String.Regex), 855 (r's/(\\\\|\\[^\\]|[^\\/])*/(\\\\|\\[^\\]|[^\\/])*/[egimosx]*',
856 String.Regex),
847 (r's!(\\\\|\\!|[^!])*!(\\\\|\\!|[^!])*![egimosx]*', String.Regex), 857 (r's!(\\\\|\\!|[^!])*!(\\\\|\\!|[^!])*![egimosx]*', String.Regex),
848 (r's\\(\\\\|[^\\])*\\(\\\\|[^\\])*\\[egimosx]*', String.Regex), 858 (r's\\(\\\\|[^\\])*\\(\\\\|[^\\])*\\[egimosx]*', String.Regex),
849 (r's@(\\\\|\\@|[^@])*@(\\\\|\\@|[^@])*@[egimosx]*', String.Regex), 859 (r's@(\\\\|\\[^\\]|[^\\@])*@(\\\\|\\[^\\]|[^\\@])*@[egimosx]*',
850 (r's%(\\\\|\\%|[^%])*%(\\\\|\\%|[^%])*%[egimosx]*', String.Regex), 860 String.Regex),
861 (r's%(\\\\|\\[^\\]|[^\\%])*%(\\\\|\\[^\\]|[^\\%])*%[egimosx]*',
862 String.Regex),
851 # balanced delimiters 863 # balanced delimiters
852 (r's{(\\\\|\\}|[^}])*}\s*', String.Regex, 'balanced-regex'), 864 (r's{(\\\\|\\[^\\]|[^\\}])*}\s*', String.Regex, 'balanced-regex'),
853 (r's<(\\\\|\\>|[^>])*>\s*', String.Regex, 'balanced-regex'), 865 (r's<(\\\\|\\[^\\]|[^\\>])*>\s*', String.Regex, 'balanced-regex'),
854 (r's\[(\\\\|\\\]|[^\]])*\]\s*', String.Regex, 'balanced-regex'), 866 (r's\[(\\\\|\\[^\\]|[^\\\]])*\]\s*', String.Regex,
855 (r's\((\\\\|\\\)|[^\)])*\)\s*', String.Regex, 'balanced-regex'), 867 'balanced-regex'),
856 868 (r's\((\\\\|\\[^\\]|[^\\\)])*\)\s*', String.Regex,
857 (r'm?/(\\\\|\\/|[^/\n])*/[gcimosx]*', String.Regex), 869 'balanced-regex'),
870
871 (r'm?/(\\\\|\\[^\\]|[^\\/\n])*/[gcimosx]*', String.Regex),
858 (r'm(?=[/!\\{<\[\(@%\$])', String.Regex, 'balanced-regex'), 872 (r'm(?=[/!\\{<\[\(@%\$])', String.Regex, 'balanced-regex'),
859 (r'((?<==~)|(?<=\())\s*/(\\\\|\\/|[^/])*/[gcimosx]*', String.Regex), 873 (r'((?<==~)|(?<=\())\s*/(\\\\|\\[^\\]|[^\\/])*/[gcimosx]*',
874 String.Regex),
860 (r'\s+', Text), 875 (r'\s+', Text),
861 (r'(abs|accept|alarm|atan2|bind|binmode|bless|caller|chdir|' 876 (r'(abs|accept|alarm|atan2|bind|binmode|bless|caller|chdir|'
862 r'chmod|chomp|chop|chown|chr|chroot|close|closedir|connect|' 877 r'chmod|chomp|chop|chown|chr|chroot|close|closedir|connect|'
863 r'continue|cos|crypt|dbmclose|dbmopen|defined|delete|die|' 878 r'continue|cos|crypt|dbmclose|dbmopen|defined|delete|die|'
864 r'dump|each|endgrent|endhostent|endnetent|endprotoent|' 879 r'dump|each|endgrent|endhostent|endnetent|endprotoent|'
896 (r'0b[01]+(_[01]+)*', Number.Bin), 911 (r'0b[01]+(_[01]+)*', Number.Bin),
897 (r'(?i)(\d*(_\d*)*\.\d+(_\d*)*|\d+(_\d*)*\.\d+(_\d*)*)(e[+-]?\d+)?', 912 (r'(?i)(\d*(_\d*)*\.\d+(_\d*)*|\d+(_\d*)*\.\d+(_\d*)*)(e[+-]?\d+)?',
898 Number.Float), 913 Number.Float),
899 (r'(?i)\d+(_\d*)*e[+-]?\d+(_\d*)*', Number.Float), 914 (r'(?i)\d+(_\d*)*e[+-]?\d+(_\d*)*', Number.Float),
900 (r'\d+(_\d+)*', Number.Integer), 915 (r'\d+(_\d+)*', Number.Integer),
901 (r"'(\\\\|\\'|[^'])*'", String), 916 (r"'(\\\\|\\[^\\]|[^'\\])*'", String),
902 (r'"(\\\\|\\"|[^"])*"', String), 917 (r'"(\\\\|\\[^\\]|[^"\\])*"', String),
903 (r'`(\\\\|\\`|[^`])*`', String.Backtick), 918 (r'`(\\\\|\\[^\\]|[^`\\])*`', String.Backtick),
904 (r'<([^\s>]+)>', String.Regex), 919 (r'<([^\s>]+)>', String.Regex),
905 (r'(q|qq|qw|qr|qx)\{', String.Other, 'cb-string'), 920 (r'(q|qq|qw|qr|qx)\{', String.Other, 'cb-string'),
906 (r'(q|qq|qw|qr|qx)\(', String.Other, 'rb-string'), 921 (r'(q|qq|qw|qr|qx)\(', String.Other, 'rb-string'),
907 (r'(q|qq|qw|qr|qx)\[', String.Other, 'sb-string'), 922 (r'(q|qq|qw|qr|qx)\[', String.Other, 'sb-string'),
908 (r'(q|qq|qw|qr|qx)\<', String.Other, 'lt-string'), 923 (r'(q|qq|qw|qr|qx)\<', String.Other, 'lt-string'),
909 (r'(q|qq|qw|qr|qx)([^a-zA-Z0-9])(.|\n)*?\2', String.Other), 924 (r'(q|qq|qw|qr|qx)([^a-zA-Z0-9])(.|\n)*?\2', String.Other),
910 (r'package\s+', Keyword, 'modulename'), 925 (r'package\s+', Keyword, 'modulename'),
911 (r'sub\s+', Keyword, 'funcname'), 926 (r'sub\s+', Keyword, 'funcname'),
912 (r'(\[\]|\*\*|::|<<|>>|>=|<=|<=>|={3}|!=|=~|' 927 (r'(\[\]|\*\*|::|<<|>>|>=|<=>|<=|={3}|!=|=~|'
913 r'!~|&&?|\|\||\.{1,3})', Operator), 928 r'!~|&&?|\|\||\.{1,3})', Operator),
914 (r'[-+/*%=<>&^|!\\~]=?', Operator), 929 (r'[-+/*%=<>&^|!\\~]=?', Operator),
915 (r'[\(\)\[\]:;,<>/\?\{\}]', Punctuation), # yes, there's no shortage 930 (r'[\(\)\[\]:;,<>/\?\{\}]', Punctuation), # yes, there's no shortage
916 # of punctuation in Perl! 931 # of punctuation in Perl!
917 (r'(?=\w)', Name, 'name'), 932 (r'(?=\w)', Name, 'name'),
932 (r'[a-zA-Z0-9_:]+', Name, '#pop'), 947 (r'[a-zA-Z0-9_:]+', Name, '#pop'),
933 (r'[A-Z_]+(?=[^a-zA-Z0-9_])', Name.Constant, '#pop'), 948 (r'[A-Z_]+(?=[^a-zA-Z0-9_])', Name.Constant, '#pop'),
934 (r'(?=[^a-zA-Z0-9_])', Text, '#pop'), 949 (r'(?=[^a-zA-Z0-9_])', Text, '#pop'),
935 ], 950 ],
936 'modulename': [ 951 'modulename': [
937 (r'[a-zA-Z_][\w_]*', Name.Namespace, '#pop') 952 (r'[a-zA-Z_]\w*', Name.Namespace, '#pop')
938 ], 953 ],
939 'funcname': [ 954 'funcname': [
940 (r'[a-zA-Z_][\w_]*[\!\?]?', Name.Function), 955 (r'[a-zA-Z_]\w*[\!\?]?', Name.Function),
941 (r'\s+', Text), 956 (r'\s+', Text),
942 # argument declaration 957 # argument declaration
943 (r'(\([$@%]*\))(\s*)', bygroups(Punctuation, Text)), 958 (r'(\([$@%]*\))(\s*)', bygroups(Punctuation, Text)),
944 (r'.*?{', Punctuation, '#pop'), 959 (r'.*?{', Punctuation, '#pop'),
945 (r';', Punctuation, '#pop'), 960 (r';', Punctuation, '#pop'),
1031 (r'\n', Text), 1046 (r'\n', Text),
1032 (r'[^\S\n]', Text), 1047 (r'[^\S\n]', Text),
1033 # multiline strings 1048 # multiline strings
1034 (r'(?s)\[(=*)\[.*?\]\1\]', String), 1049 (r'(?s)\[(=*)\[.*?\]\1\]', String),
1035 1050
1036 (r'(==|~=|<=|>=|\.\.|\.\.\.|[=+\-*/%^<>#])', Operator), 1051 (r'(==|~=|<=|>=|\.\.\.|\.\.|[=+\-*/%^<>#])', Operator),
1037 (r'[\[\]\{\}\(\)\.,:;]', Punctuation), 1052 (r'[\[\]\{\}\(\)\.,:;]', Punctuation),
1038 (r'(and|or|not)\b', Operator.Word), 1053 (r'(and|or|not)\b', Operator.Word),
1039 1054
1040 ('(break|do|else|elseif|end|for|if|in|repeat|return|then|until|' 1055 ('(break|do|else|elseif|end|for|if|in|repeat|return|then|until|'
1041 r'while)\b', Keyword), 1056 r'while)\b', Keyword),
1042 (r'(local)\b', Keyword.Declaration), 1057 (r'(local)\b', Keyword.Declaration),
1043 (r'(true|false|nil)\b', Keyword.Constant), 1058 (r'(true|false|nil)\b', Keyword.Constant),
1044 1059
1045 (r'(function)(\s+)', bygroups(Keyword, Text), 'funcname'), 1060 (r'(function)\b', Keyword, 'funcname'),
1046 (r'(class)(\s+)', bygroups(Keyword, Text), 'classname'),
1047 1061
1048 (r'[A-Za-z_][A-Za-z0-9_]*(\.[A-Za-z_][A-Za-z0-9_]*)?', Name), 1062 (r'[A-Za-z_][A-Za-z0-9_]*(\.[A-Za-z_][A-Za-z0-9_]*)?', Name),
1049 1063
1050 ("'", String.Single, combined('stringescape', 'sqs')), 1064 ("'", String.Single, combined('stringescape', 'sqs')),
1051 ('"', String.Double, combined('stringescape', 'dqs')) 1065 ('"', String.Double, combined('stringescape', 'dqs'))
1052 ], 1066 ],
1053 1067
1054 'funcname': [ 1068 'funcname': [
1069 (r'\s+', Text),
1055 ('(?:([A-Za-z_][A-Za-z0-9_]*)(\.))?([A-Za-z_][A-Za-z0-9_]*)', 1070 ('(?:([A-Za-z_][A-Za-z0-9_]*)(\.))?([A-Za-z_][A-Za-z0-9_]*)',
1056 bygroups(Name.Class, Punctuation, Name.Function), '#pop'), 1071 bygroups(Name.Class, Punctuation, Name.Function), '#pop'),
1057 # inline function 1072 # inline function
1058 ('\(', Punctuation, '#pop'), 1073 ('\(', Punctuation, '#pop'),
1059 ],
1060
1061 'classname': [
1062 ('[A-Za-z_][A-Za-z0-9_]*', Name.Class, '#pop')
1063 ], 1074 ],
1064 1075
1065 # if I understand correctly, every character is valid in a lua string, 1076 # if I understand correctly, every character is valid in a lua string,
1066 # so this state is only for later corrections 1077 # so this state is only for later corrections
1067 'string': [ 1078 'string': [
1108 yield index, Name, a 1119 yield index, Name, a
1109 yield index + len(a), Punctuation, '.' 1120 yield index + len(a), Punctuation, '.'
1110 yield index + len(a) + 1, Name, b 1121 yield index + len(a) + 1, Name, b
1111 continue 1122 continue
1112 yield index, token, value 1123 yield index, token, value
1124
1125
1126 class MoonScriptLexer(LuaLexer):
1127 """
1128 For `MoonScript <http://moonscript.org.org>`_ source code.
1129
1130 *New in Pygments 1.5.*
1131 """
1132
1133 name = "MoonScript"
1134 aliases = ["moon", "moonscript"]
1135 filenames = ["*.moon"]
1136 mimetypes = ['text/x-moonscript', 'application/x-moonscript']
1137
1138 tokens = {
1139 'root': [
1140 (r'#!(.*?)$', Comment.Preproc),
1141 (r'', Text, 'base'),
1142 ],
1143 'base': [
1144 ('--.*$', Comment.Single),
1145 (r'(?i)(\d*\.\d+|\d+\.\d*)(e[+-]?\d+)?', Number.Float),
1146 (r'(?i)\d+e[+-]?\d+', Number.Float),
1147 (r'(?i)0x[0-9a-f]*', Number.Hex),
1148 (r'\d+', Number.Integer),
1149 (r'\n', Text),
1150 (r'[^\S\n]+', Text),
1151 (r'(?s)\[(=*)\[.*?\]\1\]', String),
1152 (r'(->|=>)', Name.Function),
1153 (r':[a-zA-Z_][a-zA-Z0-9_]*', Name.Variable),
1154 (r'(==|!=|~=|<=|>=|\.\.\.|\.\.|[=+\-*/%^<>#!.\\:])', Operator),
1155 (r'[;,]', Punctuation),
1156 (r'[\[\]\{\}\(\)]', Keyword.Type),
1157 (r'[a-zA-Z_][a-zA-Z0-9_]*:', Name.Variable),
1158 (r"(class|extends|if|then|super|do|with|import|export|"
1159 r"while|elseif|return|for|in|from|when|using|else|"
1160 r"and|or|not|switch|break)\b", Keyword),
1161 (r'(true|false|nil)\b', Keyword.Constant),
1162 (r'(and|or|not)\b', Operator.Word),
1163 (r'(self)\b', Name.Builtin.Pseudo),
1164 (r'@@?([a-zA-Z_][a-zA-Z0-9_]*)?', Name.Variable.Class),
1165 (r'[A-Z]\w*', Name.Class), # proper name
1166 (r'[A-Za-z_][A-Za-z0-9_]*(\.[A-Za-z_][A-Za-z0-9_]*)?', Name),
1167 ("'", String.Single, combined('stringescape', 'sqs')),
1168 ('"', String.Double, combined('stringescape', 'dqs'))
1169 ],
1170 'stringescape': [
1171 (r'''\\([abfnrtv\\"']|\d{1,3})''', String.Escape)
1172 ],
1173 'sqs': [
1174 ("'", String.Single, '#pop'),
1175 (".", String)
1176 ],
1177 'dqs': [
1178 ('"', String.Double, '#pop'),
1179 (".", String)
1180 ]
1181 }
1182
1183 def get_tokens_unprocessed(self, text):
1184 # set . as Operator instead of Punctuation
1185 for index, token, value in \
1186 LuaLexer.get_tokens_unprocessed(self, text):
1187 if token == Punctuation and value == ".":
1188 token = Operator
1189 yield index, token, value
1190
1113 1191
1114 1192
1115 class MiniDLexer(RegexLexer): 1193 class MiniDLexer(RegexLexer):
1116 """ 1194 """
1117 For `MiniD <http://www.dsource.org/projects/minid>`_ (a D-like scripting 1195 For `MiniD <http://www.dsource.org/projects/minid>`_ (a D-like scripting
1152 r"""|\\u[0-9a-fA-F]{4}|\\U[0-9a-fA-F]{8}|.)'""", 1230 r"""|\\u[0-9a-fA-F]{4}|\\U[0-9a-fA-F]{8}|.)'""",
1153 String.Char 1231 String.Char
1154 ), 1232 ),
1155 # StringLiteral 1233 # StringLiteral
1156 # -- WysiwygString 1234 # -- WysiwygString
1157 (r'@"(""|.)*"', String), 1235 (r'@"(""|[^"])*"', String),
1158 # -- AlternateWysiwygString 1236 # -- AlternateWysiwygString
1159 (r'`(``|.)*`', String), 1237 (r'`(``|.)*`', String),
1160 # -- DoubleQuotedString 1238 # -- DoubleQuotedString
1161 (r'"(\\\\|\\"|[^"])*"', String), 1239 (r'"(\\\\|\\"|[^"])*"', String),
1162 # Tokens 1240 # Tokens
1206 (r'(clone|do|doFile|doString|method|for|if|else|elseif|then)\b', 1284 (r'(clone|do|doFile|doString|method|for|if|else|elseif|then)\b',
1207 Keyword), 1285 Keyword),
1208 # constants 1286 # constants
1209 (r'(nil|false|true)\b', Name.Constant), 1287 (r'(nil|false|true)\b', Name.Constant),
1210 # names 1288 # names
1211 ('(Object|list|List|Map|args|Sequence|Coroutine|File)\b', 1289 (r'(Object|list|List|Map|args|Sequence|Coroutine|File)\b',
1212 Name.Builtin), 1290 Name.Builtin),
1213 ('[a-zA-Z_][a-zA-Z0-9_]*', Name), 1291 ('[a-zA-Z_][a-zA-Z0-9_]*', Name),
1214 # numbers 1292 # numbers
1215 (r'(\d+\.?\d*|\d*\.\d+)([eE][+-]?[0-9]+)?', Number.Float), 1293 (r'(\d+\.?\d*|\d*\.\d+)([eE][+-]?[0-9]+)?', Number.Float),
1216 (r'\d+', Number.Integer) 1294 (r'\d+', Number.Integer)
1298 (r'([\w\.\-\:]+)', Text), 1376 (r'([\w\.\-\:]+)', Text),
1299 ], 1377 ],
1300 'params': [ 1378 'params': [
1301 (r';', Keyword, '#pop'), 1379 (r';', Keyword, '#pop'),
1302 (r'\n', Text, '#pop'), 1380 (r'\n', Text, '#pop'),
1303 (r'(else|elseif|then)', Keyword), 1381 (r'(else|elseif|then)\b', Keyword),
1304 include('basic'), 1382 include('basic'),
1305 include('data'), 1383 include('data'),
1306 ], 1384 ],
1307 'params-in-brace': [ 1385 'params-in-brace': [
1308 (r'}', Keyword, ('#pop', '#pop')), 1386 (r'}', Keyword, ('#pop', '#pop')),
1350 ], 1428 ],
1351 } 1429 }
1352 1430
1353 def analyse_text(text): 1431 def analyse_text(text):
1354 return shebang_matches(text, r'(tcl)') 1432 return shebang_matches(text, r'(tcl)')
1355
1356
1357 class ClojureLexer(RegexLexer):
1358 """
1359 Lexer for `Clojure <http://clojure.org/>`_ source code.
1360
1361 *New in Pygments 0.11.*
1362 """
1363 name = 'Clojure'
1364 aliases = ['clojure', 'clj']
1365 filenames = ['*.clj']
1366 mimetypes = ['text/x-clojure', 'application/x-clojure']
1367
1368 keywords = [
1369 'fn', 'def', 'defn', 'defmacro', 'defmethod', 'defmulti', 'defn-',
1370 'defstruct',
1371 'if', 'cond',
1372 'let', 'for'
1373 ]
1374 builtins = [
1375 '.', '..',
1376 '*', '+', '-', '->', '..', '/', '<', '<=', '=', '==', '>', '>=',
1377 'accessor', 'agent', 'agent-errors', 'aget', 'alength', 'all-ns',
1378 'alter', 'and', 'append-child', 'apply', 'array-map', 'aset',
1379 'aset-boolean', 'aset-byte', 'aset-char', 'aset-double', 'aset-float',
1380 'aset-int', 'aset-long', 'aset-short', 'assert', 'assoc', 'await',
1381 'await-for', 'bean', 'binding', 'bit-and', 'bit-not', 'bit-or',
1382 'bit-shift-left', 'bit-shift-right', 'bit-xor', 'boolean', 'branch?',
1383 'butlast', 'byte', 'cast', 'char', 'children', 'class',
1384 'clear-agent-errors', 'comment', 'commute', 'comp', 'comparator',
1385 'complement', 'concat', 'conj', 'cons', 'constantly',
1386 'construct-proxy', 'contains?', 'count', 'create-ns', 'create-struct',
1387 'cycle', 'dec', 'deref', 'difference', 'disj', 'dissoc', 'distinct',
1388 'doall', 'doc', 'dorun', 'doseq', 'dosync', 'dotimes', 'doto',
1389 'double', 'down', 'drop', 'drop-while', 'edit', 'end?', 'ensure',
1390 'eval', 'every?', 'false?', 'ffirst', 'file-seq', 'filter', 'find',
1391 'find-doc', 'find-ns', 'find-var', 'first', 'float', 'flush',
1392 'fnseq', 'frest', 'gensym', 'get', 'get-proxy-class',
1393 'hash-map', 'hash-set', 'identical?', 'identity', 'if-let', 'import',
1394 'in-ns', 'inc', 'index', 'insert-child', 'insert-left', 'insert-right',
1395 'inspect-table', 'inspect-tree', 'instance?', 'int', 'interleave',
1396 'intersection', 'into', 'into-array', 'iterate', 'join', 'key', 'keys',
1397 'keyword', 'keyword?', 'last', 'lazy-cat', 'lazy-cons', 'left',
1398 'lefts', 'line-seq', 'list', 'list*', 'load', 'load-file',
1399 'locking', 'long', 'loop', 'macroexpand', 'macroexpand-1',
1400 'make-array', 'make-node', 'map', 'map-invert', 'map?', 'mapcat',
1401 'max', 'max-key', 'memfn', 'merge', 'merge-with', 'meta', 'min',
1402 'min-key', 'name', 'namespace', 'neg?', 'new', 'newline', 'next',
1403 'nil?', 'node', 'not', 'not-any?', 'not-every?', 'not=', 'ns-imports',
1404 'ns-interns', 'ns-map', 'ns-name', 'ns-publics', 'ns-refers',
1405 'ns-resolve', 'ns-unmap', 'nth', 'nthrest', 'or', 'parse', 'partial',
1406 'path', 'peek', 'pop', 'pos?', 'pr', 'pr-str', 'print', 'print-str',
1407 'println', 'println-str', 'prn', 'prn-str', 'project', 'proxy',
1408 'proxy-mappings', 'quot', 'rand', 'rand-int', 'range', 're-find',
1409 're-groups', 're-matcher', 're-matches', 're-pattern', 're-seq',
1410 'read', 'read-line', 'reduce', 'ref', 'ref-set', 'refer', 'rem',
1411 'remove', 'remove-method', 'remove-ns', 'rename', 'rename-keys',
1412 'repeat', 'replace', 'replicate', 'resolve', 'rest', 'resultset-seq',
1413 'reverse', 'rfirst', 'right', 'rights', 'root', 'rrest', 'rseq',
1414 'second', 'select', 'select-keys', 'send', 'send-off', 'seq',
1415 'seq-zip', 'seq?', 'set', 'short', 'slurp', 'some', 'sort',
1416 'sort-by', 'sorted-map', 'sorted-map-by', 'sorted-set',
1417 'special-symbol?', 'split-at', 'split-with', 'str', 'string?',
1418 'struct', 'struct-map', 'subs', 'subvec', 'symbol', 'symbol?',
1419 'sync', 'take', 'take-nth', 'take-while', 'test', 'time', 'to-array',
1420 'to-array-2d', 'tree-seq', 'true?', 'union', 'up', 'update-proxy',
1421 'val', 'vals', 'var-get', 'var-set', 'var?', 'vector', 'vector-zip',
1422 'vector?', 'when', 'when-first', 'when-let', 'when-not',
1423 'with-local-vars', 'with-meta', 'with-open', 'with-out-str',
1424 'xml-seq', 'xml-zip', 'zero?', 'zipmap', 'zipper']
1425
1426 # valid names for identifiers
1427 # well, names can only not consist fully of numbers
1428 # but this should be good enough for now
1429 valid_name = r'[a-zA-Z0-9!$%&*+,/:<=>?@^_~-]+'
1430
1431 tokens = {
1432 'root' : [
1433 # the comments - always starting with semicolon
1434 # and going to the end of the line
1435 (r';.*$', Comment.Single),
1436
1437 # whitespaces - usually not relevant
1438 (r'\s+', Text),
1439
1440 # numbers
1441 (r'-?\d+\.\d+', Number.Float),
1442 (r'-?\d+', Number.Integer),
1443 # support for uncommon kinds of numbers -
1444 # have to figure out what the characters mean
1445 #(r'(#e|#i|#b|#o|#d|#x)[\d.]+', Number),
1446
1447 # strings, symbols and characters
1448 (r'"(\\\\|\\"|[^"])*"', String),
1449 (r"'" + valid_name, String.Symbol),
1450 (r"\\([()/'\".'_!§$%& ?;=#+-]{1}|[a-zA-Z0-9]+)", String.Char),
1451
1452 # constants
1453 (r'(#t|#f)', Name.Constant),
1454
1455 # special operators
1456 (r"('|#|`|,@|,|\.)", Operator),
1457
1458 # highlight the keywords
1459 ('(%s)' % '|'.join([
1460 re.escape(entry) + ' ' for entry in keywords]),
1461 Keyword
1462 ),
1463
1464 # first variable in a quoted string like
1465 # '(this is syntactic sugar)
1466 (r"(?<='\()" + valid_name, Name.Variable),
1467 (r"(?<=#\()" + valid_name, Name.Variable),
1468
1469 # highlight the builtins
1470 ("(?<=\()(%s)" % '|'.join([
1471 re.escape(entry) + ' ' for entry in builtins]),
1472 Name.Builtin
1473 ),
1474
1475 # the remaining functions
1476 (r'(?<=\()' + valid_name, Name.Function),
1477 # find the remaining variables
1478 (valid_name, Name.Variable),
1479
1480 # Clojure accepts vector notation
1481 (r'(\[|\])', Punctuation),
1482
1483 # Clojure accepts map notation
1484 (r'(\{|\})', Punctuation),
1485
1486 # the famous parentheses!
1487 (r'(\(|\))', Punctuation),
1488 ],
1489 }
1490 1433
1491 1434
1492 class FactorLexer(RegexLexer): 1435 class FactorLexer(RegexLexer):
1493 """ 1436 """
1494 Lexer for the `Factor <http://factorcode.org>`_ language. 1437 Lexer for the `Factor <http://factorcode.org>`_ language.
1649 # TODO: (( inputs -- outputs )) 1592 # TODO: (( inputs -- outputs ))
1650 # TODO: << ... >> 1593 # TODO: << ... >>
1651 1594
1652 # defining words 1595 # defining words
1653 (r'(\s*)(:|::|MACRO:|MEMO:)(\s+)(\S+)', 1596 (r'(\s*)(:|::|MACRO:|MEMO:)(\s+)(\S+)',
1654 bygroups(Text, Keyword, Text, Name.Function)), 1597 bygroups(Text, Keyword, Text, Name.Function)),
1655 (r'(\s*)(M:)(\s+)(\S+)(\s+)(\S+)', 1598 (r'(\s*)(M:)(\s+)(\S+)(\s+)(\S+)',
1656 bygroups(Text, Keyword, Text, Name.Class, Text, Name.Function)), 1599 bygroups(Text, Keyword, Text, Name.Class, Text, Name.Function)),
1657 (r'(\s*)(GENERIC:)(\s+)(\S+)', 1600 (r'(\s*)(GENERIC:)(\s+)(\S+)',
1658 bygroups(Text, Keyword, Text, Name.Function)), 1601 bygroups(Text, Keyword, Text, Name.Function)),
1659 (r'(\s*)(HOOK:|GENERIC#)(\s+)(\S+)(\s+)(\S+)', 1602 (r'(\s*)(HOOK:|GENERIC#)(\s+)(\S+)(\s+)(\S+)',
1660 bygroups(Text, Keyword, Text, Name.Function, Text, Name.Function)), 1603 bygroups(Text, Keyword, Text, Name.Function, Text, Name.Function)),
1661 (r'(\()(\s+)', bygroups(Name.Function, Text), 'stackeffect'), 1604 (r'(\()(\s+)', bygroups(Name.Function, Text), 'stackeffect'),
1662 (r'\;\s', Keyword), 1605 (r'\;\s', Keyword),
1663 1606
1664 # imports and namespaces 1607 # imports and namespaces
1665 (r'(USING:)((?:\s|\\\s)+)', bygroups(Keyword.Namespace, Text), 'import'), 1608 (r'(USING:)((?:\s|\\\s)+)',
1666 (r'(USE:)(\s+)(\S+)', bygroups(Keyword.Namespace, Text, Name.Namespace)), 1609 bygroups(Keyword.Namespace, Text), 'import'),
1667 (r'(UNUSE:)(\s+)(\S+)', bygroups(Keyword.Namespace, Text, Name.Namespace)), 1610 (r'(USE:)(\s+)(\S+)',
1611 bygroups(Keyword.Namespace, Text, Name.Namespace)),
1612 (r'(UNUSE:)(\s+)(\S+)',
1613 bygroups(Keyword.Namespace, Text, Name.Namespace)),
1668 (r'(QUALIFIED:)(\s+)(\S+)', 1614 (r'(QUALIFIED:)(\s+)(\S+)',
1669 bygroups(Keyword.Namespace, Text, Name.Namespace)), 1615 bygroups(Keyword.Namespace, Text, Name.Namespace)),
1670 (r'(QUALIFIED-WITH:)(\s+)(\S+)', 1616 (r'(QUALIFIED-WITH:)(\s+)(\S+)',
1671 bygroups(Keyword.Namespace, Text, Name.Namespace)), 1617 bygroups(Keyword.Namespace, Text, Name.Namespace)),
1672 (r'(FROM:|EXCLUDE:)(\s+)(\S+)(\s+)(=>)', 1618 (r'(FROM:|EXCLUDE:)(\s+)(\S+)(\s+)(=>)',
1673 bygroups(Keyword.Namespace, Text, Name.Namespace, Text, Text)), 1619 bygroups(Keyword.Namespace, Text, Name.Namespace, Text, Text)),
1674 (r'(IN:)(\s+)(\S+)', bygroups(Keyword.Namespace, Text, Name.Namespace)), 1620 (r'(IN:)(\s+)(\S+)',
1621 bygroups(Keyword.Namespace, Text, Name.Namespace)),
1675 (r'(?:ALIAS|DEFER|FORGET|POSTPONE):', Keyword.Namespace), 1622 (r'(?:ALIAS|DEFER|FORGET|POSTPONE):', Keyword.Namespace),
1676 1623
1677 # tuples and classes 1624 # tuples and classes
1678 (r'(TUPLE:)(\s+)(\S+)(\s+<\s+)(\S+)', 1625 (r'(TUPLE:)(\s+)(\S+)(\s+<\s+)(\S+)',
1679 bygroups(Keyword, Text, Name.Class, Text, Name.Class), 'slots'), 1626 bygroups(Keyword, Text, Name.Class, Text, Name.Class), 'slots'),
1680 (r'(TUPLE:)(\s+)(\S+)', bygroups(Keyword, Text, Name.Class), 'slots'), 1627 (r'(TUPLE:)(\s+)(\S+)',
1628 bygroups(Keyword, Text, Name.Class), 'slots'),
1681 (r'(UNION:)(\s+)(\S+)', bygroups(Keyword, Text, Name.Class)), 1629 (r'(UNION:)(\s+)(\S+)', bygroups(Keyword, Text, Name.Class)),
1682 (r'(INTERSECTION:)(\s+)(\S+)', bygroups(Keyword, Text, Name.Class)), 1630 (r'(INTERSECTION:)(\s+)(\S+)', bygroups(Keyword, Text, Name.Class)),
1683 (r'(PREDICATE:)(\s+)(\S+)(\s+<\s+)(\S+)', 1631 (r'(PREDICATE:)(\s+)(\S+)(\s+<\s+)(\S+)',
1684 bygroups(Keyword, Text, Name.Class, Text, Name.Class)), 1632 bygroups(Keyword, Text, Name.Class, Text, Name.Class)),
1685 (r'(C:)(\s+)(\S+)(\s+)(\S+)', 1633 (r'(C:)(\s+)(\S+)(\s+)(\S+)',
1693 (r'CONSTANT:', Keyword), 1641 (r'CONSTANT:', Keyword),
1694 (r'(?:SYMBOL|SYMBOLS):', Keyword), 1642 (r'(?:SYMBOL|SYMBOLS):', Keyword),
1695 (r'ERROR:', Keyword), 1643 (r'ERROR:', Keyword),
1696 (r'SYNTAX:', Keyword), 1644 (r'SYNTAX:', Keyword),
1697 (r'(HELP:)(\s+)(\S+)', bygroups(Keyword, Text, Name.Function)), 1645 (r'(HELP:)(\s+)(\S+)', bygroups(Keyword, Text, Name.Function)),
1698 (r'(MAIN:)(\s+)(\S+)', bygroups(Keyword.Namespace, Text, Name.Function)), 1646 (r'(MAIN:)(\s+)(\S+)',
1647 bygroups(Keyword.Namespace, Text, Name.Function)),
1699 (r'(?:ALIEN|TYPEDEF|FUNCTION|STRUCT):', Keyword), 1648 (r'(?:ALIEN|TYPEDEF|FUNCTION|STRUCT):', Keyword),
1700 1649
1701 # vocab.private 1650 # vocab.private
1702 # TODO: words inside vocab.private should have red names? 1651 # TODO: words inside vocab.private should have red names?
1703 (r'(?:<PRIVATE|PRIVATE>)', Keyword.Namespace), 1652 (r'(?:<PRIVATE|PRIVATE>)', Keyword.Namespace),
1723 1672
1724 # operators 1673 # operators
1725 (r'[-+/*=<>^]\s', Operator), 1674 (r'[-+/*=<>^]\s', Operator),
1726 1675
1727 # keywords 1676 # keywords
1728 (r'(?:deprecated|final|foldable|flushable|inline|recursive)\s', Keyword), 1677 (r'(?:deprecated|final|foldable|flushable|inline|recursive)\s',
1678 Keyword),
1729 1679
1730 # builtins 1680 # builtins
1731 (builtin_kernel, Name.Builtin), 1681 (builtin_kernel, Name.Builtin),
1732 (builtin_assocs, Name.Builtin), 1682 (builtin_assocs, Name.Builtin),
1733 (builtin_combinators, Name.Builtin), 1683 (builtin_combinators, Name.Builtin),
1767 (r'\s+', Text), 1717 (r'\s+', Text),
1768 ], 1718 ],
1769 } 1719 }
1770 1720
1771 1721
1772 class IokeLexer(RegexLexer): 1722 class FancyLexer(RegexLexer):
1773 """ 1723 """
1774 For `Ioke <http://ioke.org/>`_ (a strongly typed, dynamic, 1724 Pygments Lexer For `Fancy <http://www.fancy-lang.org/>`_.
1775 prototype based programming language) source. 1725
1776 1726 Fancy is a self-hosted, pure object-oriented, dynamic,
1777 *New in Pygments 1.4.* 1727 class-based, concurrent general-purpose programming language
1778 """ 1728 running on Rubinius, the Ruby VM.
1779 name = 'Ioke' 1729
1780 filenames = ['*.ik'] 1730 *New in Pygments 1.5.*
1781 aliases = ['ioke', 'ik'] 1731 """
1782 mimetypes = ['text/x-iokesrc'] 1732 name = 'Fancy'
1733 filenames = ['*.fy', '*.fancypack']
1734 aliases = ['fancy', 'fy']
1735 mimetypes = ['text/x-fancysrc']
1736
1783 tokens = { 1737 tokens = {
1784 'interpolatableText': [ 1738 # copied from PerlLexer:
1785 (r'(\\b|\\e|\\t|\\n|\\f|\\r|\\"|\\\\|\\#|\\\Z|\\u[0-9a-fA-F]{1,4}' 1739 'balanced-regex': [
1786 r'|\\[0-3]?[0-7]?[0-7])', String.Escape), 1740 (r'/(\\\\|\\/|[^/])*/[egimosx]*', String.Regex, '#pop'),
1787 (r'#{', Punctuation, 'textInterpolationRoot') 1741 (r'!(\\\\|\\!|[^!])*![egimosx]*', String.Regex, '#pop'),
1788 ], 1742 (r'\\(\\\\|[^\\])*\\[egimosx]*', String.Regex, '#pop'),
1789 1743 (r'{(\\\\|\\}|[^}])*}[egimosx]*', String.Regex, '#pop'),
1790 'text': [ 1744 (r'<(\\\\|\\>|[^>])*>[egimosx]*', String.Regex, '#pop'),
1791 (r'(?<!\\)"', String, '#pop'), 1745 (r'\[(\\\\|\\\]|[^\]])*\][egimosx]*', String.Regex, '#pop'),
1792 include('interpolatableText'), 1746 (r'\((\\\\|\\\)|[^\)])*\)[egimosx]*', String.Regex, '#pop'),
1793 (r'[^"]', String) 1747 (r'@(\\\\|\\\@|[^\@])*@[egimosx]*', String.Regex, '#pop'),
1794 ], 1748 (r'%(\\\\|\\\%|[^\%])*%[egimosx]*', String.Regex, '#pop'),
1795 1749 (r'\$(\\\\|\\\$|[^\$])*\$[egimosx]*', String.Regex, '#pop'),
1796 'documentation': [ 1750 ],
1797 (r'(?<!\\)"', String.Doc, '#pop'),
1798 include('interpolatableText'),
1799 (r'[^"]', String.Doc)
1800 ],
1801
1802 'textInterpolationRoot': [
1803 (r'}', Punctuation, '#pop'),
1804 include('root')
1805 ],
1806
1807 'slashRegexp': [
1808 (r'(?<!\\)/[oxpniums]*', String.Regex, '#pop'),
1809 include('interpolatableText'),
1810 (r'\\/', String.Regex),
1811 (r'[^/]', String.Regex)
1812 ],
1813
1814 'squareRegexp': [
1815 (r'(?<!\\)][oxpniums]*', String.Regex, '#pop'),
1816 include('interpolatableText'),
1817 (r'\\]', String.Regex),
1818 (r'[^\]]', String.Regex)
1819 ],
1820
1821 'squareText': [
1822 (r'(?<!\\)]', String, '#pop'),
1823 include('interpolatableText'),
1824 (r'[^\]]', String)
1825 ],
1826
1827 'root': [ 1751 'root': [
1828 (r'\n', Text),
1829 (r'\s+', Text), 1752 (r'\s+', Text),
1830 1753
1754 # balanced delimiters (copied from PerlLexer):
1755 (r's{(\\\\|\\}|[^}])*}\s*', String.Regex, 'balanced-regex'),
1756 (r's<(\\\\|\\>|[^>])*>\s*', String.Regex, 'balanced-regex'),
1757 (r's\[(\\\\|\\\]|[^\]])*\]\s*', String.Regex, 'balanced-regex'),
1758 (r's\((\\\\|\\\)|[^\)])*\)\s*', String.Regex, 'balanced-regex'),
1759 (r'm?/(\\\\|\\/|[^/\n])*/[gcimosx]*', String.Regex),
1760 (r'm(?=[/!\\{<\[\(@%\$])', String.Regex, 'balanced-regex'),
1761
1831 # Comments 1762 # Comments
1832 (r';(.*?)\n', Comment), 1763 (r'#(.*?)\n', Comment.Single),
1833 (r'\A#!(.*?)\n', Comment), 1764 # Symbols
1834 1765 (r'\'([^\'\s\[\]\(\)\{\}]+|\[\])', String.Symbol),
1835 #Regexps 1766 # Multi-line DoubleQuotedString
1836 (r'#/', String.Regex, 'slashRegexp'), 1767 (r'"""(\\\\|\\"|[^"])*"""', String),
1837 (r'#r\[', String.Regex, 'squareRegexp'), 1768 # DoubleQuotedString
1838 1769 (r'"(\\\\|\\"|[^"])*"', String),
1839 #Symbols
1840 (r':[a-zA-Z0-9_!:?]+', String.Symbol),
1841 (r'[a-zA-Z0-9_!:?]+:(?![a-zA-Z0-9_!?])', String.Other),
1842 (r':"(\\\\|\\"|[^"])*"', String.Symbol),
1843
1844 #Documentation
1845 (r'((?<=fn\()|(?<=fnx\()|(?<=method\()|(?<=macro\()|(?<=lecro\()'
1846 r'|(?<=syntax\()|(?<=dmacro\()|(?<=dlecro\()|(?<=dlecrox\()'
1847 r'|(?<=dsyntax\())[\s\n\r]*"', String.Doc, 'documentation'),
1848
1849 #Text
1850 (r'"', String, 'text'),
1851 (r'#\[', String, 'squareText'),
1852
1853 #Mimic
1854 (r'[a-zA-Z0-9_][a-zA-Z0-9!?_:]+(?=\s*=.*mimic\s)', Name.Entity),
1855
1856 #Assignment
1857 (r'[a-zA-Z_][a-zA-Z0-9_!:?]*(?=[\s]*[+*/-]?=[^=].*($|\.))', Name.Variable),
1858
1859 # keywords 1770 # keywords
1860 (r'(break|cond|continue|do|ensure|for|for:dict|for:set|if|let|' 1771 (r'(def|class|try|catch|finally|retry|return|return_local|match|'
1861 r'loop|p:for|p:for:dict|p:for:set|return|unless|until|while|' 1772 r'case|->|=>)\b', Keyword),
1862 r'with)(?![a-zA-Z0-9!:_?])', Keyword.Reserved),
1863
1864 # Origin
1865 (r'(eval|mimic|print|println)(?![a-zA-Z0-9!:_?])', Keyword),
1866
1867 # Base
1868 (r'(cell\?|cellNames|cellOwner\?|cellOwner|cells|cell|'
1869 r'documentation|hash|identity|mimic|removeCell\!|undefineCell\!)'
1870 r'(?![a-zA-Z0-9!:_?])', Keyword),
1871
1872 # Ground
1873 (r'(stackTraceAsText)(?![a-zA-Z0-9!:_?])', Keyword),
1874
1875 #DefaultBehaviour Literals
1876 (r'(dict|list|message|set)(?![a-zA-Z0-9!:_?])', Keyword.Reserved),
1877
1878 #DefaultBehaviour Case
1879 (r'(case|case:and|case:else|case:nand|case:nor|case:not|case:or|'
1880 r'case:otherwise|case:xor)(?![a-zA-Z0-9!:_?])', Keyword.Reserved),
1881
1882 #DefaultBehaviour Reflection
1883 (r'(asText|become\!|derive|freeze\!|frozen\?|in\?|is\?|kind\?|'
1884 r'mimic\!|mimics|mimics\?|prependMimic\!|removeAllMimics\!|'
1885 r'removeMimic\!|same\?|send|thaw\!|uniqueHexId)'
1886 r'(?![a-zA-Z0-9!:_?])', Keyword),
1887
1888 #DefaultBehaviour Aspects
1889 (r'(after|around|before)(?![a-zA-Z0-9!:_?])', Keyword.Reserved),
1890
1891 # DefaultBehaviour
1892 (r'(kind|cellDescriptionDict|cellSummary|genSym|inspect|notice)'
1893 r'(?![a-zA-Z0-9!:_?])', Keyword),
1894 (r'(use|destructuring)', Keyword.Reserved),
1895
1896 #DefaultBehavior BaseBehavior
1897 (r'(cell\?|cellOwner\?|cellOwner|cellNames|cells|cell|'
1898 r'documentation|identity|removeCell!|undefineCell)'
1899 r'(?![a-zA-Z0-9!:_?])', Keyword),
1900
1901 #DefaultBehavior Internal
1902 (r'(internal:compositeRegexp|internal:concatenateText|'
1903 r'internal:createDecimal|internal:createNumber|'
1904 r'internal:createRegexp|internal:createText)'
1905 r'(?![a-zA-Z0-9!:_?])', Keyword.Reserved),
1906
1907 #DefaultBehaviour Conditions
1908 (r'(availableRestarts|bind|error\!|findRestart|handle|'
1909 r'invokeRestart|rescue|restart|signal\!|warn\!)'
1910 r'(?![a-zA-Z0-9!:_?])', Keyword.Reserved),
1911
1912 # constants 1773 # constants
1913 (r'(nil|false|true)(?![a-zA-Z0-9!:_?])', Name.Constant), 1774 (r'(self|super|nil|false|true)\b', Name.Constant),
1914 1775 (r'[(){};,/?\|:\\]', Punctuation),
1915 # names 1776 # names
1916 (r'(Arity|Base|Call|Condition|DateTime|Aspects|Pointcut|' 1777 (r'(Object|Array|Hash|Directory|File|Class|String|Number|'
1917 r'Assignment|BaseBehavior|Boolean|Case|AndCombiner|Else|' 1778 r'Enumerable|FancyEnumerable|Block|TrueClass|NilClass|'
1918 r'NAndCombiner|NOrCombiner|NotCombiner|OrCombiner|XOrCombiner|' 1779 r'FalseClass|Tuple|Symbol|Stack|Set|FancySpec|Method|Package|'
1919 r'Conditions|Definitions|FlowControl|Internal|Literals|' 1780 r'Range)\b', Name.Builtin),
1920 r'Reflection|DefaultMacro|DefaultMethod|DefaultSyntax|Dict|'
1921 r'FileSystem|Ground|Handler|Hook|IO|IokeGround|Struct|'
1922 r'LexicalBlock|LexicalMacro|List|Message|Method|Mixins|'
1923 r'NativeMethod|Number|Origin|Pair|Range|Reflector|Regexp Match|'
1924 r'Regexp|Rescue|Restart|Runtime|Sequence|Set|Symbol|'
1925 r'System|Text|Tuple)(?![a-zA-Z0-9!:_?])', Name.Builtin),
1926
1927 # functions 1781 # functions
1928 (r'(generateMatchMethod|aliasMethod|\u03bb|\u028E|fnx|fn|method|' 1782 (r'[a-zA-Z]([a-zA-Z0-9_]|[-+?!=*/^><%])*:', Name.Function),
1929 r'dmacro|dlecro|syntax|macro|dlecrox|lecrox|lecro|syntax)' 1783 # operators, must be below functions
1930 r'(?![a-zA-Z0-9!:_?])', Name.Function), 1784 (r'[-+*/~,<>=&!?%^\[\]\.$]+', Operator),
1931 1785 ('[A-Z][a-zA-Z0-9_]*', Name.Constant),
1932 # Numbers 1786 ('@[a-zA-Z_][a-zA-Z0-9_]*', Name.Variable.Instance),
1933 (r'-?0[xX][0-9a-fA-F]+', Number.Hex), 1787 ('@@[a-zA-Z_][a-zA-Z0-9_]*', Name.Variable.Class),
1934 (r'-?(\d+\.?\d*|\d*\.\d+)([eE][+-]?[0-9]+)?', Number.Float), 1788 ('@@?', Operator),
1935 (r'-?\d+', Number.Integer), 1789 ('[a-zA-Z_][a-zA-Z0-9_]*', Name),
1936 1790 # numbers - / checks are necessary to avoid mismarking regexes,
1937 (r'#\(', Punctuation), 1791 # see comment in RubyLexer
1938 1792 (r'(0[oO]?[0-7]+(?:_[0-7]+)*)(\s*)([/?])?',
1939 # Operators 1793 bygroups(Number.Oct, Text, Operator)),
1940 (r'(&&>>|\|\|>>|\*\*>>|:::|::|\.\.\.|===|\*\*>|\*\*=|&&>|&&=|' 1794 (r'(0[xX][0-9A-Fa-f]+(?:_[0-9A-Fa-f]+)*)(\s*)([/?])?',
1941 r'\|\|>|\|\|=|\->>|\+>>|!>>|<>>>|<>>|&>>|%>>|#>>|@>>|/>>|\*>>|' 1795 bygroups(Number.Hex, Text, Operator)),
1942 r'\?>>|\|>>|\^>>|~>>|\$>>|=>>|<<=|>>=|<=>|<\->|=~|!~|=>|\+\+|' 1796 (r'(0[bB][01]+(?:_[01]+)*)(\s*)([/?])?',
1943 r'\-\-|<=|>=|==|!=|&&|\.\.|\+=|\-=|\*=|\/=|%=|&=|\^=|\|=|<\-|' 1797 bygroups(Number.Bin, Text, Operator)),
1944 r'\+>|!>|<>|&>|%>|#>|\@>|\/>|\*>|\?>|\|>|\^>|~>|\$>|<\->|\->|' 1798 (r'([\d]+(?:_\d+)*)(\s*)([/?])?',
1945 r'<<|>>|\*\*|\?\||\?&|\|\||>|<|\*|\/|%|\+|\-|&|\^|\||=|\$|!|~|' 1799 bygroups(Number.Integer, Text, Operator)),
1946 r'\?|#|\u2260|\u2218|\u2208|\u2209)', Operator), 1800 (r'\d+([eE][+-]?[0-9]+)|\d+\.\d+([eE][+-]?[0-9]+)?', Number.Float),
1947 (r'(and|nand|or|xor|nor|return|import)(?![a-zA-Z0-9_!?])', 1801 (r'\d+', Number.Integer)
1948 Operator),
1949
1950 # Punctuation
1951 (r'(\`\`|\`|\'\'|\'|\.|\,|@|@@|\[|\]|\(|\)|{|})', Punctuation),
1952
1953 #kinds
1954 (r'[A-Z][a-zA-Z0-9_!:?]*', Name.Class),
1955
1956 #default cellnames
1957 (r'[a-z_][a-zA-Z0-9_!:?]*', Name)
1958 ] 1802 ]
1959 } 1803 }

eric ide

mercurial