csp.vim 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183
  1. " Vim syntax file
  2. " Language: CSP (Communication Sequential Processes, using FDR input syntax)
  3. " Maintainer: Jan Bredereke <brederek@tzi.de>
  4. " Version: 0.6.0
  5. " Last change: Mon Mar 25, 2002
  6. " URL: http://www.tzi.de/~brederek/vim/
  7. " Copying: You may distribute and use this file freely, in the same
  8. " way as the vim editor itself.
  9. "
  10. " To Do: - Probably I missed some keywords or operators, please
  11. " fix them and notify me, the maintainer.
  12. " - Currently, we do lexical highlighting only. It would be
  13. " nice to have more actual syntax checks, including
  14. " highlighting of wrong syntax.
  15. " - The additional syntax for the RT-Tester (pseudo-comments)
  16. " should be optional.
  17. " quit when a syntax file was already loaded
  18. if exists("b:current_syntax")
  19. finish
  20. endif
  21. " case is significant to FDR:
  22. syn case match
  23. " Block comments in CSP are between {- and -}
  24. syn region cspComment start="{-" end="-}" contains=cspTodo
  25. " Single-line comments start with --
  26. syn region cspComment start="--" end="$" contains=cspTodo,cspOldRttComment,cspSdlRttComment keepend
  27. " Numbers:
  28. syn match cspNumber "\<\d\+\>"
  29. " Conditionals:
  30. syn keyword cspConditional if then else
  31. " Operators on processes:
  32. " -> ? : ! ' ; /\ \ [] |~| [> & [[..<-..]] ||| [|..|] || [..<->..] ; : @ |||
  33. syn match cspOperator "->"
  34. syn match cspOperator "/\\"
  35. syn match cspOperator "[^/]\\"lc=1
  36. syn match cspOperator "\[\]"
  37. syn match cspOperator "|\~|"
  38. syn match cspOperator "\[>"
  39. syn match cspOperator "\[\["
  40. syn match cspOperator "\]\]"
  41. syn match cspOperator "<-"
  42. syn match cspOperator "|||"
  43. syn match cspOperator "[^|]||[^|]"lc=1,me=e-1
  44. syn match cspOperator "[^|{\~]|[^|}\~]"lc=1,me=e-1
  45. syn match cspOperator "\[|"
  46. syn match cspOperator "|\]"
  47. syn match cspOperator "\[[^>]"me=e-1
  48. syn match cspOperator "\]"
  49. syn match cspOperator "<->"
  50. syn match cspOperator "[?:!';@]"
  51. syn match cspOperator "&"
  52. syn match cspOperator "\."
  53. " (not on processes:)
  54. " syn match cspDelimiter "{|"
  55. " syn match cspDelimiter "|}"
  56. " syn match cspDelimiter "{[^-|]"me=e-1
  57. " syn match cspDelimiter "[^-|]}"lc=1
  58. " Keywords:
  59. syn keyword cspKeyword length null head tail concat elem
  60. syn keyword cspKeyword union inter diff Union Inter member card
  61. syn keyword cspKeyword empty set Set Seq
  62. syn keyword cspKeyword true false and or not within let
  63. syn keyword cspKeyword nametype datatype diamond normal
  64. syn keyword cspKeyword sbisim tau_loop_factor model_compress
  65. syn keyword cspKeyword explicate
  66. syn match cspKeyword "transparent"
  67. syn keyword cspKeyword external chase prioritize
  68. syn keyword cspKeyword channel Events
  69. syn keyword cspKeyword extensions productions
  70. syn keyword cspKeyword Bool Int
  71. " Reserved keywords:
  72. syn keyword cspReserved attribute embed module subtype
  73. " Include:
  74. syn region cspInclude matchgroup=cspIncludeKeyword start="^include" end="$" keepend contains=cspIncludeArg
  75. syn region cspIncludeArg start='\s\+\"' end= '\"\s*' contained
  76. " Assertions:
  77. syn keyword cspAssert assert deterministic divergence free deadlock
  78. syn keyword cspAssert livelock
  79. syn match cspAssert "\[T="
  80. syn match cspAssert "\[F="
  81. syn match cspAssert "\[FD="
  82. syn match cspAssert "\[FD\]"
  83. syn match cspAssert "\[F\]"
  84. " Types and Sets
  85. " (first char a capital, later at least one lower case, no trailing underscore):
  86. syn match cspType "\<_*[A-Z][A-Z_0-9]*[a-z]\(\|[A-Za-z_0-9]*[A-Za-z0-9]\)\>"
  87. " Processes (all upper case, no trailing underscore):
  88. " (For identifiers that could be types or sets, too, this second rule set
  89. " wins.)
  90. syn match cspProcess "\<[A-Z_][A-Z_0-9]*[A-Z0-9]\>"
  91. syn match cspProcess "\<[A-Z_]\>"
  92. " reserved identifiers for tool output (ending in underscore):
  93. syn match cspReservedIdentifier "\<[A-Za-z_][A-Za-z_0-9]*_\>"
  94. " ToDo markers:
  95. syn match cspTodo "FIXME" contained
  96. syn match cspTodo "TODO" contained
  97. syn match cspTodo "!!!" contained
  98. " RT-Tester pseudo comments:
  99. " (The now obsolete syntax:)
  100. syn match cspOldRttComment "^--\$\$AM_UNDEF"lc=2 contained
  101. syn match cspOldRttComment "^--\$\$AM_ERROR"lc=2 contained
  102. syn match cspOldRttComment "^--\$\$AM_WARNING"lc=2 contained
  103. syn match cspOldRttComment "^--\$\$AM_SET_TIMER"lc=2 contained
  104. syn match cspOldRttComment "^--\$\$AM_RESET_TIMER"lc=2 contained
  105. syn match cspOldRttComment "^--\$\$AM_ELAPSED_TIMER"lc=2 contained
  106. syn match cspOldRttComment "^--\$\$AM_OUTPUT"lc=2 contained
  107. syn match cspOldRttComment "^--\$\$AM_INPUT"lc=2 contained
  108. " (The current syntax:)
  109. syn region cspRttPragma matchgroup=cspRttPragmaKeyword start="^pragma\s\+" end="\s*$" oneline keepend contains=cspRttPragmaArg,cspRttPragmaSdl
  110. syn keyword cspRttPragmaArg AM_ERROR AM_WARNING AM_SET_TIMER contained
  111. syn keyword cspRttPragmaArg AM_RESET_TIMER AM_ELAPSED_TIMER contained
  112. syn keyword cspRttPragmaArg AM_OUTPUT AM_INPUT AM_INTERNAL contained
  113. " the "SDL_MATCH" extension:
  114. syn region cspRttPragmaSdl matchgroup=cspRttPragmaKeyword start="SDL_MATCH\s\+" end="\s*$" contains=cspRttPragmaSdlArg contained
  115. syn keyword cspRttPragmaSdlArg TRANSLATE nextgroup=cspRttPragmaSdlTransName contained
  116. syn keyword cspRttPragmaSdlArg PARAM SKIP OPTIONAL CHOICE ARRAY nextgroup=cspRttPragmaSdlName contained
  117. syn match cspRttPragmaSdlName "\s*\S\+\s*" nextgroup=cspRttPragmaSdlTail contained
  118. syn region cspRttPragmaSdlTail start="" end="\s*$" contains=cspRttPragmaSdlTailArg contained
  119. syn keyword cspRttPragmaSdlTailArg SUBSET_USED DEFAULT_VALUE Present contained
  120. syn match cspRttPragmaSdlTransName "\s*\w\+\s*" nextgroup=cspRttPragmaSdlTransTail contained
  121. syn region cspRttPragmaSdlTransTail start="" end="\s*$" contains=cspRttPragmaSdlTransTailArg contained
  122. syn keyword cspRttPragmaSdlTransTailArg sizeof contained
  123. syn match cspRttPragmaSdlTransTailArg "\*" contained
  124. syn match cspRttPragmaSdlTransTailArg "(" contained
  125. syn match cspRttPragmaSdlTransTailArg ")" contained
  126. " temporary syntax extension for commented-out "pragma SDL_MATCH":
  127. syn match cspSdlRttComment "pragma\s\+SDL_MATCH\s\+" nextgroup=cspRttPragmaSdlArg contained
  128. syn sync lines=250
  129. " Define the default highlighting.
  130. " Only when an item doesn't have highlighting yet
  131. " The default methods for highlighting. Can be overridden later
  132. " (For vim version <=5.7, the command groups are defined in
  133. " $VIMRUNTIME/syntax/synload.vim )
  134. hi def link cspComment Comment
  135. hi def link cspNumber Number
  136. hi def link cspConditional Conditional
  137. hi def link cspOperator Delimiter
  138. hi def link cspKeyword Keyword
  139. hi def link cspReserved SpecialChar
  140. hi def link cspInclude Error
  141. hi def link cspIncludeKeyword Include
  142. hi def link cspIncludeArg Include
  143. hi def link cspAssert PreCondit
  144. hi def link cspType Type
  145. hi def link cspProcess Function
  146. hi def link cspTodo Todo
  147. hi def link cspOldRttComment Define
  148. hi def link cspRttPragmaKeyword Define
  149. hi def link cspSdlRttComment Define
  150. hi def link cspRttPragmaArg Define
  151. hi def link cspRttPragmaSdlArg Define
  152. hi def link cspRttPragmaSdlName Default
  153. hi def link cspRttPragmaSdlTailArg Define
  154. hi def link cspRttPragmaSdlTransName Default
  155. hi def link cspRttPragmaSdlTransTailArg Define
  156. hi def link cspReservedIdentifier Error
  157. " (Currently unused vim method: Debug)
  158. let b:current_syntax = "csp"
  159. " vim: ts=8