Coverage for /pythoncovmergedfiles/medio/medio/usr/local/lib/python3.11/site-packages/pygments/lexers/scripting.py: 62%

Shortcuts on this page

r m x   toggle line displays

j k   next/prev highlighted chunk

0   (zero) top of page

1   (one) first highlighted chunk

330 statements  

1""" 

2 pygments.lexers.scripting 

3 ~~~~~~~~~~~~~~~~~~~~~~~~~ 

4 

5 Lexer for scripting and embedded languages. 

6 

7 :copyright: Copyright 2006-2025 by the Pygments team, see AUTHORS. 

8 :license: BSD, see LICENSE for details. 

9""" 

10 

11import re 

12 

13from pygments.lexer import RegexLexer, include, bygroups, default, combined, \ 

14 words 

15from pygments.token import Text, Comment, Operator, Keyword, Name, String, \ 

16 Number, Punctuation, Error, Whitespace, Other 

17from pygments.util import get_bool_opt, get_list_opt 

18 

19__all__ = ['LuaLexer', 'LuauLexer', 'MoonScriptLexer', 'ChaiscriptLexer', 'LSLLexer', 

20 'AppleScriptLexer', 'RexxLexer', 'MOOCodeLexer', 'HybrisLexer', 

21 'EasytrieveLexer', 'JclLexer', 'MiniScriptLexer'] 

22 

23 

24def all_lua_builtins(): 

25 from pygments.lexers._lua_builtins import MODULES 

26 return [w for values in MODULES.values() for w in values] 

27 

28class LuaLexer(RegexLexer): 

29 """ 

30 For Lua source code. 

31 

32 Additional options accepted: 

33 

34 `func_name_highlighting` 

35 If given and ``True``, highlight builtin function names 

36 (default: ``True``). 

37 `disabled_modules` 

38 If given, must be a list of module names whose function names 

39 should not be highlighted. By default all modules are highlighted. 

40 

41 To get a list of allowed modules have a look into the 

42 `_lua_builtins` module: 

43 

44 .. sourcecode:: pycon 

45 

46 >>> from pygments.lexers._lua_builtins import MODULES 

47 >>> MODULES.keys() 

48 ['string', 'coroutine', 'modules', 'io', 'basic', ...] 

49 """ 

50 

51 name = 'Lua' 

52 url = 'https://www.lua.org/' 

53 aliases = ['lua'] 

54 filenames = ['*.lua', '*.wlua'] 

55 mimetypes = ['text/x-lua', 'application/x-lua'] 

56 version_added = '' 

57 

58 _comment_multiline = r'(?:--\[(?P<level>=*)\[[\w\W]*?\](?P=level)\])' 

59 _comment_single = r'(?:--.*$)' 

60 _space = r'(?:\s+(?!\s))' 

61 _s = rf'(?:{_comment_multiline}|{_comment_single}|{_space})' 

62 _name = r'(?:[^\W\d]\w*)' 

63 

64 tokens = { 

65 'root': [ 

66 # Lua allows a file to start with a shebang. 

67 (r'#!.*', Comment.Preproc), 

68 default('base'), 

69 ], 

70 'ws': [ 

71 (_comment_multiline, Comment.Multiline), 

72 (_comment_single, Comment.Single), 

73 (_space, Whitespace), 

74 ], 

75 'base': [ 

76 include('ws'), 

77 

78 (r'(?i)0x[\da-f]*(\.[\da-f]*)?(p[+-]?\d+)?', Number.Hex), 

79 (r'(?i)(\d*\.\d+|\d+\.\d*)(e[+-]?\d+)?', Number.Float), 

80 (r'(?i)\d+e[+-]?\d+', Number.Float), 

81 (r'\d+', Number.Integer), 

82 

83 # multiline strings 

84 (r'(?s)\[(=*)\[.*?\]\1\]', String), 

85 

86 (r'::', Punctuation, 'label'), 

87 (r'\.{3}', Punctuation), 

88 (r'[=<>|~&+\-*/%#^]+|\.\.', Operator), 

89 (r'[\[\]{}().,:;]+', Punctuation), 

90 (r'(and|or|not)\b', Operator.Word), 

91 

92 (words([ 

93 'break', 'do', 'else', 'elseif', 'end', 'for', 'if', 'in', 

94 'repeat', 'return', 'then', 'until', 'while' 

95 ], suffix=r'\b'), Keyword.Reserved), 

96 (r'goto\b', Keyword.Reserved, 'goto'), 

97 (r'(local)\b', Keyword.Declaration), 

98 (r'(true|false|nil)\b', Keyword.Constant), 

99 

100 (r'(function)\b', Keyword.Reserved, 'funcname'), 

101 

102 (words(all_lua_builtins(), suffix=r"\b"), Name.Builtin), 

103 (fr'[A-Za-z_]\w*(?={_s}*[.:])', Name.Variable, 'varname'), 

104 (fr'[A-Za-z_]\w*(?={_s}*\()', Name.Function), 

105 (r'[A-Za-z_]\w*', Name.Variable), 

106 

107 ("'", String.Single, combined('stringescape', 'sqs')), 

108 ('"', String.Double, combined('stringescape', 'dqs')) 

109 ], 

110 

111 'varname': [ 

112 include('ws'), 

113 (r'\.\.', Operator, '#pop'), 

114 (r'[.:]', Punctuation), 

115 (rf'{_name}(?={_s}*[.:])', Name.Property), 

116 (rf'{_name}(?={_s}*\()', Name.Function, '#pop'), 

117 (_name, Name.Property, '#pop'), 

118 ], 

119 

120 'funcname': [ 

121 include('ws'), 

122 (r'[.:]', Punctuation), 

123 (rf'{_name}(?={_s}*[.:])', Name.Class), 

124 (_name, Name.Function, '#pop'), 

125 # inline function 

126 (r'\(', Punctuation, '#pop'), 

127 ], 

128 

129 'goto': [ 

130 include('ws'), 

131 (_name, Name.Label, '#pop'), 

132 ], 

133 

134 'label': [ 

135 include('ws'), 

136 (r'::', Punctuation, '#pop'), 

137 (_name, Name.Label), 

138 ], 

139 

140 'stringescape': [ 

141 (r'\\([abfnrtv\\"\']|[\r\n]{1,2}|z\s*|x[0-9a-fA-F]{2}|\d{1,3}|' 

142 r'u\{[0-9a-fA-F]+\})', String.Escape), 

143 ], 

144 

145 'sqs': [ 

146 (r"'", String.Single, '#pop'), 

147 (r"[^\\']+", String.Single), 

148 ], 

149 

150 'dqs': [ 

151 (r'"', String.Double, '#pop'), 

152 (r'[^\\"]+', String.Double), 

153 ] 

154 } 

155 

156 def __init__(self, **options): 

157 self.func_name_highlighting = get_bool_opt( 

158 options, 'func_name_highlighting', True) 

159 self.disabled_modules = get_list_opt(options, 'disabled_modules', []) 

160 

161 self._functions = set() 

162 if self.func_name_highlighting: 

163 from pygments.lexers._lua_builtins import MODULES 

164 for mod, func in MODULES.items(): 

165 if mod not in self.disabled_modules: 

166 self._functions.update(func) 

167 RegexLexer.__init__(self, **options) 

168 

169 def get_tokens_unprocessed(self, text): 

170 for index, token, value in \ 

171 RegexLexer.get_tokens_unprocessed(self, text): 

172 if token is Name.Builtin and value not in self._functions: 

173 if '.' in value: 

174 a, b = value.split('.') 

175 yield index, Name, a 

176 yield index + len(a), Punctuation, '.' 

177 yield index + len(a) + 1, Name, b 

178 else: 

179 yield index, Name, value 

180 continue 

181 yield index, token, value 

182 

183def _luau_make_expression(should_pop, _s): 

184 temp_list = [ 

185 (r'0[xX][\da-fA-F_]*', Number.Hex, '#pop'), 

186 (r'0[bB][\d_]*', Number.Bin, '#pop'), 

187 (r'\.?\d[\d_]*(?:\.[\d_]*)?(?:[eE][+-]?[\d_]+)?', Number.Float, '#pop'), 

188 

189 (words(( 

190 'true', 'false', 'nil' 

191 ), suffix=r'\b'), Keyword.Constant, '#pop'), 

192 

193 (r'\[(=*)\[[.\n]*?\]\1\]', String, '#pop'), 

194 

195 (r'(\.)([a-zA-Z_]\w*)(?=%s*[({"\'])', bygroups(Punctuation, Name.Function), '#pop'), 

196 (r'(\.)([a-zA-Z_]\w*)', bygroups(Punctuation, Name.Variable), '#pop'), 

197 

198 (rf'[a-zA-Z_]\w*(?:\.[a-zA-Z_]\w*)*(?={_s}*[({{"\'])', Name.Other, '#pop'), 

199 (r'[a-zA-Z_]\w*(?:\.[a-zA-Z_]\w*)*', Name, '#pop'), 

200 ] 

201 if should_pop: 

202 return temp_list 

203 return [entry[:2] for entry in temp_list] 

204 

205def _luau_make_expression_special(should_pop): 

206 temp_list = [ 

207 (r'\{', Punctuation, ('#pop', 'closing_brace_base', 'expression')), 

208 (r'\(', Punctuation, ('#pop', 'closing_parenthesis_base', 'expression')), 

209 

210 (r'::?', Punctuation, ('#pop', 'type_end', 'type_start')), 

211 

212 (r"'", String.Single, ('#pop', 'string_single')), 

213 (r'"', String.Double, ('#pop', 'string_double')), 

214 (r'`', String.Backtick, ('#pop', 'string_interpolated')), 

215 ] 

216 if should_pop: 

217 return temp_list 

218 return [(entry[0], entry[1], entry[2][1:]) for entry in temp_list] 

219 

220class LuauLexer(RegexLexer): 

221 """ 

222 For Luau source code. 

223 

224 Additional options accepted: 

225 

226 `include_luau_builtins` 

227 If given and ``True``, automatically highlight Luau builtins 

228 (default: ``True``). 

229 `include_roblox_builtins` 

230 If given and ``True``, automatically highlight Roblox-specific builtins 

231 (default: ``False``). 

232 `additional_builtins` 

233 If given, must be a list of additional builtins to highlight. 

234 `disabled_builtins` 

235 If given, must be a list of builtins that will not be highlighted. 

236 """ 

237 

238 name = 'Luau' 

239 url = 'https://luau-lang.org/' 

240 aliases = ['luau'] 

241 filenames = ['*.luau'] 

242 version_added = '2.18' 

243 

244 _comment_multiline = r'(?:--\[(?P<level>=*)\[[\w\W]*?\](?P=level)\])' 

245 _comment_single = r'(?:--.*$)' 

246 _s = r'(?:{}|{}|{})'.format(_comment_multiline, _comment_single, r'\s+') 

247 

