7
|
1 " Vim syntax file
|
|
2 " Language: SML
|
|
3 " Filenames: *.sml *.sig
|
20
|
4 " Maintainers: Markus Mottl <markus@oefai.at>
|
|
5 " Fabrizio Zeno Cornelli <zeno@filibusta.crema.unimi.it>
|
|
6 " URL: http://www.oefai.at/~markus/vim/syntax/sml.vim
|
|
7 " Last Change: 2004 Jul 26
|
|
8 " 2001 Nov 20 - Fixed small highlighting bug with modules (MM)
|
|
9 " 2001 Aug 29 - Fixed small highlighting bug (MM)
|
7
|
10
|
|
11 " For version 5.x: Clear all syntax items
|
|
12 " For version 6.x: Quit when a syntax file was already loaded
|
|
13 if version < 600
|
|
14 syntax clear
|
|
15 elseif exists("b:current_syntax")
|
|
16 finish
|
|
17 endif
|
|
18
|
|
19 " SML is case sensitive.
|
|
20 syn case match
|
|
21
|
|
22 " lowercase identifier - the standard way to match
|
|
23 syn match smlLCIdentifier /\<\(\l\|_\)\(\w\|'\)*\>/
|
|
24
|
|
25 syn match smlKeyChar "|"
|
|
26
|
|
27 " Errors
|
|
28 syn match smlBraceErr "}"
|
|
29 syn match smlBrackErr "\]"
|
|
30 syn match smlParenErr ")"
|
|
31 syn match smlCommentErr "\*)"
|
|
32 syn match smlThenErr "\<then\>"
|
|
33
|
|
34 " Error-highlighting of "end" without synchronization:
|
|
35 " as keyword or as error (default)
|
|
36 if exists("sml_noend_error")
|
|
37 syn match smlKeyword "\<end\>"
|
|
38 else
|
|
39 syn match smlEndErr "\<end\>"
|
|
40 endif
|
|
41
|
|
42 " Some convenient clusters
|
|
43 syn cluster smlAllErrs contains=smlBraceErr,smlBrackErr,smlParenErr,smlCommentErr,smlEndErr,smlThenErr
|
|
44
|
|
45 syn cluster smlAENoParen contains=smlBraceErr,smlBrackErr,smlCommentErr,smlEndErr,smlThenErr
|
|
46
|
|
47 syn cluster smlContained contains=smlTodo,smlPreDef,smlModParam,smlModParam1,smlPreMPRestr,smlMPRestr,smlMPRestr1,smlMPRestr2,smlMPRestr3,smlModRHS,smlFuncWith,smlFuncStruct,smlModTypeRestr,smlModTRWith,smlWith,smlWithRest,smlModType,smlFullMod
|
|
48
|
|
49
|
|
50 " Enclosing delimiters
|
|
51 syn region smlEncl transparent matchgroup=smlKeyword start="(" matchgroup=smlKeyword end=")" contains=ALLBUT,@smlContained,smlParenErr
|
|
52 syn region smlEncl transparent matchgroup=smlKeyword start="{" matchgroup=smlKeyword end="}" contains=ALLBUT,@smlContained,smlBraceErr
|
|
53 syn region smlEncl transparent matchgroup=smlKeyword start="\[" matchgroup=smlKeyword end="\]" contains=ALLBUT,@smlContained,smlBrackErr
|
|
54 syn region smlEncl transparent matchgroup=smlKeyword start="#\[" matchgroup=smlKeyword end="\]" contains=ALLBUT,@smlContained,smlBrackErr
|
|
55
|
|
56
|
|
57 " Comments
|
|
58 syn region smlComment start="(\*" end="\*)" contains=smlComment,smlTodo
|
|
59 syn keyword smlTodo contained TODO FIXME XXX
|
|
60
|
|
61
|
|
62 " let
|
|
63 syn region smlEnd matchgroup=smlKeyword start="\<let\>" matchgroup=smlKeyword end="\<end\>" contains=ALLBUT,@smlContained,smlEndErr
|
|
64
|
|
65 " local
|
|
66 syn region smlEnd matchgroup=smlKeyword start="\<local\>" matchgroup=smlKeyword end="\<end\>" contains=ALLBUT,@smlContained,smlEndErr
|
|
67
|
|
68 " abstype
|
|
69 syn region smlNone matchgroup=smlKeyword start="\<abstype\>" matchgroup=smlKeyword end="\<end\>" contains=ALLBUT,@smlContained,smlEndErr
|
|
70
|
|
71 " begin
|
|
72 syn region smlEnd matchgroup=smlKeyword start="\<begin\>" matchgroup=smlKeyword end="\<end\>" contains=ALLBUT,@smlContained,smlEndErr
|
|
73
|
|
74 " if
|
|
75 syn region smlNone matchgroup=smlKeyword start="\<if\>" matchgroup=smlKeyword end="\<then\>" contains=ALLBUT,@smlContained,smlThenErr
|
|
76
|
|
77
|
|
78 "" Modules
|
|
79
|
|
80 " "struct"
|
|
81 syn region smlStruct matchgroup=smlModule start="\<struct\>" matchgroup=smlModule end="\<end\>" contains=ALLBUT,@smlContained,smlEndErr
|
|
82
|
|
83 " "sig"
|
|
84 syn region smlSig matchgroup=smlModule start="\<sig\>" matchgroup=smlModule end="\<end\>" contains=ALLBUT,@smlContained,smlEndErr,smlModule
|
|
85 syn region smlModSpec matchgroup=smlKeyword start="\<structure\>" matchgroup=smlModule end="\<\u\(\w\|'\)*\>" contained contains=@smlAllErrs,smlComment skipwhite skipempty nextgroup=smlModTRWith,smlMPRestr
|
|
86
|
|
87 " "open"
|
|
88 syn region smlNone matchgroup=smlKeyword start="\<open\>" matchgroup=smlModule end="\<\u\(\w\|'\)*\(\.\u\(\w\|'\)*\)*\>" contains=@smlAllErrs,smlComment
|
|
89
|
|
90 " "structure" - somewhat complicated stuff ;-)
|
|
91 syn region smlModule matchgroup=smlKeyword start="\<\(structure\|functor\)\>" matchgroup=smlModule end="\<\u\(\w\|'\)*\>" contains=@smlAllErrs,smlComment skipwhite skipempty nextgroup=smlPreDef
|
|
92 syn region smlPreDef start="."me=e-1 matchgroup=smlKeyword end="\l\|="me=e-1 contained contains=@smlAllErrs,smlComment,smlModParam,smlModTypeRestr,smlModTRWith nextgroup=smlModPreRHS
|
|
93 syn region smlModParam start="([^*]" end=")" contained contains=@smlAENoParen,smlModParam1
|
|
94 syn match smlModParam1 "\<\u\(\w\|'\)*\>" contained skipwhite skipempty nextgroup=smlPreMPRestr
|
|
95
|
|
96 syn region smlPreMPRestr start="."me=e-1 end=")"me=e-1 contained contains=@smlAllErrs,smlComment,smlMPRestr,smlModTypeRestr
|
|
97
|
|
98 syn region smlMPRestr start=":" end="."me=e-1 contained contains=@smlComment skipwhite skipempty nextgroup=smlMPRestr1,smlMPRestr2,smlMPRestr3
|
|
99 syn region smlMPRestr1 matchgroup=smlModule start="\ssig\s\=" matchgroup=smlModule end="\<end\>" contained contains=ALLBUT,@smlContained,smlEndErr,smlModule
|
|
100 syn region smlMPRestr2 start="\sfunctor\(\s\|(\)\="me=e-1 matchgroup=smlKeyword end="->" contained contains=@smlAllErrs,smlComment,smlModParam skipwhite skipempty nextgroup=smlFuncWith
|
|
101 syn match smlMPRestr3 "\w\(\w\|'\)*\(\.\w\(\w\|'\)*\)*" contained
|
|
102 syn match smlModPreRHS "=" contained skipwhite skipempty nextgroup=smlModParam,smlFullMod
|
|
103 syn region smlModRHS start="." end=".\w\|([^*]"me=e-2 contained contains=smlComment skipwhite skipempty nextgroup=smlModParam,smlFullMod
|
|
104 syn match smlFullMod "\<\u\(\w\|'\)*\(\.\u\(\w\|'\)*\)*" contained skipwhite skipempty nextgroup=smlFuncWith
|
|
105
|
|
106 syn region smlFuncWith start="([^*]"me=e-1 end=")" contained contains=smlComment,smlWith,smlFuncStruct
|
|
107 syn region smlFuncStruct matchgroup=smlModule start="[^a-zA-Z]struct\>"hs=s+1 matchgroup=smlModule end="\<end\>" contains=ALLBUT,@smlContained,smlEndErr
|
|
108
|
|
109 syn match smlModTypeRestr "\<\w\(\w\|'\)*\(\.\w\(\w\|'\)*\)*\>" contained
|
|
110 syn region smlModTRWith start=":\s*("hs=s+1 end=")" contained contains=@smlAENoParen,smlWith
|
|
111 syn match smlWith "\<\(\u\(\w\|'\)*\.\)*\w\(\w\|'\)*\>" contained skipwhite skipempty nextgroup=smlWithRest
|
|
112 syn region smlWithRest start="[^)]" end=")"me=e-1 contained contains=ALLBUT,@smlContained
|
|
113
|
|
114 " "signature"
|
|
115 syn region smlKeyword start="\<signature\>" matchgroup=smlModule end="\<\w\(\w\|'\)*\>" contains=smlComment skipwhite skipempty nextgroup=smlMTDef
|
|
116 syn match smlMTDef "=\s*\w\(\w\|'\)*\>"hs=s+1,me=s
|
|
117
|
|
118 syn keyword smlKeyword and andalso case
|
|
119 syn keyword smlKeyword datatype else eqtype
|
|
120 syn keyword smlKeyword exception fn fun handle
|
|
121 syn keyword smlKeyword in infix infixl infixr
|
|
122 syn keyword smlKeyword match nonfix of orelse
|
|
123 syn keyword smlKeyword raise handle type
|
|
124 syn keyword smlKeyword val where while with withtype
|
|
125
|
|
126 syn keyword smlType bool char exn int list option
|
|
127 syn keyword smlType real string unit
|
|
128
|
|
129 syn keyword smlOperator div mod not or quot rem
|
|
130
|
|
131 syn keyword smlBoolean true false
|
|
132 syn match smlConstructor "(\s*)"
|
|
133 syn match smlConstructor "\[\s*\]"
|
|
134 syn match smlConstructor "#\[\s*\]"
|
|
135 syn match smlConstructor "\u\(\w\|'\)*\>"
|
|
136
|
|
137 " Module prefix
|
|
138 syn match smlModPath "\u\(\w\|'\)*\."he=e-1
|
|
139
|
|
140 syn match smlCharacter +#"."\|#"\\\d\d\d"+
|
|
141 syn match smlCharErr +#"\\\d\d"\|#"\\\d"+
|
|
142 syn region smlString start=+"+ skip=+\\\\\|\\"+ end=+"+
|
|
143
|
|
144 syn match smlFunDef "=>"
|
|
145 syn match smlRefAssign ":="
|
|
146 syn match smlTopStop ";;"
|
|
147 syn match smlOperator "\^"
|
|
148 syn match smlOperator "::"
|
|
149 syn match smlAnyVar "\<_\>"
|
|
150 syn match smlKeyChar "!"
|
|
151 syn match smlKeyChar ";"
|
|
152 syn match smlKeyChar "\*"
|
|
153 syn match smlKeyChar "="
|
|
154
|
|
155 syn match smlNumber "\<-\=\d\+\>"
|
|
156 syn match smlNumber "\<-\=0[x|X]\x\+\>"
|
|
157 syn match smlReal "\<-\=\d\+\.\d*\([eE][-+]\=\d\+\)\=[fl]\=\>"
|
|
158
|
|
159 " Synchronization
|
|
160 syn sync minlines=20
|
|
161 syn sync maxlines=500
|
|
162
|
|
163 syn sync match smlEndSync grouphere smlEnd "\<begin\>"
|
|
164 syn sync match smlEndSync groupthere smlEnd "\<end\>"
|
|
165 syn sync match smlStructSync grouphere smlStruct "\<struct\>"
|
|
166 syn sync match smlStructSync groupthere smlStruct "\<end\>"
|
|
167 syn sync match smlSigSync grouphere smlSig "\<sig\>"
|
|
168 syn sync match smlSigSync groupthere smlSig "\<end\>"
|
|
169
|
|
170 " Define the default highlighting.
|
|
171 " For version 5.7 and earlier: only when not done already
|
|
172 " For version 5.8 and later: only when an item doesn't have highlighting yet
|
|
173 if version >= 508 || !exists("did_sml_syntax_inits")
|
|
174 if version < 508
|
|
175 let did_sml_syntax_inits = 1
|
|
176 command -nargs=+ HiLink hi link <args>
|
|
177 else
|
|
178 command -nargs=+ HiLink hi def link <args>
|
|
179 endif
|
|
180
|
|
181 HiLink smlBraceErr Error
|
|
182 HiLink smlBrackErr Error
|
|
183 HiLink smlParenErr Error
|
|
184
|
|
185 HiLink smlCommentErr Error
|
|
186
|
|
187 HiLink smlEndErr Error
|
|
188 HiLink smlThenErr Error
|
|
189
|
|
190 HiLink smlCharErr Error
|
|
191
|
|
192 HiLink smlComment Comment
|
|
193
|
|
194 HiLink smlModPath Include
|
|
195 HiLink smlModule Include
|
|
196 HiLink smlModParam1 Include
|
|
197 HiLink smlModType Include
|
|
198 HiLink smlMPRestr3 Include
|
|
199 HiLink smlFullMod Include
|
|
200 HiLink smlModTypeRestr Include
|
|
201 HiLink smlWith Include
|
|
202 HiLink smlMTDef Include
|
|
203
|
|
204 HiLink smlConstructor Constant
|
|
205
|
|
206 HiLink smlModPreRHS Keyword
|
|
207 HiLink smlMPRestr2 Keyword
|
|
208 HiLink smlKeyword Keyword
|
|
209 HiLink smlFunDef Keyword
|
|
210 HiLink smlRefAssign Keyword
|
|
211 HiLink smlKeyChar Keyword
|
|
212 HiLink smlAnyVar Keyword
|
|
213 HiLink smlTopStop Keyword
|
|
214 HiLink smlOperator Keyword
|
|
215
|
|
216 HiLink smlBoolean Boolean
|
|
217 HiLink smlCharacter Character
|
|
218 HiLink smlNumber Number
|
|
219 HiLink smlReal Float
|
|
220 HiLink smlString String
|
|
221 HiLink smlType Type
|
|
222 HiLink smlTodo Todo
|
|
223 HiLink smlEncl Keyword
|
|
224
|
|
225 delcommand HiLink
|
|
226 endif
|
|
227
|
|
228 let b:current_syntax = "sml"
|
|
229
|
|
230 " vim: ts=8
|