iso.vim (15306B)
1 " Vim syntax file 2 " Language: Modula-2 (ISO) 3 " Maintainer: B.Kowarsch <trijezdci@moc.liamg> 4 " Last Change: 2016 August 22 5 6 " ---------------------------------------------------- 7 " THIS FILE IS LICENSED UNDER THE VIM LICENSE 8 " see https://github.com/vim/vim/blob/master/LICENSE 9 " ---------------------------------------------------- 10 11 " Remarks: 12 " Vim Syntax files are available for the following Modula-2 dialects: 13 " * for the PIM dialect : m2pim.vim 14 " * for the ISO dialect : m2iso.vim (this file) 15 " * for the R10 dialect : m2r10.vim 16 17 " ----------------------------------------------------------------------------- 18 " This syntax description follows ISO standard IS-10514 (aka ISO Modula-2) 19 " with the addition of the following language extensions: 20 " * non-standard types LONGCARD and LONGBITSET 21 " * non-nesting code disabling tags ?< and >? at the start of a line 22 " ----------------------------------------------------------------------------- 23 24 " Parameters: 25 " 26 " Vim's filetype script recognises Modula-2 dialect tags within the first 200 27 " lines of Modula-2 .def and .mod input files. The script sets filetype and 28 " dialect automatically when a valid dialect tag is found in the input file. 29 " The dialect tag for the ISO dialect is (*!m2iso*). It is recommended to put 30 " the tag immediately after the module header in the Modula-2 input file. 31 " 32 " Example: 33 " DEFINITION MODULE Foolib; (*!m2iso*) 34 " 35 " Variable g:modula2_default_dialect sets the default Modula-2 dialect when the 36 " dialect cannot be determined from the contents of the Modula-2 input file: 37 " if defined and set to 'm2iso', the default dialect is ISO. 38 " 39 " Variable g:modula2_iso_allow_lowline controls support for lowline in identifiers: 40 " if defined and set to a non-zero value, they are recognised, otherwise not 41 " 42 " Variable g:modula2_iso_disallow_octals controls the rendering of octal literals: 43 " if defined and set to a non-zero value, they are rendered as errors. 44 " 45 " Variable g:modula2_iso_disallow_synonyms controls the rendering of @, & and ~: 46 " if defined and set to a non-zero value, they are rendered as errors. 47 " 48 " Variables may be defined in Vim startup file .vimrc 49 " 50 " Examples: 51 " let g:modula2_default_dialect = 'm2iso' 52 " let g:modula2_iso_allow_lowline = 1 53 " let g:modula2_iso_disallow_octals = 1 54 " let g:modula2_iso_disallow_synonyms = 1 55 56 57 if exists("b:current_syntax") 58 finish 59 endif 60 61 " Modula-2 is case sensitive 62 syn case match 63 64 65 " ----------------------------------------------------------------------------- 66 " Reserved Words 67 " ----------------------------------------------------------------------------- 68 syn keyword modula2Resword AND ARRAY BEGIN BY CASE CONST DEFINITION DIV DO ELSE 69 syn keyword modula2Resword ELSIF EXCEPT EXIT EXPORT FINALLY FOR FORWARD FROM IF 70 syn keyword modula2Resword IMPLEMENTATION IMPORT IN LOOP MOD NOT OF OR PACKEDSET 71 syn keyword modula2Resword POINTER QUALIFIED RECORD REPEAT REM RETRY RETURN SET 72 syn keyword modula2Resword THEN TO TYPE UNTIL VAR WHILE WITH 73 74 75 " ----------------------------------------------------------------------------- 76 " Builtin Constant Identifiers 77 " ----------------------------------------------------------------------------- 78 syn keyword modula2ConstIdent FALSE NIL TRUE INTERRUPTIBLE UNINTERRUPTIBLE 79 80 81 " ----------------------------------------------------------------------------- 82 " Builtin Type Identifiers 83 " ----------------------------------------------------------------------------- 84 syn keyword modula2TypeIdent BITSET BOOLEAN CHAR PROC 85 syn keyword modula2TypeIdent CARDINAL INTEGER LONGINT REAL LONGREAL 86 syn keyword modula2TypeIdent COMPLEX LONGCOMPLEX PROTECTION 87 88 89 " ----------------------------------------------------------------------------- 90 " Builtin Procedure and Function Identifiers 91 " ----------------------------------------------------------------------------- 92 syn keyword modula2ProcIdent CAP DEC EXCL HALT INC INCL 93 syn keyword modula2FuncIdent ABS CHR CMPLX FLOAT HIGH IM INT LENGTH LFLOAT MAX MIN 94 syn keyword modula2FuncIdent ODD ORD RE SIZE TRUNC VAL 95 96 97 " ----------------------------------------------------------------------------- 98 " Wirthian Macro Identifiers 99 " ----------------------------------------------------------------------------- 100 syn keyword modula2MacroIdent NEW DISPOSE 101 102 103 " ----------------------------------------------------------------------------- 104 " Unsafe Facilities via Pseudo-Module SYSTEM 105 " ----------------------------------------------------------------------------- 106 syn keyword modula2UnsafeIdent ADDRESS BYTE LOC WORD 107 syn keyword modula2UnsafeIdent ADR CAST TSIZE SYSTEM 108 syn keyword modula2UnsafeIdent MAKEADR ADDADR SUBADR DIFADR ROTATE SHIFT 109 110 111 " ----------------------------------------------------------------------------- 112 " Non-Portable Language Extensions 113 " ----------------------------------------------------------------------------- 114 syn keyword modula2NonPortableIdent LONGCARD LONGBITSET 115 116 117 " ----------------------------------------------------------------------------- 118 " User Defined Identifiers 119 " ----------------------------------------------------------------------------- 120 syn match modula2Ident "[a-zA-Z][a-zA-Z0-9]*\(_\)\@!" 121 syn match modula2LowLineIdent "[a-zA-Z][a-zA-Z0-9]*\(_[a-zA-Z0-9]\+\)\+" 122 123 124 " ----------------------------------------------------------------------------- 125 " String Literals 126 " ----------------------------------------------------------------------------- 127 syn region modula2String start=/"/ end=/"/ oneline 128 syn region modula2String start=/'/ end=/'/ oneline 129 130 131 " ----------------------------------------------------------------------------- 132 " Numeric Literals 133 " ----------------------------------------------------------------------------- 134 syn match modula2Num 135 \ "\(\([0-7]\+\)[BC]\@!\|[89]\)[0-9]*\(\.[0-9]\+\([eE][+-]\?[0-9]\+\)\?\)\?" 136 syn match modula2Num "[0-9A-F]\+H" 137 syn match modula2Octal "[0-7]\+[BC]" 138 139 140 " ----------------------------------------------------------------------------- 141 " Punctuation 142 " ----------------------------------------------------------------------------- 143 syn match modula2Punctuation 144 \ "\.\|[,:;]\|\*\|[/+-]\|\#\|[=<>]\|\^\|\[\|\]\|(\(\*\)\@!\|[){}]" 145 syn match modula2Synonym "[@&~]" 146 147 148 " ----------------------------------------------------------------------------- 149 " Pragmas 150 " ----------------------------------------------------------------------------- 151 syn region modula2Pragma start="<\*" end="\*>" 152 syn match modula2DialectTag "(\*!m2iso\(+[a-z0-9]\+\)\?\*)" 153 154 " ----------------------------------------------------------------------------- 155 " Block Comments 156 " ----------------------------------------------------------------------------- 157 syn region modula2Comment start="(\*\(!m2iso\(+[a-z0-9]\+\)\?\*)\)\@!" end="\*)" 158 \ contains = modula2Comment, modula2CommentKey, modula2TechDebtMarker 159 syn match modula2CommentKey "[Aa]uthor[s]\?\|[Cc]opyright\|[Ll]icense\|[Ss]ynopsis" 160 syn match modula2CommentKey "\([Pp]re\|[Pp]ost\|[Ee]rror\)\-condition[s]\?:" 161 162 163 " ----------------------------------------------------------------------------- 164 " Technical Debt Markers 165 " ----------------------------------------------------------------------------- 166 syn keyword modula2TechDebtMarker contained DEPRECATED FIXME 167 syn match modula2TechDebtMarker "TODO[:]\?" contained 168 169 " ----------------------------------------------------------------------------- 170 " Disabled Code Sections 171 " ----------------------------------------------------------------------------- 172 syn region modula2DisabledCode start="^?<" end="^>?" 173 174 175 " ----------------------------------------------------------------------------- 176 " Headers 177 " ----------------------------------------------------------------------------- 178 " !!! this section must be second last !!! 179 180 " new module header 181 syn match modula2ModuleHeader 182 \ "MODULE\( [A-Z][a-zA-Z0-9]*\)\?" 183 \ contains = modula2ReswordModule, modula2ModuleIdent 184 185 syn match modula2ModuleIdent 186 \ "[A-Z][a-zA-Z0-9]*" contained 187 188 syn match modula2ModuleTail 189 \ "END [A-Z][a-zA-Z0-9]*\.$" 190 \ contains = modula2ReswordEnd, modula2ModuleIdent, modula2Punctuation 191 192 " new procedure header 193 syn match modula2ProcedureHeader 194 \ "PROCEDURE\( [a-zA-Z][a-zA-Z0-9]*\(_[a-zA-Z0-9]\+\)*\)\?" 195 \ contains = modula2ReswordProcedure, 196 \ modula2ProcedureIdent, modula2ProcedureLowlineIdent, modula2IllegalChar, modula2IllegalIdent 197 198 syn match modula2ProcedureIdent 199 \ "\([a-zA-Z]\)\([a-zA-Z0-9]*\)" contained 200 201 syn match modula2ProcedureLowlineIdent 202 \ "[a-zA-Z][a-zA-Z0-9]*\(_[a-zA-Z0-9]\+\)\+" contained 203 204 syn match modula2ProcedureTail 205 \ "END\( \([a-zA-Z][a-zA-Z0-9]*\(_[a-zA-Z0-9]\+\)*\)[.;]$\)\?" 206 \ contains = modula2ReswordEnd, 207 \ modula2ProcedureIdent, modula2ProcedureLowLineIdent, 208 \ modula2Punctuation, modula2IllegalChar, modula2IllegalIdent 209 210 syn keyword modula2ReswordModule contained MODULE 211 syn keyword modula2ReswordProcedure contained PROCEDURE 212 syn keyword modula2ReswordEnd contained END 213 214 215 " ----------------------------------------------------------------------------- 216 " Illegal Symbols 217 " ----------------------------------------------------------------------------- 218 " !!! this section must be last !!! 219 220 " any '`' '!' '$' '%' or '\' 221 syn match modula2IllegalChar "[`!$%\\]" 222 223 " any solitary sequence of '_' 224 syn match modula2IllegalChar "\<_\+\>" 225 226 " any '?' at start of line if not followed by '<' 227 syn match modula2IllegalChar "^?\(<\)\@!" 228 229 " any '?' not following '>' at start of line 230 syn match modula2IllegalChar "\(\(^>\)\|\(^\)\)\@<!?" 231 232 " any identifiers with leading occurrences of '_' 233 syn match modula2IllegalIdent "_\+[a-zA-Z][a-zA-Z0-9]*\(_\+[a-zA-Z0-9]*\)*" 234 235 " any identifiers containing consecutive occurences of '_' 236 syn match modula2IllegalIdent 237 \ "[a-zA-Z][a-zA-Z0-9]*\(_[a-zA-Z0-9]\+\)*\(__\+[a-zA-Z0-9]\+\(_[a-zA-Z0-9]\+\)*\)\+" 238 239 " any identifiers with trailing occurrences of '_' 240 syn match modula2IllegalIdent "[a-zA-Z][a-zA-Z0-9]*\(_\+[a-zA-Z0-9]\+\)*_\+\>" 241 242 243 " ----------------------------------------------------------------------------- 244 " Define Rendering Styles 245 " ----------------------------------------------------------------------------- 246 247 " highlight default link modula2PredefIdentStyle Keyword 248 " highlight default link modula2ConstIdentStyle modula2PredefIdentStyle 249 " highlight default link modula2TypeIdentStyle modula2PredefIdentStyle 250 " highlight default link modula2ProcIdentStyle modula2PredefIdentStyle 251 " highlight default link modula2FuncIdentStyle modula2PredefIdentStyle 252 " highlight default link modula2MacroIdentStyle modula2PredefIdentStyle 253 254 highlight default link modula2ConstIdentStyle Constant 255 highlight default link modula2TypeIdentStyle Type 256 highlight default link modula2ProcIdentStyle Function 257 highlight default link modula2FuncIdentStyle Function 258 highlight default link modula2MacroIdentStyle Function 259 highlight default link modula2UnsafeIdentStyle Question 260 highlight default link modula2NonPortableIdentStyle Question 261 highlight default link modula2StringLiteralStyle String 262 highlight default link modula2CommentStyle Comment 263 highlight default link modula2PragmaStyle PreProc 264 highlight default link modula2DialectTagStyle SpecialComment 265 highlight default link modula2TechDebtMarkerStyle SpecialComment 266 highlight default link modula2ReswordStyle Keyword 267 highlight default link modula2HeaderIdentStyle Function 268 highlight default link modula2UserDefIdentStyle Normal 269 highlight default link modula2NumericLiteralStyle Number 270 highlight default link modula2PunctuationStyle Delimiter 271 highlight default link modula2CommentKeyStyle SpecialComment 272 highlight default link modula2DisabledCodeStyle NonText 273 274 " ----------------------------------------------------------------------------- 275 " Assign Rendering Styles 276 " ----------------------------------------------------------------------------- 277 278 " headers 279 highlight default link modula2ModuleIdent modula2HeaderIdentStyle 280 highlight default link modula2ProcedureIdent modula2HeaderIdentStyle 281 highlight default link modula2ModuleHeader Normal 282 highlight default link modula2ModuleTail Normal 283 highlight default link modula2ProcedureHeader Normal 284 highlight default link modula2ProcedureTail Normal 285 286 " lowline identifiers are rendered as errors if g:modula2_iso_allow_lowline is unset 287 if exists("g:modula2_iso_allow_lowline") 288 if g:modula2_iso_allow_lowline != 0 289 highlight default link modula2ProcedureLowlineIdent modula2HeaderIdentStyle 290 else 291 highlight default link modula2ProcedureLowlineIdent Error 292 endif 293 else 294 highlight default link modula2ProcedureLowlineIdent modula2HeaderIdentStyle 295 endif 296 297 " reserved words 298 highlight default link modula2Resword modula2ReswordStyle 299 highlight default link modula2ReswordModule modula2ReswordStyle 300 highlight default link modula2ReswordProcedure modula2ReswordStyle 301 highlight default link modula2ReswordEnd modula2ReswordStyle 302 303 " predefined identifiers 304 highlight default link modula2ConstIdent modula2ConstIdentStyle 305 highlight default link modula2TypeIdent modula2TypeIdentStyle 306 highlight default link modula2ProcIdent modula2ProcIdentStyle 307 highlight default link modula2FuncIdent modula2FuncIdentStyle 308 highlight default link modula2MacroIdent modula2MacroIdentStyle 309 310 " unsafe and non-portable identifiers 311 highlight default link modula2UnsafeIdent modula2UnsafeIdentStyle 312 highlight default link modula2NonPortableIdent modula2NonPortableIdentStyle 313 314 " user defined identifiers 315 highlight default link modula2Ident modula2UserDefIdentStyle 316 317 " lowline identifiers are rendered as errors if g:modula2_iso_allow_lowline is unset 318 if exists("g:modula2_iso_allow_lowline") 319 if g:modula2_iso_allow_lowline != 0 320 highlight default link modula2LowLineIdent modula2UserDefIdentStyle 321 else 322 highlight default link modula2LowLineIdent Error 323 endif 324 else 325 highlight default link modula2LowLineIdent modula2UserDefIdentStyle 326 endif 327 328 " literals 329 highlight default link modula2String modula2StringLiteralStyle 330 highlight default link modula2Num modula2NumericLiteralStyle 331 332 " octal literals are rendered as errors if g:modula2_iso_disallow_octals is set 333 if exists("g:modula2_iso_disallow_octals") 334 if g:modula2_iso_disallow_octals != 0 335 highlight default link modula2Octal Error 336 else 337 highlight default link modula2Octal modula2NumericLiteralStyle 338 endif 339 else 340 highlight default link modula2Octal modula2NumericLiteralStyle 341 endif 342 343 " punctuation 344 highlight default link modula2Punctuation modula2PunctuationStyle 345 346 " synonyms & and ~ are rendered as errors if g:modula2_iso_disallow_synonyms is set 347 if exists("g:modula2_iso_disallow_synonyms") 348 if g:modula2_iso_disallow_synonyms != 0 349 highlight default link modula2Synonym Error 350 else 351 highlight default link modula2Synonym modula2PunctuationStyle 352 endif 353 else 354 highlight default link modula2Synonym modula2PunctuationStyle 355 endif 356 357 " pragmas 358 highlight default link modula2Pragma modula2PragmaStyle 359 highlight default link modula2DialectTag modula2DialectTagStyle 360 361 " comments 362 highlight default link modula2Comment modula2CommentStyle 363 highlight default link modula2CommentKey modula2CommentKeyStyle 364 365 " technical debt markers 366 highlight default link modula2TechDebtMarker modula2TechDebtMarkerStyle 367 368 " disabled code 369 highlight default link modula2DisabledCode modula2DisabledCodeStyle 370 371 " illegal symbols 372 highlight default link modula2IllegalChar Error 373 highlight default link modula2IllegalIdent Error 374 375 376 let b:current_syntax = "modula2" 377 378 " vim: ts=4 379 380 " END OF FILE