248 tokens = { 

249 'root': [ 

250 (r'#!.*', Comment.Hashbang, 'base'), 

251 default('base'), 

252 ], 

253 

254 'ws': [ 

255 (_comment_multiline, Comment.Multiline), 

256 (_comment_single, Comment.Single), 

257 (r'\s+', Whitespace), 

258 ], 

259 

260 'base': [ 

261 include('ws'), 

262 

263 *_luau_make_expression_special(False), 

264 (r'\.\.\.', Punctuation), 

265 

266 (rf'type\b(?={_s}+[a-zA-Z_])', Keyword.Reserved, 'type_declaration'), 

267 (rf'export\b(?={_s}+[a-zA-Z_])', Keyword.Reserved), 

268 

269 (r'(?:\.\.|//|[+\-*\/%^<>=])=?', Operator, 'expression'), 

270 (r'~=', Operator, 'expression'), 

271 

272 (words(( 

273 'and', 'or', 'not' 

274 ), suffix=r'\b'), Operator.Word, 'expression'), 

275 

276 (words(( 

277 'elseif', 'for', 'if', 'in', 'repeat', 'return', 'until', 

278 'while'), suffix=r'\b'), Keyword.Reserved, 'expression'), 

279 (r'local\b', Keyword.Declaration, 'expression'), 

280 

281 (r'function\b', Keyword.Reserved, ('expression', 'func_name')), 

282 

283 (r'[\])};]+', Punctuation), 

284 

285 include('expression_static'), 

286 *_luau_make_expression(False, _s), 

287 

288 (r'[\[.,]', Punctuation, 'expression'), 

289 ], 

290 'expression_static': [ 

291 (words(( 

292 'break', 'continue', 'do', 'else', 'elseif', 'end', 'for', 

293 'if', 'in', 'repeat', 'return', 'then', 'until', 'while'), 

294 suffix=r'\b'), Keyword.Reserved), 

295 ], 

296 'expression': [ 

297 include('ws'), 

298 

299 (r'if\b', Keyword.Reserved, ('ternary', 'expression')), 

300 

301 (r'local\b', Keyword.Declaration), 

302 *_luau_make_expression_special(True), 

303 (r'\.\.\.', Punctuation, '#pop'), 

304 

305 (r'function\b', Keyword.Reserved, 'func_name'), 

306 

307 include('expression_static'), 

308 *_luau_make_expression(True, _s), 

309 

310 default('#pop'), 

311 ], 

312 'ternary': [ 

313 include('ws'), 

314 

315 (r'else\b', Keyword.Reserved, '#pop'), 

316 (words(( 

317 'then', 'elseif', 

318 ), suffix=r'\b'), Operator.Reserved, 'expression'), 

319 

320 default('#pop'), 

321 ], 

322 

323 'closing_brace_pop': [ 

324 (r'\}', Punctuation, '#pop'), 

325 ], 

326 'closing_parenthesis_pop': [ 

327 (r'\)', Punctuation, '#pop'), 

328 ], 

329 'closing_gt_pop': [ 

330 (r'>', Punctuation, '#pop'), 

331 ], 

332 

333 'closing_parenthesis_base': [ 

334 include('closing_parenthesis_pop'), 

335 include('base'), 

336 ], 

337 'closing_parenthesis_type': [ 

338 include('closing_parenthesis_pop'), 

339 include('type'), 

340 ], 

341 'closing_brace_base': [ 

342 include('closing_brace_pop'), 

343 include('base'), 

344 ], 

345 'closing_brace_type': [ 

346 include('closing_brace_pop'), 

347 include('type'), 

348 ], 

349 'closing_gt_type': [ 

350 include('closing_gt_pop'), 

351 include('type'), 

352 ], 

353 

354 'string_escape': [ 

355 (r'\\z\s*', String.Escape), 

356 (r'\\(?:[abfnrtvz\\"\'`\{\n])|[\r\n]{1,2}|x[\da-fA-F]{2}|\d{1,3}|' 

357 r'u\{\}[\da-fA-F]*\}', String.Escape), 

358 ], 

359 'string_single': [ 

360 include('string_escape'), 

361 

362 (r"'", String.Single, "#pop"), 

363 (r"[^\\']+", String.Single), 

364 ], 

365 'string_double': [ 

366 include('string_escape'), 

367 

368 (r'"', String.Double, "#pop"), 

369 (r'[^\\"]+', String.Double), 

370 ], 

371 'string_interpolated': [ 

372 include('string_escape'), 

373 

374 (r'\{', Punctuation, ('closing_brace_base', 'expression')), 

375 

376 (r'`', String.Backtick, "#pop"), 

377 (r'[^\\`\{]+', String.Backtick), 

378 ], 

379 

380 'func_name': [ 

381 include('ws'), 

382 

383 (r'[.:]', Punctuation), 

384 (rf'[a-zA-Z_]\w*(?={_s}*[.:])', Name.Class), 

385 (r'[a-zA-Z_]\w*', Name.Function), 

386 

387 (r'<', Punctuation, 'closing_gt_type'), 

388 

389 (r'\(', Punctuation, '#pop'), 

390 ], 

391 

392 'type': [ 

393 include('ws'), 

394 

395 (r'\(', Punctuation, 'closing_parenthesis_type'), 

396 (r'\{', Punctuation, 'closing_brace_type'), 

397 (r'<', Punctuation, 'closing_gt_type'), 

398 

399 (r"'", String.Single, 'string_single'), 

400 (r'"', String.Double, 'string_double'), 

401 

402 (r'[|&\.,\[\]:=]+', Punctuation), 

403 (r'->', Punctuation), 

404 

405 (r'typeof\(', Name.Builtin, ('closing_parenthesis_base', 

406 'expression')), 

407 (r'[a-zA-Z_]\w*', Name.Class), 

408 ], 

409 'type_start': [ 

410 include('ws'), 

411 

412 (r'\(', Punctuation, ('#pop', 'closing_parenthesis_type')), 

413 (r'\{', Punctuation, ('#pop', 'closing_brace_type')), 

414 (r'<', Punctuation, ('#pop', 'closing_gt_type')), 

415 

416 (r"'", String.Single, ('#pop', 'string_single')), 

417 (r'"', String.Double, ('#pop', 'string_double')), 

418 

419 (r'typeof\(', Name.Builtin, ('#pop', 'closing_parenthesis_base', 

420 'expression')), 

421 (r'[a-zA-Z_]\w*', Name.Class, '#pop'), 

422 ], 

423 'type_end': [ 

424 include('ws'), 

425 

426 (r'[|&\.]', Punctuation, 'type_start'), 

427 (r'->', Punctuation, 'type_start'), 

428 

429 (r'<', Punctuation, 'closing_gt_type'), 

430 

431 default('#pop'), 

432 ], 

433 'type_declaration': [ 

434 include('ws'), 

435 

436 (r'[a-zA-Z_]\w*', Name.Class), 

437 (r'<', Punctuation, 'closing_gt_type'), 

438 

439 (r'=', Punctuation, ('#pop', 'type_end', 'type_start')), 

440 ], 

441 } 

442 

443 def __init__(self, **options): 

444 self.include_luau_builtins = get_bool_opt( 

445 options, 'include_luau_builtins', True) 

446 self.include_roblox_builtins = get_bool_opt( 

447 options, 'include_roblox_builtins', False) 

448 self.additional_builtins = get_list_opt(options, 'additional_builtins', []) 

449 self.disabled_builtins = get_list_opt(options, 'disabled_builtins', []) 

450 

451 self._builtins = set(self.additional_builtins) 

452 if self.include_luau_builtins: 

453 from pygments.lexers._luau_builtins import LUAU_BUILTINS 

454 self._builtins.update(LUAU_BUILTINS) 

455 if self.include_roblox_builtins: 

456 from pygments.lexers._luau_builtins import ROBLOX_BUILTINS 

457 self._builtins.update(ROBLOX_BUILTINS) 

458 if self.additional_builtins: 

459 self._builtins.update(self.additional_builtins) 

460 self._builtins.difference_update(self.disabled_builtins) 

461 

462 RegexLexer.__init__(self, **options) 

463 

464 def get_tokens_unprocessed(self, text): 

465 for index, token, value in \ 

466 RegexLexer.get_tokens_unprocessed(self, text): 

467 if token is Name or token is Name.Other: 

468 split_value = value.split('.') 

469 complete_value = [] 

470 new_index = index 

471 for position in range(len(split_value), 0, -1): 

472 potential_string = '.'.join(split_value[:position]) 

473 if potential_string in self._builtins: 

474 yield index, Name.Builtin, potential_string 

475 new_index += len(potential_string) 

476 

477 if complete_value: 

478 yield new_index, Punctuation, '.' 

479 new_index += 1 

480 break 

481 complete_value.insert(0, split_value[position - 1]) 

482 

483 for position, substring in enumerate(complete_value): 

484 if position + 1 == len(complete_value): 

485 if token is Name: 

486 yield new_index, Name.Variable, substring 

487 continue 

488 yield new_index, Name.Function, substring 

489 continue 

490 yield new_index, Name.Variable, substring 

491 new_index += len(substring) 

492 yield new_index, Punctuation, '.' 

493 new_index += 1 

494 

495 continue 

496 yield index, token, value 

497 

498class MoonScriptLexer(LuaLexer): 

499 """ 

500 For MoonScript source code. 

501 """ 

502 

503 name = 'MoonScript' 

504 url = 'http://moonscript.org' 

505 aliases = ['moonscript', 'moon'] 

506 filenames = ['*.moon'] 

507 mimetypes = ['text/x-moonscript', 'application/x-moonscript'] 

508 version_added = '1.5' 

509 

510 tokens = { 

511 'root': [ 

512 (r'#!(.*?)$', Comment.Preproc), 

513 default('base'), 

514 ], 

515 'base': [ 

516 ('--.*$', Comment.Single), 

517 (r'(?i)(\d*\.\d+|\d+\.\d*)(e[+-]?\d+)?', Number.Float), 

518 (r'(?i)\d+e[+-]?\d+', Number.Float), 

519 (r'(?i)0x[0-9a-f]*', Number.Hex), 

520 (r'\d+', Number.Integer), 

521 (r'\n', Whitespace), 

522 (r'[^\S\n]+', Text), 

523 (r'(?s)\[(=*)\[.*?\]\1\]', String), 

524 (r'(->|=>)', Name.Function), 

525 (r':[a-zA-Z_]\w*', Name.Variable), 

526 (r'(==|!=|~=|<=|>=|\.\.\.|\.\.|[=+\-*/%^<>#!.\\:])', Operator), 

527 (r'[;,]', Punctuation), 

528 (r'[\[\]{}()]', Keyword.Type), 

529 (r'[a-zA-Z_]\w*:', Name.Variable), 

530 (words(( 

531 'class', 'extends', 'if', 'then', 'super', 'do', 'with', 

532 'import', 'export', 'while', 'elseif', 'return', 'for', 'in', 

533 'from', 'when', 'using', 'else', 'and', 'or', 'not', 'switch', 

534 'break'), suffix=r'\b'), 

535 Keyword), 

536 (r'(true|false|nil)\b', Keyword.Constant), 

537 (r'(and|or|not)\b', Operator.Word), 

538 (r'(self)\b', Name.Builtin.Pseudo), 

539 (r'@@?([a-zA-Z_]\w*)?', Name.Variable.Class), 

540 (r'[A-Z]\w*', Name.Class), # proper name 

541 (words(all_lua_builtins(), suffix=r"\b"), Name.Builtin), 

542 (r'[A-Za-z_]\w*', Name), 

543 ("'", String.Single, combined('stringescape', 'sqs')), 

544 ('"', String.Double, combined('stringescape', 'dqs')) 

545 ], 

546 'stringescape': [ 

547 (r'''\\([abfnrtv\\"']|\d{1,3})''', String.Escape) 

548 ], 

549 'sqs': [ 

550 ("'", String.Single, '#pop'), 

551 ("[^']+", String) 

552 ], 

553 'dqs': [ 

554 ('"', String.Double, '#pop'), 

555 ('[^"]+', String) 

556 ] 

557 } 

558 

559 def get_tokens_unprocessed(self, text): 

560 # set . as Operator instead of Punctuation 

561 for index, token, value in LuaLexer.get_tokens_unprocessed(self, text): 

562 if token == Punctuation and value == ".": 

563 token = Operator 

564 yield index, token, value 

565 

566 

567class ChaiscriptLexer(RegexLexer): 

568 """ 

569 For ChaiScript source code. 

570 """ 

571 

572 name = 'ChaiScript' 

573 url = 'http://chaiscript.com/' 

574 aliases = ['chaiscript', 'chai'] 

575 filenames = ['*.chai'] 

576 mimetypes = ['text/x-chaiscript', 'application/x-chaiscript'] 

577 version_added = '2.0' 

578 

579 flags = re.DOTALL | re.MULTILINE 

580 

581 tokens = { 

582 'commentsandwhitespace': [ 

583 (r'\s+', Text), 

584 (r'//.*?\n', Comment.Single), 

585 (r'/\*.*?\*/', Comment.Multiline), 

586 (r'^\#.*?\n', Comment.Single) 

587 ], 

588 'slashstartsregex': [ 

589 include('commentsandwhitespace'), 

590 (r'/(\\.|[^[/\\\n]|\[(\\.|[^\]\\\n])*])+/' 

591 r'([gim]+\b|\B)', String.Regex, '#pop'), 

592 (r'(?=/)', Text, ('#pop', 'badregex')), 

593 default('#pop') 

594 ], 

595 'badregex': [ 

596 (r'\n', Text, '#pop') 

597 ], 

598 'root': [ 

599 include('commentsandwhitespace'), 

600 (r'\n', Text), 

601 (r'[^\S\n]+', Text), 

602 (r'\+\+|--|~|&&|\?|:|\|\||\\(?=\n)|\.\.' 

603 r'(<<|>>>?|==?|!=?|[-<>+*%&|^/])=?', Operator, 'slashstartsregex'), 

604 (r'[{(\[;,]', Punctuation, 'slashstartsregex'), 

605 (r'[})\].]', Punctuation), 

606 (r'[=+\-*/]', Operator), 

607 (r'(for|in|while|do|break|return|continue|if|else|' 

608 r'throw|try|catch' 

609 r')\b', Keyword, 'slashstartsregex'), 

610 (r'(var)\b', Keyword.Declaration, 'slashstartsregex'), 

611 (r'(attr|def|fun)\b', Keyword.Reserved), 

612 (r'(true|false)\b', Keyword.Constant), 

613 (r'(eval|throw)\b', Name.Builtin), 

614 (r'`\S+`', Name.Builtin), 

615 (r'[$a-zA-Z_]\w*', Name.Other), 

616 (r'[0-9][0-9]*\.[0-9]+([eE][0-9]+)?[fd]?', Number.Float), 

617 (r'0x[0-9a-fA-F]+', Number.Hex), 

618 (r'[0-9]+', Number.Integer), 

619 (r'"', String.Double, 'dqstring'), 

620 (r"'(\\\\|\\[^\\]|[^'\\])*'", String.Single), 

621 ], 

622 'dqstring': [ 

623 (r'\$\{[^"}]+?\}', String.Interpol), 

624 (r'\$', String.Double), 

625 (r'\\\\', String.Double), 

626 (r'\\"', String.Double), 

627 (r'[^\\"$]+', String.Double), 

628 (r'"', String.Double, '#pop'), 

629 ], 

630 } 

