ezhil.py 2.9 KB

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