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

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

332 statements  

1""" 

2 pygments.lexers.scripting 

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

4 

5 Lexer for scripting and embedded languages. 

6 

7 :copyright: Copyright 2006-present 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 # A lookahead-safe version of _s that avoids catastrophic backtracking. 

63 # The _comment_multiline pattern contains [\w\W]*? which, when used 

64 # inside a lookahead with a * quantifier, causes exponential blowup. 

65 # This version skips only whitespace; comments between an identifier 

66 # and a following [.:] or ( are rare enough to sacrifice. 

67 _s_la = r'\s' 

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

69 

70 tokens = { 

71 'root': [ 

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

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

74 default('base'), 

75 ], 

76 'ws': [ 

77 (_comment_multiline, Comment.Multiline), 

78 (_comment_single, Comment.Single), 

79 (_space, Whitespace), 

80 ], 

81 'base': [ 

82 include('ws'), 

83 

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

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

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

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

88 

89 # multiline strings 

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

91 

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

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

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

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

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

97 

98 (words([ 

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

100 'repeat', 'return', 'then', 'until', 'while' 

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

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

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

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

105 

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

107 

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

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

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

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

112 

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

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

115 ], 

116 

117 'varname': [ 

118 include('ws'), 

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

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

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

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

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

124 ], 

125 

126 'funcname': [ 

127 include('ws'), 

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

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

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

131 # inline function 

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

133 ], 

134 

135 'goto': [ 

136 include('ws'), 

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

138 ], 

139 

140 'label': [ 

141 include('ws'), 

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

143 (_name, Name.Label), 

144 ], 

145 

146 'stringescape': [ 

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

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

149 ], 

150 

151 'sqs': [ 

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

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

154 ], 

155 

156 'dqs': [ 

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

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

159 ] 

160 } 

161 

162 def __init__(self, **options): 

163 self.func_name_highlighting = get_bool_opt( 

164 options, 'func_name_highlighting', True) 

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

166 

167 self._functions = set() 

168 if self.func_name_highlighting: 

169 from pygments.lexers._lua_builtins import MODULES 

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

171 if mod not in self.disabled_modules: 

172 self._functions.update(func) 

173 RegexLexer.__init__(self, **options) 

174 

175 def get_tokens_unprocessed(self, text): 

176 for index, token, value in \ 

177 RegexLexer.get_tokens_unprocessed(self, text): 

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

179 if '.' in value: 

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

181 yield index, Name, a 

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

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

184 else: 

185 yield index, Name, value 

186 continue 

187 yield index, token, value 

188 

189def _luau_make_expression(should_pop, _s, _s_la): 

190 temp_list = [ 

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

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

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

194 

195 (words(( 

196 'true', 'false', 'nil' 

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

198 

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

200 

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

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

203 

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

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

206 ] 

207 if should_pop: 

208 return temp_list 

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

210 

211def _luau_make_expression_special(should_pop): 

212 temp_list = [ 

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

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

215 

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

217 

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

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

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

221 ] 

222 if should_pop: 

223 return temp_list 

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

225 

226class LuauLexer(RegexLexer): 

227 """ 

228 For Luau source code. 

229 

230 Additional options accepted: 

231 

232 `include_luau_builtins` 

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

234 (default: ``True``). 

235 `include_roblox_builtins` 

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

237 (default: ``False``). 

238 `additional_builtins` 

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

240 `disabled_builtins` 

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

