Coverage for /pythoncovmergedfiles/medio/medio/usr/local/lib/python3.8/site-packages/pygments/lexers/roboconf.py: 100%

15 statements  

« prev     ^ index     » next       coverage.py v7.3.1, created at 2023-09-18 06:13 +0000

1""" 

2 pygments.lexers.roboconf 

3 ~~~~~~~~~~~~~~~~~~~~~~~~ 

4 

5 Lexers for Roboconf DSL. 

6 

7 :copyright: Copyright 2006-2023 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 .. versionadded:: 2.1 

22 """ 

23 name = 'Roboconf Graph' 

24 aliases = ['roboconf-graph'] 

25 filenames = ['*.graph'] 

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 .. versionadded:: 2.1 

57 """ 

58 name = 'Roboconf Instances' 

59 aliases = ['roboconf-instances'] 

60 filenames = ['*.instances'] 

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 }