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'([gim]+\b|\B)', String.Regex, '#pop'), |
56 r'([gimuy]+\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') |
62 ], |
62 ], |
63 'root': [ |
63 'root': [ |
64 (r'\A#! ?/.*?\n', Comment.Hashbang), # recognized by node.js |
64 (r'\A#! ?/.*?\n', Comment.Hashbang), # recognized by node.js |
65 (r'^(?=\s|/|<!--)', Text, 'slashstartsregex'), |
65 (r'^(?=\s|/|<!--)', Text, 'slashstartsregex'), |
66 include('commentsandwhitespace'), |
66 include('commentsandwhitespace'), |
|
67 (r'(\.\d+|[0-9]+\.[0-9]*)([eE][-+]?[0-9]+)?', Number.Float), |
|
68 (r'0[bB][01]+', Number.Bin), |
|
69 (r'0[oO][0-7]+', Number.Oct), |
|
70 (r'0[xX][0-9a-fA-F]+', Number.Hex), |
|
71 (r'[0-9]+', Number.Integer), |
|
72 (r'\.\.\.|=>', Punctuation), |
67 (r'\+\+|--|~|&&|\?|:|\|\||\\(?=\n)|' |
73 (r'\+\+|--|~|&&|\?|:|\|\||\\(?=\n)|' |
68 r'(<<|>>>?|=>|==?|!=?|[-<>+*%&|^/])=?', Operator, 'slashstartsregex'), |
74 r'(<<|>>>?|==?|!=?|[-<>+*%&|^/])=?', Operator, 'slashstartsregex'), |
69 (r'\.\.\.', Punctuation), |
|
70 (r'[{(\[;,]', Punctuation, 'slashstartsregex'), |
75 (r'[{(\[;,]', Punctuation, 'slashstartsregex'), |
71 (r'[})\].]', Punctuation), |
76 (r'[})\].]', Punctuation), |
72 (r'(for|in|while|do|break|return|continue|switch|case|default|if|else|' |
77 (r'(for|in|while|do|break|return|continue|switch|case|default|if|else|' |
73 r'throw|try|catch|finally|new|delete|typeof|instanceof|void|yield|' |
78 r'throw|try|catch|finally|new|delete|typeof|instanceof|void|yield|' |
74 r'this|of)\b', Keyword, 'slashstartsregex'), |
79 r'this|of)\b', Keyword, 'slashstartsregex'), |
82 r'Number|Object|Packages|RegExp|String|Promise|Proxy|sun|decodeURI|' |
87 r'Number|Object|Packages|RegExp|String|Promise|Proxy|sun|decodeURI|' |
83 r'decodeURIComponent|encodeURI|encodeURIComponent|' |
88 r'decodeURIComponent|encodeURI|encodeURIComponent|' |
84 r'Error|eval|isFinite|isNaN|isSafeInteger|parseFloat|parseInt|' |
89 r'Error|eval|isFinite|isNaN|isSafeInteger|parseFloat|parseInt|' |
85 r'document|this|window)\b', Name.Builtin), |
90 r'document|this|window)\b', Name.Builtin), |
86 (JS_IDENT, Name.Other), |
91 (JS_IDENT, Name.Other), |
87 (r'[0-9][0-9]*\.[0-9]+([eE][0-9]+)?[fd]?', Number.Float), |
|
88 (r'0b[01]+', Number.Bin), |
|
89 (r'0o[0-7]+', Number.Oct), |
|
90 (r'0x[0-9a-fA-F]+', Number.Hex), |
|
91 (r'[0-9]+', Number.Integer), |
|
92 (r'"(\\\\|\\"|[^"])*"', String.Double), |
92 (r'"(\\\\|\\"|[^"])*"', String.Double), |
93 (r"'(\\\\|\\'|[^'])*'", String.Single), |
93 (r"'(\\\\|\\'|[^'])*'", String.Single), |
94 (r'`', String.Backtick, 'interp'), |
94 (r'`', String.Backtick, 'interp'), |
95 ], |
95 ], |
96 'interp': [ |
96 'interp': [ |
97 (r'`', String.Backtick, '#pop'), |
97 (r'`', String.Backtick, '#pop'), |
98 (r'\\\\', String.Backtick), |
98 (r'\\\\', String.Backtick), |
99 (r'\\`', String.Backtick), |
99 (r'\\`', String.Backtick), |
100 (r'\${', String.Interpol, 'interp-inside'), |
100 (r'\$\{', String.Interpol, 'interp-inside'), |
101 (r'\$', String.Backtick), |
101 (r'\$', String.Backtick), |
102 (r'[^`\\$]+', String.Backtick), |
102 (r'[^`\\$]+', String.Backtick), |
103 ], |
103 ], |
104 'interp-inside': [ |
104 'interp-inside': [ |
105 # TODO: should this include single-line comments and allow nesting strings? |
105 # TODO: should this include single-line comments and allow nesting strings? |
106 (r'}', String.Interpol, '#pop'), |
106 (r'\}', String.Interpol, '#pop'), |
107 include('root'), |
107 include('root'), |
108 ], |
108 ], |
109 # (\\\\|\\`|[^`])*`', String.Backtick), |
109 # (\\\\|\\`|[^`])*`', String.Backtick), |
110 } |
110 } |
111 |
111 |
543 flags = re.IGNORECASE | re.DOTALL | re.MULTILINE |
567 flags = re.IGNORECASE | re.DOTALL | re.MULTILINE |
544 |
568 |
545 tokens = { |
569 tokens = { |
546 'root': [ |
570 'root': [ |
547 (r'^#![ \S]+lasso9\b', Comment.Preproc, 'lasso'), |
571 (r'^#![ \S]+lasso9\b', Comment.Preproc, 'lasso'), |
548 (r'\[no_square_brackets\]', Comment.Preproc, 'nosquarebrackets'), |
572 (r'(?=\[|<)', Other, 'delimiters'), |
549 (r'\[noprocess\]', Comment.Preproc, ('delimiters', 'noprocess')), |
|
550 (r'\[', Comment.Preproc, ('delimiters', 'squarebrackets')), |
|
551 (r'<\?(LassoScript|lasso|=)', Comment.Preproc, |
|
552 ('delimiters', 'anglebrackets')), |
|
553 (r'<(!--.*?-->)?', Other, 'delimiters'), |
|
554 (r'\s+', Other), |
573 (r'\s+', Other), |
555 default(('delimiters', 'lassofile')), |
574 default(('delimiters', 'lassofile')), |
556 ], |
575 ], |
557 'delimiters': [ |
576 'delimiters': [ |
558 (r'\[no_square_brackets\]', Comment.Preproc, 'nosquarebrackets'), |
577 (r'\[no_square_brackets\]', Comment.Preproc, 'nosquarebrackets'), |
559 (r'\[noprocess\]', Comment.Preproc, 'noprocess'), |
578 (r'\[noprocess\]', Comment.Preproc, 'noprocess'), |
560 (r'\[', Comment.Preproc, 'squarebrackets'), |
579 (r'\[', Comment.Preproc, 'squarebrackets'), |
561 (r'<\?(LassoScript|lasso|=)', Comment.Preproc, 'anglebrackets'), |
580 (r'<\?(lasso(script)?|=)', Comment.Preproc, 'anglebrackets'), |
562 (r'<(!--.*?-->)?', Other), |
581 (r'<(!--.*?-->)?', Other), |
563 (r'[^[<]+', Other), |
582 (r'[^[<]+', Other), |
564 ], |
583 ], |
565 'nosquarebrackets': [ |
584 'nosquarebrackets': [ |
566 (r'\[noprocess\]', Comment.Preproc, 'noprocess'), |
585 (r'\[noprocess\]', Comment.Preproc, 'noprocess'), |
567 (r'\[', Other), |
586 (r'\[', Other), |
568 (r'<\?(LassoScript|lasso|=)', Comment.Preproc, 'anglebrackets'), |
587 (r'<\?(lasso(script)?|=)', Comment.Preproc, 'anglebrackets'), |
569 (r'<(!--.*?-->)?', Other), |
588 (r'<(!--.*?-->)?', Other), |
570 (r'[^[<]+', Other), |
589 (r'[^[<]+', Other), |
571 ], |
590 ], |
572 'noprocess': [ |
591 'noprocess': [ |
573 (r'\[/noprocess\]', Comment.Preproc, '#pop'), |
592 (r'\[/noprocess\]', Comment.Preproc, '#pop'), |
1243 'root': [ |
1268 'root': [ |
1244 (r'\n', Text), |
1269 (r'\n', Text), |
1245 include('control'), |
1270 include('control'), |
1246 (r'[^\S\n]+', Text), |
1271 (r'[^\S\n]+', Text), |
1247 (r';;.*\n', Comment), |
1272 (r';;.*\n', Comment), |
1248 (r'[\[\]\{\}\:\(\)\,\;]', Punctuation), |
1273 (r'[\[\]{}:(),;]', Punctuation), |
1249 (r'\\\n', Text), |
1274 (r'\\\n', Text), |
1250 (r'\\', Text), |
1275 (r'\\', Text), |
1251 include('errors'), |
1276 include('errors'), |
1252 (words(( |
1277 (words(( |
1253 'with', 'where', 'when', 'and', 'not', 'or', 'in', |
1278 'with', 'where', 'when', 'and', 'not', 'or', 'in', |
1254 'as', 'of', 'is'), |
1279 'as', 'of', 'is'), |
1255 prefix=r'(?<=\s|\[)', suffix=r'(?![\w\$\-])'), |
1280 prefix=r'(?<=\s|\[)', suffix=r'(?![\w$\-])'), |
1256 Operator.Word), |
1281 Operator.Word), |
1257 (r'[\*@]?->', Name.Function), |
1282 (r'[*@]?->', Name.Function), |
1258 (r'[+\-*/~^<>%&|?!@#.]*=', Operator.Word), |
1283 (r'[+\-*/~^<>%&|?!@#.]*=', Operator.Word), |
1259 (r'\.{2,3}', Operator.Word), # Range Operator |
1284 (r'\.{2,3}', Operator.Word), # Range Operator |
1260 (r'([+*/~^<>&|?!]+)|([#\-](?=\s))|@@+(?=\s)|=+', Operator), |
1285 (r'([+*/~^<>&|?!]+)|([#\-](?=\s))|@@+(?=\s)|=+', Operator), |
1261 (r'(?<![\w\$\-])(var|let)(?:[^\w\$])', Keyword.Declaration), |
1286 (r'(?<![\w$\-])(var|let)(?:[^\w$])', Keyword.Declaration), |
1262 include('keywords'), |
1287 include('keywords'), |
1263 include('builtins'), |
1288 include('builtins'), |
1264 include('assignment'), |
1289 include('assignment'), |
1265 (r'''(?x) |
1290 (r'''(?x) |
1266 (?:()([a-zA-Z$_](?:[a-zA-Z$0-9_\-]*[a-zA-Z$0-9_])?)| |
1291 (?:()([a-zA-Z$_](?:[\w$\-]*[\w$])?)| |
1267 (?<=[\s\{\[\(])(\.)([a-zA-Z$_](?:[a-zA-Z$0-9_\-]*[a-zA-Z$0-9_])?)) |
1292 (?<=[\s{\[(])(\.)([a-zA-Z$_](?:[\w$\-]*[\w$])?)) |
1268 (?=.*%)''', |
1293 (?=.*%)''', |
1269 bygroups(Punctuation, Name.Tag, Punctuation, Name.Class.Start), 'dbs'), |
1294 bygroups(Punctuation, Name.Tag, Punctuation, Name.Class.Start), 'dbs'), |
1270 (r'[rR]?`', String.Backtick, 'bt'), |
1295 (r'[rR]?`', String.Backtick, 'bt'), |
1271 (r'[rR]?```', String.Backtick, 'tbt'), |
1296 (r'[rR]?```', String.Backtick, 'tbt'), |
1272 (r'(?<=[\s\[\{\(,;])\.([a-zA-Z$_](?:[a-zA-Z$0-9_-]*[a-zA-Z$0-9_])?)' |
1297 (r'(?<=[\s\[{(,;])\.([a-zA-Z$_](?:[\w$\-]*[\w$])?)' |
1273 r'(?=[\s\]\}\),;])', String.Symbol), |
1298 r'(?=[\s\]}),;])', String.Symbol), |
1274 include('nested'), |
1299 include('nested'), |
1275 (r'(?:[rR]|[rR]\.[gmi]{1,3})?"', String, combined('stringescape', 'dqs')), |
1300 (r'(?:[rR]|[rR]\.[gmi]{1,3})?"', String, combined('stringescape', 'dqs')), |
1276 (r'(?:[rR]|[rR]\.[gmi]{1,3})?\'', String, combined('stringescape', 'sqs')), |
1301 (r'(?:[rR]|[rR]\.[gmi]{1,3})?\'', String, combined('stringescape', 'sqs')), |
1277 (r'"""', String, combined('stringescape', 'tdqs')), |
1302 (r'"""', String, combined('stringescape', 'tdqs')), |
1278 include('tuple'), |
1303 include('tuple'), |
1279 include('import_paths'), |
1304 include('import_paths'), |
1280 include('name'), |
1305 include('name'), |
1281 include('numbers'), |
1306 include('numbers'), |
1282 ], |
1307 ], |
1283 'dbs': [ |
1308 'dbs': [ |
1284 (r'(\.)([a-zA-Z$_](?:[a-zA-Z$0-9_\-]*[a-zA-Z$0-9_])?)(?=[\[\.\s])', |
1309 (r'(\.)([a-zA-Z$_](?:[\w$\-]*[\w$])?)(?=[.\[\s])', |
1285 bygroups(Punctuation, Name.Class.DBS)), |
1310 bygroups(Punctuation, Name.Class.DBS)), |
1286 (r'(\[)([\^#][a-zA-Z$_](?:[a-zA-Z$0-9_\-]*[a-zA-Z$0-9_])?)(\])', |
1311 (r'(\[)([\^#][a-zA-Z$_](?:[\w$\-]*[\w$])?)(\])', |
1287 bygroups(Punctuation, Name.Entity.DBS, Punctuation)), |
1312 bygroups(Punctuation, Name.Entity.DBS, Punctuation)), |
1288 (r'\s+', Text), |
1313 (r'\s+', Text), |
1289 (r'%', Operator.DBS, '#pop'), |
1314 (r'%', Operator.DBS, '#pop'), |
1290 ], |
1315 ], |
1291 'import_paths': [ |
1316 'import_paths': [ |
1292 (r'(?<=[\s:;,])(\.{1,3}(?:[\w\-]*/)*)(\w(?:[\w\-]*\w)*)(?=[\s;,])', |
1317 (r'(?<=[\s:;,])(\.{1,3}(?:[\w\-]*/)*)(\w(?:[\w\-]*\w)*)(?=[\s;,])', |
1293 bygroups(Text.Whitespace, Text)), |
1318 bygroups(Text.Whitespace, Text)), |
1294 ], |
1319 ], |
1295 'assignment': [ |
1320 'assignment': [ |
1296 (r'(\.)?([a-zA-Z$_](?:[a-zA-Z$0-9_-]*[a-zA-Z$0-9_])?)' |
1321 (r'(\.)?([a-zA-Z$_](?:[\w$\-]*[\w$])?)' |
1297 r'(?=\s+[+\-*/~^<>%&|?!@#.]*\=\s)', |
1322 r'(?=\s+[+\-*/~^<>%&|?!@#.]*\=\s)', |
1298 bygroups(Punctuation, Name.Variable)) |
1323 bygroups(Punctuation, Name.Variable)) |
1299 ], |
1324 ], |
1300 'errors': [ |
1325 'errors': [ |
1301 (words(('Error', 'TypeError', 'ReferenceError'), |
1326 (words(('Error', 'TypeError', 'ReferenceError'), |
1302 prefix=r'(?<![\w\$\-\.])', suffix=r'(?![\w\$\-\.])'), |
1327 prefix=r'(?<![\w\-$.])', suffix=r'(?![\w\-$.])'), |
1303 Name.Exception), |
1328 Name.Exception), |
1304 (r'''(?x) |
1329 (r'''(?x) |
1305 (?<![\w\$]) |
1330 (?<![\w$]) |
1306 E\.[\w\$](?:[\w\$\-]*[\w\$])? |
1331 E\.[\w$](?:[\w$\-]*[\w$])? |
1307 (?:\.[\w\$](?:[\w\$\-]*[\w\$])?)* |
1332 (?:\.[\w$](?:[\w$\-]*[\w$])?)* |
1308 (?=[\(\{\[\?\!\s])''', |
1333 (?=[({\[?!\s])''', |
1309 Name.Exception), |
1334 Name.Exception), |
1310 ], |
1335 ], |
1311 'control': [ |
1336 'control': [ |
1312 (r'''(?x) |
1337 (r'''(?x) |
1313 ([a-zA-Z$_](?:[a-zA-Z$0-9_-]*[a-zA-Z$0-9_])?) |
1338 ([a-zA-Z$_](?:[\w$-]*[\w$])?) |
1314 (?!\n)\s+ |
1339 (?!\n)\s+ |
1315 (?!and|as|each\*|each|in|is|mod|of|or|when|where|with) |
1340 (?!and|as|each\*|each|in|is|mod|of|or|when|where|with) |
1316 (?=(?:[+\-*/~^<>%&|?!@#.])?[a-zA-Z$_](?:[a-zA-Z$0-9_-]*[a-zA-Z$0-9_])?)''', |
1341 (?=(?:[+\-*/~^<>%&|?!@#.])?[a-zA-Z$_](?:[\w$-]*[\w$])?)''', |
1317 Keyword.Control), |
1342 Keyword.Control), |
1318 (r'([a-zA-Z$_](?:[a-zA-Z$0-9_-]*[a-zA-Z$0-9_])?)(?!\n)\s+(?=[\'"\d\{\[\(])', |
1343 (r'([a-zA-Z$_](?:[\w$-]*[\w$])?)(?!\n)\s+(?=[\'"\d{\[(])', |
1319 Keyword.Control), |
1344 Keyword.Control), |
1320 (r'''(?x) |
1345 (r'''(?x) |
1321 (?: |
1346 (?: |
1322 (?<=[%=])| |
1347 (?<=[%=])| |
1323 (?<=[=\-]>)| |
1348 (?<=[=\-]>)| |
1324 (?<=with|each|with)| |
1349 (?<=with|each|with)| |
1325 (?<=each\*|where) |
1350 (?<=each\*|where) |
1326 )(\s+) |
1351 )(\s+) |
1327 ([a-zA-Z$_](?:[a-zA-Z$0-9_\-]*[a-zA-Z$0-9_])?)(:)''', |
1352 ([a-zA-Z$_](?:[\w$-]*[\w$])?)(:)''', |
1328 bygroups(Text, Keyword.Control, Punctuation)), |
1353 bygroups(Text, Keyword.Control, Punctuation)), |
1329 (r'''(?x) |
1354 (r'''(?x) |
1330 (?<![+\-*/~^<>%&|?!@#.])(\s+) |
1355 (?<![+\-*/~^<>%&|?!@#.])(\s+) |
1331 ([a-zA-Z$_](?:[a-zA-Z$0-9_-]*[a-zA-Z$0-9_])?)(:)''', |
1356 ([a-zA-Z$_](?:[\w$-]*[\w$])?)(:)''', |
1332 bygroups(Text, Keyword.Control, Punctuation)), |
1357 bygroups(Text, Keyword.Control, Punctuation)), |
1333 ], |
1358 ], |
1334 'nested': [ |
1359 'nested': [ |
1335 (r'''(?x) |
1360 (r'''(?x) |
1336 (?<=[a-zA-Z$0-9_\]\}\)])(\.) |
1361 (?<=[\w$\]})])(\.) |
1337 ([a-zA-Z$_](?:[a-zA-Z$0-9_-]*[a-zA-Z$0-9_])?) |
1362 ([a-zA-Z$_](?:[\w$-]*[\w$])?) |
1338 (?=\s+with(?:\s|\n))''', |
1363 (?=\s+with(?:\s|\n))''', |
1339 bygroups(Punctuation, Name.Function)), |
1364 bygroups(Punctuation, Name.Function)), |
1340 (r'''(?x) |
1365 (r'''(?x) |
1341 (?<!\s)(\.) |
1366 (?<!\s)(\.) |
1342 ([a-zA-Z$_](?:[a-zA-Z$0-9_-]*[a-zA-Z$0-9_])?) |
1367 ([a-zA-Z$_](?:[\w$-]*[\w$])?) |
1343 (?=[\}\]\)\.,;:\s])''', |
1368 (?=[}\]).,;:\s])''', |
1344 bygroups(Punctuation, Name.Field)), |
1369 bygroups(Punctuation, Name.Field)), |
1345 (r'''(?x) |
1370 (r'''(?x) |
1346 (?<=[a-zA-Z$0-9_\]\}\)])(\.) |
1371 (?<=[\w$\]})])(\.) |
1347 ([a-zA-Z$_](?:[a-zA-Z$0-9_-]*[a-zA-Z$0-9_])?) |
1372 ([a-zA-Z$_](?:[\w$-]*[\w$])?) |
1348 (?=[\[\{\(:])''', |
1373 (?=[\[{(:])''', |
1349 bygroups(Punctuation, Name.Function)), |
1374 bygroups(Punctuation, Name.Function)), |
1350 ], |
1375 ], |
1351 'keywords': [ |
1376 'keywords': [ |
1352 (words(( |
1377 (words(( |
1353 'each', 'each*', 'mod', 'await', 'break', 'chain', |
1378 'each', 'each*', 'mod', 'await', 'break', 'chain', |
1354 'continue', 'elif', 'expr-value', 'if', 'match', |
1379 'continue', 'elif', 'expr-value', 'if', 'match', |
1355 'return', 'yield', 'pass', 'else', 'require', 'var', |
1380 'return', 'yield', 'pass', 'else', 'require', 'var', |
1356 'let', 'async', 'method', 'gen'), |
1381 'let', 'async', 'method', 'gen'), |
1357 prefix=r'(?<![\w\$\-\.])', suffix=r'(?![\w\$\-\.])'), |
1382 prefix=r'(?<![\w\-$.])', suffix=r'(?![\w\-$.])'), |
1358 Keyword.Pseudo), |
1383 Keyword.Pseudo), |
1359 (words(('this', 'self', '@'), |
1384 (words(('this', 'self', '@'), |
1360 prefix=r'(?<![\w\$\-\.])', suffix=r'(?![\w\$\-])'), |
1385 prefix=r'(?<![\w\-$.])', suffix=r'(?![\w\-$])'), |
1361 Keyword.Constant), |
1386 Keyword.Constant), |
1362 (words(( |
1387 (words(( |
1363 'Function', 'Object', 'Array', 'String', 'Number', |
1388 'Function', 'Object', 'Array', 'String', 'Number', |
1364 'Boolean', 'ErrorFactory', 'ENode', 'Promise'), |
1389 'Boolean', 'ErrorFactory', 'ENode', 'Promise'), |
1365 prefix=r'(?<![\w\$\-\.])', suffix=r'(?![\w\$\-])'), |
1390 prefix=r'(?<![\w\-$.])', suffix=r'(?![\w\-$])'), |
1366 Keyword.Type), |
1391 Keyword.Type), |
1367 ], |
1392 ], |
1368 'builtins': [ |
1393 'builtins': [ |
1369 (words(( |
1394 (words(( |
1370 'send', 'object', 'keys', 'items', 'enumerate', 'zip', |
1395 'send', 'object', 'keys', 'items', 'enumerate', 'zip', |
1371 'product', 'neighbours', 'predicate', 'equal', |
1396 'product', 'neighbours', 'predicate', 'equal', |
1372 'nequal', 'contains', 'repr', 'clone', 'range', |
1397 'nequal', 'contains', 'repr', 'clone', 'range', |
1373 'getChecker', 'get-checker', 'getProperty', 'get-property', |
1398 'getChecker', 'get-checker', 'getProperty', 'get-property', |
1374 'getProjector', 'get-projector', 'consume', 'take', |
1399 'getProjector', 'get-projector', 'consume', 'take', |
1375 'promisify', 'spawn', 'constructor'), |
1400 'promisify', 'spawn', 'constructor'), |
1376 prefix=r'(?<![\w\-#\.])', suffix=r'(?![\w\-\.])'), |
1401 prefix=r'(?<![\w\-#.])', suffix=r'(?![\w\-.])'), |
1377 Name.Builtin), |
1402 Name.Builtin), |
1378 (words(( |
1403 (words(( |
1379 'true', 'false', 'null', 'undefined'), |
1404 'true', 'false', 'null', 'undefined'), |
1380 prefix=r'(?<![\w\$\-\.])', suffix=r'(?![\w\$\-\.])'), |
1405 prefix=r'(?<![\w\-$.])', suffix=r'(?![\w\-$.])'), |
1381 Name.Constant), |
1406 Name.Constant), |
1382 ], |
1407 ], |
1383 'name': [ |
1408 'name': [ |
1384 (r'@([a-zA-Z$_](?:[a-zA-Z$0-9_-]*[a-zA-Z$0-9_])?)', Name.Variable.Instance), |
1409 (r'@([a-zA-Z$_](?:[\w$-]*[\w$])?)', Name.Variable.Instance), |
1385 (r'([a-zA-Z$_](?:[a-zA-Z$0-9_-]*[a-zA-Z$0-9_])?)(\+\+|\-\-)?', |
1410 (r'([a-zA-Z$_](?:[\w$-]*[\w$])?)(\+\+|\-\-)?', |
1386 bygroups(Name.Symbol, Operator.Word)) |
1411 bygroups(Name.Symbol, Operator.Word)) |
1387 ], |
1412 ], |
1388 'tuple': [ |
1413 'tuple': [ |
1389 (r'#[a-zA-Z_][a-zA-Z_\-0-9]*(?=[\s\{\(,;\n])', Name.Namespace) |
1414 (r'#[a-zA-Z_][\w\-]*(?=[\s{(,;])', Name.Namespace) |
1390 ], |
1415 ], |
1391 'interpoling_string': [ |
1416 'interpoling_string': [ |
1392 (r'\}', String.Interpol, '#pop'), |
1417 (r'\}', String.Interpol, '#pop'), |
1393 include('root') |
1418 include('root') |
1394 ], |
1419 ], |
1424 ], |
1449 ], |
1425 'tbt': [ |
1450 'tbt': [ |
1426 (r'```', String.Backtick, '#pop'), |
1451 (r'```', String.Backtick, '#pop'), |
1427 (r'\n', String.Backtick), |
1452 (r'\n', String.Backtick), |
1428 (r'\^=?', String.Escape), |
1453 (r'\^=?', String.Escape), |
1429 (r'[^\`]+', String.Backtick), |
1454 (r'[^`]+', String.Backtick), |
1430 ], |
1455 ], |
1431 'numbers': [ |
1456 'numbers': [ |
1432 (r'\d+\.(?!\.)\d*([eE][+-]?[0-9]+)?', Number.Float), |
1457 (r'\d+\.(?!\.)\d*([eE][+-]?[0-9]+)?', Number.Float), |
1433 (r'\d+[eE][+-]?[0-9]+', Number.Float), |
1458 (r'\d+[eE][+-]?[0-9]+', Number.Float), |
1434 (r'8r[0-7]+', Number.Oct), |
1459 (r'8r[0-7]+', Number.Oct), |
1435 (r'2r[01]+', Number.Bin), |
1460 (r'2r[01]+', Number.Bin), |
1436 (r'16r[a-fA-F0-9]+', Number.Hex), |
1461 (r'16r[a-fA-F0-9]+', Number.Hex), |
1437 (r'([3-79]|[1-2][0-9]|3[0-6])r[a-zA-Z\d]+(\.[a-zA-Z\d]+)?', Number.Radix), |
1462 (r'([3-79]|[12][0-9]|3[0-6])r[a-zA-Z\d]+(\.[a-zA-Z\d]+)?', Number.Radix), |
1438 (r'\d+', Number.Integer) |
1463 (r'\d+', Number.Integer) |
1439 ], |
1464 ], |
1440 } |
1465 } |
|
1466 |
|
1467 class JuttleLexer(RegexLexer): |
|
1468 """ |
|
1469 For `Juttle`_ source code. |
|
1470 |
|
1471 .. _Juttle: https://github.com/juttle/juttle |
|
1472 |
|
1473 """ |
|
1474 |
|
1475 name = 'Juttle' |
|
1476 aliases = ['juttle', 'juttle'] |
|
1477 filenames = ['*.juttle'] |
|
1478 mimetypes = ['application/juttle', 'application/x-juttle', |
|
1479 'text/x-juttle', 'text/juttle'] |
|
1480 |
|
1481 flags = re.DOTALL | re.UNICODE | re.MULTILINE |
|
1482 |
|
1483 tokens = { |
|
1484 'commentsandwhitespace': [ |
|
1485 (r'\s+', Text), |
|
1486 (r'//.*?\n', Comment.Single), |
|
1487 (r'/\*.*?\*/', Comment.Multiline) |
|
1488 ], |
|
1489 'slashstartsregex': [ |
|
1490 include('commentsandwhitespace'), |
|
1491 (r'/(\\.|[^[/\\\n]|\[(\\.|[^\]\\\n])*])+/' |
|
1492 r'([gim]+\b|\B)', String.Regex, '#pop'), |
|
1493 (r'(?=/)', Text, ('#pop', 'badregex')), |
|
1494 default('#pop') |
|
1495 ], |
|
1496 'badregex': [ |
|
1497 (r'\n', Text, '#pop') |
|
1498 ], |
|
1499 'root': [ |
|
1500 (r'^(?=\s|/)', Text, 'slashstartsregex'), |
|
1501 include('commentsandwhitespace'), |
|
1502 (r':\d{2}:\d{2}:\d{2}(\.\d*)?:', String.Moment), |
|
1503 (r':(now|beginning|end|forever|yesterday|today|tomorrow|(\d+(\.\d*)?|\.\d+)(ms|[smhdwMy])?):', String.Moment), |
|
1504 (r':\d{4}-\d{2}-\d{2}(T\d{2}:\d{2}:\d{2}(\.\d*)?)?(Z|[+-]\d{2}:\d{2}|[+-]\d{4})?:', String.Moment), |
|
1505 (r':((\d+(\.\d*)?|\.\d+)[ ]+)?(millisecond|second|minute|hour|day|week|month|year)[s]?' |
|
1506 r'(([ ]+and[ ]+(\d+[ ]+)?(millisecond|second|minute|hour|day|week|month|year)[s]?)' |
|
1507 r'|[ ]+(ago|from[ ]+now))*:', String.Moment), |
|
1508 (r'\+\+|--|~|&&|\?|:|\|\||\\(?=\n)|' |
|
1509 r'(==?|!=?|[-<>+*%&|^/])=?', Operator, 'slashstartsregex'), |
|
1510 (r'[{(\[;,]', Punctuation, 'slashstartsregex'), |
|
1511 (r'[})\].]', Punctuation), |
|
1512 (r'(import|return|continue|if|else)\b', Keyword, 'slashstartsregex'), |
|
1513 (r'(var|const|function|reducer|sub|input)\b', Keyword.Declaration, 'slashstartsregex'), |
|
1514 (r'(batch|emit|filter|head|join|keep|pace|pass|put|read|reduce|remove|' |
|
1515 r'sequence|skip|sort|split|tail|unbatch|uniq|view|write)\b', Keyword.Reserved), |
|
1516 (r'(true|false|null|Infinity)\b', Keyword.Constant), |
|
1517 (r'(Array|Date|Juttle|Math|Number|Object|RegExp|String)\b', Name.Builtin), |
|
1518 (JS_IDENT, Name.Other), |
|
1519 (r'[0-9][0-9]*\.[0-9]+([eE][0-9]+)?[fd]?', Number.Float), |
|
1520 (r'[0-9]+', Number.Integer), |
|
1521 (r'"(\\\\|\\"|[^"])*"', String.Double), |
|
1522 (r"'(\\\\|\\'|[^'])*'", String.Single) |
|
1523 ] |
|
1524 |
|
1525 } |