242 """ 

243 

244 name = 'Luau' 

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

246 aliases = ['luau'] 

247 filenames = ['*.luau'] 

248 version_added = '2.18' 

249 

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

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

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

253 # Lookahead-safe version — avoids catastrophic backtracking from 

254 # [\w\W]*? inside _comment_multiline when combined with * quantifier. 

255 _s_la = r'\s' 

256 

257 tokens = { 

258 'root': [ 

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

260 default('base'), 

261 ], 

262 

263 'ws': [ 

264 (_comment_multiline, Comment.Multiline), 

265 (_comment_single, Comment.Single), 

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

267 ], 

268 

269 'base': [ 

270 include('ws'), 

271 

272 *_luau_make_expression_special(False), 

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

274 

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

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

277 

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

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

280 

281 (words(( 

282 'and', 'or', 'not' 

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

284 

285 (words(( 

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

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

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

289 

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

291 

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

293 

294 include('expression_static'), 

295 *_luau_make_expression(False, _s, _s_la), 

296 

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

298 ], 

299 'expression_static': [ 

300 (words(( 

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

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

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

304 ], 

305 'expression': [ 

306 include('ws'), 

307 

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

309 

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

311 *_luau_make_expression_special(True), 

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

313 

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

315 

316 include('expression_static'), 

317 *_luau_make_expression(True, _s, _s_la), 

318 

319 default('#pop'), 

320 ], 

321 'ternary': [ 

322 include('ws'), 

323 

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

325 (words(( 

326 'then', 'elseif', 

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

328 

329 default('#pop'), 

330 ], 

331 

332 'closing_brace_pop': [ 

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

334 ], 

335 'closing_parenthesis_pop': [ 

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

337 ], 

338 'closing_gt_pop': [ 

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

340 ], 

341 

342 'closing_parenthesis_base': [ 

343 include('closing_parenthesis_pop'), 

344 include('base'), 

345 ], 

346 'closing_parenthesis_type': [ 

347 include('closing_parenthesis_pop'), 

348 include('type'), 

349 ], 

350 'closing_brace_base': [ 

351 include('closing_brace_pop'), 

352 include('base'), 

353 ], 

354 'closing_brace_type': [ 

355 include('closing_brace_pop'), 

356 include('type'), 

357 ], 

358 'closing_gt_type': [ 

359 include('closing_gt_pop'), 

360 include('type'), 

361 ], 

362 

363 'string_escape': [ 

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

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

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

367 ], 

368 'string_single': [ 

369 include('string_escape'), 

370 

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

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

373 ], 

374 'string_double': [ 

375 include('string_escape'), 

376 

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

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

379 ], 

380 'string_interpolated': [ 

381 include('string_escape'), 

382 

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

384 

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

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

387 ], 

388 

389 'func_name': [ 

390 include('ws'), 

391 

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

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

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

395 

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

397 

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

399 ], 

400 

401 'type': [ 

402 include('ws'), 

403 

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

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

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

407 

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

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

410 

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

412 (r'->', Punctuation), 

413 

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

415 'expression')), 

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

417 ], 

418 'type_start': [ 

419 include('ws'), 

420 

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

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

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

424 

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

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

427 

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

429 'expression')), 

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

431 ], 

432 'type_end': [ 

433 include('ws'), 

434 

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

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

437 

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

439 

440 default('#pop'), 

441 ], 

442 'type_declaration': [ 

443 include('ws'), 

444 

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

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

447 

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

449 ], 

450 } 

451 

452 def __init__(self, **options): 

453 self.include_luau_builtins = get_bool_opt( 

454 options, 'include_luau_builtins', True) 

455 self.include_roblox_builtins = get_bool_opt( 

456 options, 'include_roblox_builtins', False) 

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

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

459 

460 self._builtins = set(self.additional_builtins) 

461 if self.include_luau_builtins: 

462 from pygments.lexers._luau_builtins import LUAU_BUILTINS 

463 self._builtins.update(LUAU_BUILTINS) 

464 if self.include_roblox_builtins: 

465 from pygments.lexers._luau_builtins import ROBLOX_BUILTINS 

466 self._builtins.update(ROBLOX_BUILTINS) 

467 if self.additional_builtins: 

468 self._builtins.update(self.additional_builtins) 

469 self._builtins.difference_update(self.disabled_builtins) 

470 

471 RegexLexer.__init__(self, **options) 

472 

473 def get_tokens_unprocessed(self, text): 

474 for index, token, value in \ 

475 RegexLexer.get_tokens_unprocessed(self, text): 

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

477 split_value = value.split('.') 

478 complete_value = [] 

479 new_index = index 

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

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

482 if potential_string in self._builtins: 

483 yield index, Name.Builtin, potential_string 

484 new_index += len(potential_string) 

485 

486 if complete_value: 

487 yield new_index, Punctuation, '.' 

488 new_index += 1 

489 break 

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

491 

492 for position, substring in enumerate(complete_value): 

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

494 if token is Name: 

495 yield new_index, Name.Variable, substring 

496 continue 

497 yield new_index, Name.Function, substring 

498 continue 

499 yield new_index, Name.Variable, substring 

500 new_index += len(substring) 

501 yield new_index, Punctuation, '.' 

502 new_index += 1 

503 

504 continue 

505 yield index, token, value 

506 

507class MoonScriptLexer(LuaLexer): 

508 """ 

