smv.py 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. """
  2. pygments.lexers.smv
  3. ~~~~~~~~~~~~~~~~~~~
  4. Lexers for the SMV languages.
  5. :copyright: Copyright 2006-2024 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. """
  16. name = 'NuSMV'
  17. aliases = ['nusmv']
  18. filenames = ['*.smv']
  19. mimetypes = []
  20. url = 'https://nusmv.fbk.eu'
  21. version_added = '2.2'
  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.Decimal),
  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. }