631 

632 

633class LSLLexer(RegexLexer): 

634 """ 

635 For Second Life's Linden Scripting Language source code. 

636 """ 

637 

638 name = 'LSL' 

639 aliases = ['lsl'] 

640 filenames = ['*.lsl'] 

641 mimetypes = ['text/x-lsl'] 

642 url = 'https://wiki.secondlife.com/wiki/Linden_Scripting_Language' 

643 version_added = '2.0' 

644 

645 flags = re.MULTILINE 

646 

647 lsl_keywords = r'\b(?:do|else|for|if|jump|return|while)\b' 

648 lsl_types = r'\b(?:float|integer|key|list|quaternion|rotation|string|vector)\b' 

649 lsl_states = r'\b(?:(?:state)\s+\w+|default)\b' 

650 lsl_events = r'\b(?:state_(?:entry|exit)|touch(?:_(?:start|end))?|(?:land_)?collision(?:_(?:start|end))?|timer|listen|(?:no_)?sensor|control|(?:not_)?at_(?:rot_)?target|money|email|run_time_permissions|changed|attach|dataserver|moving_(?:start|end)|link_message|(?:on|object)_rez|remote_data|http_re(?:sponse|quest)|path_update|transaction_result)\b' 

651 lsl_functions_builtin = r'\b(?:ll(?:ReturnObjectsBy(?:ID|Owner)|Json(?:2List|[GS]etValue|ValueType)|Sin|Cos|Tan|Atan2|Sqrt|Pow|Abs|Fabs|Frand|Floor|Ceil|Round|Vec(?:Mag|Norm|Dist)|Rot(?:Between|2(?:Euler|Fwd|Left|Up))|(?:Euler|Axes)2Rot|Whisper|(?:Region|Owner)?Say|Shout|Listen(?:Control|Remove)?|Sensor(?:Repeat|Remove)?|Detected(?:Name|Key|Owner|Type|Pos|Vel|Grab|Rot|Group|LinkNumber)|Die|Ground|Wind|(?:[GS]et)(?:AnimationOverride|MemoryLimit|PrimMediaParams|ParcelMusicURL|Object(?:Desc|Name)|PhysicsMaterial|Status|Scale|Color|Alpha|Texture|Pos|Rot|Force|Torque)|ResetAnimationOverride|(?:Scale|Offset|Rotate)Texture|(?:Rot)?Target(?:Remove)?|(?:Stop)?MoveToTarget|Apply(?:Rotational)?Impulse|Set(?:KeyframedMotion|ContentType|RegionPos|(?:Angular)?Velocity|Buoyancy|HoverHeight|ForceAndTorque|TimerEvent|ScriptState|Damage|TextureAnim|Sound(?:Queueing|Radius)|Vehicle(?:Type|(?:Float|Vector|Rotation)Param)|(?:Touch|Sit)?Text|Camera(?:Eye|At)Offset|PrimitiveParams|ClickAction|Link(?:Alpha|Color|PrimitiveParams(?:Fast)?|Texture(?:Anim)?|Camera|Media)|RemoteScriptAccessPin|PayPrice|LocalRot)|ScaleByFactor|Get(?:(?:Max|Min)ScaleFactor|ClosestNavPoint|StaticPath|SimStats|Env|PrimitiveParams|Link(?:PrimitiveParams|Number(?:OfSides)?|Key|Name|Media)|HTTPHeader|FreeURLs|Object(?:Details|PermMask|PrimCount)|Parcel(?:MaxPrims|Details|Prim(?:Count|Owners))|Attached|(?:SPMax|Free|Used)Memory|Region(?:Name|TimeDilation|FPS|Corner|AgentCount)|Root(?:Position|Rotation)|UnixTime|(?:Parcel|Region)Flags|(?:Wall|GMT)clock|SimulatorHostname|BoundingBox|GeometricCenter|Creator|NumberOf(?:Prims|NotecardLines|Sides)|Animation(?:List)?|(?:Camera|Local)(?:Pos|Rot)|Vel|Accel|Omega|Time(?:stamp|OfDay)|(?:Object|CenterOf)?Mass|MassMKS|Energy|Owner|(?:Owner)?Key|SunDirection|Texture(?:Offset|Scale|Rot)|Inventory(?:Number|Name|Key|Type|Creator|PermMask)|Permissions(?:Key)?|StartParameter|List(?:Length|EntryType)|Date|Agent(?:Size|Info|Language|List)|LandOwnerAt|NotecardLine|Script(?:Name|State))|(?:Get|Reset|GetAndReset)Time|PlaySound(?:Slave)?|LoopSound(?:Master|Slave)?|(?:Trigger|Stop|Preload)Sound|(?:(?:Get|Delete)Sub|Insert)String|To(?:Upper|Lower)|Give(?:InventoryList|Money)|RezObject|(?:Stop)?LookAt|Sleep|CollisionFilter|(?:Take|Release)Controls|DetachFromAvatar|AttachToAvatar(?:Temp)?|InstantMessage|(?:GetNext)?Email|StopHover|MinEventDelay|RotLookAt|String(?:Length|Trim)|(?:Start|Stop)Animation|TargetOmega|RequestPermissions|(?:Create|Break)Link|BreakAllLinks|(?:Give|Remove)Inventory|Water|PassTouches|Request(?:Agent|Inventory)Data|TeleportAgent(?:Home|GlobalCoords)?|ModifyLand|CollisionSound|ResetScript|MessageLinked|PushObject|PassCollisions|AxisAngle2Rot|Rot2(?:Axis|Angle)|A(?:cos|sin)|AngleBetween|AllowInventoryDrop|SubStringIndex|List2(?:CSV|Integer|Json|Float|String|Key|Vector|Rot|List(?:Strided)?)|DeleteSubList|List(?:Statistics|Sort|Randomize|(?:Insert|Find|Replace)List)|EdgeOfWorld|AdjustSoundVolume|Key2Name|TriggerSoundLimited|EjectFromLand|(?:CSV|ParseString)2List|OverMyLand|SameGroup|UnSit|Ground(?:Slope|Normal|Contour)|GroundRepel|(?:Set|Remove)VehicleFlags|(?:AvatarOn)?(?:Link)?SitTarget|Script(?:Danger|Profiler)|Dialog|VolumeDetect|ResetOtherScript|RemoteLoadScriptPin|(?:Open|Close)RemoteDataChannel|SendRemoteData|RemoteDataReply|(?:Integer|String)ToBase64|XorBase64|Log(?:10)?|Base64To(?:String|Integer)|ParseStringKeepNulls|RezAtRoot|RequestSimulatorData|ForceMouselook|(?:Load|Release|(?:E|Une)scape)URL|ParcelMedia(?:CommandList|Query)|ModPow|MapDestination|(?:RemoveFrom|AddTo|Reset)Land(?:Pass|Ban)List|(?:Set|Clear)CameraParams|HTTP(?:Request|Response)|TextBox|DetectedTouch(?:UV|Face|Pos|(?:N|Bin)ormal|ST)|(?:MD5|SHA1|DumpList2)String|Request(?:Secure)?URL|Clear(?:Prim|Link)Media|(?:Link)?ParticleSystem|(?:Get|Request)(?:Username|DisplayName)|RegionSayTo|CastRay|GenerateKey|TransferLindenDollars|ManageEstateAccess|(?:Create|Delete)Character|ExecCharacterCmd|Evade|FleeFrom|NavigateTo|PatrolPoints|Pursue|UpdateCharacter|WanderWithin))\b' 

652 lsl_constants_float = r'\b(?:DEG_TO_RAD|PI(?:_BY_TWO)?|RAD_TO_DEG|SQRT2|TWO_PI)\b' 

