blob: 67243db600662c39904a012084443fbf6487940c [file] [log] [blame]
Bram Moolenaar071d4272004-06-13 20:20:40 +00001" Vim syntax file
Bram Moolenaar56994d22021-04-17 16:31:09 +02002" Language: Modula-3
3" Maintainer: Doug Kearns <dougkearns@gmail.com>
4" Previous Maintainer: Timo Pedersen <dat97tpe@ludat.lth.se>
Bram Moolenaar76db9e02022-11-09 21:21:04 +00005" Last Change: 2022 Oct 31
Bram Moolenaar071d4272004-06-13 20:20:40 +00006
Bram Moolenaar89bcfda2016-08-30 23:26:57 +02007if exists("b:current_syntax")
Bram Moolenaar071d4272004-06-13 20:20:40 +00008 finish
9endif
10
Bram Moolenaar76db9e02022-11-09 21:21:04 +000011" Whitespace errors {{{1
12if 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
19endif
20
21" Keywords {{{1
22syn keyword modula3Keyword ANY ARRAY AS BITS BRANDED BY CASE CONST
23syn keyword modula3Keyword DEFINITION EVAL EXIT EXCEPT EXCEPTION EXIT
24syn keyword modula3Keyword EXPORTS FINALLY FROM GENERIC IMPORT LOCK METHOD
25syn keyword modula3Keyword OF RAISE RAISES READONLY RECORD REF
26syn keyword modula3Keyword RETURN SET TRY TYPE TYPECASE UNSAFE
27syn keyword modula3Keyword VALUE VAR WITH
Bram Moolenaar56994d22021-04-17 16:31:09 +020028
29syn match modula3keyword "\<UNTRACED\>"
Bram Moolenaar071d4272004-06-13 20:20:40 +000030
31" Special keywords, block delimiters etc
32syn keyword modula3Block PROCEDURE FUNCTION MODULE INTERFACE REPEAT THEN
33syn keyword modula3Block BEGIN END OBJECT METHODS OVERRIDES RECORD REVEAL
34syn keyword modula3Block WHILE UNTIL DO TO IF FOR ELSIF ELSE LOOP
35
Bram Moolenaar76db9e02022-11-09 21:21:04 +000036" Reserved identifiers {{{1
Bram Moolenaar56994d22021-04-17 16:31:09 +020037syn keyword modula3Identifier ABS ADR ADRSIZE BITSIZE BYTESIZE CEILING DEC
38syn keyword modula3Identifier DISPOSE FIRST FLOAT FLOOR INC ISTYPE LAST
39syn keyword modula3Identifier LOOPHOLE MAX MIN NARROW NEW NUMBER ORD ROUND
40syn keyword modula3Identifier SUBARRAY TRUNC TYPECODE VAL
41
Bram Moolenaar76db9e02022-11-09 21:21:04 +000042" Predefined types {{{1
Bram Moolenaar56994d22021-04-17 16:31:09 +020043syn keyword modula3Type ADDRESS BOOLEAN CARDINAL CHAR EXTENDED INTEGER
44syn keyword modula3Type LONGCARD LONGINT LONGREAL MUTEX NULL REAL REFANY TEXT
45syn keyword modula3Type WIDECHAR
46
47syn match modula3Type "\<\%(UNTRACED\s\+\)\=ROOT\>"
48
Bram Moolenaar76db9e02022-11-09 21:21:04 +000049" Operators {{{1
50syn keyword modula3Operator DIV MOD
51syn keyword modula3Operator IN
52syn keyword modula3Operator NOT AND OR
Bram Moolenaar56994d22021-04-17 16:31:09 +020053
Bram Moolenaar76db9e02022-11-09 21:21:04 +000054" TODO: exclude = from declarations
Bram Moolenaar56994d22021-04-17 16:31:09 +020055if exists("modula3_operators")
56 syn match modula3Operator "\^"
Bram Moolenaar76db9e02022-11-09 21:21:04 +000057 syn match modula3Operator "[-+/*]"
58 syn match modula3Operator "&"
59 syn match modula3Operator "<=\|<:\@!\|>=\|>"
60 syn match modula3Operator ":\@<!=\|#"
Bram Moolenaar56994d22021-04-17 16:31:09 +020061endif
62
Bram Moolenaar76db9e02022-11-09 21:21:04 +000063" Literals {{{1
64
Bram Moolenaar56994d22021-04-17 16:31:09 +020065" Booleans
66syn keyword modula3Boolean TRUE FALSE
67
68" Nil
69syn keyword modula3Nil NIL
70
Bram Moolenaar76db9e02022-11-09 21:21:04 +000071" Numbers {{{2
Bram Moolenaar56994d22021-04-17 16:31:09 +020072
Bram Moolenaar76db9e02022-11-09 21:21:04 +000073" NOTE: Negated numbers are constant expressions not literals
74
75syn 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
94syn case match
95
96" Strings and characters {{{2
Bram Moolenaar56994d22021-04-17 16:31:09 +020097
98" String escape sequences
99syn match modula3Escape "\\['"ntrf]" contained display
Bram Moolenaar76db9e02022-11-09 21:21:04 +0000100" TODO: limit to <= 377 (255)
Bram Moolenaar56994d22021-04-17 16:31:09 +0200101syn match modula3Escape "\\\o\{3}" contained display
102syn match modula3Escape "\\\\" contained display
103
104" Characters
105syn match modula3Character "'\%([^']\|\\.\|\\\o\{3}\)'" contains=modula3Escape
Bram Moolenaar071d4272004-06-13 20:20:40 +0000106
107" Strings
Bram Moolenaar56994d22021-04-17 16:31:09 +0200108syn region modula3String start=+"+ end=+"+ contains=modula3Escape
Bram Moolenaar071d4272004-06-13 20:20:40 +0000109
Bram Moolenaar76db9e02022-11-09 21:21:04 +0000110" 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
Bram Moolenaar56994d22021-04-17 16:31:09 +0200113syn region modula3Pragma start="<\*" end="\*>"
Bram Moolenaar071d4272004-06-13 20:20:40 +0000114
Bram Moolenaar76db9e02022-11-09 21:21:04 +0000115" Comments {{{1
116if !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
119else
120 syn region modula3Comment start="(\*" end="\*)" contains=modula3Comment,@Spell
121endif
Bram Moolenaar56994d22021-04-17 16:31:09 +0200122
Bram Moolenaar76db9e02022-11-09 21:21:04 +0000123" Syncing "{{{1
124syn sync minlines=100
125
126" Default highlighting {{{1
Bram Moolenaar56994d22021-04-17 16:31:09 +0200127hi def link modula3Block Statement
128hi def link modula3Boolean Boolean
129hi def link modula3Character Character
Bram Moolenaarf37506f2016-08-31 22:22:10 +0200130hi def link modula3Comment Comment
Bram Moolenaar56994d22021-04-17 16:31:09 +0200131hi def link modula3Escape Special
132hi def link modula3Identifier Keyword
133hi def link modula3Integer Number
134hi def link modula3Keyword Statement
135hi def link modula3Nil Constant
Bram Moolenaar76db9e02022-11-09 21:21:04 +0000136hi def link modula3IntegerError Error
Bram Moolenaar56994d22021-04-17 16:31:09 +0200137hi def link modula3Operator Operator
138hi def link modula3Pragma PreProc
139hi def link modula3Real Float
140hi def link modula3String String
Bram Moolenaar76db9e02022-11-09 21:21:04 +0000141hi def link modula3Type Type "}}}
Bram Moolenaar071d4272004-06-13 20:20:40 +0000142
143let b:current_syntax = "modula3"
144
Bram Moolenaar76db9e02022-11-09 21:21:04 +0000145" vim: nowrap sw=2 sts=2 ts=8 noet fdm=marker: