xorg.py 865 B

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