smv.py 2.7 KB

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