roboconf.py 2.0 KB

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