roboconf.py 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. # -*- coding: utf-8 -*-
  2. """
  3. pygments.lexers.roboconf
  4. ~~~~~~~~~~~~~~~~~~~~~~~~
  5. Lexers for Roboconf DSL.
  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, words, re
  10. from pygments.token import Text, Operator, Keyword, Name, Comment
  11. __all__ = ['RoboconfGraphLexer', 'RoboconfInstancesLexer']
  12. class RoboconfGraphLexer(RegexLexer):
  13. """
  14. Lexer for `Roboconf <http://roboconf.net/en/roboconf.html>`_ graph files.
  15. .. versionadded:: 2.1
  16. """
  17. name = 'Roboconf Graph'
  18. aliases = ['roboconf-graph']
  19. filenames = ['*.graph']
  20. flags = re.IGNORECASE | re.MULTILINE
  21. tokens = {
  22. 'root': [
  23. # Skip white spaces
  24. (r'\s+', Text),
  25. # There is one operator
  26. (r'=', Operator),
  27. # Keywords
  28. (words(('facet', 'import'), suffix=r'\s*\b', prefix=r'\b'), Keyword),
  29. (words((
  30. 'installer', 'extends', 'exports', 'imports', 'facets',
  31. 'children'), suffix=r'\s*:?', prefix=r'\b'), Name),
  32. # Comments
  33. (r'#.*\n', Comment),
  34. # Default
  35. (r'[^#]', Text),
  36. (r'.*\n', Text)
  37. ]
  38. }
  39. class RoboconfInstancesLexer(RegexLexer):
  40. """
  41. Lexer for `Roboconf <http://roboconf.net/en/roboconf.html>`_ instances files.
  42. .. versionadded:: 2.1
  43. """
  44. name = 'Roboconf Instances'
  45. aliases = ['roboconf-instances']
  46. filenames = ['*.instances']
  47. flags = re.IGNORECASE | re.MULTILINE
  48. tokens = {
  49. 'root': [
  50. # Skip white spaces
  51. (r'\s+', Text),
  52. # Keywords
  53. (words(('instance of', 'import'), suffix=r'\s*\b', prefix=r'\b'), Keyword),
  54. (words(('name', 'count'), suffix=r's*:?', prefix=r'\b'), Name),
  55. (r'\s*[\w.-]+\s*:', Name),
  56. # Comments
  57. (r'#.*\n', Comment),
  58. # Default
  59. (r'[^#]', Text),
  60. (r'.*\n', Text)
  61. ]
  62. }