xorg.py 887 B

12345678910111213141516171819202122232425262728293031323334353637
  1. # -*- coding: utf-8 -*-
  2. """
  3. pygments.lexers.xorg
  4. ~~~~~~~~~~~~~~~~~~~~
  5. Lexers for Xorg configs.
  6. :copyright: Copyright 2006-2019 by the Pygments team, see AUTHORS.
  7. :license: BSD, see LICENSE for details.
  8. """
  9. from pygments.lexer import RegexLexer, bygroups
  10. from pygments.token import Comment, String, Name, Text
  11. __all__ = ['XorgLexer']
  12. class XorgLexer(RegexLexer):
  13. """Lexer for xorg.conf file."""
  14. name = 'Xorg'
  15. aliases = ['xorg.conf']
  16. filenames = ['xorg.conf']
  17. mimetypes = []
  18. tokens = {
  19. 'root': [
  20. (r'\s+', Text),
  21. (r'#.*$', Comment),
  22. (r'((?:Sub)?Section)(\s+)("\w+")',
  23. bygroups(String.Escape, Text, String.Escape)),
  24. (r'(End(|Sub)Section)', String.Escape),
  25. (r'(\w+)(\s+)([^\n#]+)',
  26. bygroups(Name.Builtin, Text, Name.Constant)),
  27. ],
  28. }