509 For MoonScript source code. 

510 """ 

511 

512 name = 'MoonScript' 

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

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

515 filenames = ['*.moon'] 

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

517 version_added = '1.5' 

518 

519 tokens = { 

520 'root': [ 

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

522 default('base'), 

523 ], 

524 'base': [ 

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

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

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

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

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

530 (r'\n', Whitespace), 

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

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

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

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

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

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

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

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

539 (words(( 

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

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

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

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

544 Keyword), 

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

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

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

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

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

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

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

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

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

554 ], 

555 'stringescape': [ 

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

557 ], 

558 'strings': [ 

559 (r'[^#\\\'"]+', String), 

560 # note that strings are multi-line. 

561 # hashmarks, quotes and backslashes must be parsed one at a time 

562 ], 

563 'interpoling_string': [ 

564 (r'\}', String.Interpol, "#pop"), 

565 include('base') 

566 ], 

567 'dqs': [ 

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

569 (r'\\.|\'', String), # double-quoted string don't need ' escapes 

570 (r'#\{', String.Interpol, "interpoling_string"), 

571 (r'#', String), 

572 include('strings') 

573 ], 

574 'sqs': [ 

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

576 (r'#|\\.|"', String), # single quoted strings don't need " escapses 

577 include('strings') 

578 ] 

579 } 

580 

581 def get_tokens_unprocessed(self, text): 

582 # set . as Operator instead of Punctuation 

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

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

585 token = Operator 

586 yield index, token, value 

587 

588 

589class ChaiscriptLexer(RegexLexer): 

590 """ 

591 For ChaiScript source code. 

592 """ 

593 

594 name = 'ChaiScript' 

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

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

597 filenames = ['*.chai'] 

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

599 version_added = '2.0' 

600 

601 flags = re.DOTALL | re.MULTILINE 

602 

603 tokens = { 

604 'commentsandwhitespace': [ 

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

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

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

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

609 ], 

610 'slashstartsregex': [ 

611 include('commentsandwhitespace'), 

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

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

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

615 default('#pop') 

616 ], 

617 'badregex': [ 

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

619 ], 

620 'root': [ 

621 include('commentsandwhitespace'), 

622 (r'\n', Text), 

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

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

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

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

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

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

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

630 r'throw|try|catch' 

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

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

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

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

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

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

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

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

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

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

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

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

643 ], 

644 'dqstring': [ 

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

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

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

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

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

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

651 ], 

652 } 

653 

654 

655class LSLLexer(RegexLexer): 

656 """ 

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

