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

12 statements  

« prev     ^ index     » next       coverage.py v7.2.7, created at 2023-06-07 06:16 +0000

1""" 

2 pygments.lexers.bdd 

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

4 

5 Lexer for BDD(Behavior-driven development). 

6 More information: https://en.wikipedia.org/wiki/Behavior-driven_development 

7 

8 :copyright: Copyright 2006-2023 by the Pygments team, see AUTHORS. 

9 :license: BSD, see LICENSE for details. 

10""" 

11 

12from pygments.lexer import RegexLexer, include 

13from pygments.token import Comment, Keyword, Name, String, Number, Text, \ 

14 Punctuation, Whitespace 

15 

16__all__ = ['BddLexer'] 

17 

18class BddLexer(RegexLexer): 

19 """ 

20 Lexer for BDD(Behavior-driven development), which highlights not only 

21 keywords, but also comments, punctuations, strings, numbers, and variables. 

22 

23 .. versionadded:: 2.11 

24 """ 

25 

26 name = 'Bdd' 

27 aliases = ['bdd'] 

28 filenames = ['*.feature'] 

29 mimetypes = ['text/x-bdd'] 

30 

31 step_keywords = (r'Given|When|Then|Add|And|Feature|Scenario Outline|' 

32 r'Scenario|Background|Examples|But') 

33 

34 tokens = { 

35 'comments': [ 

36 (r'^\s*#.*$', Comment), 

37 ], 

38 'miscellaneous': [ 

39 (r'(<|>|\[|\]|=|\||:|\(|\)|\{|\}|,|\.|;|-|_|\$)', Punctuation), 

40 (r'((?<=\<)[^\\>]+(?=\>))', Name.Variable), 

41 (r'"([^\"]*)"', String), 

42 (r'^@\S+', Name.Label), 

43 ], 

44 'numbers': [ 

45 (r'(\d+\.?\d*|\d*\.\d+)([eE][+-]?[0-9]+)?', Number), 

46 ], 

47 'root': [ 

48 (r'\n|\s+', Whitespace), 

49 (step_keywords, Keyword), 

50 include('comments'), 

51 include('miscellaneous'), 

52 include('numbers'), 

53 (r'\S+', Text), 

54 ] 

55 } 

56 

57 def analyse_text(self, text): 

58 return