eric6/ThirdParty/Pygments/pygments/lexers/javascript.py

changeset 7983
54c5cfbb1e29
parent 7701
25f42e208e08
equal deleted inserted replaced
7982:48d210e41c65 7983:54c5cfbb1e29
3 pygments.lexers.javascript 3 pygments.lexers.javascript
4 ~~~~~~~~~~~~~~~~~~~~~~~~~~ 4 ~~~~~~~~~~~~~~~~~~~~~~~~~~
5 5
6 Lexers for JavaScript and related languages. 6 Lexers for JavaScript and related languages.
7 7
8 :copyright: Copyright 2006-2020 by the Pygments team, see AUTHORS. 8 :copyright: Copyright 2006-2021 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
51 (r'/\*.*?\*/', Comment.Multiline) 51 (r'/\*.*?\*/', Comment.Multiline)
52 ], 52 ],
53 'slashstartsregex': [ 53 'slashstartsregex': [
54 include('commentsandwhitespace'), 54 include('commentsandwhitespace'),
55 (r'/(\\.|[^[/\\\n]|\[(\\.|[^\]\\\n])*])+/' 55 (r'/(\\.|[^[/\\\n]|\[(\\.|[^\]\\\n])*])+/'
56 r'([gimuy]+\b|\B)', String.Regex, '#pop'), 56 r'([gimuys]+\b|\B)', String.Regex, '#pop'),
57 (r'(?=/)', Text, ('#pop', 'badregex')), 57 (r'(?=/)', Text, ('#pop', 'badregex')),
58 default('#pop') 58 default('#pop')
59 ], 59 ],
60 'badregex': [ 60 'badregex': [
61 (r'\n', Text, '#pop') 61 (r'\n', Text, '#pop')
65 (r'^(?=\s|/|<!--)', Text, 'slashstartsregex'), 65 (r'^(?=\s|/|<!--)', Text, 'slashstartsregex'),
66 include('commentsandwhitespace'), 66 include('commentsandwhitespace'),
67 67
68 # Numeric literals 68 # Numeric literals
69 (r'0[bB][01]+n?', Number.Bin), 69 (r'0[bB][01]+n?', Number.Bin),
70 (r'0[oO]?[0-7]+n?', Number.Oct), # Browsers support "0o7" and "07" notations 70 (r'0[oO]?[0-7]+n?', Number.Oct), # Browsers support "0o7" and "07" (< ES5) notations
71 (r'0[xX][0-9a-fA-F]+n?', Number.Hex), 71 (r'0[xX][0-9a-fA-F]+n?', Number.Hex),
72 (r'[0-9]+n', Number.Integer), # Javascript BigInt requires an "n" postfix 72 (r'[0-9]+n', Number.Integer), # Javascript BigInt requires an "n" postfix
73 # Javascript doesn't have actual integer literals, so every other 73 # Javascript doesn't have actual integer literals, so every other
74 # numeric literal is handled by the regex below (including "normal") 74 # numeric literal is handled by the regex below (including "normal")
75 # integers 75 # integers
79 (r'\+\+|--|~|&&|\?|:|\|\||\\(?=\n)|' 79 (r'\+\+|--|~|&&|\?|:|\|\||\\(?=\n)|'
80 r'(<<|>>>?|==?|!=?|[-<>+*%&|^/])=?', Operator, 'slashstartsregex'), 80 r'(<<|>>>?|==?|!=?|[-<>+*%&|^/])=?', Operator, 'slashstartsregex'),
81 (r'[{(\[;,]', Punctuation, 'slashstartsregex'), 81 (r'[{(\[;,]', Punctuation, 'slashstartsregex'),
82 (r'[})\].]', Punctuation), 82 (r'[})\].]', Punctuation),
83 (r'(for|in|while|do|break|return|continue|switch|case|default|if|else|' 83 (r'(for|in|while|do|break|return|continue|switch|case|default|if|else|'
84 r'throw|try|catch|finally|new|delete|typeof|instanceof|void|yield|' 84 r'throw|try|catch|finally|new|delete|typeof|instanceof|void|yield|await|async|'
85 r'this|of)\b', Keyword, 'slashstartsregex'), 85 r'this|of|static|export|import|debugger|extends|super)\b', Keyword, 'slashstartsregex'),
86 (r'(var|let|with|function)\b', Keyword.Declaration, 'slashstartsregex'), 86 (r'(var|let|const|with|function|class)\b', Keyword.Declaration, 'slashstartsregex'),
87 (r'(abstract|boolean|byte|char|class|const|debugger|double|enum|export|' 87 (r'(abstract|boolean|byte|char|double|enum|final|float|goto'
88 r'extends|final|float|goto|implements|import|int|interface|long|native|' 88 r'implements|int|interface|long|native|package|private|protected'
89 r'package|private|protected|public|short|static|super|synchronized|throws|' 89 r'public|short|synchronized|throws|transient|volatile)\b', Keyword.Reserved),
90 r'transient|volatile)\b', Keyword.Reserved),
91 (r'(true|false|null|NaN|Infinity|undefined)\b', Keyword.Constant), 90 (r'(true|false|null|NaN|Infinity|undefined)\b', Keyword.Constant),
92 (r'(Array|Boolean|Date|Error|Function|Math|netscape|' 91 (r'(Array|Boolean|Date|BigInt|Error|Function|Math|'
93 r'Number|Object|Packages|RegExp|String|Promise|Proxy|sun|decodeURI|' 92 r'Number|Object|RegExp|String|Promise|Proxy|decodeURI|'
94 r'decodeURIComponent|encodeURI|encodeURIComponent|' 93 r'decodeURIComponent|encodeURI|encodeURIComponent|'
95 r'Error|eval|isFinite|isNaN|isSafeInteger|parseFloat|parseInt|' 94 r'Error|eval|isFinite|isNaN|isSafeInteger|parseFloat|parseInt|'
96 r'document|this|window)\b', Name.Builtin), 95 r'document|this|window|globalThis|Symbol)\b', Name.Builtin),
97 (JS_IDENT, Name.Other), 96 (JS_IDENT, Name.Other),
98 (r'"(\\\\|\\"|[^"])*"', String.Double), 97 (r'"(\\\\|\\[^\\]|[^"\\])*"', String.Double),
99 (r"'(\\\\|\\'|[^'])*'", String.Single), 98 (r"'(\\\\|\\[^\\]|[^'\\])*'", String.Single),
100 (r'`', String.Backtick, 'interp'), 99 (r'`', String.Backtick, 'interp'),
101 ], 100 ],
102 'interp': [ 101 'interp': [
103 (r'`', String.Backtick, '#pop'), 102 (r'`', String.Backtick, '#pop'),
104 (r'\\\\', String.Backtick), 103 (r'\\\\', String.Backtick),
110 'interp-inside': [ 109 'interp-inside': [
111 # TODO: should this include single-line comments and allow nesting strings? 110 # TODO: should this include single-line comments and allow nesting strings?
112 (r'\}', String.Interpol, '#pop'), 111 (r'\}', String.Interpol, '#pop'),
113 include('root'), 112 include('root'),
114 ], 113 ],
115 # (\\\\|\\`|[^`])*`', String.Backtick),
116 } 114 }
117 115
118 116
119 class KalLexer(RegexLexer): 117 class KalLexer(RegexLexer):
120 """ 118 """
159 include('root'), 157 include('root'),
160 ], 158 ],
161 'root': [ 159 'root': [
162 include('commentsandwhitespace'), 160 include('commentsandwhitespace'),
163 (r'/(?! )(\\.|[^[/\\\n]|\[(\\.|[^\]\\\n])*])+/' 161 (r'/(?! )(\\.|[^[/\\\n]|\[(\\.|[^\]\\\n])*])+/'
164 r'([gim]+\b|\B)', String.Regex), 162 r'([gimuys]+\b|\B)', String.Regex),
165 (r'\?|:|_(?=\n)|==?|!=|-(?!>)|[<>+*/-]=?', 163 (r'\?|:|_(?=\n)|==?|!=|-(?!>)|[<>+*/-]=?',
166 Operator), 164 Operator),
167 (r'\b(and|or|isnt|is|not|but|bitwise|mod|\^|xor|exists|' 165 (r'\b(and|or|isnt|is|not|but|bitwise|mod|\^|xor|exists|'
168 r'doesnt\s+exist)\b', Operator.Word), 166 r'doesnt\s+exist)\b', Operator.Word),
169 (r'(?:\([^()]+\))?\s*>', Name.Function), 167 (r'(?:\([^()]+\))?\s*>', Name.Function),
181 r'typeof|instanceof|super|run\s+in\s+parallel|' 179 r'typeof|instanceof|super|run\s+in\s+parallel|'
182 r'inherits\s+from)\b', Keyword), 180 r'inherits\s+from)\b', Keyword),
183 (r'(?<![.$])(true|false|yes|no|on|off|null|nothing|none|' 181 (r'(?<![.$])(true|false|yes|no|on|off|null|nothing|none|'
184 r'NaN|Infinity|undefined)\b', 182 r'NaN|Infinity|undefined)\b',
185 Keyword.Constant), 183 Keyword.Constant),
186 (r'(Array|Boolean|Date|Error|Function|Math|netscape|' 184 (r'(Array|Boolean|Date|Error|Function|Math|'
187 r'Number|Object|Packages|RegExp|String|sun|decodeURI|' 185 r'Number|Object|RegExp|String|decodeURI|'
188 r'decodeURIComponent|encodeURI|encodeURIComponent|' 186 r'decodeURIComponent|encodeURI|encodeURIComponent|'
189 r'eval|isFinite|isNaN|isSafeInteger|parseFloat|parseInt|document|' 187 r'eval|isFinite|isNaN|isSafeInteger|parseFloat|parseInt|document|'
190 r'window|' 188 r'window|globalThis|Symbol|print)\b', Name.Builtin),
191 r'print)\b',
192 Name.Builtin),
193 (r'[$a-zA-Z_][\w.$]*\s*(:|[+\-*/]?\=)?\b', Name.Variable), 189 (r'[$a-zA-Z_][\w.$]*\s*(:|[+\-*/]?\=)?\b', Name.Variable),
194 (r'[0-9][0-9]*\.[0-9]+([eE][0-9]+)?[fd]?', Number.Float), 190 (r'[0-9][0-9]*\.[0-9]+([eE][0-9]+)?[fd]?', Number.Float),
195 (r'0x[0-9a-fA-F]+', Number.Hex), 191 (r'0x[0-9a-fA-F]+', Number.Hex),
196 (r'[0-9]+', Number.Integer), 192 (r'[0-9]+', Number.Integer),
197 ('"""', String, 'tdqs'), 193 ('"""', String, 'tdqs'),
254 (r'/\*.*?\*/', Comment.Multiline), 250 (r'/\*.*?\*/', Comment.Multiline),
255 (r'#.*?\n', Comment.Single), 251 (r'#.*?\n', Comment.Single),
256 ], 252 ],
257 'multilineregex': [ 253 'multilineregex': [
258 include('commentsandwhitespace'), 254 include('commentsandwhitespace'),
259 (r'//([gim]+\b|\B)', String.Regex, '#pop'), 255 (r'//([gimuys]+\b|\B)', String.Regex, '#pop'),
260 (r'/', String.Regex), 256 (r'/', String.Regex),
261 (r'[^/#]+', String.Regex) 257 (r'[^/#]+', String.Regex)
262 ], 258 ],
263 'slashstartsregex': [ 259 'slashstartsregex': [
264 include('commentsandwhitespace'), 260 include('commentsandwhitespace'),
265 (r'//', String.Regex, ('#pop', 'multilineregex')), 261 (r'//', String.Regex, ('#pop', 'multilineregex')),
266 (r'/(?! )(\\.|[^[/\\\n]|\[(\\.|[^\]\\\n])*])+/' 262 (r'/(?! )(\\.|[^[/\\\n]|\[(\\.|[^\]\\\n])*])+/'
267 r'([gim]+\b|\B)', String.Regex, '#pop'), 263 r'([gimuys]+\b|\B)', String.Regex, '#pop'),
268 (r'/', Operator, '#pop'), 264 (r'/', Operator, '#pop'),
269 default('#pop'), 265 default('#pop'),
270 ], 266 ],
271 'root': [ 267 'root': [
272 (r'\A(?=\s|/)', Text, 'slashstartsregex'), 268 (r'\A(?=\s|/)', Text, 'slashstartsregex'),
286 r'extends|this|class|by|const|var|to|til)\b', Keyword, 282 r'extends|this|class|by|const|var|to|til)\b', Keyword,
287 'slashstartsregex'), 283 'slashstartsregex'),
288 (r'(?<![.$])(true|false|yes|no|on|off|' 284 (r'(?<![.$])(true|false|yes|no|on|off|'
289 r'null|NaN|Infinity|undefined|void)\b', 285 r'null|NaN|Infinity|undefined|void)\b',
290 Keyword.Constant), 286 Keyword.Constant),
291 (r'(Array|Boolean|Date|Error|Function|Math|netscape|' 287 (r'(Array|Boolean|Date|Error|Function|Math|'
292 r'Number|Object|Packages|RegExp|String|sun|decodeURI|' 288 r'Number|Object|RegExp|String|decodeURI|'
293 r'decodeURIComponent|encodeURI|encodeURIComponent|' 289 r'decodeURIComponent|encodeURI|encodeURIComponent|'
294 r'eval|isFinite|isNaN|parseFloat|parseInt|document|window)\b', 290 r'eval|isFinite|isNaN|parseFloat|parseInt|document|window|'
295 Name.Builtin), 291 r'globalThis|Symbol|Symbol|BigInt)\b', Name.Builtin),
296 (r'[$a-zA-Z_][\w.\-:$]*\s*[:=]\s', Name.Variable, 292 (r'[$a-zA-Z_][\w.\-:$]*\s*[:=]\s', Name.Variable,
297 'slashstartsregex'), 293 'slashstartsregex'),
298 (r'@[$a-zA-Z_][\w.\-:$]*\s*[:=]\s', Name.Variable.Instance, 294 (r'@[$a-zA-Z_][\w.\-:$]*\s*[:=]\s', Name.Variable.Instance,
299 'slashstartsregex'), 295 'slashstartsregex'),
300 (r'@', Name.Other, 'slashstartsregex'), 296 (r'@', Name.Other, 'slashstartsregex'),
473 (r'/\*.*?\*/', Comment.Multiline) 469 (r'/\*.*?\*/', Comment.Multiline)
474 ], 470 ],
475 'slashstartsregex': [ 471 'slashstartsregex': [
476 include('commentsandwhitespace'), 472 include('commentsandwhitespace'),
477 (r'/(\\.|[^[/\\\n]|\[(\\.|[^\]\\\n])*])+/' 473 (r'/(\\.|[^[/\\\n]|\[(\\.|[^\]\\\n])*])+/'
478 r'([gim]+\b|\B)', String.Regex, '#pop'), 474 r'([gimuys]+\b|\B)', String.Regex, '#pop'),
479 (r'(?=/)', Text, ('#pop', 'badregex')), 475 (r'(?=/)', Text, ('#pop', 'badregex')),
480 default('#pop') 476 default('#pop')
481 ], 477 ],
482 'badregex': [ 478 'badregex': [
483 (r'\n', Text, '#pop') 479 (r'\n', Text, '#pop')
489 r'(<<|>>>?|==?|!=?|[-<>+*%&|^/])=?', Operator, 'slashstartsregex'), 485 r'(<<|>>>?|==?|!=?|[-<>+*%&|^/])=?', Operator, 'slashstartsregex'),
490 (r'[{(\[;,]', Punctuation, 'slashstartsregex'), 486 (r'[{(\[;,]', Punctuation, 'slashstartsregex'),
491 (r'[})\].]', Punctuation), 487 (r'[})\].]', Punctuation),
492 (r'(for|in|while|do|break|return|continue|switch|case|default|if|else|' 488 (r'(for|in|while|do|break|return|continue|switch|case|default|if|else|'
493 r'throw|try|catch|finally|new|delete|typeof|instanceof|void|of|' 489 r'throw|try|catch|finally|new|delete|typeof|instanceof|void|of|'
494 r'this)\b', Keyword, 'slashstartsregex'), 490 r'this|async|await|debugger|yield|abstract|static|import|export|'
495 (r'(var|let|with|function)\b', Keyword.Declaration, 'slashstartsregex'), 491 r'implements|super|extends|private|protected|public|readonly)\b', Keyword, 'slashstartsregex'),
496 (r'(abstract|boolean|byte|char|class|const|debugger|double|enum|export|' 492 (r'(var|let|const|with|function|class|type|enum|interface)\b', Keyword.Declaration, 'slashstartsregex'),
497 r'extends|final|float|goto|implements|import|int|interface|long|native|' 493 (r'(boolean|byte|char|double|final|float|goto|int|long|native|'
498 r'package|private|protected|public|short|static|super|synchronized|throws|' 494 r'package|short|synchronized|throws|transient|volatile)\b', Keyword.Reserved),
499 r'transient|volatile)\b', Keyword.Reserved),
500 (r'(true|false|null|NaN|Infinity|undefined)\b', Keyword.Constant), 495 (r'(true|false|null|NaN|Infinity|undefined)\b', Keyword.Constant),
501 (r'(Array|Boolean|Date|Error|Function|Math|netscape|' 496 (r'(Array|Boolean|Date|Error|Function|Math|'
502 r'Number|Object|Packages|RegExp|String|sun|decodeURI|' 497 r'Number|Object|RegExp|String|decodeURI|'
503 r'decodeURIComponent|encodeURI|encodeURIComponent|' 498 r'decodeURIComponent|encodeURI|encodeURIComponent|'
504 r'Error|eval|isFinite|isNaN|parseFloat|parseInt|document|this|' 499 r'Error|eval|isFinite|isNaN|parseFloat|parseInt|document|this|'
505 r'window)\b', Name.Builtin), 500 r'window|globalThis|Symbol|BigInt)\b', Name.Builtin),
506 # Match stuff like: module name {...} 501 # Match stuff like: module name {...}
507 (r'\b(module)(\s*)(\s*[\w?.$][\w?.$]*)(\s*)', 502 (r'\b(module)(\s*)(\s*[\w?.$][\w?.$]*)(\s*)',
508 bygroups(Keyword.Reserved, Text, Name.Other, Text), 'slashstartsregex'), 503 bygroups(Keyword.Reserved, Text, Name.Other, Text), 'slashstartsregex'),
509 # Match variable type keywords 504 # Match variable type keywords
510 (r'\b(string|bool|number)\b', Keyword.Type), 505 (r'\b(string|bool|number)\b', Keyword.Type),
512 (r'\b(constructor|declare|interface|as|AS)\b', Keyword.Reserved), 507 (r'\b(constructor|declare|interface|as|AS)\b', Keyword.Reserved),
513 # Match stuff like: super(argument, list) 508 # Match stuff like: super(argument, list)
514 (r'(super)(\s*)(\([\w,?.$\s]+\s*\))', 509 (r'(super)(\s*)(\([\w,?.$\s]+\s*\))',
515 bygroups(Keyword.Reserved, Text), 'slashstartsregex'), 510 bygroups(Keyword.Reserved, Text), 'slashstartsregex'),
516 # Match stuff like: function() {...} 511 # Match stuff like: function() {...}
517 (r'([a-zA-Z_?.$][\w?.$]*)\(\) \{', Name.Other, 'slashstartsregex'), 512 (r'([a-zA-Z_?.$][\w?.$]*)(?=\(\) \{)', Name.Other, 'slashstartsregex'),
518 # Match stuff like: (function: return type) 513 # Match stuff like: (function: return type)
519 (r'([\w?.$][\w?.$]*)(\s*:\s*)([\w?.$][\w?.$]*)', 514 (r'([\w?.$][\w?.$]*)(\s*:\s*)([\w?.$][\w?.$]*)',
520 bygroups(Name.Other, Text, Keyword.Type)), 515 bygroups(Name.Other, Text, Keyword.Type)),
521 (r'[$a-zA-Z_]\w*', Name.Other), 516 (r'[$a-zA-Z_]\w*', Name.Other),
522 (r'[0-9][0-9]*\.[0-9]+([eE][0-9]+)?[fd]?', Number.Float), 517 (r'0[bB][01]+n?', Number.Bin),
523 (r'0x[0-9a-fA-F]+', Number.Hex), 518 (r'0[oO]?[0-7]+n?', Number.Oct), # Browsers support "0o7" and "07" (< ES5) notations
524 (r'[0-9]+', Number.Integer), 519 (r'0[xX][0-9a-fA-F]+n?', Number.Hex),
525 (r'"(\\\\|\\"|[^"])*"', String.Double), 520 (r'[0-9]+n', Number.Integer),
526 (r"'(\\\\|\\'|[^'])*'", String.Single), 521 (r'(\.[0-9]+|[0-9]+\.[0-9]*|[0-9]+)([eE][-+]?[0-9]+)?', Number.Float),
522 (r'"(\\\\|\\[^\\]|[^"\\])*"', String.Double),
523 (r"'(\\\\|\\[^\\]|[^'\\])*'", String.Single),
527 (r'`', String.Backtick, 'interp'), 524 (r'`', String.Backtick, 'interp'),
528 # Match stuff like: Decorators 525 # Match stuff like: Decorators
529 (r'@\w+', Keyword.Declaration), 526 (r'@\w+', Keyword.Declaration),
530 ], 527 ],
531 528
873 ], 870 ],
874 'statements': [ 871 'statements': [
875 (r'(L|@)?"', String, 'string'), 872 (r'(L|@)?"', String, 'string'),
876 (r"(L|@)?'(\\.|\\[0-7]{1,3}|\\x[a-fA-F0-9]{1,2}|[^\\\'\n])'", 873 (r"(L|@)?'(\\.|\\[0-7]{1,3}|\\x[a-fA-F0-9]{1,2}|[^\\\'\n])'",
877 String.Char), 874 String.Char),
878 (r'"(\\\\|\\"|[^"])*"', String.Double), 875 (r'"(\\\\|\\[^\\]|[^"\\])*"', String.Double),
879 (r"'(\\\\|\\'|[^'])*'", String.Single), 876 (r"'(\\\\|\\[^\\]|[^'\\])*'", String.Single),
880 (r'(\d+\.\d*|\.\d+|\d+)[eE][+-]?\d+[lL]?', Number.Float), 877 (r'(\d+\.\d*|\.\d+|\d+)[eE][+-]?\d+[lL]?', Number.Float),
881 (r'(\d+\.\d*|\.\d+|\d+[fF])[fF]?', Number.Float), 878 (r'(\d+\.\d*|\.\d+|\d+[fF])[fF]?', Number.Float),
882 (r'0x[0-9a-fA-F]+[Ll]?', Number.Hex), 879 (r'0x[0-9a-fA-F]+[Ll]?', Number.Hex),
883 (r'0[0-7]+[Ll]?', Number.Oct), 880 (r'0[0-7]+[Ll]?', Number.Oct),
884 (r'\d+[Ll]?', Number.Integer), 881 (r'\d+[Ll]?', Number.Integer),
911 (r'(true|false|null|NaN|Infinity|undefined)\b', Keyword.Constant), 908 (r'(true|false|null|NaN|Infinity|undefined)\b', Keyword.Constant),
912 (r'(ABS|ASIN|ACOS|ATAN|ATAN2|SIN|COS|TAN|EXP|POW|CEIL|FLOOR|ROUND|' 909 (r'(ABS|ASIN|ACOS|ATAN|ATAN2|SIN|COS|TAN|EXP|POW|CEIL|FLOOR|ROUND|'
913 r'MIN|MAX|RAND|SQRT|E|LN2|LN10|LOG2E|LOG10E|PI|PI2|PI_2|SQRT1_2|' 910 r'MIN|MAX|RAND|SQRT|E|LN2|LN10|LOG2E|LOG10E|PI|PI2|PI_2|SQRT1_2|'
914 r'SQRT2)\b', Keyword.Constant), 911 r'SQRT2)\b', Keyword.Constant),
915 912
916 (r'(Array|Boolean|Date|Error|Function|Math|netscape|' 913 (r'(Array|Boolean|Date|Error|Function|Math|'
917 r'Number|Object|Packages|RegExp|String|sun|decodeURI|' 914 r'Number|Object|RegExp|String|decodeURI|'
918 r'decodeURIComponent|encodeURI|encodeURIComponent|' 915 r'decodeURIComponent|encodeURI|encodeURIComponent|'
919 r'Error|eval|isFinite|isNaN|parseFloat|parseInt|document|this|' 916 r'Error|eval|isFinite|isNaN|parseFloat|parseInt|document|this|'
920 r'window)\b', Name.Builtin), 917 r'window|globalThis|Symbol)\b', Name.Builtin),
921 918
922 (r'([$a-zA-Z_]\w*)(' + _ws + r')(?=\()', 919 (r'([$a-zA-Z_]\w*)(' + _ws + r')(?=\()',
923 bygroups(Name.Function, using(this))), 920 bygroups(Name.Function, using(this))),
924 921
925 (r'[$a-zA-Z_]\w*', Name), 922 (r'[$a-zA-Z_]\w*', Name),
1053 (r'###[^#].*?###', Comment.Multiline), 1050 (r'###[^#].*?###', Comment.Multiline),
1054 (r'#(?!##[^#]).*?\n', Comment.Single), 1051 (r'#(?!##[^#]).*?\n', Comment.Single),
1055 ], 1052 ],
1056 'multilineregex': [ 1053 'multilineregex': [
1057 (r'[^/#]+', String.Regex), 1054 (r'[^/#]+', String.Regex),
1058 (r'///([gim]+\b|\B)', String.Regex, '#pop'), 1055 (r'///([gimuys]+\b|\B)', String.Regex, '#pop'),
1059 (r'#\{', String.Interpol, 'interpoling_string'), 1056 (r'#\{', String.Interpol, 'interpoling_string'),
1060 (r'[/#]', String.Regex), 1057 (r'[/#]', String.Regex),
1061 ], 1058 ],
1062 'slashstartsregex': [ 1059 'slashstartsregex': [
1063 include('commentsandwhitespace'), 1060 include('commentsandwhitespace'),
1064 (r'///', String.Regex, ('#pop', 'multilineregex')), 1061 (r'///', String.Regex, ('#pop', 'multilineregex')),
1065 (r'/(?! )(\\.|[^[/\\\n]|\[(\\.|[^\]\\\n])*])+/' 1062 (r'/(?! )(\\.|[^[/\\\n]|\[(\\.|[^\]\\\n])*])+/'
1066 r'([gim]+\b|\B)', String.Regex, '#pop'), 1063 r'([gimuys]+\b|\B)', String.Regex, '#pop'),
1067 # This isn't really guarding against mishighlighting well-formed 1064 # This isn't really guarding against mishighlighting well-formed
1068 # code, just the ability to infinite-loop between root and 1065 # code, just the ability to infinite-loop between root and
1069 # slashstartsregex. 1066 # slashstartsregex.
1070 (r'/', Operator, '#pop'), 1067 (r'/', Operator, '#pop'),
1071 default('#pop'), 1068 default('#pop'),
1083 r'throw|try|catch|finally|new|delete|typeof|instanceof|super|' 1080 r'throw|try|catch|finally|new|delete|typeof|instanceof|super|'
1084 r'extends|this|class|by)\b', Keyword, 'slashstartsregex'), 1081 r'extends|this|class|by)\b', Keyword, 'slashstartsregex'),
1085 (r'(?<![.$])(true|false|yes|no|on|off|null|' 1082 (r'(?<![.$])(true|false|yes|no|on|off|null|'
1086 r'NaN|Infinity|undefined)\b', 1083 r'NaN|Infinity|undefined)\b',
1087 Keyword.Constant), 1084 Keyword.Constant),
1088 (r'(Array|Boolean|Date|Error|Function|Math|netscape|' 1085 (r'(Array|Boolean|Date|Error|Function|Math|'
1089 r'Number|Object|Packages|RegExp|String|sun|decodeURI|' 1086 r'Number|Object|RegExp|String|decodeURI|'
1090 r'decodeURIComponent|encodeURI|encodeURIComponent|' 1087 r'decodeURIComponent|encodeURI|encodeURIComponent|'
1091 r'eval|isFinite|isNaN|parseFloat|parseInt|document|window)\b', 1088 r'eval|isFinite|isNaN|parseFloat|parseInt|document|window|globalThis|Symbol)\b',
1092 Name.Builtin), 1089 Name.Builtin),
1093 (r'[$a-zA-Z_][\w.:$]*\s*[:=]\s', Name.Variable, 1090 (r'[$a-zA-Z_][\w.:$]*\s*[:=]\s', Name.Variable,
1094 'slashstartsregex'), 1091 'slashstartsregex'),
1095 (r'@[$a-zA-Z_][\w.:$]*\s*[:=]\s', Name.Variable.Instance, 1092 (r'@[$a-zA-Z_][\w.:$]*\s*[:=]\s', Name.Variable.Instance,
1096 'slashstartsregex'), 1093 'slashstartsregex'),
1479 1476
1480 .. versionadded:: 2.2 1477 .. versionadded:: 2.2
1481 """ 1478 """
1482 1479
1483 name = 'Juttle' 1480 name = 'Juttle'
1484 aliases = ['juttle', 'juttle'] 1481 aliases = ['juttle']
1485 filenames = ['*.juttle'] 1482 filenames = ['*.juttle']
1486 mimetypes = ['application/juttle', 'application/x-juttle', 1483 mimetypes = ['application/juttle', 'application/x-juttle',
1487 'text/x-juttle', 'text/juttle'] 1484 'text/x-juttle', 'text/juttle']
1488 1485
1489 flags = re.DOTALL | re.UNICODE | re.MULTILINE 1486 flags = re.DOTALL | re.UNICODE | re.MULTILINE
1495 (r'/\*.*?\*/', Comment.Multiline) 1492 (r'/\*.*?\*/', Comment.Multiline)
1496 ], 1493 ],
1497 'slashstartsregex': [ 1494 'slashstartsregex': [
1498 include('commentsandwhitespace'), 1495 include('commentsandwhitespace'),
1499 (r'/(\\.|[^[/\\\n]|\[(\\.|[^\]\\\n])*])+/' 1496 (r'/(\\.|[^[/\\\n]|\[(\\.|[^\]\\\n])*])+/'
1500 r'([gim]+\b|\B)', String.Regex, '#pop'), 1497 r'([gimuys]+\b|\B)', String.Regex, '#pop'),
1501 (r'(?=/)', Text, ('#pop', 'badregex')), 1498 (r'(?=/)', Text, ('#pop', 'badregex')),
1502 default('#pop') 1499 default('#pop')
1503 ], 1500 ],
1504 'badregex': [ 1501 'badregex': [
1505 (r'\n', Text, '#pop') 1502 (r'\n', Text, '#pop')
1531 (r'(Array|Date|Juttle|Math|Number|Object|RegExp|String)\b', 1528 (r'(Array|Date|Juttle|Math|Number|Object|RegExp|String)\b',
1532 Name.Builtin), 1529 Name.Builtin),
1533 (JS_IDENT, Name.Other), 1530 (JS_IDENT, Name.Other),
1534 (r'[0-9][0-9]*\.[0-9]+([eE][0-9]+)?[fd]?', Number.Float), 1531 (r'[0-9][0-9]*\.[0-9]+([eE][0-9]+)?[fd]?', Number.Float),
1535 (r'[0-9]+', Number.Integer), 1532 (r'[0-9]+', Number.Integer),
1536 (r'"(\\\\|\\"|[^"])*"', String.Double), 1533 (r'"(\\\\|\\[^\\]|[^"\\])*"', String.Double),
1537 (r"'(\\\\|\\'|[^'])*'", String.Single) 1534 (r"'(\\\\|\\[^\\]|[^'\\])*'", String.Single),
1538 ] 1535 ]
1539 1536
1540 } 1537 }

eric ide

mercurial