658 """ 

659 

660 name = 'LSL' 

661 aliases = ['lsl'] 

662 filenames = ['*.lsl'] 

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

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

665 version_added = '2.0' 

666 

667 flags = re.MULTILINE 

668 

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

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

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

672 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' 

673 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' 

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

675 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' 

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

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

678 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' 

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

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

681 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' 

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

683 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' 

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

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

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

687 

688 tokens = { 

689 'root': 

690 [ 

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

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

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

694 (lsl_keywords, Keyword), 

695 (lsl_types, Keyword.Type), 

696 (lsl_states, Name.Class), 

697 (lsl_events, Name.Builtin), 

698 (lsl_functions_builtin, Name.Function), 

699 (lsl_constants_float, Keyword.Constant), 

700 (lsl_constants_integer, Keyword.Constant), 

701 (lsl_constants_integer_boolean, Keyword.Constant), 

702 (lsl_constants_rotation, Keyword.Constant), 

703 (lsl_constants_string, Keyword.Constant), 

704 (lsl_constants_vector, Keyword.Constant), 

705 (lsl_invalid_broken, Error), 

706 (lsl_invalid_deprecated, Error), 

707 (lsl_invalid_illegal, Error), 

708 (lsl_invalid_unimplemented, Error), 

709 (lsl_reserved_godmode, Keyword.Reserved), 

710 (lsl_reserved_log, Keyword.Reserved), 

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

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

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

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

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

716 (lsl_operators, Operator), 

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

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

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

720 (r'\s+', Whitespace) 

721 ], 

722 'comment': 

723 [ 

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

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

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

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

728 ], 

729 'string': 

730 [ 

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

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

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

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

735 ] 

736 } 

737 

738 

739class AppleScriptLexer(RegexLexer): 

740 """ 

741 For AppleScript source code, 

742 including `AppleScript Studio 

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

744 Reference/StudioReference>`_. 

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

