robin/laufey

git clone https://git.robinwobin.dev/robin/laufey

zeertzjqMerge pull request #23105 from zeertzjq/vim-8.2.477062b7b1daf3

master
4.4 KiB145 linesraw
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
7if exists("b:current_syntax")
8  finish
9endif
10
11" 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
28
29syn match modula3keyword "\<UNTRACED\>"
30
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
36" Reserved identifiers {{{1
37syn 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
42" Predefined types {{{1
43syn 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
49" Operators {{{1
50syn keyword modula3Operator DIV MOD
51syn keyword modula3Operator IN
52syn keyword modula3Operator NOT AND OR
53
54" TODO: exclude = from declarations
55if exists("modula3_operators")
56  syn match modula3Operator "\^"
57  syn match modula3Operator "[-+/*]"
58  syn match modula3Operator "&"
59  syn match modula3Operator "<=\|<:\@!\|>=\|>"
60  syn match modula3Operator ":\@<!=\|#"
61endif
62
63" Literals {{{1
64
65" Booleans
66syn keyword modula3Boolean TRUE FALSE
67
68" Nil
69syn keyword modula3Nil NIL
70
71" Numbers {{{2
72
73" 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
97
98" String escape sequences
99syn match modula3Escape "\\['"ntrf]" contained display
100" TODO: limit to <= 377 (255)
101syn match modula3Escape "\\\o\{3}"   contained display
102syn match modula3Escape "\\\\"	     contained display
103
104" Characters
105syn match modula3Character "'\%([^']\|\\.\|\\\o\{3}\)'" contains=modula3Escape
106
107" Strings
108syn 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
113syn region modula3Pragma start="<\*" end="\*>"
114
115" 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
122
123" Syncing "{{{1
124syn sync minlines=100
125
126" Default highlighting {{{1
127hi def link modula3Block	Statement
128hi def link modula3Boolean	Boolean
129hi def link modula3Character	Character
130hi def link modula3Comment	Comment
131hi def link modula3Escape	Special
132hi def link modula3Identifier	Keyword
133hi def link modula3Integer	Number
134hi def link modula3Keyword	Statement
135hi def link modula3Nil		Constant
136hi def link modula3IntegerError	Error
137hi def link modula3Operator	Operator
138hi def link modula3Pragma	PreProc
139hi def link modula3Real		Float
140hi def link modula3String	String
141hi def link modula3Type		Type		"}}}
142
143let b:current_syntax = "modula3"
144
145" vim: nowrap sw=2 sts=2 ts=8 noet fdm=marker: