modula3.vim (4536B)
1 " Vim syntax file 2 " Language: Modula-3 3 " Maintainer: Doug Kearns <dougkearns@gmail.com> 4 " Previous Maintainer: Timo Pedersen <dat97tpe@ludat.lth.se> 5 " Last Change: 2022 Oct 31 6 7 if exists("b:current_syntax") 8 finish 9 endif 10 11 " Whitespace errors {{{1 12 if exists("modula3_space_errors") 13 if !exists("modula3_no_trail_space_error") 14 syn match modula3SpaceError display excludenl "\s\+$" 15 endif 16 if !exists("modula3_no_tab_space_error") 17 syn match modula3SpaceError display " \+\t"me=e-1 18 endif 19 endif 20 21 " Keywords {{{1 22 syn keyword modula3Keyword ANY ARRAY AS BITS BRANDED BY CASE CONST 23 syn keyword modula3Keyword DEFINITION EVAL EXIT EXCEPT EXCEPTION EXIT 24 syn keyword modula3Keyword EXPORTS FINALLY FROM GENERIC IMPORT LOCK METHOD 25 syn keyword modula3Keyword OF RAISE RAISES READONLY RECORD REF 26 syn keyword modula3Keyword RETURN SET TRY TYPE TYPECASE UNSAFE 27 syn keyword modula3Keyword VALUE VAR WITH 28 29 syn match modula3keyword "\<UNTRACED\>" 30 31 " Special keywords, block delimiters etc 32 syn keyword modula3Block PROCEDURE FUNCTION MODULE INTERFACE REPEAT THEN 33 syn keyword modula3Block BEGIN END OBJECT METHODS OVERRIDES RECORD REVEAL 34 syn keyword modula3Block WHILE UNTIL DO TO IF FOR ELSIF ELSE LOOP 35 36 " Reserved identifiers {{{1 37 syn keyword modula3Identifier ABS ADR ADRSIZE BITSIZE BYTESIZE CEILING DEC 38 syn keyword modula3Identifier DISPOSE FIRST FLOAT FLOOR INC ISTYPE LAST 39 syn keyword modula3Identifier LOOPHOLE MAX MIN NARROW NEW NUMBER ORD ROUND 40 syn keyword modula3Identifier SUBARRAY TRUNC TYPECODE VAL 41 42 " Predefined types {{{1 43 syn keyword modula3Type ADDRESS BOOLEAN CARDINAL CHAR EXTENDED INTEGER 44 syn keyword modula3Type LONGCARD LONGINT LONGREAL MUTEX NULL REAL REFANY TEXT 45 syn keyword modula3Type WIDECHAR 46 47 syn match modula3Type "\<\%(UNTRACED\s\+\)\=ROOT\>" 48 49 " Operators {{{1 50 syn keyword modula3Operator DIV MOD 51 syn keyword modula3Operator IN 52 syn keyword modula3Operator NOT AND OR 53 54 " TODO: exclude = from declarations 55 if exists("modula3_operators") 56 syn match modula3Operator "\^" 57 syn match modula3Operator "[-+/*]" 58 syn match modula3Operator "&" 59 syn match modula3Operator "<=\|<:\@!\|>=\|>" 60 syn match modula3Operator ":\@<!=\|#" 61 endif 62 63 " Literals {{{1 64 65 " Booleans 66 syn keyword modula3Boolean TRUE FALSE 67 68 " Nil 69 syn keyword modula3Nil NIL 70 71 " Numbers {{{2 72 73 " NOTE: Negated numbers are constant expressions not literals 74 75 syn case ignore 76 77 " Integers 78 79 syn match modula3Integer "\<\d\+L\=\>" 80 81 if exists("modula3_number_errors") 82 syn match modula3IntegerError "\<\d\d\=_\x\+L\=\>" 83 endif 84 85 let s:digits = "0123456789ABCDEF" 86 for s:radix in range(2, 16) 87 exe $'syn match modula3Integer "\<{s:radix}_[{s:digits[:s:radix - 1]}]\+L\=\>"' 88 endfor 89 unlet s:digits s:radix 90 91 " Reals 92 syn match modula3Real "\<\d\+\.\d\+\%([EDX][+-]\=\d\+\)\=\>" 93 94 syn case match 95 96 " Strings and characters {{{2 97 98 " String escape sequences 99 syn match modula3Escape "\\['"ntrf]" contained display 100 " TODO: limit to <= 377 (255) 101 syn match modula3Escape "\\\o\{3}" contained display 102 syn match modula3Escape "\\\\" contained display 103 104 " Characters 105 syn match modula3Character "'\%([^']\|\\.\|\\\o\{3}\)'" contains=modula3Escape 106 107 " Strings 108 syn region modula3String start=+"+ end=+"+ contains=modula3Escape 109 110 " Pragmas {{{1 111 " EXTERNAL INLINE ASSERT TRACE FATAL UNUSED OBSOLETE CALLBACK EXPORTED PRAGMA NOWARN LINE LL LL.sup SPEC 112 " Documented: INLINE ASSERT TRACE FATAL UNUSED OBSOLETE NOWARN 113 syn region modula3Pragma start="<\*" end="\*>" 114 115 " Comments {{{1 116 if !exists("modula3_no_comment_fold") 117 syn region modula3Comment start="(\*" end="\*)" contains=modula3Comment,@Spell fold 118 syn region modula3LineCommentBlock start="^\s*(\*.*\*)\s*\n\%(^\s*(\*.*\*)\s*$\)\@=" end="^\s*(\*.*\*)\s*\n\%(^\s*(\*.*\*)\s*$\)\@!" contains=modula3Comment transparent fold keepend 119 else 120 syn region modula3Comment start="(\*" end="\*)" contains=modula3Comment,@Spell 121 endif 122 123 " Syncing "{{{1 124 syn sync minlines=100 125 126 " Default highlighting {{{1 127 hi def link modula3Block Statement 128 hi def link modula3Boolean Boolean 129 hi def link modula3Character Character 130 hi def link modula3Comment Comment 131 hi def link modula3Escape Special 132 hi def link modula3Identifier Keyword 133 hi def link modula3Integer Number 134 hi def link modula3Keyword Statement 135 hi def link modula3Nil Constant 136 hi def link modula3IntegerError Error 137 hi def link modula3Operator Operator 138 hi def link modula3Pragma PreProc 139 hi def link modula3Real Float 140 hi def link modula3String String 141 hi def link modula3Type Type "}}} 142 143 let b:current_syntax = "modula3" 144 145 " vim: nowrap sw=2 sts=2 ts=8 noet fdm=marker: