28 filenames = ['*.n'] |
28 filenames = ['*.n'] |
29 mimetypes = ['text/x-ezhil'] |
29 mimetypes = ['text/x-ezhil'] |
30 flags = re.MULTILINE | re.UNICODE |
30 flags = re.MULTILINE | re.UNICODE |
31 # Refer to tamil.utf8.tamil_letters from open-tamil for a stricter version of this. |
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. |
32 # This much simpler version is close enough, and includes combining marks. |
33 _TALETTERS = u'[a-zA-Z_]|[\u0b80-\u0bff]' |
33 _TALETTERS = '[a-zA-Z_]|[\u0b80-\u0bff]' |
34 tokens = { |
34 tokens = { |
35 'root': [ |
35 'root': [ |
36 include('keywords'), |
36 include('keywords'), |
37 (r'#.*\n', Comment.Single), |
37 (r'#.*\n', Comment.Single), |
38 (r'[@+/*,^\-%]|[!<>=]=?|&&?|\|\|?', Operator), |
38 (r'[@+/*,^\-%]|[!<>=]=?|&&?|\|\|?', Operator), |
39 (u'இல்', Operator.Word), |
39 ('இல்', Operator.Word), |
40 (words((u'assert', u'max', u'min', |
40 (words(('assert', 'max', 'min', |
41 u'நீளம்', u'சரம்_இடமாற்று', u'சரம்_கண்டுபிடி', |
41 'நீளம்', 'சரம்_இடமாற்று', 'சரம்_கண்டுபிடி', |
42 u'பட்டியல்', u'பின்இணை', u'வரிசைப்படுத்து', |
42 'பட்டியல்', 'பின்இணை', 'வரிசைப்படுத்து', |
43 u'எடு', u'தலைகீழ்', u'நீட்டிக்க', u'நுழைக்க', u'வை', |
43 'எடு', 'தலைகீழ்', 'நீட்டிக்க', 'நுழைக்க', 'வை', |
44 u'கோப்பை_திற', u'கோப்பை_எழுது', u'கோப்பை_மூடு', |
44 'கோப்பை_திற', 'கோப்பை_எழுது', 'கோப்பை_மூடு', |
45 u'pi', u'sin', u'cos', u'tan', u'sqrt', u'hypot', u'pow', |
45 'pi', 'sin', 'cos', 'tan', 'sqrt', 'hypot', 'pow', |
46 u'exp', u'log', u'log10', u'exit', |
46 'exp', 'log', 'log10', 'exit', |
47 ), suffix=r'\b'), Name.Builtin), |
47 ), suffix=r'\b'), Name.Builtin), |
48 (r'(True|False)\b', Keyword.Constant), |
48 (r'(True|False)\b', Keyword.Constant), |
49 (r'[^\S\n]+', Text), |
49 (r'[^\S\n]+', Text), |
50 include('identifier'), |
50 include('identifier'), |
51 include('literal'), |
51 include('literal'), |
52 (r'[(){}\[\]:;.]', Punctuation), |
52 (r'[(){}\[\]:;.]', Punctuation), |
53 ], |
53 ], |
54 'keywords': [ |
54 'keywords': [ |
55 (u'பதிப்பி|தேர்ந்தெடு|தேர்வு|ஏதேனில்|ஆனால்|இல்லைஆனால்|இல்லை|ஆக|ஒவ்வொன்றாக|இல்|வரை|செய்|முடியேனில்|பின்கொடு|முடி|நிரல்பாகம்|தொடர்|நிறுத்து|நிரல்பாகம்', Keyword), |
55 ('பதிப்பி|தேர்ந்தெடு|தேர்வு|ஏதேனில்|ஆனால்|இல்லைஆனால்|இல்லை|ஆக|ஒவ்வொன்றாக|இல்|வரை|செய்|முடியேனில்|பின்கொடு|முடி|நிரல்பாகம்|தொடர்|நிறுத்து|நிரல்பாகம்', Keyword), |
56 ], |
56 ], |
57 'identifier': [ |
57 'identifier': [ |
58 (u'(?:'+_TALETTERS+u')(?:[0-9]|'+_TALETTERS+u')*', Name), |
58 ('(?:'+_TALETTERS+')(?:[0-9]|'+_TALETTERS+')*', Name), |
59 ], |
59 ], |
60 'literal': [ |
60 'literal': [ |
61 (r'".*?"', String), |
61 (r'".*?"', String), |
62 (r'(?u)\d+((\.\d*)?[eE][+-]?\d+|\.\d*)', Number.Float), |
62 (r'(?u)\d+((\.\d*)?[eE][+-]?\d+|\.\d*)', Number.Float), |
63 (r'(?u)\d+', Number.Integer), |
63 (r'(?u)\d+', Number.Integer), |
64 ] |
64 ] |
65 } |
65 } |
66 |
66 |
67 def __init__(self, **options): |
67 def __init__(self, **options): |
68 super(EzhilLexer, self).__init__(**options) |
68 super().__init__(**options) |
69 self.encoding = options.get('encoding', 'utf-8') |
69 self.encoding = options.get('encoding', 'utf-8') |