tlb.py 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. """
  2. pygments.lexers.tlb
  3. ~~~~~~~~~~~~~~~~~~~
  4. Lexers for TL-b.
  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, include, words
  9. from pygments.token import Operator, Name, \
  10. Number, Whitespace, Punctuation, Comment
  11. __all__ = ['TlbLexer']
  12. class TlbLexer(RegexLexer):
  13. """
  14. For TL-b source code.
  15. """
  16. name = 'Tl-b'
  17. aliases = ['tlb']
  18. filenames = ['*.tlb']
  19. url = 'https://docs.ton.org/#/overviews/TL-B'
  20. version_added = ''
  21. tokens = {
  22. 'root': [
  23. (r'\s+', Whitespace),
  24. include('comments'),
  25. (r'[0-9]+', Number),
  26. (words((
  27. '+', '-', '*', '=', '?', '~', '.',
  28. '^', '==', '<', '>', '<=', '>=', '!='
  29. )), Operator),
  30. (words(('##', '#<', '#<=')), Name.Tag),
  31. (r'#[0-9a-f]*_?', Name.Tag),
  32. (r'\$[01]*_?', Name.Tag),
  33. (r'[a-zA-Z_][0-9a-zA-Z_]*', Name),
  34. (r'[;():\[\]{}]', Punctuation)
  35. ],
  36. 'comments': [
  37. (r'//.*', Comment.Singleline),
  38. (r'/\*', Comment.Multiline, 'comment'),
  39. ],
  40. 'comment': [
  41. (r'[^/*]+', Comment.Multiline),
  42. (r'/\*', Comment.Multiline, '#push'),
  43. (r'\*/', Comment.Multiline, '#pop'),
  44. (r'[*/]', Comment.Multiline),
  45. ],
  46. }