rita.py 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. """
  2. pygments.lexers.rita
  3. ~~~~~~~~~~~~~~~~~~~~
  4. Lexers for RITA language
  5. :copyright: Copyright 2006-2024 by the Pygments team, see AUTHORS.
  6. :license: BSD, see LICENSE for details.
  7. """
  8. from pygments.lexer import RegexLexer
  9. from pygments.token import Comment, Operator, Keyword, Name, Literal, \
  10. Punctuation, Whitespace
  11. __all__ = ['RitaLexer']
  12. class RitaLexer(RegexLexer):
  13. """
  14. Lexer for RITA.
  15. """
  16. name = 'Rita'
  17. url = 'https://github.com/zaibacu/rita-dsl'
  18. filenames = ['*.rita']
  19. aliases = ['rita']
  20. mimetypes = ['text/rita']
  21. version_added = '2.11'
  22. tokens = {
  23. 'root': [
  24. (r'\n', Whitespace),
  25. (r'\s+', Whitespace),
  26. (r'#(.*?)\n', Comment.Single),
  27. (r'@(.*?)\n', Operator), # Yes, whole line as an operator
  28. (r'"(\w|\d|\s|(\\")|[\'_\-./,\?\!])+?"', Literal),
  29. (r'\'(\w|\d|\s|(\\\')|["_\-./,\?\!])+?\'', Literal),
  30. (r'([A-Z_]+)', Keyword),
  31. (r'([a-z0-9_]+)', Name),
  32. (r'((->)|[!?+*|=])', Operator),
  33. (r'[\(\),\{\}]', Punctuation)
  34. ]
  35. }