653 lsl_constants_integer = r'\b(?:JSON_APPEND|STATUS_(?:PHYSICS|ROTATE_[XYZ]|PHANTOM|SANDBOX|BLOCK_GRAB(?:_OBJECT)?|(?:DIE|RETURN)_AT_EDGE|CAST_SHADOWS|OK|MALFORMED_PARAMS|TYPE_MISMATCH|BOUNDS_ERROR|NOT_(?:FOUND|SUPPORTED)|INTERNAL_ERROR|WHITELIST_FAILED)|AGENT(?:_(?:BY_(?:LEGACY_|USER)NAME|FLYING|ATTACHMENTS|SCRIPTED|MOUSELOOK|SITTING|ON_OBJECT|AWAY|WALKING|IN_AIR|TYPING|CROUCHING|BUSY|ALWAYS_RUN|AUTOPILOT|LIST_(?:PARCEL(?:_OWNER)?|REGION)))?|CAMERA_(?:PITCH|DISTANCE|BEHINDNESS_(?:ANGLE|LAG)|(?:FOCUS|POSITION)(?:_(?:THRESHOLD|LOCKED|LAG))?|FOCUS_OFFSET|ACTIVE)|ANIM_ON|LOOP|REVERSE|PING_PONG|SMOOTH|ROTATE|SCALE|ALL_SIDES|LINK_(?:ROOT|SET|ALL_(?:OTHERS|CHILDREN)|THIS)|ACTIVE|PASSIVE|SCRIPTED|CONTROL_(?:FWD|BACK|(?:ROT_)?(?:LEFT|RIGHT)|UP|DOWN|(?:ML_)?LBUTTON)|PERMISSION_(?:RETURN_OBJECTS|DEBIT|OVERRIDE_ANIMATIONS|SILENT_ESTATE_MANAGEMENT|TAKE_CONTROLS|TRIGGER_ANIMATION|ATTACH|CHANGE_LINKS|(?:CONTROL|TRACK)_CAMERA|TELEPORT)|INVENTORY_(?:TEXTURE|SOUND|OBJECT|SCRIPT|LANDMARK|CLOTHING|NOTECARD|BODYPART|ANIMATION|GESTURE|ALL|NONE)|CHANGED_(?:INVENTORY|COLOR|SHAPE|SCALE|TEXTURE|LINK|ALLOWED_DROP|OWNER|REGION(?:_START)?|TELEPORT|MEDIA)|OBJECT_(?:(?:PHYSICS|SERVER|STREAMING)_COST|UNKNOWN_DETAIL|CHARACTER_TIME|PHANTOM|PHYSICS|TEMP_ON_REZ|NAME|DESC|POS|PRIM_EQUIVALENCE|RETURN_(?:PARCEL(?:_OWNER)?|REGION)|ROO?T|VELOCITY|OWNER|GROUP|CREATOR|ATTACHED_POINT|RENDER_WEIGHT|PATHFINDING_TYPE|(?:RUNNING|TOTAL)_SCRIPT_COUNT|SCRIPT_(?:MEMORY|TIME))|TYPE_(?:INTEGER|FLOAT|STRING|KEY|VECTOR|ROTATION|INVALID)|(?:DEBUG|PUBLIC)_CHANNEL|ATTACH_(?:AVATAR_CENTER|CHEST|HEAD|BACK|PELVIS|MOUTH|CHIN|NECK|NOSE|BELLY|[LR](?:SHOULDER|HAND|FOOT|EAR|EYE|[UL](?:ARM|LEG)|HIP)|(?:LEFT|RIGHT)_PEC|HUD_(?:CENTER_[12]|TOP_(?:RIGHT|CENTER|LEFT)|BOTTOM(?:_(?:RIGHT|LEFT))?))|LAND_(?:LEVEL|RAISE|LOWER|SMOOTH|NOISE|REVERT)|DATA_(?:ONLINE|NAME|BORN|SIM_(?:POS|STATUS|RATING)|PAYINFO)|PAYMENT_INFO_(?:ON_FILE|USED)|REMOTE_DATA_(?:CHANNEL|REQUEST|REPLY)|PSYS_(?:PART_(?:BF_(?:ZERO|ONE(?:_MINUS_(?:DEST_COLOR|SOURCE_(ALPHA|COLOR)))?|DEST_COLOR|SOURCE_(ALPHA|COLOR))|BLEND_FUNC_(DEST|SOURCE)|FLAGS|(?:START|END)_(?:COLOR|ALPHA|SCALE|GLOW)|MAX_AGE|(?:RIBBON|WIND|INTERP_(?:COLOR|SCALE)|BOUNCE|FOLLOW_(?:SRC|VELOCITY)|TARGET_(?:POS|LINEAR)|EMISSIVE)_MASK)|SRC_(?:MAX_AGE|PATTERN|ANGLE_(?:BEGIN|END)|BURST_(?:RATE|PART_COUNT|RADIUS|SPEED_(?:MIN|MAX))|ACCEL|TEXTURE|TARGET_KEY|OMEGA|PATTERN_(?:DROP|EXPLODE|ANGLE(?:_CONE(?:_EMPTY)?)?)))|VEHICLE_(?:REFERENCE_FRAME|TYPE_(?:NONE|SLED|CAR|BOAT|AIRPLANE|BALLOON)|(?:LINEAR|ANGULAR)_(?:FRICTION_TIMESCALE|MOTOR_DIRECTION)|LINEAR_MOTOR_OFFSET|HOVER_(?:HEIGHT|EFFICIENCY|TIMESCALE)|BUOYANCY|(?:LINEAR|ANGULAR)_(?:DEFLECTION_(?:EFFICIENCY|TIMESCALE)|MOTOR_(?:DECAY_)?TIMESCALE)|VERTICAL_ATTRACTION_(?:EFFICIENCY|TIMESCALE)|BANKING_(?:EFFICIENCY|MIX|TIMESCALE)|FLAG_(?:NO_DEFLECTION_UP|LIMIT_(?:ROLL_ONLY|MOTOR_UP)|HOVER_(?:(?:WATER|TERRAIN|UP)_ONLY|GLOBAL_HEIGHT)|MOUSELOOK_(?:STEER|BANK)|CAMERA_DECOUPLED))|PRIM_(?:TYPE(?:_(?:BOX|CYLINDER|PRISM|SPHERE|TORUS|TUBE|RING|SCULPT))?|HOLE_(?:DEFAULT|CIRCLE|SQUARE|TRIANGLE)|MATERIAL(?:_(?:STONE|METAL|GLASS|WOOD|FLESH|PLASTIC|RUBBER))?|SHINY_(?:NONE|LOW|MEDIUM|HIGH)|BUMP_(?:NONE|BRIGHT|DARK|WOOD|BARK|BRICKS|CHECKER|CONCRETE|TILE|STONE|DISKS|GRAVEL|BLOBS|SIDING|LARGETILE|STUCCO|SUCTION|WEAVE)|TEXGEN_(?:DEFAULT|PLANAR)|SCULPT_(?:TYPE_(?:SPHERE|TORUS|PLANE|CYLINDER|MASK)|FLAG_(?:MIRROR|INVERT))|PHYSICS(?:_(?:SHAPE_(?:CONVEX|NONE|PRIM|TYPE)))?|(?:POS|ROT)_LOCAL|SLICE|TEXT|FLEXIBLE|POINT_LIGHT|TEMP_ON_REZ|PHANTOM|POSITION|SIZE|ROTATION|TEXTURE|NAME|OMEGA|DESC|LINK_TARGET|COLOR|BUMP_SHINY|FULLBRIGHT|TEXGEN|GLOW|MEDIA_(?:ALT_IMAGE_ENABLE|CONTROLS|(?:CURRENT|HOME)_URL|AUTO_(?:LOOP|PLAY|SCALE|ZOOM)|FIRST_CLICK_INTERACT|(?:WIDTH|HEIGHT)_PIXELS|WHITELIST(?:_ENABLE)?|PERMS_(?:INTERACT|CONTROL)|PARAM_MAX|CONTROLS_(?:STANDARD|MINI)|PERM_(?:NONE|OWNER|GROUP|ANYONE)|MAX_(?:URL_LENGTH|WHITELIST_(?:SIZE|COUNT)|(?:WIDTH|HEIGHT)_PIXELS)))|MASK_(?:BASE|OWNER|GROUP|EVERYONE|NEXT)|PERM_(?:TRANSFER|MODIFY|COPY|MOVE|ALL)|PARCEL_(?:MEDIA_COMMAND_(?:STOP|PAUSE|PLAY|LOOP|TEXTURE|URL|TIME|AGENT|UNLOAD|AUTO_ALIGN|TYPE|SIZE|DESC|LOOP_SET)|FLAG_(?:ALLOW_(?:FLY|(?:GROUP_)?SCRIPTS|LANDMARK|TERRAFORM|DAMAGE|CREATE_(?:GROUP_)?OBJECTS)|USE_(?:ACCESS_(?:GROUP|LIST)|BAN_LIST|LAND_PASS_LIST)|LOCAL_SOUND_ONLY|RESTRICT_PUSHOBJECT|ALLOW_(?:GROUP|ALL)_OBJECT_ENTRY)|COUNT_(?:TOTAL|OWNER|GROUP|OTHER|SELECTED|TEMP)|DETAILS_(?:NAME|DESC|OWNER|GROUP|AREA|ID|SEE_AVATARS))|LIST_STAT_(?:MAX|MIN|MEAN|MEDIAN|STD_DEV|SUM(?:_SQUARES)?|NUM_COUNT|GEOMETRIC_MEAN|RANGE)|PAY_(?:HIDE|DEFAULT)|REGION_FLAG_(?:ALLOW_DAMAGE|FIXED_SUN|BLOCK_TERRAFORM|SANDBOX|DISABLE_(?:COLLISIONS|PHYSICS)|BLOCK_FLY|ALLOW_DIRECT_TELEPORT|RESTRICT_PUSHOBJECT)|HTTP_(?:METHOD|MIMETYPE|BODY_(?:MAXLENGTH|TRUNCATED)|CUSTOM_HEADER|PRAGMA_NO_CACHE|VERBOSE_THROTTLE|VERIFY_CERT)|STRING_(?:TRIM(?:_(?:HEAD|TAIL))?)|CLICK_ACTION_(?:NONE|TOUCH|SIT|BUY|PAY|OPEN(?:_MEDIA)?|PLAY|ZOOM)|TOUCH_INVALID_FACE|PROFILE_(?:NONE|SCRIPT_MEMORY)|RC_(?:DATA_FLAGS|DETECT_PHANTOM|GET_(?:LINK_NUM|NORMAL|ROOT_KEY)|MAX_HITS|REJECT_(?:TYPES|AGENTS|(?:NON)?PHYSICAL|LAND))|RCERR_(?:CAST_TIME_EXCEEDED|SIM_PERF_LOW|UNKNOWN)|ESTATE_ACCESS_(?:ALLOWED_(?:AGENT|GROUP)_(?:ADD|REMOVE)|BANNED_AGENT_(?:ADD|REMOVE))|DENSITY|FRICTION|RESTITUTION|GRAVITY_MULTIPLIER|KFM_(?:COMMAND|CMD_(?:PLAY|STOP|PAUSE|SET_MODE)|MODE|FORWARD|LOOP|PING_PONG|REVERSE|DATA|ROTATION|TRANSLATION)|ERR_(?:GENERIC|PARCEL_PERMISSIONS|MALFORMED_PARAMS|RUNTIME_PERMISSIONS|THROTTLED)|CHARACTER_(?:CMD_(?:(?:SMOOTH_)?STOP|JUMP)|DESIRED_(?:TURN_)?SPEED|RADIUS|STAY_WITHIN_PARCEL|LENGTH|ORIENTATION|ACCOUNT_FOR_SKIPPED_FRAMES|AVOIDANCE_MODE|TYPE(?:_(?:[A-D]|NONE))?|MAX_(?:DECEL|TURN_RADIUS|(?:ACCEL|SPEED)))|PURSUIT_(?:OFFSET|FUZZ_FACTOR|GOAL_TOLERANCE|INTERCEPT)|REQUIRE_LINE_OF_SIGHT|FORCE_DIRECT_PATH|VERTICAL|HORIZONTAL|AVOID_(?:CHARACTERS|DYNAMIC_OBSTACLES|NONE)|PU_(?:EVADE_(?:HIDDEN|SPOTTED)|FAILURE_(?:DYNAMIC_PATHFINDING_DISABLED|INVALID_(?:GOAL|START)|NO_(?:NAVMESH|VALID_DESTINATION)|OTHER|TARGET_GONE|(?:PARCEL_)?UNREACHABLE)|(?:GOAL|SLOWDOWN_DISTANCE)_REACHED)|TRAVERSAL_TYPE(?:_(?:FAST|NONE|SLOW))?|CONTENT_TYPE_(?:ATOM|FORM|HTML|JSON|LLSD|RSS|TEXT|XHTML|XML)|GCNP_(?:RADIUS|STATIC)|(?:PATROL|WANDER)_PAUSE_AT_WAYPOINTS|OPT_(?:AVATAR|CHARACTER|EXCLUSION_VOLUME|LEGACY_LINKSET|MATERIAL_VOLUME|OTHER|STATIC_OBSTACLE|WALKABLE)|SIM_STAT_PCT_CHARS_STEPPED)\b' 

654 lsl_constants_integer_boolean = r'\b(?:FALSE|TRUE)\b' 

655 lsl_constants_rotation = r'\b(?:ZERO_ROTATION)\b' 

656 lsl_constants_string = r'\b(?:EOF|JSON_(?:ARRAY|DELETE|FALSE|INVALID|NULL|NUMBER|OBJECT|STRING|TRUE)|NULL_KEY|TEXTURE_(?:BLANK|DEFAULT|MEDIA|PLYWOOD|TRANSPARENT)|URL_REQUEST_(?:GRANTED|DENIED))\b' 

657 lsl_constants_vector = r'\b(?:TOUCH_INVALID_(?:TEXCOORD|VECTOR)|ZERO_VECTOR)\b' 

658 lsl_invalid_broken = r'\b(?:LAND_(?:LARGE|MEDIUM|SMALL)_BRUSH)\b' 

659 lsl_invalid_deprecated = r'\b(?:ATTACH_[LR]PEC|DATA_RATING|OBJECT_ATTACHMENT_(?:GEOMETRY_BYTES|SURFACE_AREA)|PRIM_(?:CAST_SHADOWS|MATERIAL_LIGHT|TYPE_LEGACY)|PSYS_SRC_(?:INNER|OUTER)ANGLE|VEHICLE_FLAG_NO_FLY_UP|ll(?:Cloud|Make(?:Explosion|Fountain|Smoke|Fire)|RemoteDataSetRegion|Sound(?:Preload)?|XorBase64Strings(?:Correct)?))\b' 

660 lsl_invalid_illegal = r'\b(?:event)\b' 

661 lsl_invalid_unimplemented = r'\b(?:CHARACTER_(?:MAX_ANGULAR_(?:ACCEL|SPEED)|TURN_SPEED_MULTIPLIER)|PERMISSION_(?:CHANGE_(?:JOINTS|PERMISSIONS)|RELEASE_OWNERSHIP|REMAP_CONTROLS)|PRIM_PHYSICS_MATERIAL|PSYS_SRC_OBJ_REL_MASK|ll(?:CollisionSprite|(?:Stop)?PointAt|(?:(?:Refresh|Set)Prim)URL|(?:Take|Release)Camera|RemoteLoadScript))\b' 

662 lsl_reserved_godmode = r'\b(?:ll(?:GodLikeRezObject|Set(?:Inventory|Object)PermMask))\b' 

663 lsl_reserved_log = r'\b(?:print)\b' 

664 lsl_operators = r'\+\+|\-\-|<<|>>|&&?|\|\|?|\^|~|[!%<>=*+\-/]=?' 

665 

666 tokens = { 

667 'root': 

668 [ 

669 (r'//.*?\n', Comment.Single), 

670 (r'/\*', Comment.Multiline, 'comment'), 

671 (r'"', String.Double, 'string'), 

672 (lsl_keywords, Keyword), 

673 (lsl_types, Keyword.Type), 

674 (lsl_states, Name.Class), 

675 (lsl_events, Name.Builtin), 

676 (lsl_functions_builtin, Name.Function), 

677 (lsl_constants_float, Keyword.Constant), 

678 (lsl_constants_integer, Keyword.Constant), 

679 (lsl_constants_integer_boolean, Keyword.Constant), 

680 (lsl_constants_rotation, Keyword.Constant), 

681 (lsl_constants_string, Keyword.Constant), 

682 (lsl_constants_vector, Keyword.Constant), 

683 (lsl_invalid_broken, Error), 

684 (lsl_invalid_deprecated, Error), 

685 (lsl_invalid_illegal, Error), 

686 (lsl_invalid_unimplemented, Error), 

687 (lsl_reserved_godmode, Keyword.Reserved), 

688 (lsl_reserved_log, Keyword.Reserved), 

689 (r'\b([a-zA-Z_]\w*)\b', Name.Variable), 

690 (r'(\d+\.\d*|\.\d+|\d+)[eE][+-]?\d*', Number.Float), 

691 (r'(\d+\.\d*|\.\d+)', Number.Float), 

692 (r'0[xX][0-9a-fA-F]+', Number.Hex), 

693 (r'\d+', Number.Integer), 

694 (lsl_operators, Operator), 

695 (r':=?', Error), 

696 (r'[,;{}()\[\]]', Punctuation), 

697 (r'\n+', Whitespace), 

698 (r'\s+', Whitespace) 

699 ], 

700 'comment': 

701 [ 

702 (r'[^*/]+', Comment.Multiline), 

703 (r'/\*', Comment.Multiline, '#push'), 

704 (r'\*/', Comment.Multiline, '#pop'), 

705 (r'[*/]', Comment.Multiline) 

706 ], 

707 'string': 

708 [ 

709 (r'\\([nt"\\])', String.Escape), 

710 (r'"', String.Double, '#pop'), 

711 (r'\\.', Error), 

712 (r'[^"\\]+', String.Double), 

713 ] 

714 } 

