|
1 # -*- coding: utf-8 -*- |
|
2 """ |
|
3 pygments.lexers.smv |
|
4 ~~~~~~~~~~~~~~~~~~~ |
|
5 |
|
6 Lexers for the SMV languages. |
|
7 |
|
8 :copyright: Copyright 2006-2017 by the Pygments team, see AUTHORS. |
|
9 :license: BSD, see LICENSE for details. |
|
10 """ |
|
11 |
|
12 from pygments.lexer import RegexLexer, words |
|
13 from pygments.token import Comment, Generic, Keyword, Name, Number, \ |
|
14 Operator, Punctuation, Text |
|
15 |
|
16 __all__ = ['NuSMVLexer'] |
|
17 |
|
18 |
|
19 class NuSMVLexer(RegexLexer): |
|
20 """ |
|
21 Lexer for the NuSMV language. |
|
22 |
|
23 .. versionadded:: 2.2 |
|
24 """ |
|
25 |
|
26 name = 'NuSMV' |
|
27 aliases = ['nusmv'] |
|
28 filenames = ['*.smv'] |
|
29 mimetypes = [] |
|
30 |
|
31 tokens = { |
|
32 'root': [ |
|
33 # Comments |
|
34 (r'(?s)\/\-\-.*?\-\-/', Comment), |
|
35 (r'--.*\n', Comment), |
|
36 |
|
37 # Reserved |
|
38 (words(('MODULE', 'DEFINE', 'MDEFINE', 'CONSTANTS', 'VAR', 'IVAR', |
|
39 'FROZENVAR', 'INIT', 'TRANS', 'INVAR', 'SPEC', 'CTLSPEC', |
|
40 'LTLSPEC', 'PSLSPEC', 'COMPUTE', 'NAME', 'INVARSPEC', |
|
41 'FAIRNESS', 'JUSTICE', 'COMPASSION', 'ISA', 'ASSIGN', |
|
42 'CONSTRAINT', 'SIMPWFF', 'CTLWFF', 'LTLWFF', 'PSLWFF', |
|
43 'COMPWFF', 'IN', 'MIN', 'MAX', 'MIRROR', 'PRED', |
|
44 'PREDICATES'), suffix=r'(?![\w$#-])'), |
|
45 Keyword.Declaration), |
|
46 (r'process(?![\w$#-])', Keyword), |
|
47 (words(('array', 'of', 'boolean', 'integer', 'real', 'word'), |
|
48 suffix=r'(?![\w$#-])'), Keyword.Type), |
|
49 (words(('case', 'esac'), suffix=r'(?![\w$#-])'), Keyword), |
|
50 (words(('word1', 'bool', 'signed', 'unsigned', 'extend', 'resize', |
|
51 'sizeof', 'uwconst', 'swconst', 'init', 'self', 'count', |
|
52 'abs', 'max', 'min'), suffix=r'(?![\w$#-])'), |
|
53 Name.Builtin), |
|
54 (words(('EX', 'AX', 'EF', 'AF', 'EG', 'AG', 'E', 'F', 'O', 'G', |
|
55 'H', 'X', 'Y', 'Z', 'A', 'U', 'S', 'V', 'T', 'BU', 'EBF', |
|
56 'ABF', 'EBG', 'ABG', 'next', 'mod', 'union', 'in', 'xor', |
|
57 'xnor'), suffix=r'(?![\w$#-])'), |
|
58 Operator.Word), |
|
59 (words(('TRUE', 'FALSE'), suffix=r'(?![\w$#-])'), Keyword.Constant), |
|
60 |
|
61 # Names |
|
62 (r'[a-zA-Z_][\w$#-]*', Name.Variable), |
|
63 |
|
64 # Operators |
|
65 (r':=', Operator), |
|
66 (r'[-&|+*/<>!=]', Operator), |
|
67 |
|
68 # Literals |
|
69 (r'\-?\d+\b', Number.Integer), |
|
70 (r'0[su][bB]\d*_[01_]+', Number.Bin), |
|
71 (r'0[su][oO]\d*_[0-7_]+', Number.Oct), |
|
72 (r'0[su][dD]\d*_[\d_]+', Number.Dec), |
|
73 (r'0[su][hH]\d*_[\da-fA-F_]+', Number.Hex), |
|
74 |
|
75 # Whitespace, punctuation and the rest |
|
76 (r'\s+', Text.Whitespace), |
|
77 (r'[()\[\]{};?:.,]', Punctuation), |
|
78 ], |
|
79 } |