|
1 # -*- coding: utf-8 -*- |
|
2 """ |
|
3 pygments.lexers.ezhil |
|
4 ~~~~~~~~~~~~~~~~~~~~~ |
|
5 |
|
6 Pygments lexers for Ezhil language. |
|
7 |
|
8 :copyright: Copyright 2006-2017 by the Pygments team, see AUTHORS. |
|
9 :license: BSD, see LICENSE for details. |
|
10 """ |
|
11 |
|
12 import re |
|
13 from pygments.lexer import RegexLexer, include, words |
|
14 from pygments.token import Keyword, Text, Comment, Name |
|
15 from pygments.token import String, Number, Punctuation, Operator |
|
16 |
|
17 __all__ = ['EzhilLexer'] |
|
18 |
|
19 |
|
20 class EzhilLexer(RegexLexer): |
|
21 """ |
|
22 Lexer for `Ezhil, a Tamil script-based programming language <http://ezhillang.org>`_ |
|
23 |
|
24 .. versionadded:: 2.1 |
|
25 """ |
|
26 name = 'Ezhil' |
|
27 aliases = ['ezhil'] |
|
28 filenames = ['*.n'] |
|
29 mimetypes = ['text/x-ezhil'] |
|
30 flags = re.MULTILINE | re.UNICODE |
|
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 = u'[a-zA-Z_]|[\u0b80-\u0bff]' |
|
34 tokens = { |
|
35 'root': [ |
|
36 include('keywords'), |
|
37 (r'#.*\n', Comment.Single), |
|
38 (r'[@+/*,^\-%]|[!<>=]=?|&&?|\|\|?', Operator), |
|
39 (u'இல்', Operator.Word), |
|
40 (words((u'assert', u'max', u'min', |
|
41 u'நீளம்', u'சரம்_இடமாற்று', u'சரம்_கண்டுபிடி', |
|
42 u'பட்டியல்', u'பின்இணை', u'வரிசைப்படுத்து', |
|
43 u'எடு', u'தலைகீழ்', u'நீட்டிக்க', u'நுழைக்க', u'வை', |
|
44 u'கோப்பை_திற', u'கோப்பை_எழுது', u'கோப்பை_மூடு', |
|
45 u'pi', u'sin', u'cos', u'tan', u'sqrt', u'hypot', u'pow', |
|
46 u'exp', u'log', u'log10', u'exit', |
|
47 ), suffix=r'\b'), Name.Builtin), |
|
48 (r'(True|False)\b', Keyword.Constant), |
|
49 (r'[^\S\n]+', Text), |
|
50 include('identifier'), |
|
51 include('literal'), |
|
52 (r'[(){}\[\]:;.]', Punctuation), |
|
53 ], |
|
54 'keywords': [ |
|
55 (u'பதிப்பி|தேர்ந்தெடு|தேர்வு|ஏதேனில்|ஆனால்|இல்லைஆனால்|இல்லை|ஆக|ஒவ்வொன்றாக|இல்|வரை|செய்|முடியேனில்|பின்கொடு|முடி|நிரல்பாகம்|தொடர்|நிறுத்து|நிரல்பாகம்', Keyword), |
|
56 ], |
|
57 'identifier': [ |
|
58 (u'(?:'+_TALETTERS+u')(?:[0-9]|'+_TALETTERS+u')*', Name), |
|
59 ], |
|
60 'literal': [ |
|
61 (r'".*?"', String), |
|
62 (r'(?u)\d+((\.\d*)?[eE][+-]?\d+|\.\d*)', Number.Float), |
|
63 (r'(?u)\d+', Number.Integer), |
|
64 ] |
|
65 } |
|
66 |
|
67 def __init__(self, **options): |
|
68 super(EzhilLexer, self).__init__(**options) |
|
69 self.encoding = options.get('encoding', 'utf-8') |