715 

716 

717class AppleScriptLexer(RegexLexer): 

718 """ 

719 For AppleScript source code, 

720 including `AppleScript Studio 

721 <http://developer.apple.com/documentation/AppleScript/ 

722 Reference/StudioReference>`_. 

723 Contributed by Andreas Amann <aamann@mac.com>. 

724 """ 

725 

726 name = 'AppleScript' 

727 url = 'https://developer.apple.com/library/archive/documentation/AppleScript/Conceptual/AppleScriptLangGuide/introduction/ASLR_intro.html' 

728 aliases = ['applescript'] 

729 filenames = ['*.applescript'] 

730 version_added = '1.0' 

731 

732 flags = re.MULTILINE | re.DOTALL 

733 

734 Identifiers = r'[a-zA-Z]\w*' 

735 

736 # XXX: use words() for all of these 

737 Literals = ('AppleScript', 'current application', 'false', 'linefeed', 

738 'missing value', 'pi', 'quote', 'result', 'return', 'space', 

739 'tab', 'text item delimiters', 'true', 'version') 

740 Classes = ('alias ', 'application ', 'boolean ', 'class ', 'constant ', 

741 'date ', 'file ', 'integer ', 'list ', 'number ', 'POSIX file ', 

742 'real ', 'record ', 'reference ', 'RGB color ', 'script ', 

743 'text ', 'unit types', '(?:Unicode )?text', 'string') 

744 BuiltIn = ('attachment', 'attribute run', 'character', 'day', 'month', 

745 'paragraph', 'word', 'year') 

746 HandlerParams = ('about', 'above', 'against', 'apart from', 'around', 

747 'aside from', 'at', 'below', 'beneath', 'beside', 

748 'between', 'for', 'given', 'instead of', 'on', 'onto', 

749 'out of', 'over', 'since') 

750 Commands = ('ASCII (character|number)', 'activate', 'beep', 'choose URL', 

751 'choose application', 'choose color', 'choose file( name)?', 

752 'choose folder', 'choose from list', 

753 'choose remote application', 'clipboard info', 

754 'close( access)?', 'copy', 'count', 'current date', 'delay', 

755 'delete', 'display (alert|dialog)', 'do shell script', 

756 'duplicate', 'exists', 'get eof', 'get volume settings', 

757 'info for', 'launch', 'list (disks|folder)', 'load script', 

758 'log', 'make', 'mount volume', 'new', 'offset', 

759 'open( (for access|location))?', 'path to', 'print', 'quit', 

760 'random number', 'read', 'round', 'run( script)?', 

761 'say', 'scripting components', 

762 'set (eof|the clipboard to|volume)', 'store script', 

763 'summarize', 'system attribute', 'system info', 

764 'the clipboard', 'time to GMT', 'write', 'quoted form') 

765 References = ('(in )?back of', '(in )?front of', '[0-9]+(st|nd|rd|th)', 

766 'first', 'second', 'third', 'fourth', 'fifth', 'sixth', 

767 'seventh', 'eighth', 'ninth', 'tenth', 'after', 'back', 

768 'before', 'behind', 'every', 'front', 'index', 'last', 

769 'middle', 'some', 'that', 'through', 'thru', 'where', 'whose') 

770 Operators = ("and", "or", "is equal", "equals", "(is )?equal to", "is not", 

771 "isn't", "isn't equal( to)?", "is not equal( to)?", 

772 "doesn't equal", "does not equal", "(is )?greater than", 

773 "comes after", "is not less than or equal( to)?", 

774 "isn't less than or equal( to)?", "(is )?less than", 

775 "comes before", "is not greater than or equal( to)?", 

776 "isn't greater than or equal( to)?", 

777 "(is )?greater than or equal( to)?", "is not less than", 

778 "isn't less than", "does not come before", 

779 "doesn't come before", "(is )?less than or equal( to)?", 

780 "is not greater than", "isn't greater than", 

781 "does not come after", "doesn't come after", "starts? with", 

782 "begins? with", "ends? with", "contains?", "does not contain", 

783 "doesn't contain", "is in", "is contained by", "is not in", 

784 "is not contained by", "isn't contained by", "div", "mod", 

785 "not", "(a )?(ref( to)?|reference to)", "is", "does") 

786 Control = ('considering', 'else', 'error', 'exit', 'from', 'if', 

787 'ignoring', 'in', 'repeat', 'tell', 'then', 'times', 'to', 

788 'try', 'until', 'using terms from', 'while', 'whith', 

789 'with timeout( of)?', 'with transaction', 'by', 'continue', 

790 'end', 'its?', 'me', 'my', 'return', 'of', 'as') 

791 Declarations = ('global', 'local', 'prop(erty)?', 'set', 'get') 

792 Reserved = ('but', 'put', 'returning', 'the') 

793 StudioClasses = ('action cell', 'alert reply', 'application', 'box', 

794 'browser( cell)?', 'bundle', 'button( cell)?', 'cell', 

795 'clip view', 'color well', 'color-panel', 

796 'combo box( item)?', 'control', 

797 'data( (cell|column|item|row|source))?', 'default entry', 

798 'dialog reply', 'document', 'drag info', 'drawer', 

799 'event', 'font(-panel)?', 'formatter', 

800 'image( (cell|view))?', 'matrix', 'menu( item)?', 'item', 

801 'movie( view)?', 'open-panel', 'outline view', 'panel', 

802 'pasteboard', 'plugin', 'popup button', 

803 'progress indicator', 'responder', 'save-panel', 

804 'scroll view', 'secure text field( cell)?', 'slider', 

805 'sound', 'split view', 'stepper', 'tab view( item)?', 

806 'table( (column|header cell|header view|view))', 

807 'text( (field( cell)?|view))?', 'toolbar( item)?', 

808 'user-defaults', 'view', 'window') 

809 StudioEvents = ('accept outline drop', 'accept table drop', 'action', 

810 'activated', 'alert ended', 'awake from nib', 'became key', 

811 'became main', 'begin editing', 'bounds changed', 

812 'cell value', 'cell value changed', 'change cell value', 

813 'change item value', 'changed', 'child of item', 

814 'choose menu item', 'clicked', 'clicked toolbar item', 

815 'closed', 'column clicked', 'column moved', 

816 'column resized', 'conclude drop', 'data representation', 

817 'deminiaturized', 'dialog ended', 'document nib name', 

818 'double clicked', 'drag( (entered|exited|updated))?', 

819 'drop', 'end editing', 'exposed', 'idle', 'item expandable', 

820 'item value', 'item value changed', 'items changed', 

821 'keyboard down', 'keyboard up', 'launched', 

822 'load data representation', 'miniaturized', 'mouse down', 

823 'mouse dragged', 'mouse entered', 'mouse exited', 

824 'mouse moved', 'mouse up', 'moved', 

825 'number of browser rows', 'number of items', 

826 'number of rows', 'open untitled', 'opened', 'panel ended', 

827 'parameters updated', 'plugin loaded', 'prepare drop', 

828 'prepare outline drag', 'prepare outline drop', 

829 'prepare table drag', 'prepare table drop', 

830 'read from file', 'resigned active', 'resigned key', 

831 'resigned main', 'resized( sub views)?', 

832 'right mouse down', 'right mouse dragged', 

833 'right mouse up', 'rows changed', 'scroll wheel', 

834 'selected tab view item', 'selection changed', 

835 'selection changing', 'should begin editing', 

836 'should close', 'should collapse item', 

837 'should end editing', 'should expand item', 

838 'should open( untitled)?', 

839 'should quit( after last window closed)?', 

840 'should select column', 'should select item', 

841 'should select row', 'should select tab view item', 

842 'should selection change', 'should zoom', 'shown', 

843 'update menu item', 'update parameters', 

844 'update toolbar item', 'was hidden', 'was miniaturized', 

845 'will become active', 'will close', 'will dismiss', 

846 'will display browser cell', 'will display cell', 

847 'will display item cell', 'will display outline cell', 

848 'will finish launching', 'will hide', 'will miniaturize', 

849 'will move', 'will open', 'will pop up', 'will quit', 

850 'will resign active', 'will resize( sub views)?', 

851 'will select tab view item', 'will show', 'will zoom', 

852 'write to file', 'zoomed') 

853 StudioCommands = ('animate', 'append', 'call method', 'center', 

854 'close drawer', 'close panel', 'display', 

855 'display alert', 'display dialog', 'display panel', 'go', 

856 'hide', 'highlight', 'increment', 'item for', 

857 'load image', 'load movie', 'load nib', 'load panel', 

858 'load sound', 'localized string', 'lock focus', 'log', 

859 'open drawer', 'path for', 'pause', 'perform action', 

860 'play', 'register', 'resume', 'scroll', 'select( all)?', 

861 'show', 'size to fit', 'start', 'step back', 

862 'step forward', 'stop', 'synchronize', 'unlock focus', 

863 'update') 

864 StudioProperties = ('accepts arrow key', 'action method', 'active', 

865 'alignment', 'allowed identifiers', 

866 'allows branch selection', 'allows column reordering', 

867 'allows column resizing', 'allows column selection', 

868 'allows customization', 

869 'allows editing text attributes', 

870 'allows empty selection', 'allows mixed state', 

871 'allows multiple selection', 'allows reordering', 

872 'allows undo', 'alpha( value)?', 'alternate image', 

873 'alternate increment value', 'alternate title', 

874 'animation delay', 'associated file name', 

875 'associated object', 'auto completes', 'auto display', 

876 'auto enables items', 'auto repeat', 

877 'auto resizes( outline column)?', 

878 'auto save expanded items', 'auto save name', 

879 'auto save table columns', 'auto saves configuration', 

880 'auto scroll', 'auto sizes all columns to fit', 

881 'auto sizes cells', 'background color', 'bezel state', 

882 'bezel style', 'bezeled', 'border rect', 'border type', 

883 'bordered', 'bounds( rotation)?', 'box type', 

884 'button returned', 'button type', 

885 'can choose directories', 'can choose files', 

886 'can draw', 'can hide', 

887 'cell( (background color|size|type))?', 'characters', 

888 'class', 'click count', 'clicked( data)? column', 

889 'clicked data item', 'clicked( data)? row', 

890 'closeable', 'collating', 'color( (mode|panel))', 

891 'command key down', 'configuration', 

892 'content(s| (size|view( margins)?))?', 'context', 

893 'continuous', 'control key down', 'control size', 

894 'control tint', 'control view', 

895 'controller visible', 'coordinate system', 

896 'copies( on scroll)?', 'corner view', 'current cell', 

897 'current column', 'current( field)? editor', 

898 'current( menu)? item', 'current row', 

899 'current tab view item', 'data source', 

900 'default identifiers', 'delta (x|y|z)', 

901 'destination window', 'directory', 'display mode', 

902 'displayed cell', 'document( (edited|rect|view))?', 

903 'double value', 'dragged column', 'dragged distance', 

904 'dragged items', 'draws( cell)? background', 

905 'draws grid', 'dynamically scrolls', 'echos bullets', 

906 'edge', 'editable', 'edited( data)? column', 

907 'edited data item', 'edited( data)? row', 'enabled', 

908 'enclosing scroll view', 'ending page', 

909 'error handling', 'event number', 'event type', 

910 'excluded from windows menu', 'executable path', 

911 'expanded', 'fax number', 'field editor', 'file kind', 

912 'file name', 'file type', 'first responder', 

913 'first visible column', 'flipped', 'floating', 

914 'font( panel)?', 'formatter', 'frameworks path', 

915 'frontmost', 'gave up', 'grid color', 'has data items', 

916 'has horizontal ruler', 'has horizontal scroller', 

917 'has parent data item', 'has resize indicator', 

918 'has shadow', 'has sub menu', 'has vertical ruler', 

919 'has vertical scroller', 'header cell', 'header view', 

920 'hidden', 'hides when deactivated', 'highlights by', 

921 'horizontal line scroll', 'horizontal page scroll', 

922 'horizontal ruler view', 'horizontally resizable', 

923 'icon image', 'id', 'identifier', 

924 'ignores multiple clicks', 

925 'image( (alignment|dims when disabled|frame style|scaling))?', 

926 'imports graphics', 'increment value', 

927 'indentation per level', 'indeterminate', 'index', 

928 'integer value', 'intercell spacing', 'item height', 

929 'key( (code|equivalent( modifier)?|window))?', 

930 'knob thickness', 'label', 'last( visible)? column', 

931 'leading offset', 'leaf', 'level', 'line scroll', 

932 'loaded', 'localized sort', 'location', 'loop mode', 

933 'main( (bunde|menu|window))?', 'marker follows cell', 

934 'matrix mode', 'maximum( content)? size', 

935 'maximum visible columns', 

936 'menu( form representation)?', 'miniaturizable', 

937 'miniaturized', 'minimized image', 'minimized title', 

938 'minimum column width', 'minimum( content)? size', 

939 'modal', 'modified', 'mouse down state', 

940 'movie( (controller|file|rect))?', 'muted', 'name', 

941 'needs display', 'next state', 'next text', 

942 'number of tick marks', 'only tick mark values', 

943 'opaque', 'open panel', 'option key down', 

944 'outline table column', 'page scroll', 'pages across', 

945 'pages down', 'palette label', 'pane splitter', 

946 'parent data item', 'parent window', 'pasteboard', 

947 'path( (names|separator))?', 'playing', 

948 'plays every frame', 'plays selection only', 'position', 

949 'preferred edge', 'preferred type', 'pressure', 

950 'previous text', 'prompt', 'properties', 

951 'prototype cell', 'pulls down', 'rate', 

952 'released when closed', 'repeated', 

953 'requested print time', 'required file type', 

954 'resizable', 'resized column', 'resource path', 

955 'returns records', 'reuses columns', 'rich text', 

956 'roll over', 'row height', 'rulers visible', 

957 'save panel', 'scripts path', 'scrollable', 

958 'selectable( identifiers)?', 'selected cell', 

959 'selected( data)? columns?', 'selected data items?', 

960 'selected( data)? rows?', 'selected item identifier', 

961 'selection by rect', 'send action on arrow key', 

962 'sends action when done editing', 'separates columns', 

963 'separator item', 'sequence number', 'services menu', 

964 'shared frameworks path', 'shared support path', 

965 'sheet', 'shift key down', 'shows alpha', 

966 'shows state by', 'size( mode)?', 

967 'smart insert delete enabled', 'sort case sensitivity', 

968 'sort column', 'sort order', 'sort type', 

969 'sorted( data rows)?', 'sound', 'source( mask)?', 

970 'spell checking enabled', 'starting page', 'state', 

971 'string value', 'sub menu', 'super menu', 'super view', 

972 'tab key traverses cells', 'tab state', 'tab type', 

973 'tab view', 'table view', 'tag', 'target( printer)?', 

974 'text color', 'text container insert', 

975 'text container origin', 'text returned', 

976 'tick mark position', 'time stamp', 

977 'title(d| (cell|font|height|position|rect))?', 

978 'tool tip', 'toolbar', 'trailing offset', 'transparent', 

979 'treat packages as directories', 'truncated labels', 

980 'types', 'unmodified characters', 'update views', 

981 'use sort indicator', 'user defaults', 

982 'uses data source', 'uses ruler', 

983 'uses threaded animation', 

984 'uses title from previous column', 'value wraps', 

985 'version', 

986 'vertical( (line scroll|page scroll|ruler view))?', 

987 'vertically resizable', 'view', 

988 'visible( document rect)?', 'volume', 'width', 'window', 

989 'windows menu', 'wraps', 'zoomable', 'zoomed') 