746 """ 

747 

748 name = 'AppleScript' 

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

750 aliases = ['applescript'] 

751 filenames = ['*.applescript'] 

752 version_added = '1.0' 

753 

754 flags = re.MULTILINE | re.DOTALL 

755 

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

757 

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

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

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

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

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

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

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

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

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

767 'paragraph', 'word', 'year') 

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

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

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

771 'out of', 'over', 'since') 

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

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

774 'choose folder', 'choose from list', 

775 'choose remote application', 'clipboard info', 

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

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

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

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

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

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

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

783 'say', 'scripting components', 

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

785 'summarize', 'system attribute', 'system info', 

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

824 'pasteboard', 'plugin', 'popup button', 

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

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

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

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

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

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

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

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

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

834 'cell value', 'cell value changed', 'change cell value', 

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

836 'choose menu item', 'clicked', 'clicked toolbar item', 

837 'closed', 'column clicked', 'column moved', 

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

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

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

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

842 'item value', 'item value changed', 'items changed', 

843 'keyboard down', 'keyboard up', 'launched', 

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

845 'mouse dragged', 'mouse entered', 'mouse exited', 

846 'mouse moved', 'mouse up', 'moved', 

847 'number of browser rows', 'number of items', 

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

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

850 'prepare outline drag', 'prepare outline drop', 

851 'prepare table drag', 'prepare table drop', 

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

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

854 'right mouse down', 'right mouse dragged', 

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

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

857 'selection changing', 'should begin editing', 

858 'should close', 'should collapse item', 

859 'should end editing', 'should expand item', 

860 'should open( untitled)?', 

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

862 'should select column', 'should select item', 

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

864 'should selection change', 'should zoom', 'shown', 

865 'update menu item', 'update parameters', 

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

867 'will become active', 'will close', 'will dismiss', 

868 'will display browser cell', 'will display cell', 

869 'will display item cell', 'will display outline cell', 

870 'will finish launching', 'will hide', 'will miniaturize', 

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

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

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

874 'write to file', 'zoomed') 

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

876 'close drawer', 'close panel', 'display', 

877 'display alert', 'display dialog', 'display panel', 'go', 

878 'hide', 'highlight', 'increment', 'item for', 

879 'load image', 'load movie', 'load nib', 'load panel', 

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

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

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

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

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

885 'update') 

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

887 'alignment', 'allowed identifiers', 

888 'allows branch selection', 'allows column reordering', 

889 'allows column resizing', 'allows column selection', 

890 'allows customization', 

891 'allows editing text attributes', 

892 'allows empty selection', 'allows mixed state', 

893 'allows multiple selection', 'allows reordering', 

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

895 'alternate increment value', 'alternate title', 

896 'animation delay', 'associated file name', 

897 'associated object', 'auto completes', 'auto display', 

898 'auto enables items', 'auto repeat', 

899 'auto resizes( outline column)?', 

900 'auto save expanded items', 'auto save name', 

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

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

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

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

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

906 'button returned', 'button type', 

907 'can choose directories', 'can choose files', 

908 'can draw', 'can hide', 

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

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

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

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

913 'command key down', 'configuration', 

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

915 'continuous', 'control key down', 'control size', 

916 'control tint', 'control view', 

917 'controller visible', 'coordinate system', 

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

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

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

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

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

923 'destination window', 'directory', 'display mode', 

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

925 'double value', 'dragged column', 'dragged distance', 

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

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

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

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

930 'enclosing scroll view', 'ending page', 

931 'error handling', 'event number', 'event type', 

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

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

934 'file name', 'file type', 'first responder', 

935 'first visible column', 'flipped', 'floating', 

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

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

938 'has horizontal ruler', 'has horizontal scroller', 

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

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

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

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

943 'horizontal line scroll', 'horizontal page scroll', 

944 'horizontal ruler view', 'horizontally resizable', 

945 'icon image', 'id', 'identifier', 

946 'ignores multiple clicks', 

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

948 'imports graphics', 'increment value', 

949 'indentation per level', 'indeterminate', 'index', 

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

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

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

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

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

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

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

957 'maximum visible columns', 

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

959 'miniaturized', 'minimized image', 'minimized title', 

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

961 'modal', 'modified', 'mouse down state', 

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

963 'needs display', 'next state', 'next text', 

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

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

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

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

968 'parent data item', 'parent window', 'pasteboard', 

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

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

971 'preferred edge', 'preferred type', 'pressure', 

972 'previous text', 'prompt', 'properties', 

973 'prototype cell', 'pulls down', 'rate', 

974 'released when closed', 'repeated', 

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

976 'resizable', 'resized column', 'resource path', 

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

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

979 'save panel', 'scripts path', 'scrollable', 

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

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

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

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

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

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

986 'shared frameworks path', 'shared support path', 

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

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

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

990 'sort column', 'sort order', 'sort type', 

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

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

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

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

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

996 'text color', 'text container insert', 

997 'text container origin', 'text returned', 

998 'tick mark position', 'time stamp', 

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

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

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

1002 'types', 'unmodified characters', 'update views', 

1003 'use sort indicator', 'user defaults', 

1004 'uses data source', 'uses ruler', 

1005 'uses threaded animation', 

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

1007 'version', 

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

1009 'vertically resizable', 'view', 

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

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

1012 

1013 tokens = { 

1014 'root': [ 

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

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

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

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

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

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

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

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

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

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

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

1026 bygroups(Keyword, Name.Builtin)), 

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

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

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

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

1031 bygroups(Keyword, Name.Function)), 

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

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

1034 bygroups(Keyword, Name.Class)), 

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

1050 ], 

1051 'comment': [ 

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

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

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

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

1056 ], 

1057 } 

1058 

1059 

1060class RexxLexer(RegexLexer): 

1061 """ 

1062 Rexx is a scripting language available for 

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

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

1065 language to bind different applications together. 

