codekingpro/portable-devtools
114k
1"""2 pygments.lexers.ezhil3 ~~~~~~~~~~~~~~~~~~~~~4 5 Pygments lexers for Ezhil language.6 7 :copyright: Copyright 2006-2024 by the Pygments team, see AUTHORS.8 :license: BSD, see LICENSE for details.9"""10 11import re12 13from pygments.lexer import RegexLexer, include, words14from pygments.token import Keyword, Comment, Name, String, Number, \15 Punctuation, Operator, Whitespace16 17__all__ = ['EzhilLexer']18 19 20class EzhilLexer(RegexLexer):21 """22 Lexer for Ezhil, a Tamil script-based programming language.23 """24 name = 'Ezhil'25 url = 'http://ezhillang.org'26 aliases = ['ezhil']27 filenames = ['*.n']28 mimetypes = ['text/x-ezhil']29 version_added = '2.1'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 = '[a-zA-Z_]|[\u0b80-\u0bff]'33 tokens = {34 'root': [35 include('keywords'),36 (r'#.*$', Comment.Single),37 (r'[@+/*,^\-%]|[!<>=]=?|&&?|\|\|?', Operator),38 ('இல்', Operator.Word),39 (words(('assert', 'max', 'min',40 'நீளம்', 'சரம்_இடமாற்று', 'சரம்_கண்டுபிடி',41 'பட்டியல்', 'பின்இணை', 'வரிசைப்படுத்து',42 'எடு', 'தலைகீழ்', 'நீட்டிக்க', 'நுழைக்க', 'வை',43 'கோப்பை_திற', 'கோப்பை_எழுது', 'கோப்பை_மூடு',44 'pi', 'sin', 'cos', 'tan', 'sqrt', 'hypot', 'pow',45 'exp', 'log', 'log10', 'exit',46 ), suffix=r'\b'), Name.Builtin),47 (r'(True|False)\b', Keyword.Constant),48 (r'[^\S\n]+', Whitespace),49 include('identifier'),50 include('literal'),51 (r'[(){}\[\]:;.]', Punctuation),52 ],53 'keywords': [54 ('பதிப்பி|தேர்ந்தெடு|தேர்வு|ஏதேனில்|ஆனால்|இல்லைஆனால்|இல்லை|ஆக|ஒவ்வொன்றாக|இல்|வரை|செய்|முடியேனில்|பின்கொடு|முடி|நிரல்பாகம்|தொடர்|நிறுத்து|நிரல்பாகம்', Keyword),55 ],56 'identifier': [57 ('(?:'+_TALETTERS+')(?:[0-9]|'+_TALETTERS+')*', Name),58 ],59 'literal': [60 (r'".*?"', String),61 (r'\d+((\.\d*)?[eE][+-]?\d+|\.\d*)', Number.Float),62 (r'\d+', Number.Integer),63 ]64 }65 66 def analyse_text(text):67 """This language uses Tamil-script. We'll assume that if there's a68 decent amount of Tamil-characters, it's this language. This assumption69 is obviously horribly off if someone uses string literals in tamil70 in another language."""71 if len(re.findall(r'[\u0b80-\u0bff]', text)) > 10:72 return 0.2573 74 def __init__(self, **options):75 super().__init__(**options)76 self.encoding = options.get('encoding', 'utf-8')77 