990 

991 tokens = { 

992 'root': [ 

993 (r'\s+', Text), 

994 (r'¬\n', String.Escape), 

995 (r"'s\s+", Text), # This is a possessive, consider moving 

996 (r'(--|#).*?$', Comment), 

997 (r'\(\*', Comment.Multiline, 'comment'), 

998 (r'[(){}!,.:]', Punctuation), 

999 (r'(«)([^»]+)(»)', 

1000 bygroups(Text, Name.Builtin, Text)), 

1001 (r'\b((?:considering|ignoring)\s*)' 

1002 r'(application responses|case|diacriticals|hyphens|' 

1003 r'numeric strings|punctuation|white space)', 

1004 bygroups(Keyword, Name.Builtin)), 

1005 (r'(-|\*|\+|&|≠|>=?|<=?|=|≥|≤|/|÷|\^)', Operator), 

1006 (r"\b({})\b".format('|'.join(Operators)), Operator.Word), 

1007 (r'^(\s*(?:on|end)\s+)' 

1008 r'({})'.format('|'.join(StudioEvents[::-1])), 

1009 bygroups(Keyword, Name.Function)), 

1010 (r'^(\s*)(in|on|script|to)(\s+)', bygroups(Text, Keyword, Text)), 

1011 (r'\b(as )({})\b'.format('|'.join(Classes)), 

1012 bygroups(Keyword, Name.Class)), 

1013 (r'\b({})\b'.format('|'.join(Literals)), Name.Constant), 

1014 (r'\b({})\b'.format('|'.join(Commands)), Name.Builtin), 

1015 (r'\b({})\b'.format('|'.join(Control)), Keyword), 

1016 (r'\b({})\b'.format('|'.join(Declarations)), Keyword), 

1017 (r'\b({})\b'.format('|'.join(Reserved)), Name.Builtin), 

1018 (r'\b({})s?\b'.format('|'.join(BuiltIn)), Name.Builtin), 

1019 (r'\b({})\b'.format('|'.join(HandlerParams)), Name.Builtin), 

1020 (r'\b({})\b'.format('|'.join(StudioProperties)), Name.Attribute), 

1021 (r'\b({})s?\b'.format('|'.join(StudioClasses)), Name.Builtin), 

1022 (r'\b({})\b'.format('|'.join(StudioCommands)), Name.Builtin), 

1023 (r'\b({})\b'.format('|'.join(References)), Name.Builtin), 

1024 (r'"(\\\\|\\[^\\]|[^"\\])*"', String.Double), 

1025 (rf'\b({Identifiers})\b', Name.Variable), 

1026 (r'[-+]?(\d+\.\d*|\d*\.\d+)(E[-+][0-9]+)?', Number.Float), 

1027 (r'[-+]?\d+', Number.Integer), 

1028 ], 

1029 'comment': [ 

1030 (r'\(\*', Comment.Multiline, '#push'), 

1031 (r'\*\)', Comment.Multiline, '#pop'), 

1032 ('[^*(]+', Comment.Multiline), 

1033 ('[*(]', Comment.Multiline), 

1034 ], 

1035 } 

1036 

1037 

1038class RexxLexer(RegexLexer): 

1039 """ 

1040 Rexx is a scripting language available for 

1041 a wide range of different platforms with its roots found on mainframe 

1042 systems. It is popular for I/O- and data based tasks and can act as glue 

1043 language to bind different applications together. 

1044 """ 

1045 name = 'Rexx' 

1046 url = 'http://www.rexxinfo.org/' 

1047 aliases = ['rexx', 'arexx'] 

1048 filenames = ['*.rexx', '*.rex', '*.rx', '*.arexx'] 

1049 mimetypes = ['text/x-rexx'] 

1050 version_added = '2.0' 

1051 flags = re.IGNORECASE 

1052 

1053 tokens = { 

1054 'root': [ 

1055 (r'\s+', Whitespace), 

1056 (r'/\*', Comment.Multiline, 'comment'), 

1057 (r'"', String, 'string_double'), 

1058 (r"'", String, 'string_single'), 

1059 (r'[0-9]+(\.[0-9]+)?(e[+-]?[0-9])?', Number), 

1060 (r'([a-z_]\w*)(\s*)(:)(\s*)(procedure)\b', 

1061 bygroups(Name.Function, Whitespace, Operator, Whitespace, 

1062 Keyword.Declaration)), 

1063 (r'([a-z_]\w*)(\s*)(:)', 

1064 bygroups(Name.Label, Whitespace, Operator)), 

1065 include('function'), 

1066 include('keyword'), 

1067 include('operator'), 

1068 (r'[a-z_]\w*', Text), 

1069 ], 

1070 'function': [ 

1071 (words(( 

1072 'abbrev', 'abs', 'address', 'arg', 'b2x', 'bitand', 'bitor', 'bitxor', 

1073 'c2d', 'c2x', 'center', 'charin', 'charout', 'chars', 'compare', 

1074 'condition', 'copies', 'd2c', 'd2x', 'datatype', 'date', 'delstr', 

1075 'delword', 'digits', 'errortext', 'form', 'format', 'fuzz', 'insert', 

1076 'lastpos', 'left', 'length', 'linein', 'lineout', 'lines', 'max', 

1077 'min', 'overlay', 'pos', 'queued', 'random', 'reverse', 'right', 'sign', 

1078 'sourceline', 'space', 'stream', 'strip', 'substr', 'subword', 'symbol', 

1079 'time', 'trace', 'translate', 'trunc', 'value', 'verify', 'word', 

1080 'wordindex', 'wordlength', 'wordpos', 'words', 'x2b', 'x2c', 'x2d', 

1081 'xrange'), suffix=r'(\s*)(\()'), 

1082 bygroups(Name.Builtin, Whitespace, Operator)), 

1083 ], 

1084 'keyword': [ 

1085 (r'(address|arg|by|call|do|drop|else|end|exit|for|forever|if|' 

1086 r'interpret|iterate|leave|nop|numeric|off|on|options|parse|' 

1087 r'pull|push|queue|return|say|select|signal|to|then|trace|until|' 

1088 r'while)\b', Keyword.Reserved), 

1089 ], 

1090 'operator': [ 

1091 (r'(-|//|/|\(|\)|\*\*|\*|\\<<|\\<|\\==|\\=|\\>>|\\>|\\|\|\||\||' 

1092 r'&&|&|%|\+|<<=|<<|<=|<>|<|==|=|><|>=|>>=|>>|>|¬<<|¬<|¬==|¬=|' 

1093 r'¬>>|¬>|¬|\.|,)', Operator), 

1094 ], 

1095 'string_double': [ 

1096 (r'[^"\n]+', String), 

1097 (r'""', String), 

1098 (r'"', String, '#pop'), 

1099 (r'\n', Text, '#pop'), # Stray linefeed also terminates strings. 

1100 ], 

1101 'string_single': [ 

1102 (r'[^\'\n]+', String), 

1103 (r'\'\'', String), 

1104 (r'\'', String, '#pop'), 

1105 (r'\n', Text, '#pop'), # Stray linefeed also terminates strings. 

1106 ], 

1107 'comment': [ 

1108 (r'[^*]+', Comment.Multiline), 

1109 (r'\*/', Comment.Multiline, '#pop'), 

1110 (r'\*', Comment.Multiline), 

1111 ] 

1112 } 

1113 

1114 def _c(s): 

1115 return re.compile(s, re.MULTILINE) 

1116 _ADDRESS_COMMAND_PATTERN = _c(r'^\s*address\s+command\b') 

1117 _ADDRESS_PATTERN = _c(r'^\s*address\s+') 

1118 _DO_WHILE_PATTERN = _c(r'^\s*do\s+while\b') 

1119 _IF_THEN_DO_PATTERN = _c(r'^\s*if\b.+\bthen\s+do\s*$') 

1120 _PROCEDURE_PATTERN = _c(r'^\s*([a-z_]\w*)(\s*)(:)(\s*)(procedure)\b') 

1121 _ELSE_DO_PATTERN = _c(r'\belse\s+do\s*$') 

1122 _PARSE_ARG_PATTERN = _c(r'^\s*parse\s+(upper\s+)?(arg|value)\b') 

1123 PATTERNS_AND_WEIGHTS = ( 

1124 (_ADDRESS_COMMAND_PATTERN, 0.2), 

1125 (_ADDRESS_PATTERN, 0.05), 

1126 (_DO_WHILE_PATTERN, 0.1), 

1127 (_ELSE_DO_PATTERN, 0.1), 

1128 (_IF_THEN_DO_PATTERN, 0.1), 

1129 (_PROCEDURE_PATTERN, 0.5), 

1130 (_PARSE_ARG_PATTERN, 0.2), 

1131 ) 

1132 

1133 def analyse_text(text): 

1134 """ 

1135 Check for initial comment and patterns that distinguish Rexx from other 

1136 C-like languages. 

1137 """ 

1138 if re.search(r'/\*\**\s*rexx', text, re.IGNORECASE): 

1139 # Header matches MVS Rexx requirements, this is certainly a Rexx 

1140 # script. 

1141 return 1.0 

1142 elif text.startswith('/*'): 

1143 # Header matches general Rexx requirements; the source code might 

1144 # still be any language using C comments such as C++, C# or Java. 

1145 lowerText = text.lower() 

1146 result = sum(weight 

1147 for (pattern, weight) in RexxLexer.PATTERNS_AND_WEIGHTS 

1148 if pattern.search(lowerText)) + 0.01 

1149 return min(result, 1.0) 

1150 

1151 

1152class MOOCodeLexer(RegexLexer): 

1153 """ 

1154 For MOOCode (the MOO scripting language). 

1155 """ 

