tlb.py 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. """
  2. pygments.lexers.tlb
  3. ~~~~~~~~~~~~~~~~~~~
  4. Lexers for TL-b.
  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, 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. tokens = {
  20. 'root': [
  21. (r'\s+', Whitespace),
  22. include('comments'),
  23. (r'[0-9]+', Number),
  24. (words((
  25. '+', '-', '*', '=', '?', '~', '.',
  26. '^', '==', '<', '>', '<=', '>=', '!='
  27. )), Operator),
  28. (words(('##', '#<', '#<=')), Name.Tag),
  29. (r'#[0-9a-f]*_?', Name.Tag),
  30. (r'\$[01]*_?', Name.Tag),
  31. (r'[a-zA-Z_][0-9a-zA-Z_]*', Name),
  32. (r'[;():\[\]{}]', Punctuation)
  33. ],
  34. 'comments': [
  35. (r'//.*', Comment.Singleline),
  36. (r'/\*', Comment.Multiline, 'comment'),
  37. ],
  38. 'comment': [
  39. (r'[^/*]+', Comment.Multiline),
  40. (r'/\*', Comment.Multiline, '#push'),
  41. (r'\*/', Comment.Multiline, '#pop'),
  42. (r'[*/]', Comment.Multiline),
  43. ],
  44. }