robin/laufey
git clone https://git.robinwobin.dev/robin/laufey
ab20681c52
master
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 57if exists ( "b:current_syntax" ) 58finish 59endif 60 61" Modula-2 is case sensitive 62syn case match 63 64 65" ----------------------------------------------------------------------------- 66" Reserved Words 67" ----------------------------------------------------------------------------- 68syn keyword modula2Resword AND ARRAY BEGIN BY CASE CONST DEFINITION DIV DO ELSE 69syn keyword modula2Resword ELSIF EXCEPT EXIT EXPORT FINALLY FOR FORWARD FROM IF 70syn keyword modula2Resword IMPLEMENTATION IMPORT IN LOOP MOD NOT OF OR PACKEDSET 71syn keyword modula2Resword POINTER QUALIFIED RECORD REPEAT REM RETRY RETURN SET 72syn keyword modula2Resword THEN TO TYPE UNTIL VAR WHILE WITH 73 74 75" ----------------------------------------------------------------------------- 76" Builtin Constant Identifiers 77" ----------------------------------------------------------------------------- 78syn keyword modula2ConstIdent FALSE NIL TRUE INTERRUPTIBLE UNINTERRUPTIBLE 79 80 81" ----------------------------------------------------------------------------- 82" Builtin Type Identifiers 83" ----------------------------------------------------------------------------- 84syn keyword modula2TypeIdent BITSET BOOLEAN CHAR PROC 85syn keyword modula2TypeIdent CARDINAL INTEGER LONGINT REAL LONGREAL 86syn keyword modula2TypeIdent COMPLEX LONGCOMPLEX PROTECTION 87 88 89" ----------------------------------------------------------------------------- 90" Builtin Procedure and Function Identifiers 91" ----------------------------------------------------------------------------- 92syn keyword modula2ProcIdent CAP DEC EXCL HALT INC INCL 93syn keyword modula2FuncIdent ABS CHR CMPLX FLOAT HIGH IM INT LENGTH LFLOAT MAX MIN 94syn keyword modula2FuncIdent ODD ORD RE SIZE TRUNC VAL 95 96 97" ----------------------------------------------------------------------------- 98" Wirthian Macro Identifiers 99" ----------------------------------------------------------------------------- 100syn keyword modula2MacroIdent NEW DISPOSE 101 102 103" ----------------------------------------------------------------------------- 104" Unsafe Facilities via Pseudo-Module SYSTEM 105" ----------------------------------------------------------------------------- 106syn keyword modula2UnsafeIdent ADDRESS BYTE LOC WORD 107syn keyword modula2UnsafeIdent ADR CAST TSIZE SYSTEM 108syn keyword modula2UnsafeIdent MAKEADR ADDADR SUBADR DIFADR ROTATE SHIFT 109 110 111" ----------------------------------------------------------------------------- 112" Non-Portable Language Extensions 113" ----------------------------------------------------------------------------- 114syn keyword modula2NonPortableIdent LONGCARD LONGBITSET 115 116 117" ----------------------------------------------------------------------------- 118" User Defined Identifiers 119" ----------------------------------------------------------------------------- 120syn match modula2Ident "[ a-zA-Z ][ a-zA-Z0-9 ] * \(_\)\@! " 121syn match modula2LowLineIdent "[ a-zA-Z ][ a-zA-Z0-9 ] * \(_ [ a-zA-Z0-9 ] \+\)\+ " 122 123 124" ----------------------------------------------------------------------------- 125" String Literals 126" ----------------------------------------------------------------------------- 127syn region modula2String start = /" /end = /" /oneline 128syn region modula2String start = /' /end = /' /oneline 129 130 131" ----------------------------------------------------------------------------- 132" Numeric Literals 133" ----------------------------------------------------------------------------- 134syn match modula2Num 135 \ "\(\( [ 0-7 ] \+\) [ BC ] \@!\| [ 89 ] \) [ 0-9 ] * \(\. [ 0-9 ] \+\( [ eE ][ +- ] \? [ 0-9 ] \+\)\?\)\? " 136syn match modula2Num "[ 0-9A-F ] \+H " 137syn match modula2Octal "[ 0-7 ] \+ [ BC ] " 138 139 140" ----------------------------------------------------------------------------- 141" Punctuation 142" ----------------------------------------------------------------------------- 143syn match modula2Punctuation 144 \ "\.\| [ ,:; ] \|\*\| [ /+- ] \|\#\| [ =<> ] \|\^\|\[\|\]\|(\(\*\)\@!\| [ ){} ] " 145syn match modula2Synonym "[ @&~ ] " 146 147 148" ----------------------------------------------------------------------------- 149" Pragmas 150" ----------------------------------------------------------------------------- 151syn region modula2Pragma start = "<\* "end = "\*> " 152syn match modula2DialectTag "(\*!m2iso\(+ [ a-z0-9 ] \+\)\?\*) " 153 154" ----------------------------------------------------------------------------- 155" Block Comments 156" ----------------------------------------------------------------------------- 157syn region modula2Comment start = "(\*\(!m2iso\(+ [ a-z0-9 ] \+\)\?\*)\)\@! "end = "\*) " 158 \ contains = modula2Comment, modula2CommentKey, modula2TechDebtMarker 159syn match modula2CommentKey "[ Aa ] uthor [ s ] \?\| [ Cc ] opyright\| [ Ll ] icense\| [ Ss ] ynopsis " 160syn match modula2CommentKey "\( [ Pp ] re\| [ Pp ] ost\| [ Ee ] rror\)\-condition [ s ] \?: " 161 162 163" ----------------------------------------------------------------------------- 164" Technical Debt Markers 165" ----------------------------------------------------------------------------- 166syn keyword modula2TechDebtMarker contained DEPRECATED FIXME 167syn match modula2TechDebtMarker "TODO [ : ] \? "contained 168 169" ----------------------------------------------------------------------------- 170" Disabled Code Sections 171" ----------------------------------------------------------------------------- 172syn region modula2DisabledCode start = "^?< "end = "^>? " 173 174 175" ----------------------------------------------------------------------------- 176" Headers 177" ----------------------------------------------------------------------------- 178" !!! this section must be second last !!! 179 180" new module header 181syn match modula2ModuleHeader 182 \ "MODULE\( [ A-Z ][ a-zA-Z0-9 ] * \)\? " 183 \ contains =modula2ReswordModule, modula2ModuleIdent 184 185syn match modula2ModuleIdent 186 \ "[ A-Z ][ a-zA-Z0-9 ] * "contained 187 188syn match modula2ModuleTail 189 \ "END [ A-Z ][ a-zA-Z0-9 ] * \.$ " 190 \ contains =modula2ReswordEnd, modula2ModuleIdent, modula2Punctuation 191 192" new procedure header 193syn match modula2ProcedureHeader 194 \ "PROCEDURE\( [ a-zA-Z ][ a-zA-Z0-9 ] * \(_ [ a-zA-Z0-9 ] \+\) * \)\? " 195 \ contains =modula2ReswordProcedure, 196\ modula2ProcedureIdent, modula2ProcedureLowlineIdent, modula2IllegalChar, modula2IllegalIdent 197 198syn match modula2ProcedureIdent 199 \ "\( [ a-zA-Z ] \)\( [ a-zA-Z0-9 ] * \) "contained 200 201syn match modula2ProcedureLowlineIdent 202 \ "[ a-zA-Z ][ a-zA-Z0-9 ] * \(_ [ a-zA-Z0-9 ] \+\)\+ "contained 203 204syn 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 210syn keyword modula2ReswordModule contained MODULE 211syn keyword modula2ReswordProcedure contained PROCEDURE 212syn keyword modula2ReswordEnd contained END 213 214 215" ----------------------------------------------------------------------------- 216" Illegal Symbols 217" ----------------------------------------------------------------------------- 218" !!! this section must be last !!! 219 220" any '`' '!' '$' '%' or '\' 221syn match modula2IllegalChar "[ `!$%\\ ] " 222 223" any solitary sequence of '_' 224syn match modula2IllegalChar "\<_\+\> " 225 226" any '?' at start of line if not followed by '<' 227syn match modula2IllegalChar "^?\(<\)\@! " 228 229" any '?' not following '>' at start of line 230syn match modula2IllegalChar "\(\(^>\)\|\(^\)\)\@<!? " 231 232" any identifiers with leading occurrences of '_' 233syn match modula2IllegalIdent "_\+ [ a-zA-Z ][ a-zA-Z0-9 ] * \(_\+ [ a-zA-Z0-9 ] * \) * " 234 235" any identifiers containing consecutive occurences of '_' 236syn 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 '_' 240syn 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 254highlight default link modula2ConstIdentStyle Constant 255highlight default link modula2TypeIdentStyle Type 256highlight default link modula2ProcIdentStyle Function 257highlight default link modula2FuncIdentStyle Function 258highlight default link modula2MacroIdentStyle Function 259highlight default link modula2UnsafeIdentStyle Question 260highlight default link modula2NonPortableIdentStyle Question 261highlight default link modula2StringLiteralStyle String 262highlight default link modula2CommentStyle Comment 263highlight default link modula2PragmaStyle PreProc 264highlight default link modula2DialectTagStyle SpecialComment 265highlight default link modula2TechDebtMarkerStyle SpecialComment 266highlight default link modula2ReswordStyle Keyword 267highlight default link modula2HeaderIdentStyle Function 268highlight default link modula2UserDefIdentStyle Normal 269highlight default link modula2NumericLiteralStyle Number 270highlight default link modula2PunctuationStyle Delimiter 271highlight default link modula2CommentKeyStyle SpecialComment 272highlight default link modula2DisabledCodeStyle NonText 273 274" ----------------------------------------------------------------------------- 275" Assign Rendering Styles 276" ----------------------------------------------------------------------------- 277 278" headers 279highlight default link modula2ModuleIdent modula2HeaderIdentStyle 280highlight default link modula2ProcedureIdent modula2HeaderIdentStyle 281highlight default link modula2ModuleHeader Normal 282highlight default link modula2ModuleTail Normal 283highlight default link modula2ProcedureHeader Normal 284highlight default link modula2ProcedureTail Normal 285 286" lowline identifiers are rendered as errors if g:modula2_iso_allow_lowline is unset 287if exists ( "g:modula2_iso_allow_lowline" ) 288if g: modula2_iso_allow_lowline != 0 289highlight default link modula2ProcedureLowlineIdent modula2HeaderIdentStyle 290else 291highlight default link modula2ProcedureLowlineIdent Error 292endif 293else 294highlight default link modula2ProcedureLowlineIdent modula2HeaderIdentStyle 295endif 296 297" reserved words 298highlight default link modula2Resword modula2ReswordStyle 299highlight default link modula2ReswordModule modula2ReswordStyle 300highlight default link modula2ReswordProcedure modula2ReswordStyle 301highlight default link modula2ReswordEnd modula2ReswordStyle 302 303" predefined identifiers 304highlight default link modula2ConstIdent modula2ConstIdentStyle 305highlight default link modula2TypeIdent modula2TypeIdentStyle 306highlight default link modula2ProcIdent modula2ProcIdentStyle 307highlight default link modula2FuncIdent modula2FuncIdentStyle 308highlight default link modula2MacroIdent modula2MacroIdentStyle 309 310" unsafe and non-portable identifiers 311highlight default link modula2UnsafeIdent modula2UnsafeIdentStyle 312highlight default link modula2NonPortableIdent modula2NonPortableIdentStyle 313 314" user defined identifiers 315highlight default link modula2Ident modula2UserDefIdentStyle 316 317" lowline identifiers are rendered as errors if g:modula2_iso_allow_lowline is unset 318if exists ( "g:modula2_iso_allow_lowline" ) 319if g: modula2_iso_allow_lowline != 0 320highlight default link modula2LowLineIdent modula2UserDefIdentStyle 321else 322highlight default link modula2LowLineIdent Error 323endif 324else 325highlight default link modula2LowLineIdent modula2UserDefIdentStyle 326endif 327 328" literals 329highlight default link modula2String modula2StringLiteralStyle 330highlight default link modula2Num modula2NumericLiteralStyle 331 332" octal literals are rendered as errors if g:modula2_iso_disallow_octals is set 333if exists ( "g:modula2_iso_disallow_octals" ) 334if g: modula2_iso_disallow_octals != 0 335highlight default link modula2Octal Error 336else 337highlight default link modula2Octal modula2NumericLiteralStyle 338endif 339else 340highlight default link modula2Octal modula2NumericLiteralStyle 341endif 342 343" punctuation 344highlight default link modula2Punctuation modula2PunctuationStyle 345 346" synonyms & and ~ are rendered as errors if g:modula2_iso_disallow_synonyms is set 347if exists ( "g:modula2_iso_disallow_synonyms" ) 348if g: modula2_iso_disallow_synonyms != 0 349highlight default link modula2Synonym Error 350else 351highlight default link modula2Synonym modula2PunctuationStyle 352endif 353else 354highlight default link modula2Synonym modula2PunctuationStyle 355endif 356 357" pragmas 358highlight default link modula2Pragma modula2PragmaStyle 359highlight default link modula2DialectTag modula2DialectTagStyle 360 361" comments 362highlight default link modula2Comment modula2CommentStyle 363highlight default link modula2CommentKey modula2CommentKeyStyle 364 365" technical debt markers 366highlight default link modula2TechDebtMarker modula2TechDebtMarkerStyle 367 368" disabled code 369highlight default link modula2DisabledCode modula2DisabledCodeStyle 370 371" illegal symbols 372highlight default link modula2IllegalChar Error 373highlight default link modula2IllegalIdent Error 374 375 376let b: current_syntax = "modula2" 377 378" vim: ts=4 379 380" END OF FILE