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