1066 """ 

1067 name = 'Rexx' 

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

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

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

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

1072 version_added = '2.0' 

1073 flags = re.IGNORECASE 

1074 

1075 tokens = { 

1076 'root': [ 

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

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

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

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

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

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

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

1084 Keyword.Declaration)), 

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

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

1087 include('function'), 

1088 include('keyword'), 

1089 include('operator'), 

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

1091 ], 

1092 'function': [ 

1093 (words(( 

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

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

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

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

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

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

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

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

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

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

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

1105 ], 

1106 'keyword': [ 

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

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

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

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

1111 ], 

1112 'operator': [ 

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

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

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

1116 ], 

1117 'string_double': [ 

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

1119 (r'""', String), 

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

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

1122 ], 

1123 'string_single': [ 

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

1125 (r'\'\'', String), 

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

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

1128 ], 

1129 'comment': [ 

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

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

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

1133 ] 

1134 } 

1135 

1136 def _c(s): 

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

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

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

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

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

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

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

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

1145 PATTERNS_AND_WEIGHTS = ( 

1146 (_ADDRESS_COMMAND_PATTERN, 0.2), 

1147 (_ADDRESS_PATTERN, 0.05), 

1148 (_DO_WHILE_PATTERN, 0.1), 

1149 (_ELSE_DO_PATTERN, 0.1), 

1150 (_IF_THEN_DO_PATTERN, 0.1), 

1151 (_PROCEDURE_PATTERN, 0.5), 

1152 (_PARSE_ARG_PATTERN, 0.2), 

1153 ) 

1154 

1155 def analyse_text(text): 

1156 """ 

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

1158 C-like languages. 

1159 """ 

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

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

1162 # script. 

1163 return 1.0 

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

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

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

1167 lowerText = text.lower() 

1168 result = sum(weight 

1169 for (pattern, weight) in RexxLexer.PATTERNS_AND_WEIGHTS 

1170 if pattern.search(lowerText)) + 0.01 

1171 return min(result, 1.0) 

1172 

1173 

1174class MOOCodeLexer(RegexLexer): 

1175 """ 

1176 For MOOCode (the MOO scripting language). 

1177 """ 

1178 name = 'MOOCode' 

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

1180 filenames = ['*.moo'] 

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

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

1183 version_added = '0.9' 

1184 

1185 tokens = { 

1186 'root': [ 

1187 # Numbers 

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

1189 # Strings 

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

1191 # exceptions 

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

1193 # db-refs 

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

1195 # Keywords 

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

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

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

1199 # builtins 

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

1201 # special variables 

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

1203 # skip whitespace 

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

1205 (r'\n', Text), 

1206 # other operators 

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

1208 # function call 

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

1210 # variables 

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

1212 ] 

1213 } 

1214 

1215 

1216class HybrisLexer(RegexLexer): 

1217 """ 

1218 For Hybris source code. 

1219 """ 

1220 

1221 name = 'Hybris' 

1222 aliases = ['hybris'] 

1223 filenames = ['*.hyb'] 

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

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

1226 version_added = '1.4' 

1227 

1228 flags = re.MULTILINE | re.DOTALL 

1229 

1230 tokens = { 

1231 'root': [ 

1232 # method names 

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

1250 (words(( 

1251 'gc_collect', 'gc_mm_items', 'gc_mm_usage', 'gc_collect_threshold', 

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

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

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

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

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

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

1258 'var_values', 'user_functions', 'dyn_functions', 'methods', 'call', 

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

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

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

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

1263 'pthread_create_argv', 'pthread_exit', 'pthread_join', 'pthread_kill', 

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

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

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

1267 'readline', 'serial_open', 'serial_fcntl', 'serial_get_attr', 

1268 'serial_get_ispeed', 'serial_get_ospeed', 'serial_set_attr', 

1269 'serial_set_ispeed', 'serial_set_ospeed', 'serial_write', 'serial_read', 

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

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

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

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

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

1275 Name.Builtin), 

1276 (words(( 

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

1278 'Runnable', 'CGI', 'ClientSocket', 'Socket', 'ServerSocket', 

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

1280 Keyword.Type), 

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

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

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

1284 bygroups(Operator, Name.Attribute)), 

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

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

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

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

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

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

1291 (r'\n', Text), 

1292 ], 

1293 'class': [ 

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

1295 ], 

1296 'import': [ 

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

1298 ], 

1299 } 

1300 

1301 def analyse_text(text): 

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

1303 elsewhere.""" 

