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'), |
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|' |
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'), |
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'), |
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 |
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+)', |
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 } |