roboconf.py 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. """
  2. pygments.lexers.roboconf
  3. ~~~~~~~~~~~~~~~~~~~~~~~~
  4. Lexers for Roboconf DSL.
  5. :copyright: Copyright 2006-2024 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 graph files.
  14. """
  15. name = 'Roboconf Graph'
  16. aliases = ['roboconf-graph']
  17. filenames = ['*.graph']
  18. url = 'https://roboconf.github.io/en/user-guide/graph-definition.html'
  19. version_added = '2.1'
  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 instances files.
  42. """
  43. name = 'Roboconf Instances'
  44. aliases = ['roboconf-instances']
  45. filenames = ['*.instances']
  46. url = 'https://roboconf.github.io'
  47. version_added = '2.1'
  48. flags = re.IGNORECASE | re.MULTILINE
  49. tokens = {
  50. 'root': [
  51. # Skip white spaces
  52. (r'\s+', Text),
  53. # Keywords
  54. (words(('instance of', 'import'), suffix=r'\s*\b', prefix=r'\b'), Keyword),
  55. (words(('name', 'count'), suffix=r's*:?', prefix=r'\b'), Name),
  56. (r'\s*[\w.-]+\s*:', Name),
  57. # Comments
  58. (r'#.*\n', Comment),
  59. # Default
  60. (r'[^#]', Text),
  61. (r'.*\n', Text)
  62. ]
  63. }