smv.py 2.7 KB

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