Coverage for /pythoncovmergedfiles/medio/medio/usr/local/lib/python3.8/site-packages/pygments/lexers/ezhil.py: 89%

18 statements  

« prev     ^ index     » next       coverage.py v7.2.7, created at 2023-07-01 06:54 +0000

1""" 

2 pygments.lexers.ezhil 

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

4 

5 Pygments lexers for Ezhil language. 

6 

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

8 :license: BSD, see LICENSE for details. 

9""" 

10 

11import re 

12 

13from pygments.lexer import RegexLexer, include, words 

14from pygments.token import Keyword, Comment, Name, String, Number, \ 

15 Punctuation, Operator, Whitespace 

16 

17__all__ = ['EzhilLexer'] 

18 

19 

20class EzhilLexer(RegexLexer): 

21 """ 

22 Lexer for Ezhil, a Tamil script-based programming language. 

23 

24 .. versionadded:: 2.1 

25 """ 

26 name = 'Ezhil' 

27 url = 'http://ezhillang.org' 

28 aliases = ['ezhil'] 

29 filenames = ['*.n'] 

30 mimetypes = ['text/x-ezhil'] 

31 # Refer to tamil.utf8.tamil_letters from open-tamil for a stricter version of this. 

32 # This much simpler version is close enough, and includes combining marks. 

33 _TALETTERS = '[a-zA-Z_]|[\u0b80-\u0bff]' 

34 tokens = { 

35 'root': [ 

36 include('keywords'), 

37 (r'#.*$', Comment.Single), 

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

39 ('இல்', Operator.Word), 

40 (words(('assert', 'max', 'min', 

41 'நீளம்', 'சரம்_இடமாற்று', 'சரம்_கண்டுபிடி', 

42 'பட்டியல்', 'பின்இணை', 'வரிசைப்படுத்து', 

43 'எடு', 'தலைகீழ்', 'நீட்டிக்க', 'நுழைக்க', 'வை', 

44 'கோப்பை_திற', 'கோப்பை_எழுது', 'கோப்பை_மூடு', 

45 'pi', 'sin', 'cos', 'tan', 'sqrt', 'hypot', 'pow', 

46 'exp', 'log', 'log10', 'exit', 

47 ), suffix=r'\b'), Name.Builtin), 

48 (r'(True|False)\b', Keyword.Constant), 

49 (r'[^\S\n]+', Whitespace), 

50 include('identifier'), 

51 include('literal'), 

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

53 ], 

54 'keywords': [ 

55 ('பதிப்பி|தேர்ந்தெடு|தேர்வு|ஏதேனில்|ஆனால்|இல்லைஆனால்|இல்லை|ஆக|ஒவ்வொன்றாக|இல்|வரை|செய்|முடியேனில்|பின்கொடு|முடி|நிரல்பாகம்|தொடர்|நிறுத்து|நிரல்பாகம்', Keyword), 

56 ], 

57 'identifier': [ 

58 ('(?:'+_TALETTERS+')(?:[0-9]|'+_TALETTERS+')*', Name), 

59 ], 

60 'literal': [ 

61 (r'".*?"', String), 

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

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

64 ] 

65 } 

66 

67 def analyse_text(text): 

68 """This language uses Tamil-script. We'll assume that if there's a 

69 decent amount of Tamil-characters, it's this language. This assumption 

70 is obviously horribly off if someone uses string literals in tamil 

71 in another language.""" 

72 if len(re.findall(r'[\u0b80-\u0bff]', text)) > 10: 

73 return 0.25 

74 

75 def __init__(self, **options): 

76 super().__init__(**options) 

77 self.encoding = options.get('encoding', 'utf-8')