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

changeset 7983
54c5cfbb1e29
parent 7701
25f42e208e08
equal deleted inserted replaced
7982:48d210e41c65 7983:54c5cfbb1e29
3 pygments.lexers.int_fiction 3 pygments.lexers.int_fiction
4 ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4 ~~~~~~~~~~~~~~~~~~~~~~~~~~~
5 5
6 Lexers for interactive fiction languages. 6 Lexers for interactive fiction languages.
7 7
8 :copyright: Copyright 2006-2020 by the Pygments team, see AUTHORS. 8 :copyright: Copyright 2006-2021 by the Pygments team, see AUTHORS.
9 :license: BSD, see LICENSE for details. 9 :license: BSD, see LICENSE for details.
10 """ 10 """
11 11
12 import re 12 import re
13 13
513 yield index, token, value 513 yield index, token, value
514 if token not in Comment and token not in Text: 514 if token not in Comment and token not in Text:
515 previous_token = token 515 previous_token = token
516 while objectloop_queue: 516 while objectloop_queue:
517 yield objectloop_queue.pop(0) 517 yield objectloop_queue.pop(0)
518
519 def analyse_text(text):
520 """We try to find a keyword which seem relatively common, unfortunately
521 there is a decent overlap with Smalltalk keywords otherwise here.."""
522 result = 0
523 if re.search('\borigsource\b', text, re.IGNORECASE):
524 result += 0.05
525
526 return result
518 527
519 528
520 class Inform7Lexer(RegexLexer): 529 class Inform7Lexer(RegexLexer):
521 """ 530 """
522 For `Inform 7 <http://inform7.com/>`_ source code. 531 For `Inform 7 <http://inform7.com/>`_ source code.
1341 elif re.match(r'%sendif\b' % pp, value): 1350 elif re.match(r'%sendif\b' % pp, value):
1342 if_false_level -= 1 1351 if_false_level -= 1
1343 else: 1352 else:
1344 token = Comment 1353 token = Comment
1345 yield index, token, value 1354 yield index, token, value
1355
1356 def analyse_text(text):
1357 """This is a rather generic descriptive language without strong
1358 identifiers. It looks like a 'GameMainDef' has to be present,
1359 and/or a 'versionInfo' with an 'IFID' field."""
1360 result = 0
1361 if '__TADS' in text or 'GameMainDef' in text:
1362 result += 0.2
1363
1364 # This is a fairly unique keyword which is likely used in source as well
1365 if 'versionInfo' in text and 'IFID' in text:
1366 result += 0.1
1367
1368 return result

eric ide

mercurial