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

12 statements  

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

1""" 

2 pygments.lexers.parasail 

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

4 

5 Lexer for ParaSail. 

6 

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

8 :license: BSD, see LICENSE for details. 

9""" 

10 

11import re 

12 

13from pygments.lexer import RegexLexer, include 

14from pygments.token import Text, Comment, Operator, Keyword, Name, String, \ 

15 Number, Punctuation, Literal 

16 

17__all__ = ['ParaSailLexer'] 

18 

19 

20class ParaSailLexer(RegexLexer): 

21 """ 

22 For ParaSail source code. 

23 

24 .. versionadded:: 2.1 

25 """ 

26 

27 name = 'ParaSail' 

28 url = 'http://www.parasail-lang.org' 

29 aliases = ['parasail'] 

30 filenames = ['*.psi', '*.psl'] 

31 mimetypes = ['text/x-parasail'] 

32 

33 flags = re.MULTILINE 

34 

35 tokens = { 

36 'root': [ 

37 (r'[^\S\n]+', Text), 

38 (r'//.*?\n', Comment.Single), 

39 (r'\b(and|or|xor)=', Operator.Word), 

40 (r'\b(and(\s+then)?|or(\s+else)?|xor|rem|mod|' 

41 r'(is|not)\s+null)\b', 

42 Operator.Word), 

43 # Keywords 

44 (r'\b(abs|abstract|all|block|class|concurrent|const|continue|' 

45 r'each|end|exit|extends|exports|forward|func|global|implements|' 

46 r'import|in|interface|is|lambda|locked|new|not|null|of|op|' 

47 r'optional|private|queued|ref|return|reverse|separate|some|' 

48 r'type|until|var|with|' 

49 # Control flow 

50 r'if|then|else|elsif|case|for|while|loop)\b', 

51 Keyword.Reserved), 

52 (r'(abstract\s+)?(interface|class|op|func|type)', 

53 Keyword.Declaration), 

54 # Literals 

55 (r'"[^"]*"', String), 

56 (r'\\[\'ntrf"0]', String.Escape), 

57 (r'#[a-zA-Z]\w*', Literal), # Enumeration 

58 include('numbers'), 

59 (r"'[^']'", String.Char), 

60 (r'[a-zA-Z]\w*', Name), 

61 # Operators and Punctuation 

62 (r'(<==|==>|<=>|\*\*=|<\|=|<<=|>>=|==|!=|=\?|<=|>=|' 

63 r'\*\*|<<|>>|=>|:=|\+=|-=|\*=|\|=|\||/=|\+|-|\*|/|' 

64 r'\.\.|<\.\.|\.\.<|<\.\.<)', 

65 Operator), 

66 (r'(<|>|\[|\]|\(|\)|\||:|;|,|.|\{|\}|->)', 

67 Punctuation), 

68 (r'\n+', Text), 

69 ], 

70 'numbers': [ 

71 (r'\d[0-9_]*#[0-9a-fA-F][0-9a-fA-F_]*#', Number.Hex), # any base 

72 (r'0[xX][0-9a-fA-F][0-9a-fA-F_]*', Number.Hex), # C-like hex 

73 (r'0[bB][01][01_]*', Number.Bin), # C-like bin 

74 (r'\d[0-9_]*\.\d[0-9_]*[eE][+-]\d[0-9_]*', # float exp 

75 Number.Float), 

76 (r'\d[0-9_]*\.\d[0-9_]*', Number.Float), # float 

77 (r'\d[0-9_]*', Number.Integer), # integer 

78 ], 

79 }