1304 result = 0 

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

1306 result += 0.01 

1307 return result 

1308 

1309 

1310 

1311class EasytrieveLexer(RegexLexer): 

1312 """ 

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

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

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

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

1317 """ 

1318 name = 'Easytrieve' 

1319 aliases = ['easytrieve'] 

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

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

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

1323 version_added = '2.1' 

1324 flags = 0 

1325 

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

1327 # Easytrieve Plus delimiter characters are: 

1328 # 

1329 # * space ( ) 

1330 # * apostrophe (') 

1331 # * period (.) 

1332 # * comma (,) 

1333 # * parenthesis ( and ) 

1334 # * colon (:) 

1335 # 

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

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

1338 _DELIMITERS_OR_COMENT = _DELIMITERS + '*' 

1339 _DELIMITER_PATTERN = '[' + _DELIMITERS + ']' 

1340 _DELIMITER_PATTERN_CAPTURE = '(' + _DELIMITER_PATTERN + ')' 

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

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

1343 _KEYWORDS = [ 

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

1376 ] 

1377 

1378 tokens = { 

1379 'root': [ 

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

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

1382 # Macro argument 

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

1384 'after_macro_argument'), 

1385 # Macro call 

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

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

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

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

1390 bygroups(Keyword.Declaration, Operator)), 

1391 (words(_KEYWORDS, suffix=_DELIMITER_PATTERN_CAPTURE), 

1392 bygroups(Keyword.Reserved, Operator)), 

1393 (_OPERATORS_PATTERN, Operator), 

1394 # Procedure declaration 

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

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

1397 Keyword.Declaration, Whitespace)), 

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

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

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

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

1402 # Everything else just belongs to a name 

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

1404 ], 

1405 'after_declaration': [ 

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

1407 default('#pop'), 

1408 ], 

1409 'after_macro_argument': [ 

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

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

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

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

1414 # Everything else just belongs to a name 

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

1416 ], 

1417 } 

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

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

1420 

1421 def analyse_text(text): 

1422 """ 

1423 Perform a structural analysis for basic Easytrieve constructs. 

1424 """ 

1425 result = 0.0 

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

1427 hasEndProc = False 

1428 hasHeaderComment = False 

1429 hasFile = False 

1430 hasJob = False 

1431 hasProc = False 

1432 hasParm = False 

1433 hasReport = False 

1434 

1435 def isCommentLine(line): 

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

1437 

1438 def isEmptyLine(line): 

1439 return not bool(line.strip()) 

1440 

1441 # Remove possible empty lines and header comments. 

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

1443 if not isEmptyLine(lines[0]): 

1444 hasHeaderComment = True 

1445 del lines[0] 

1446 

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

1448 # Looks like an Easytrieve macro. 

1449 result = 0.4 

1450 if hasHeaderComment: 

1451 result += 0.4 

1452 else: 

1453 # Scan the source for lines starting with indicators. 

1454 for line in lines: 

1455 words = line.split() 

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

1457 firstWord = words[0] 

1458 if not hasReport: 

1459 if not hasJob: 

1460 if not hasFile: 

1461 if not hasParm: 

1462 if firstWord == 'PARM': 

1463 hasParm = True 

1464 if firstWord == 'FILE': 

1465 hasFile = True 

1466 if firstWord == 'JOB': 

1467 hasJob = True 

1468 elif firstWord == 'PROC': 

1469 hasProc = True 

1470 elif firstWord == 'END-PROC': 

1471 hasEndProc = True 

1472 elif firstWord == 'REPORT': 

1473 hasReport = True 

1474 

1475 # Weight the findings. 

1476 if hasJob and (hasProc == hasEndProc): 

1477 if hasHeaderComment: 

1478 result += 0.1 

1479 if hasParm: 

1480 if hasProc: 

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

1482 # pretty sure this is Easytrieve. 

1483 result += 0.8 

1484 else: 

