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