1156 name = 'MOOCode' 

1157 url = 'http://www.moo.mud.org/' 

1158 filenames = ['*.moo'] 

1159 aliases = ['moocode', 'moo'] 

1160 mimetypes = ['text/x-moocode'] 

1161 version_added = '0.9' 

1162 

1163 tokens = { 

1164 'root': [ 

1165 # Numbers 

1166 (r'(0|[1-9][0-9_]*)', Number.Integer), 

1167 # Strings 

1168 (r'"(\\\\|\\[^\\]|[^"\\])*"', String), 

1169 # exceptions 

1170 (r'(E_PERM|E_DIV)', Name.Exception), 

1171 # db-refs 

1172 (r'((#[-0-9]+)|(\$\w+))', Name.Entity), 

1173 # Keywords 

1174 (r'\b(if|else|elseif|endif|for|endfor|fork|endfork|while' 

1175 r'|endwhile|break|continue|return|try' 

1176 r'|except|endtry|finally|in)\b', Keyword), 

1177 # builtins 

1178 (r'(random|length)', Name.Builtin), 

1179 # special variables 

1180 (r'(player|caller|this|args)', Name.Variable.Instance), 

1181 # skip whitespace 

1182 (r'\s+', Text), 

1183 (r'\n', Text), 

1184 # other operators 

1185 (r'([!;=,{}&|:.\[\]@()<>?]+)', Operator), 

1186 # function call 

1187 (r'(\w+)(\()', bygroups(Name.Function, Operator)), 

1188 # variables 

1189 (r'(\w+)', Text), 

1190 ] 

1191 } 

1192 

1193 

1194class HybrisLexer(RegexLexer): 

1195 """ 

1196 For Hybris source code. 

1197 """ 

1198 

1199 name = 'Hybris' 

1200 aliases = ['hybris'] 

1201 filenames = ['*.hyb'] 

1202 mimetypes = ['text/x-hybris', 'application/x-hybris'] 

1203 url = 'https://github.com/evilsocket/hybris' 

1204 version_added = '1.4' 

1205 

1206 flags = re.MULTILINE | re.DOTALL 

1207 

1208 tokens = { 

1209 'root': [ 

1210 # method names 

1211 (r'^(\s*(?:function|method|operator\s+)+?)' 

1212 r'([a-zA-Z_]\w*)' 

1213 r'(\s*)(\()', bygroups(Keyword, Name.Function, Text, Operator)), 

1214 (r'[^\S\n]+', Text), 

1215 (r'//.*?\n', Comment.Single), 

1216 (r'/\*.*?\*/', Comment.Multiline), 

1217 (r'@[a-zA-Z_][\w.]*', Name.Decorator), 

1218 (r'(break|case|catch|next|default|do|else|finally|for|foreach|of|' 

1219 r'unless|if|new|return|switch|me|throw|try|while)\b', Keyword), 

1220 (r'(extends|private|protected|public|static|throws|function|method|' 

1221 r'operator)\b', Keyword.Declaration), 

1222 (r'(true|false|null|__FILE__|__LINE__|__VERSION__|__LIB_PATH__|' 

1223 r'__INC_PATH__)\b', Keyword.Constant), 

1224 (r'(class|struct)(\s+)', 

1225 bygroups(Keyword.Declaration, Text), 'class'), 

1226 (r'(import|include)(\s+)', 

1227 bygroups(Keyword.Namespace, Text), 'import'), 

1228 (words(( 

1229 'gc_collect', 'gc_mm_items', 'gc_mm_usage', 'gc_collect_threshold', 

1230 'urlencode', 'urldecode', 'base64encode', 'base64decode', 'sha1', 'crc32', 

1231 'sha2', 'md5', 'md5_file', 'acos', 'asin', 'atan', 'atan2', 'ceil', 'cos', 

1232 'cosh', 'exp', 'fabs', 'floor', 'fmod', 'log', 'log10', 'pow', 'sin', 

1233 'sinh', 'sqrt', 'tan', 'tanh', 'isint', 'isfloat', 'ischar', 'isstring', 

1234 'isarray', 'ismap', 'isalias', 'typeof', 'sizeof', 'toint', 'tostring', 

1235 'fromxml', 'toxml', 'binary', 'pack', 'load', 'eval', 'var_names', 

1236 'var_values', 'user_functions', 'dyn_functions', 'methods', 'call', 

1237 'call_method', 'mknod', 'mkfifo', 'mount', 'umount2', 'umount', 'ticks', 

1238 'usleep', 'sleep', 'time', 'strtime', 'strdate', 'dllopen', 'dlllink', 

1239 'dllcall', 'dllcall_argv', 'dllclose', 'env', 'exec', 'fork', 'getpid', 

1240 'wait', 'popen', 'pclose', 'exit', 'kill', 'pthread_create', 

1241 'pthread_create_argv', 'pthread_exit', 'pthread_join', 'pthread_kill', 

1242 'smtp_send', 'http_get', 'http_post', 'http_download', 'socket', 'bind', 

1243 'listen', 'accept', 'getsockname', 'getpeername', 'settimeout', 'connect', 

1244 'server', 'recv', 'send', 'close', 'print', 'println', 'printf', 'input', 

1245 'readline', 'serial_open', 'serial_fcntl', 'serial_get_attr', 

1246 'serial_get_ispeed', 'serial_get_ospeed', 'serial_set_attr', 

1247 'serial_set_ispeed', 'serial_set_ospeed', 'serial_write', 'serial_read', 

1248 'serial_close', 'xml_load', 'xml_parse', 'fopen', 'fseek', 'ftell', 

1249 'fsize', 'fread', 'fwrite', 'fgets', 'fclose', 'file', 'readdir', 

1250 'pcre_replace', 'size', 'pop', 'unmap', 'has', 'keys', 'values', 

1251 'length', 'find', 'substr', 'replace', 'split', 'trim', 'remove', 

1252 'contains', 'join'), suffix=r'\b'), 

1253 Name.Builtin), 

1254 (words(( 

1255 'MethodReference', 'Runner', 'Dll', 'Thread', 'Pipe', 'Process', 

1256 'Runnable', 'CGI', 'ClientSocket', 'Socket', 'ServerSocket', 

1257 'File', 'Console', 'Directory', 'Exception'), suffix=r'\b'), 

1258 Keyword.Type), 

1259 (r'"(\\\\|\\[^\\]|[^"\\])*"', String), 

1260 (r"'\\.'|'[^\\]'|'\\u[0-9a-f]{4}'", String.Char), 

1261 (r'(\.)([a-zA-Z_]\w*)', 

1262 bygroups(Operator, Name.Attribute)), 

1263 (r'[a-zA-Z_]\w*:', Name.Label), 

1264 (r'[a-zA-Z_$]\w*', Name), 

1265 (r'[~^*!%&\[\](){}<>|+=:;,./?\-@]+', Operator), 

1266 (r'[0-9][0-9]*\.[0-9]+([eE][0-9]+)?[fd]?', Number.Float), 

1267 (r'0x[0-9a-f]+', Number.Hex), 

1268 (r'[0-9]+L?', Number.Integer), 

1269 (r'\n', Text), 

1270 ], 

1271 'class': [ 

1272 (r'[a-zA-Z_]\w*', Name.Class, '#pop') 

1273 ], 

1274 'import': [ 

1275 (r'[\w.]+\*?', Name.Namespace, '#pop') 

1276 ], 

1277 } 

1278 

1279 def analyse_text(text): 

1280 """public method and private method don't seem to be quite common 

1281 elsewhere.""" 

1282 result = 0 

1283 if re.search(r'\b(?:public|private)\s+method\b', text): 

1284 result += 0.01 

1285 return result 

1286 

1287 

1288 

1289class EasytrieveLexer(RegexLexer): 

1290 """ 

1291 Easytrieve Plus is a programming language for extracting, filtering and 

1292 converting sequential data. Furthermore it can layout data for reports. 

1293 It is mainly used on mainframe platforms and can access several of the 

1294 mainframe's native file formats. It is somewhat comparable to awk. 

1295 """ 

1296 name = 'Easytrieve' 

1297 aliases = ['easytrieve'] 

1298 filenames = ['*.ezt', '*.mac'] 

1299 mimetypes = ['text/x-easytrieve'] 

1300 url = 'https://www.broadcom.com/products/mainframe/application-development/easytrieve-report-generator' 

1301 version_added = '2.1' 

1302 flags = 0 

1303 

1304 # Note: We cannot use r'\b' at the start and end of keywords because 

1305 # Easytrieve Plus delimiter characters are: 

1306 # 

1307 # * space ( ) 

1308 # * apostrophe (') 

1309 # * period (.) 

1310 # * comma (,) 

1311 # * parenthesis ( and ) 

1312 # * colon (:) 

1313 # 

1314 # Additionally words end once a '*' appears, indicatins a comment. 

1315 _DELIMITERS = r' \'.,():\n' 

1316 _DELIMITERS_OR_COMENT = _DELIMITERS + '*' 

1317 _DELIMITER_PATTERN = '[' + _DELIMITERS + ']' 

1318 _DELIMITER_PATTERN_CAPTURE = '(' + _DELIMITER_PATTERN + ')' 

1319 _NON_DELIMITER_OR_COMMENT_PATTERN = '[^' + _DELIMITERS_OR_COMENT + ']' 

1320 _OPERATORS_PATTERN = '[.+\\-/=\\[\\](){}<>;,&%¬]' 

1321 _KEYWORDS = [ 

1322 'AFTER-BREAK', 'AFTER-LINE', 'AFTER-SCREEN', 'AIM', 'AND', 'ATTR', 

1323 'BEFORE', 'BEFORE-BREAK', 'BEFORE-LINE', 'BEFORE-SCREEN', 'BUSHU', 

1324 'BY', 'CALL', 'CASE', 'CHECKPOINT', 'CHKP', 'CHKP-STATUS', 'CLEAR', 

1325 'CLOSE', 'COL', 'COLOR', 'COMMIT', 'CONTROL', 'COPY', 'CURSOR', 'D', 

1326 'DECLARE', 'DEFAULT', 'DEFINE', 'DELETE', 'DENWA', 'DISPLAY', 'DLI', 

1327 'DO', 'DUPLICATE', 'E', 'ELSE', 'ELSE-IF', 'END', 'END-CASE', 

1328 'END-DO', 'END-IF', 'END-PROC', 'ENDPAGE', 'ENDTABLE', 'ENTER', 'EOF', 

1329 'EQ', 'ERROR', 'EXIT', 'EXTERNAL', 'EZLIB', 'F1', 'F10', 'F11', 'F12', 

1330 'F13', 'F14', 'F15', 'F16', 'F17', 'F18', 'F19', 'F2', 'F20', 'F21', 

1331 'F22', 'F23', 'F24', 'F25', 'F26', 'F27', 'F28', 'F29', 'F3', 'F30', 

1332 'F31', 'F32', 'F33', 'F34', 'F35', 'F36', 'F4', 'F5', 'F6', 'F7', 

1333 'F8', 'F9', 'FETCH', 'FILE-STATUS', 'FILL', 'FINAL', 'FIRST', 

1334 'FIRST-DUP', 'FOR', 'GE', 'GET', 'GO', 'GOTO', 'GQ', 'GR', 'GT', 

1335 'HEADING', 'HEX', 'HIGH-VALUES', 'IDD', 'IDMS', 'IF', 'IN', 'INSERT', 

1336 'JUSTIFY', 'KANJI-DATE', 'KANJI-DATE-LONG', 'KANJI-TIME', 'KEY', 

1337 'KEY-PRESSED', 'KOKUGO', 'KUN', 'LAST-DUP', 'LE', 'LEVEL', 'LIKE', 

1338 'LINE', 'LINE-COUNT', 'LINE-NUMBER', 'LINK', 'LIST', 'LOW-VALUES', 

1339 'LQ', 'LS', 'LT', 'MACRO', 'MASK', 'MATCHED', 'MEND', 'MESSAGE', 

1340 'MOVE', 'MSTART', 'NE', 'NEWPAGE', 'NOMASK', 'NOPRINT', 'NOT', 

1341 'NOTE', 'NOVERIFY', 'NQ', 'NULL', 'OF', 'OR', 'OTHERWISE', 'PA1', 

1342 'PA2', 'PA3', 'PAGE-COUNT', 'PAGE-NUMBER', 'PARM-REGISTER', 

1343 'PATH-ID', 'PATTERN', 'PERFORM', 'POINT', 'POS', 'PRIMARY', 'PRINT', 

1344 'PROCEDURE', 'PROGRAM', 'PUT', 'READ', 'RECORD', 'RECORD-COUNT', 

1345 'RECORD-LENGTH', 'REFRESH', 'RELEASE', 'RENUM', 'REPEAT', 'REPORT', 

1346 'REPORT-INPUT', 'RESHOW', 'RESTART', 'RETRIEVE', 'RETURN-CODE', 

1347 'ROLLBACK', 'ROW', 'S', 'SCREEN', 'SEARCH', 'SECONDARY', 'SELECT', 

1348 'SEQUENCE', 'SIZE', 'SKIP', 'SOKAKU', 'SORT', 'SQL', 'STOP', 'SUM', 

1349 'SYSDATE', 'SYSDATE-LONG', 'SYSIN', 'SYSIPT', 'SYSLST', 'SYSPRINT', 

1350 'SYSSNAP', 'SYSTIME', 'TALLY', 'TERM-COLUMNS', 'TERM-NAME', 

1351 'TERM-ROWS', 'TERMINATION', 'TITLE', 'TO', 'TRANSFER', 'TRC', 

1352 'UNIQUE', 'UNTIL', 'UPDATE', 'UPPERCASE', 'USER', 'USERID', 'VALUE', 

1353 'VERIFY', 'W', 'WHEN', 'WHILE', 'WORK', 'WRITE', 'X', 'XDM', 'XRST' 

1354 ] 

