Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 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 | |
Bram Moolenaar | 89bcfda | 2016-08-30 23:26:57 +0200 | [diff] [blame] | 18 | " quit when a syntax file was already loaded |
| 19 | if exists("b:current_syntax") |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 20 | finish |
| 21 | endif |
| 22 | |
| 23 | " case is significant to FDR: |
| 24 | syn case match |
| 25 | |
| 26 | " Block comments in CSP are between {- and -} |
| 27 | syn region cspComment start="{-" end="-}" contains=cspTodo |
| 28 | " Single-line comments start with -- |
| 29 | syn region cspComment start="--" end="$" contains=cspTodo,cspOldRttComment,cspSdlRttComment keepend |
| 30 | |
| 31 | " Numbers: |
| 32 | syn match cspNumber "\<\d\+\>" |
| 33 | |
| 34 | " Conditionals: |
| 35 | syn keyword cspConditional if then else |
| 36 | |
| 37 | " Operators on processes: |
| 38 | " -> ? : ! ' ; /\ \ [] |~| [> & [[..<-..]] ||| [|..|] || [..<->..] ; : @ ||| |
| 39 | syn match cspOperator "->" |
| 40 | syn match cspOperator "/\\" |
| 41 | syn match cspOperator "[^/]\\"lc=1 |
| 42 | syn match cspOperator "\[\]" |
| 43 | syn match cspOperator "|\~|" |
| 44 | syn match cspOperator "\[>" |
| 45 | syn match cspOperator "\[\[" |
| 46 | syn match cspOperator "\]\]" |
| 47 | syn match cspOperator "<-" |
| 48 | syn match cspOperator "|||" |
| 49 | syn match cspOperator "[^|]||[^|]"lc=1,me=e-1 |
| 50 | syn match cspOperator "[^|{\~]|[^|}\~]"lc=1,me=e-1 |
| 51 | syn match cspOperator "\[|" |
| 52 | syn match cspOperator "|\]" |
| 53 | syn match cspOperator "\[[^>]"me=e-1 |
| 54 | syn match cspOperator "\]" |
| 55 | syn match cspOperator "<->" |
| 56 | syn match cspOperator "[?:!';@]" |
| 57 | syn match cspOperator "&" |
| 58 | syn match cspOperator "\." |
| 59 | |
| 60 | " (not on processes:) |
| 61 | " syn match cspDelimiter "{|" |
| 62 | " syn match cspDelimiter "|}" |
| 63 | " syn match cspDelimiter "{[^-|]"me=e-1 |
| 64 | " syn match cspDelimiter "[^-|]}"lc=1 |
| 65 | |
| 66 | " Keywords: |
| 67 | syn keyword cspKeyword length null head tail concat elem |
| 68 | syn keyword cspKeyword union inter diff Union Inter member card |
| 69 | syn keyword cspKeyword empty set Set Seq |
| 70 | syn keyword cspKeyword true false and or not within let |
| 71 | syn keyword cspKeyword nametype datatype diamond normal |
| 72 | syn keyword cspKeyword sbisim tau_loop_factor model_compress |
| 73 | syn keyword cspKeyword explicate |
| 74 | syn match cspKeyword "transparent" |
| 75 | syn keyword cspKeyword external chase prioritize |
| 76 | syn keyword cspKeyword channel Events |
| 77 | syn keyword cspKeyword extensions productions |
| 78 | syn keyword cspKeyword Bool Int |
| 79 | |
| 80 | " Reserved keywords: |
| 81 | syn keyword cspReserved attribute embed module subtype |
| 82 | |
| 83 | " Include: |
| 84 | syn region cspInclude matchgroup=cspIncludeKeyword start="^include" end="$" keepend contains=cspIncludeArg |
| 85 | syn region cspIncludeArg start='\s\+\"' end= '\"\s*' contained |
| 86 | |
| 87 | " Assertions: |
| 88 | syn keyword cspAssert assert deterministic divergence free deadlock |
| 89 | syn keyword cspAssert livelock |
| 90 | syn match cspAssert "\[T=" |
| 91 | syn match cspAssert "\[F=" |
| 92 | syn match cspAssert "\[FD=" |
| 93 | syn match cspAssert "\[FD\]" |
| 94 | syn match cspAssert "\[F\]" |
| 95 | |
| 96 | " Types and Sets |
| 97 | " (first char a capital, later at least one lower case, no trailing underscore): |
| 98 | syn match cspType "\<_*[A-Z][A-Z_0-9]*[a-z]\(\|[A-Za-z_0-9]*[A-Za-z0-9]\)\>" |
| 99 | |
| 100 | " Processes (all upper case, no trailing underscore): |
| 101 | " (For identifiers that could be types or sets, too, this second rule set |
| 102 | " wins.) |
| 103 | syn match cspProcess "\<[A-Z_][A-Z_0-9]*[A-Z0-9]\>" |
| 104 | syn match cspProcess "\<[A-Z_]\>" |
| 105 | |
| 106 | " reserved identifiers for tool output (ending in underscore): |
| 107 | syn match cspReservedIdentifier "\<[A-Za-z_][A-Za-z_0-9]*_\>" |
| 108 | |
| 109 | " ToDo markers: |
| 110 | syn match cspTodo "FIXME" contained |
| 111 | syn match cspTodo "TODO" contained |
| 112 | syn match cspTodo "!!!" contained |
| 113 | |
| 114 | " RT-Tester pseudo comments: |
| 115 | " (The now obsolete syntax:) |
| 116 | syn match cspOldRttComment "^--\$\$AM_UNDEF"lc=2 contained |
| 117 | syn match cspOldRttComment "^--\$\$AM_ERROR"lc=2 contained |
| 118 | syn match cspOldRttComment "^--\$\$AM_WARNING"lc=2 contained |
| 119 | syn match cspOldRttComment "^--\$\$AM_SET_TIMER"lc=2 contained |
| 120 | syn match cspOldRttComment "^--\$\$AM_RESET_TIMER"lc=2 contained |
| 121 | syn match cspOldRttComment "^--\$\$AM_ELAPSED_TIMER"lc=2 contained |
| 122 | syn match cspOldRttComment "^--\$\$AM_OUTPUT"lc=2 contained |
| 123 | syn match cspOldRttComment "^--\$\$AM_INPUT"lc=2 contained |
| 124 | " (The current syntax:) |
| 125 | syn region cspRttPragma matchgroup=cspRttPragmaKeyword start="^pragma\s\+" end="\s*$" oneline keepend contains=cspRttPragmaArg,cspRttPragmaSdl |
| 126 | syn keyword cspRttPragmaArg AM_ERROR AM_WARNING AM_SET_TIMER contained |
| 127 | syn keyword cspRttPragmaArg AM_RESET_TIMER AM_ELAPSED_TIMER contained |
| 128 | syn keyword cspRttPragmaArg AM_OUTPUT AM_INPUT AM_INTERNAL contained |
| 129 | " the "SDL_MATCH" extension: |
| 130 | syn region cspRttPragmaSdl matchgroup=cspRttPragmaKeyword start="SDL_MATCH\s\+" end="\s*$" contains=cspRttPragmaSdlArg contained |
| 131 | syn keyword cspRttPragmaSdlArg TRANSLATE nextgroup=cspRttPragmaSdlTransName contained |
| 132 | syn keyword cspRttPragmaSdlArg PARAM SKIP OPTIONAL CHOICE ARRAY nextgroup=cspRttPragmaSdlName contained |
| 133 | syn match cspRttPragmaSdlName "\s*\S\+\s*" nextgroup=cspRttPragmaSdlTail contained |
| 134 | syn region cspRttPragmaSdlTail start="" end="\s*$" contains=cspRttPragmaSdlTailArg contained |
| 135 | syn keyword cspRttPragmaSdlTailArg SUBSET_USED DEFAULT_VALUE Present contained |
| 136 | syn match cspRttPragmaSdlTransName "\s*\w\+\s*" nextgroup=cspRttPragmaSdlTransTail contained |
| 137 | syn region cspRttPragmaSdlTransTail start="" end="\s*$" contains=cspRttPragmaSdlTransTailArg contained |
| 138 | syn keyword cspRttPragmaSdlTransTailArg sizeof contained |
| 139 | syn match cspRttPragmaSdlTransTailArg "\*" contained |
| 140 | syn match cspRttPragmaSdlTransTailArg "(" contained |
| 141 | syn match cspRttPragmaSdlTransTailArg ")" contained |
| 142 | |
| 143 | " temporary syntax extension for commented-out "pragma SDL_MATCH": |
| 144 | syn match cspSdlRttComment "pragma\s\+SDL_MATCH\s\+" nextgroup=cspRttPragmaSdlArg contained |
| 145 | |
| 146 | syn sync lines=250 |
| 147 | |
| 148 | " Define the default highlighting. |
Bram Moolenaar | 89bcfda | 2016-08-30 23:26:57 +0200 | [diff] [blame] | 149 | " Only when an item doesn't have highlighting yet |
| 150 | command -nargs=+ HiLink hi def link <args> |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 151 | |
Bram Moolenaar | 89bcfda | 2016-08-30 23:26:57 +0200 | [diff] [blame] | 152 | " The default methods for highlighting. Can be overridden later |
| 153 | " (For vim version <=5.7, the command groups are defined in |
| 154 | " $VIMRUNTIME/syntax/synload.vim ) |
| 155 | HiLink cspComment Comment |
| 156 | HiLink cspNumber Number |
| 157 | HiLink cspConditional Conditional |
| 158 | HiLink cspOperator Delimiter |
| 159 | HiLink cspKeyword Keyword |
| 160 | HiLink cspReserved SpecialChar |
| 161 | HiLink cspInclude Error |
| 162 | HiLink cspIncludeKeyword Include |
| 163 | HiLink cspIncludeArg Include |
| 164 | HiLink cspAssert PreCondit |
| 165 | HiLink cspType Type |
| 166 | HiLink cspProcess Function |
| 167 | HiLink cspTodo Todo |
| 168 | HiLink cspOldRttComment Define |
| 169 | HiLink cspRttPragmaKeyword Define |
| 170 | HiLink cspSdlRttComment Define |
| 171 | HiLink cspRttPragmaArg Define |
| 172 | HiLink cspRttPragmaSdlArg Define |
| 173 | HiLink cspRttPragmaSdlName Default |
| 174 | HiLink cspRttPragmaSdlTailArg Define |
| 175 | HiLink cspRttPragmaSdlTransName Default |
| 176 | HiLink cspRttPragmaSdlTransTailArg Define |
| 177 | HiLink cspReservedIdentifier Error |
| 178 | " (Currently unused vim method: Debug) |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 179 | |
Bram Moolenaar | 89bcfda | 2016-08-30 23:26:57 +0200 | [diff] [blame] | 180 | delcommand HiLink |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 181 | |
| 182 | let b:current_syntax = "csp" |
| 183 | |
| 184 | " vim: ts=8 |