1485 # Found PARAM and JOB: probably this is Easytrieve 

1486 result += 0.5 

1487 else: 

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

1489 result += 0.11 

1490 if hasParm: 

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

1492 # regarded a much better indicator for Easytrieve than 

1493 # the other words. 

1494 result += 0.2 

1495 if hasFile: 

1496 result += 0.01 

1497 if hasReport: 

1498 result += 0.01 

1499 assert 0.0 <= result <= 1.0 

1500 return result 

1501 

1502 

1503class JclLexer(RegexLexer): 

1504 """ 

1505 Job Control Language (JCL) 

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

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

1508 comparable to MS DOS batch and Unix shell scripts. 

1509 """ 

1510 name = 'JCL' 

1511 aliases = ['jcl'] 

1512 filenames = ['*.jcl'] 

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

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

1515 version_added = '2.1' 

1516 

1517 flags = re.IGNORECASE 

1518 

1519 tokens = { 

1520 'root': [ 

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

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

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

1524 # TODO: JES3 statement 

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

1526 ], 

1527 'statement': [ 

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

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

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

1531 'option'), 

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

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

1534 ], 

1535 'statement_command': [ 

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

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

1538 include('option') 

1539 ], 

1540 'jes2_statement': [ 

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

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

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

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

1545 ], 

1546 'option': [ 

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

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

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

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

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

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

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

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

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

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

1557 (r'\.', Punctuation), 

1558 ], 

1559 'option_string': [ 

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

1561 (r"''", String), 

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

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

1564 ], 

1565 'option_comment': [ 

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

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

1568 ] 

1569 } 

1570 

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

1572 re.IGNORECASE) 

1573 

1574 def analyse_text(text): 

1575 """ 

1576 Recognize JCL job by header. 

1577 """ 

1578 result = 0.0 

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

1580 if len(lines) > 0: 

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

1582 result = 1.0 

1583 assert 0.0 <= result <= 1.0 

1584 return result 

1585 

1586 

1587class MiniScriptLexer(RegexLexer): 

1588 """ 

1589 For MiniScript source code. 

1590 """ 

1591 

1592 name = 'MiniScript' 

1593 url = 'https://miniscript.org' 

1594 aliases = ['miniscript', 'ms'] 

1595 filenames = ['*.ms'] 

1596 mimetypes = ['text/x-minicript', 'application/x-miniscript'] 

1597 version_added = '2.6' 

1598 

1599 tokens = { 

1600 'root': [ 

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

1602 default('base'), 

1603 ], 

1604 'base': [ 

1605 ('//.*$', Comment.Single), 

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

1607 (r'(?i)\d+e[+-]?\d+', Number), 

1608 (r'\d+', Number), 

1609 (r'\n', Text), 

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

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

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

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

1614 (words(( 

1615 'break', 'continue', 'else', 'end', 'for', 'function', 'if', 

1616 'in', 'isa', 'then', 'repeat', 'return', 'while'), suffix=r'\b'), 

1617 Keyword), 

1618 (words(( 

1619 'abs', 'acos', 'asin', 'atan', 'ceil', 'char', 'cos', 'floor', 

1620 'log', 'round', 'rnd', 'pi', 'sign', 'sin', 'sqrt', 'str', 'tan', 

1621 'hasIndex', 'indexOf', 'len', 'val', 'code', 'remove', 'lower', 

1622 'upper', 'replace', 'split', 'indexes', 'values', 'join', 'sum', 

1623 'sort', 'shuffle', 'push', 'pop', 'pull', 'range', 

1624 'print', 'input', 'time', 'wait', 'locals', 'globals', 'outer', 

1625 'yield'), suffix=r'\b'), 

1626 Name.Builtin), 

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

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

1629 (r'(self|super|__isa)\b', Name.Builtin.Pseudo), 

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

1631 ], 

1632 'string_double': [ 

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

1634 (r'""', String), 

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

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

1637 ] 

1638 }