1355 

1356 tokens = { 

1357 'root': [ 

1358 (r'\*.*\n', Comment.Single), 

1359 (r'\n+', Whitespace), 

1360 # Macro argument 

1361 (r'&' + _NON_DELIMITER_OR_COMMENT_PATTERN + r'+\.', Name.Variable, 

1362 'after_macro_argument'), 

1363 # Macro call 

1364 (r'%' + _NON_DELIMITER_OR_COMMENT_PATTERN + r'+', Name.Variable), 

1365 (r'(FILE|MACRO|REPORT)(\s+)', 

1366 bygroups(Keyword.Declaration, Whitespace), 'after_declaration'), 

1367 (r'(JOB|PARM)' + r'(' + _DELIMITER_PATTERN + r')', 

1368 bygroups(Keyword.Declaration, Operator)), 

1369 (words(_KEYWORDS, suffix=_DELIMITER_PATTERN_CAPTURE), 

1370 bygroups(Keyword.Reserved, Operator)), 

1371 (_OPERATORS_PATTERN, Operator), 

1372 # Procedure declaration 

1373 (r'(' + _NON_DELIMITER_OR_COMMENT_PATTERN + r'+)(\s*)(\.?)(\s*)(PROC)(\s*\n)', 

1374 bygroups(Name.Function, Whitespace, Operator, Whitespace, 

1375 Keyword.Declaration, Whitespace)), 

1376 (r'[0-9]+\.[0-9]*', Number.Float), 

1377 (r'[0-9]+', Number.Integer), 

1378 (r"'(''|[^'])*'", String), 

1379 (r'\s+', Whitespace), 

1380 # Everything else just belongs to a name 

1381 (_NON_DELIMITER_OR_COMMENT_PATTERN + r'+', Name), 

1382 ], 

1383 'after_declaration': [ 

1384 (_NON_DELIMITER_OR_COMMENT_PATTERN + r'+', Name.Function), 

1385 default('#pop'), 

1386 ], 

1387 'after_macro_argument': [ 

1388 (r'\*.*\n', Comment.Single, '#pop'), 

1389 (r'\s+', Whitespace, '#pop'), 

1390 (_OPERATORS_PATTERN, Operator, '#pop'), 

1391 (r"'(''|[^'])*'", String, '#pop'), 

1392 # Everything else just belongs to a name 

1393 (_NON_DELIMITER_OR_COMMENT_PATTERN + r'+', Name), 

1394 ], 

1395 } 

1396 _COMMENT_LINE_REGEX = re.compile(r'^\s*\*') 

1397 _MACRO_HEADER_REGEX = re.compile(r'^\s*MACRO') 

1398 

1399 def analyse_text(text): 

1400 """ 

1401 Perform a structural analysis for basic Easytrieve constructs. 

1402 """ 

1403 result = 0.0 

1404 lines = text.split('\n') 

1405 hasEndProc = False 

1406 hasHeaderComment = False 

1407 hasFile = False 

1408 hasJob = False 

1409 hasProc = False 

1410 hasParm = False 

1411 hasReport = False 

1412 

1413 def isCommentLine(line): 

1414 return EasytrieveLexer._COMMENT_LINE_REGEX.match(lines[0]) is not None 

1415 

1416 def isEmptyLine(line): 

1417 return not bool(line.strip()) 

1418 

1419 # Remove possible empty lines and header comments. 

1420 while lines and (isEmptyLine(lines[0]) or isCommentLine(lines[0])): 

1421 if not isEmptyLine(lines[0]): 

1422 hasHeaderComment = True 

1423 del lines[0] 

1424 

1425 if EasytrieveLexer._MACRO_HEADER_REGEX.match(lines[0]): 

1426 # Looks like an Easytrieve macro. 

1427 result = 0.4 

1428 if hasHeaderComment: 

1429 result += 0.4 

1430 else: 

1431 # Scan the source for lines starting with indicators. 

1432 for line in lines: 

1433 words = line.split() 

1434 if (len(words) >= 2): 

1435 firstWord = words[0] 

1436 if not hasReport: 

1437 if not hasJob: 

1438 if not hasFile: 

1439 if not hasParm: 

1440 if firstWord == 'PARM': 

1441 hasParm = True 

1442 if firstWord == 'FILE': 

1443 hasFile = True 

1444 if firstWord == 'JOB': 

1445 hasJob = True 

1446 elif firstWord == 'PROC': 

1447 hasProc = True 

1448 elif firstWord == 'END-PROC': 

1449 hasEndProc = True 

1450 elif firstWord == 'REPORT': 

1451 hasReport = True 

1452 

1453 # Weight the findings. 

1454 if hasJob and (hasProc == hasEndProc): 

1455 if hasHeaderComment: 

1456 result += 0.1 

1457 if hasParm: 

1458 if hasProc: 

1459 # Found PARM, JOB and PROC/END-PROC: 

1460 # pretty sure this is Easytrieve. 

1461 result += 0.8 

1462 else: 

1463 # Found PARAM and JOB: probably this is Easytrieve 

1464 result += 0.5 

1465 else: 

1466 # Found JOB and possibly other keywords: might be Easytrieve 

1467 result += 0.11 

1468 if hasParm: 

1469 # Note: PARAM is not a proper English word, so this is 

1470 # regarded a much better indicator for Easytrieve than 

1471 # the other words. 

1472 result += 0.2 

1473 if hasFile: 

1474 result += 0.01 

1475 if hasReport: 

1476 result += 0.01 

1477 assert 0.0 <= result <= 1.0 

1478 return result 

1479 

1480 

1481class JclLexer(RegexLexer): 

1482 """ 

1483 Job Control Language (JCL) 

1484 is a scripting language used on mainframe platforms to instruct the system 

1485 on how to run a batch job or start a subsystem. It is somewhat 

1486 comparable to MS DOS batch and Unix shell scripts. 

1487 """ 

1488 name = 'JCL' 

1489 aliases = ['jcl'] 

1490 filenames = ['*.jcl'] 

1491 mimetypes = ['text/x-jcl'] 

1492 url = 'https://en.wikipedia.org/wiki/Job_Control_Language' 

1493 version_added = '2.1' 

1494 

1495 flags = re.IGNORECASE 

1496 

1497 tokens = { 

1498 'root': [ 

1499 (r'//\*.*\n', Comment.Single), 

1500 (r'//', Keyword.Pseudo, 'statement'), 

1501 (r'/\*', Keyword.Pseudo, 'jes2_statement'), 

1502 # TODO: JES3 statement 

1503 (r'.*\n', Other) # Input text or inline code in any language. 

1504 ], 

1505 'statement': [ 

1506 (r'\s*\n', Whitespace, '#pop'), 

1507 (r'([a-z]\w*)(\s+)(exec|job)(\s*)', 

1508 bygroups(Name.Label, Whitespace, Keyword.Reserved, Whitespace), 

1509 'option'), 

1510 (r'[a-z]\w*', Name.Variable, 'statement_command'), 

1511 (r'\s+', Whitespace, 'statement_command'), 

1512 ], 

1513 'statement_command': [ 

1514 (r'\s+(command|cntl|dd|endctl|endif|else|include|jcllib|' 

1515 r'output|pend|proc|set|then|xmit)\s+', Keyword.Reserved, 'option'), 

1516 include('option') 

1517 ], 

1518 'jes2_statement': [ 

1519 (r'\s*\n', Whitespace, '#pop'), 

1520 (r'\$', Keyword, 'option'), 

1521 (r'\b(jobparam|message|netacct|notify|output|priority|route|' 

1522 r'setup|signoff|xeq|xmit)\b', Keyword, 'option'), 

1523 ], 

1524 'option': [ 

1525 # (r'\n', Text, 'root'), 

1526 (r'\*', Name.Builtin), 

1527 (r'[\[\](){}<>;,]', Punctuation), 

1528 (r'[-+*/=&%]', Operator), 

1529 (r'[a-z_]\w*', Name), 

1530 (r'\d+\.\d*', Number.Float), 

1531 (r'\.\d+', Number.Float), 

1532 (r'\d+', Number.Integer), 

1533 (r"'", String, 'option_string'), 

1534 (r'[ \t]+', Whitespace, 'option_comment'), 

1535 (r'\.', Punctuation), 

1536 ], 

1537 'option_string': [ 

1538 (r"(\n)(//)", bygroups(Text, Keyword.Pseudo)), 

1539 (r"''", String), 

1540 (r"[^']", String), 

1541 (r"'", String, '#pop'), 

1542 ], 

1543 'option_comment': [ 

1544 # (r'\n', Text, 'root'), 

1545 (r'.+', Comment.Single), 

1546 ] 

1547 } 

1548 

1549 _JOB_HEADER_PATTERN = re.compile(r'^//[a-z#$@][a-z0-9#$@]{0,7}\s+job(\s+.*)?$', 

1550 re.IGNORECASE) 

1551 

1552 def analyse_text(text): 

1553 """ 

1554 Recognize JCL job by header. 

1555 """ 

1556 result = 0.0 

1557 lines = text.split('\n') 

1558 if len(lines) > 0: 

1559 if JclLexer._JOB_HEADER_PATTERN.match(lines[0]): 

1560 result = 1.0 

1561 assert 0.0 <= result <= 1.0 

1562 return result 

1563 

1564 

1565class MiniScriptLexer(RegexLexer): 

1566 """ 

1567 For MiniScript source code. 

1568 """ 

1569 

1570 name = 'MiniScript' 

1571 url = 'https://miniscript.org' 

1572 aliases = ['miniscript', 'ms'] 

1573 filenames = ['*.ms'] 

1574 mimetypes = ['text/x-minicript', 'application/x-miniscript'] 

1575 version_added = '2.6' 

1576 

1577 tokens = { 

1578 'root': [ 

1579 (r'#!(.*?)$', Comment.Preproc), 

1580 default('base'), 

1581 ], 

1582 'base': [ 

1583 ('//.*$', Comment.Single), 

1584 (r'(?i)(\d*\.\d+|\d+\.\d*)(e[+-]?\d+)?', Number), 

1585 (r'(?i)\d+e[+-]?\d+', Number), 

1586 (r'\d+', Number), 

1587 (r'\n', Text), 

1588 (r'[^\S\n]+', Text), 

1589 (r'"', String, 'string_double'), 

1590 (r'(==|!=|<=|>=|[=+\-*/%^<>.:])', Operator), 

1591 (r'[;,\[\]{}()]', Punctuation), 

1592 (words(( 

1593 'break', 'continue', 'else', 'end', 'for', 'function', 'if', 

1594 'in', 'isa', 'then', 'repeat', 'return', 'while'), suffix=r'\b'), 

1595 Keyword), 

1596 (words(( 

1597 'abs', 'acos', 'asin', 'atan', 'ceil', 'char', 'cos', 'floor', 

1598 'log', 'round', 'rnd', 'pi', 'sign', 'sin', 'sqrt', 'str', 'tan', 

1599 'hasIndex', 'indexOf', 'len', 'val', 'code', 'remove', 'lower', 

1600 'upper', 'replace', 'split', 'indexes', 'values', 'join', 'sum', 

1601 'sort', 'shuffle', 'push', 'pop', 'pull', 'range', 

1602 'print', 'input', 'time', 'wait', 'locals', 'globals', 'outer', 

1603 'yield'), suffix=r'\b'), 

1604 Name.Builtin), 

1605 (r'(true|false|null)\b', Keyword.Constant), 

1606 (r'(and|or|not|new)\b', Operator.Word), 

1607 (r'(self|super|__isa)\b', Name.Builtin.Pseudo), 

1608 (r'[a-zA-Z_]\w*', Name.Variable) 

1609 ], 

1610 'string_double': [ 

1611 (r'[^"\n]+', String), 

1612 (r'""', String), 

1613 (r'"', String, '#pop'), 

1614 (r'\n', Text, '#pop'), # Stray linefeed also terminates strings. 

1615 ] 

1616 }