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