1"""
2 pygments.lexers.parasail
3 ~~~~~~~~~~~~~~~~~~~~~~~~
4
5 Lexer for ParaSail.
6
7 :copyright: Copyright 2006-present by the Pygments team, see AUTHORS.
8 :license: BSD, see LICENSE for details.
9"""
10
11import re
12
13from pygments.lexer import RegexLexer, include, words
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 (words(('abs', 'abstract', 'all', 'block', 'class', 'concurrent',
44 'const', 'continue', 'each', 'end', 'exit',
45 'extends', 'exports', 'forward', 'func',
46 'global', 'implements', 'import', 'in',
47 'interface', 'is', 'lambda', 'locked',
48 'new', 'not', 'null', 'of', 'op',
49 'optional', 'private', 'queued', 'ref',
50 'return', 'reverse', 'separate', 'some',
51 'type', 'until', 'var', 'with', 'if',
52 'then', 'else', 'elsif', 'case', 'for',
53 'while', 'loop'), prefix=r'\b', suffix=r'\b'),
54 Keyword.Reserved),
55 (r'(abstract\s+)?(interface|class|op|func|type)',
56 Keyword.Declaration),
57 # Literals
58 (r'"[^"]*"', String),
59 (r'\\[\'ntrf"0]', String.Escape),
60 (r'#[a-zA-Z]\w*', Literal), # Enumeration
61 include('numbers'),
62 (r"'[^']'", String.Char),
63 (r'[a-zA-Z]\w*', Name),
64 # Operators and Punctuation
65 (r'(<==|==>|<=>|\*\*=|<\|=|<<=|>>=|==|!=|=\?|<=|>=|'
66 r'\*\*|<<|>>|=>|:=|\+=|-=|\*=|\|=|\||/=|\+|-|\*|/|'
67 r'\.\.|<\.\.|\.\.<|<\.\.<)',
68 Operator),
69 (r'(<|>|\[|\]|\(|\)|\||:|;|,|.|\{|\}|->)',
70 Punctuation),
71 (r'\n+', Text),
72 ],
73 'numbers': [
74 (r'\d[0-9_]*#[0-9a-fA-F][0-9a-fA-F_]*#', Number.Hex), # any base
75 (r'0[xX][0-9a-fA-F][0-9a-fA-F_]*', Number.Hex), # C-like hex
76 (r'0[bB][01][01_]*', Number.Bin), # C-like bin
77 (r'\d[0-9_]*\.\d[0-9_]*[eE][+-]\d[0-9_]*', # float exp
78 Number.Float),
79 (r'\d[0-9_]*\.\d[0-9_]*', Number.Float), # float
80 (r'\d[0-9_]*', Number.Integer), # integer
81 ],
82 }