1"""
2 pygments.lexers.roboconf
3 ~~~~~~~~~~~~~~~~~~~~~~~~
4
5 Lexers for Roboconf DSL.
6
7 :copyright: Copyright 2006-2025 by the Pygments team, see AUTHORS.
8 :license: BSD, see LICENSE for details.
9"""
10
11from pygments.lexer import RegexLexer, words, re
12from pygments.token import Text, Operator, Keyword, Name, Comment
13
14__all__ = ['RoboconfGraphLexer', 'RoboconfInstancesLexer']
15
16
17class RoboconfGraphLexer(RegexLexer):
18 """
19 Lexer for Roboconf graph files.
20 """
21 name = 'Roboconf Graph'
22 aliases = ['roboconf-graph']
23 filenames = ['*.graph']
24 url = 'https://roboconf.github.io/en/user-guide/graph-definition.html'
25 version_added = '2.1'
26
27 flags = re.IGNORECASE | re.MULTILINE
28 tokens = {
29 'root': [
30 # Skip white spaces
31 (r'\s+', Text),
32
33 # There is one operator
34 (r'=', Operator),
35
36 # Keywords
37 (words(('facet', 'import'), suffix=r'\s*\b', prefix=r'\b'), Keyword),
38 (words((
39 'installer', 'extends', 'exports', 'imports', 'facets',
40 'children'), suffix=r'\s*:?', prefix=r'\b'), Name),
41
42 # Comments
43 (r'#.*\n', Comment),
44
45 # Default
46 (r'[^#]', Text),
47 (r'.*\n', Text)
48 ]
49 }
50
51
52class RoboconfInstancesLexer(RegexLexer):
53 """
54 Lexer for Roboconf instances files.
55 """
56 name = 'Roboconf Instances'
57 aliases = ['roboconf-instances']
58 filenames = ['*.instances']
59 url = 'https://roboconf.github.io'
60 version_added = '2.1'
61
62 flags = re.IGNORECASE | re.MULTILINE
63 tokens = {
64 'root': [
65
66 # Skip white spaces
67 (r'\s+', Text),
68
69 # Keywords
70 (words(('instance of', 'import'), suffix=r'\s*\b', prefix=r'\b'), Keyword),
71 (words(('name', 'count'), suffix=r's*:?', prefix=r'\b'), Name),
72 (r'\s*[\w.-]+\s*:', Name),
73
74 # Comments
75 (r'#.*\n', Comment),
76
77 # Default
78 (r'[^#]', Text),
79 (r'.*\n', Text)
80 ]
81 }