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

Shortcuts on this page

r m x   toggle line displays

j k   next/prev highlighted chunk

0   (zero) top of page

1   (one) first highlighted chunk

14 statements  

1""" 

2 pygments.lexers.parasail 

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

4 

5 Lexer for ParaSail. 

6 

7 :copyright: Copyright 2006-2025 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 

25 name = 'ParaSail' 

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

27 aliases = ['parasail'] 

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

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

30 version_added = '2.1' 

31 

32 flags = re.MULTILINE 

33 

34 tokens = { 

35 'root': [ 

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

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

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

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

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

41 Operator.Word), 

42 # Keywords 

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

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

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

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

47 r'type|until|var|with|' 

48 # Control flow 

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

50 Keyword.Reserved), 

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

52 Keyword.Declaration), 

53 # Literals 

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

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

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

57 include('numbers'), 

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

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

60 # Operators and Punctuation 

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

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

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

64 Operator), 

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

66 Punctuation), 

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

68 ], 

69 'numbers': [ 

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

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

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

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

74 Number.Float), 

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

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

77 ], 

78 }