rita.py 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. """
  2. pygments.lexers.rita
  3. ~~~~~~~~~~~~~~~~~~~~
  4. Lexers for RITA language
  5. :copyright: Copyright 2006-2023 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. .. versionadded:: 2.11
  16. """
  17. name = 'Rita'
  18. url = 'https://github.com/zaibacu/rita-dsl'
  19. filenames = ['*.rita']
  20. aliases = ['rita']
  21. mimetypes = ['text/rita']
  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. }