blob: c51850b13ad70d3919393c5acedad600ea9fb54e [file] [log] [blame]
Bram Moolenaar071d4272004-06-13 20:20:40 +00001" Vim syntax file
Bram Moolenaar5eb86f92004-07-26 12:53:41 +00002" Language: IDL (Interface Description Language)
Bram Moolenaar9e54a0e2006-04-14 20:42:25 +00003" Created By: Jody Goldberg
4" Maintainer: Michael Geddes <vim@frog.wheelycreek.net>
Bram Moolenaar6be7f872012-01-20 21:08:56 +01005" Last Change: 2012 Jan 11
Bram Moolenaar9e54a0e2006-04-14 20:42:25 +00006
Bram Moolenaar071d4272004-06-13 20:20:40 +00007
8" This is an experiment. IDL's structure is simple enough to permit a full
9" grammar based approach to rather than using a few heuristics. The result
10" is large and somewhat repetative but seems to work.
11
Bram Moolenaar5eb86f92004-07-26 12:53:41 +000012" There are some Microsoft extensions to idl files that are here. Some of
13" them are disabled by defining idl_no_ms_extensions.
14"
15" The more complex of the extensions are disabled by defining idl_no_extensions.
16"
Bram Moolenaar9e54a0e2006-04-14 20:42:25 +000017" History:
18" 2.0: Michael's new version
19" 2.1: Support for Vim 7 spell (Anduin Withers)
Bram Moolenaar6be7f872012-01-20 21:08:56 +010020"
Bram Moolenaar5eb86f92004-07-26 12:53:41 +000021
22if exists("b:current_syntax")
Bram Moolenaar071d4272004-06-13 20:20:40 +000023 finish
24endif
25
Bram Moolenaar6be7f872012-01-20 21:08:56 +010026let s:cpo_save = &cpo
27try
28 set cpo&vim
Bram Moolenaar5eb86f92004-07-26 12:53:41 +000029
30 if exists("idlsyntax_showerror")
Bram Moolenaar6be7f872012-01-20 21:08:56 +010031 syn match idlError +\S+ skipwhite skipempty nextgroup=idlError
Bram Moolenaar071d4272004-06-13 20:20:40 +000032 endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000033
Bram Moolenaar6be7f872012-01-20 21:08:56 +010034 syn region idlCppQuote start='\<cpp_quote\s*(' end=')' contains=idlString
Bram Moolenaar071d4272004-06-13 20:20:40 +000035
Bram Moolenaar6be7f872012-01-20 21:08:56 +010036 " Misc basic
37 syn match idlId contained "[a-zA-Z][a-zA-Z0-9_]*" skipwhite skipempty nextgroup=idlEnumComma,idlEnumNumber
38 syn match idlEnumComma contained ","
39 syn match idlEnumNumber contained "=" skipwhite skipempty nextgroup=idlString,idlLiteral
40 syn match idlSemiColon contained ";"
41 syn match idlCommaArg contained "," skipempty skipwhite nextgroup=idlSimpDecl
42 syn region idlArraySize1 contained start=:\[: end=:\]: skipempty skipwhite nextgroup=idlArraySize1,idlError,idlSemiColon,idlCommaArg contains=idlArraySize1,idlLiteral
43 syn match idlSimpDecl contained "[a-zA-Z][a-zA-Z0-9_]*" skipempty skipwhite nextgroup=idlError,idlSemiColon,idlCommaArg,idlArraySize1
44 syn region idlString contained start=+"+ skip=+\\\(\\\\\)*"+ end=+"+ contains=@Spell
45 syn match idlLiteral contained "[1-9]\d*\(\.\d*\)\="
46 syn match idlLiteral contained "0"
47 syn match idlLiteral contained "\.\d\+"
48 syn match idlLiteral contained "0x[0-9A-Fa-f]\+"
49 syn match idlLiteral contained "0[0-7]\+"
50 syn keyword idlLiteral contained TRUE FALSE
51
52 " Comments
53 syn keyword idlTodo contained TODO FIXME XXX
54 syn region idlComment start="/\*" end="\*/" contains=idlTodo,@Spell
55 syn match idlComment "//.*" contains=idlTodo,@Spell
56 syn match idlCommentError "\*/"
57
58 " C style Preprocessor
59 syn region idlIncluded contained start=+"+ skip=+\\\(\\\\\)*"+ end=+"+
60 syn match idlIncluded contained "<[^>]*>"
61 syn match idlInclude "^[ \t]*#[ \t]*include\>[ \t]*["<]" contains=idlIncluded,idlString
62 syn region idlPreCondit start="^[ \t]*#[ \t]*\(if\>\|ifdef\>\|ifndef\>\|elif\>\|else\>\|endif\>\)" skip="\\$" end="$" contains=idlComment,idlCommentError
63 syn region idlDefine start="^[ \t]*#[ \t]*\(define\>\|undef\>\)" skip="\\$" end="$" contains=idlLiteral,idlString
64
65 " Constants
66 syn keyword idlConst const skipempty skipwhite nextgroup=idlBaseType,idlBaseTypeInt
67
68 " Attribute
69 syn keyword idlROAttr readonly skipempty skipwhite nextgroup=idlAttr
70 syn keyword idlAttr attribute skipempty skipwhite nextgroup=idlBaseTypeInt,idlBaseType
71
72 " Types
73 syn region idlD4 contained start="<" end=">" skipempty skipwhite nextgroup=idlSimpDecl contains=idlSeqType,idlBaseTypeInt,idlBaseType,idlLiteral
74 syn keyword idlSeqType contained sequence skipempty skipwhite nextgroup=idlD4
75 syn keyword idlBaseType contained float double char boolean octet any skipempty skipwhite nextgroup=idlSimpDecl
76 syn keyword idlBaseTypeInt contained short long skipempty skipwhite nextgroup=idlSimpDecl
77 syn keyword idlBaseType contained unsigned skipempty skipwhite nextgroup=idlBaseTypeInt
78 syn region idlD1 contained start="<" end=">" skipempty skipwhite nextgroup=idlSimpDecl contains=idlString,idlLiteral
79 syn keyword idlBaseType contained string skipempty skipwhite nextgroup=idlD1,idlSimpDecl
80 syn match idlBaseType contained "[a-zA-Z0-9_]\+[ \t]*\(::[ \t]*[a-zA-Z0-9_]\+\)*" skipempty skipwhite nextgroup=idlSimpDecl
81
82 " Modules
83 syn region idlModuleContent contained start="{" end="}" skipempty skipwhite nextgroup=idlError,idlSemiColon contains=idlUnion,idlStruct,idlEnum,idlInterface,idlComment,idlTypedef,idlConst,idlException,idlModule
84 syn match idlModuleName contained "[a-zA-Z0-9_]\+" skipempty skipwhite nextgroup=idlModuleContent,idlError,idlSemiColon
85 syn keyword idlModule module skipempty skipwhite nextgroup=idlModuleName
86
87 " Interfaces
88 syn cluster idlCommentable contains=idlComment
89 syn cluster idlContentCluster contains=idlUnion,idlStruct,idlEnum,idlROAttr,idlAttr,idlOp,idlOneWayOp,idlException,idlConst,idlTypedef,idlAttributes,idlErrorSquareBracket,idlErrorBracket,idlInterfaceSections
90
91 syn region idlInterfaceContent contained start="{" end="}" skipempty skipwhite nextgroup=idlError,idlSemiColon contains=@idlContentCluster,@idlCommentable
92 syn match idlInheritFrom2 contained "," skipempty skipwhite nextgroup=idlInheritFrom
93 syn match idlInheritFrom contained "[a-zA-Z0-9_]\+[ \t]*\(::[ \t]*[a-zA-Z0-9_]\+\)*" skipempty skipwhite nextgroup=idlInheritFrom2,idlInterfaceContent
94 syn match idlInherit contained ":" skipempty skipwhite nextgroup=idlInheritFrom
95 syn match idlInterfaceName contained "[a-zA-Z0-9_]\+" skipempty skipwhite nextgroup=idlInterfaceContent,idlInherit,idlError,idlSemiColon
96 syn keyword idlInterface interface dispinterface skipempty skipwhite nextgroup=idlInterfaceName
97 syn keyword idlInterfaceSections contained properties methods skipempty skipwhite nextgroup=idlSectionColon,idlError
98 syn match idlSectionColon contained ":"
99
100
101 syn match idlLibraryName contained "[a-zA-Z0-9_]\+" skipempty skipwhite nextgroup=idlLibraryContent,idlError,idlSemiColon
102 syn keyword idlLibrary library skipempty skipwhite nextgroup=idlLibraryName
103 syn region idlLibraryContent contained start="{" end="}" skipempty skipwhite nextgroup=idlError,idlSemiColon contains=@idlCommentable,idlAttributes,idlErrorSquareBracket,idlErrorBracket,idlImportlib,idlCoclass,idlTypedef,idlInterface
104
105 syn keyword idlImportlib contained importlib skipempty skipwhite nextgroup=idlStringArg
106 syn region idlStringArg contained start="(" end=")" contains=idlString nextgroup=idlError,idlSemiColon,idlErrorBrace,idlErrorSquareBracket
107
108 syn keyword idlCoclass coclass contained skipempty skipwhite nextgroup=idlCoclassName
109 syn match idlCoclassName "[a-zA-Z0-9_]\+" contained skipempty skipwhite nextgroup=idlCoclassDefinition,idlError,idlSemiColon
110
111 syn region idlCoclassDefinition contained start="{" end="}" contains=idlCoclassAttributes,idlInterface,idlErrorBracket,idlErrorSquareBracket skipempty skipwhite nextgroup=idlError,idlSemiColon
112 syn region idlCoclassAttributes contained start=+\[+ end=+]+ skipempty skipwhite nextgroup=idlInterface contains=idlErrorBracket,idlErrorBrace,idlCoclassAttribute
113 syn keyword idlCoclassAttribute contained default source
114 "syn keyword idlInterface interface skipempty skipwhite nextgroup=idlInterfaceStubName
115
116 syn match idlImportString +"\f\+"+ skipempty skipwhite nextgroup=idlError,idlSemiColon
117 syn keyword idlImport import skipempty skipwhite nextgroup=idlImportString
118
119 syn region idlAttributes start="\[" end="\]" contains=idlAttribute,idlAttributeParam,idlErrorBracket,idlErrorBrace,idlComment
120 syn keyword idlAttribute contained propput propget propputref id helpstring object uuid pointer_default
121 if !exists('idl_no_ms_extensions')
122 syn keyword idlAttribute contained nonextensible dual version aggregatable restricted hidden noncreatable oleautomation
123 endif
124 syn region idlAttributeParam contained start="(" end=")" contains=idlString,idlUuid,idlLiteral,idlErrorBrace,idlErrorSquareBracket
125 " skipwhite nextgroup=idlArraySize,idlParmList contains=idlArraySize,idlLiteral
126 syn match idlErrorBrace contained "}"
127 syn match idlErrorBracket contained ")"
128 syn match idlErrorSquareBracket contained "\]"
129
130 syn match idlUuid contained +[0-9a-zA-Z]\{8}-\([0-9a-zA-Z]\{4}-\)\{3}[0-9a-zA-Z]\{12}+
131
132 " Raises
133 syn keyword idlRaises contained raises skipempty skipwhite nextgroup=idlRaises,idlContext,idlError,idlSemiColon
134
135 " Context
136 syn keyword idlContext contained context skipempty skipwhite nextgroup=idlRaises,idlContext,idlError,idlSemiColon
137
138 " Operation
139 syn match idlParmList contained "," skipempty skipwhite nextgroup=idlOpParms
140 syn region idlArraySize contained start="\[" end="\]" skipempty skipwhite nextgroup=idlArraySize,idlParmList contains=idlArraySize,idlLiteral
141 syn match idlParmName contained "[a-zA-Z0-9_]\+" skipempty skipwhite nextgroup=idlParmList,idlArraySize
142 syn keyword idlParmInt contained short long skipempty skipwhite nextgroup=idlParmName
143 syn keyword idlParmType contained unsigned skipempty skipwhite nextgroup=idlParmInt
144 syn region idlD3 contained start="<" end=">" skipempty skipwhite nextgroup=idlParmName contains=idlString,idlLiteral
145 syn keyword idlParmType contained string skipempty skipwhite nextgroup=idlD3,idlParmName
146 syn keyword idlParmType contained void float double char boolean octet any skipempty skipwhite nextgroup=idlParmName
147 syn match idlParmType contained "[a-zA-Z0-9_]\+[ \t]*\(::[ \t]*[a-zA-Z0-9_]\+\)*" skipempty skipwhite nextgroup=idlParmName
148 syn keyword idlOpParms contained in out inout skipempty skipwhite nextgroup=idlParmType
149
150 if !exists('idl_no_ms_extensions')
151 syn keyword idlOpParms contained retval optional skipempty skipwhite nextgroup=idlParmType
152 syn match idlOpParms contained +\<\(iid_is\|defaultvalue\)\s*([^)]*)+ skipempty skipwhite nextgroup=idlParamType
153
154 syn keyword idlVariantType contained BSTR VARIANT VARIANT_BOOL long short unsigned double CURRENCY DATE
155 syn region idlSafeArray contained matchgroup=idlVariantType start=+SAFEARRAY(\s*+ end=+)+ contains=idlVariantType
156 endif
157
158 syn region idlOpContents contained start="(" end=")" skipempty skipwhite nextgroup=idlRaises,idlContext,idlError,idlSemiColon contains=idlOpParms,idlSafeArray,idlVariantType,@idlCommentable
159 syn match idlOpName contained "[a-zA-Z0-9_]\+" skipempty skipwhite nextgroup=idlOpContents
160 syn keyword idlOpInt contained short long skipempty skipwhite nextgroup=idlOpName
161 syn region idlD2 contained start="<" end=">" skipempty skipwhite nextgroup=idlOpName contains=idlString,idlLiteral
162 syn keyword idlOp contained unsigned skipempty skipwhite nextgroup=idlOpInt
163 syn keyword idlOp contained string skipempty skipwhite nextgroup=idlD2,idlOpName
164 syn keyword idlOp contained void float double char boolean octet any skipempty skipwhite nextgroup=idlOpName
165 syn match idlOp contained "[a-zA-Z0-9_]\+[ \t]*\(::[ \t]*[a-zA-Z0-9_]\+\)*" skipempty skipwhite nextgroup=idlOpName
166 syn keyword idlOp contained void skipempty skipwhite nextgroup=idlOpName
167 syn keyword idlOneWayOp contained oneway skipempty skipwhite nextgroup=idOp
168
169 " Enum
170 syn region idlEnumContents contained start="{" end="}" skipempty skipwhite nextgroup=idlError,idlSemiColon,idlSimpDecl contains=idlId,idlAttributes,@idlCommentable
171 syn match idlEnumName contained "[a-zA-Z0-9_]\+" skipempty skipwhite nextgroup=idlEnumContents
172 syn keyword idlEnum enum skipempty skipwhite nextgroup=idlEnumName,idlEnumContents
173
174 " Typedef
175 syn keyword idlTypedef typedef skipempty skipwhite nextgroup=idlTypedefOtherTypeQualifier,idlDefBaseType,idlDefBaseTypeInt,idlDefSeqType,idlDefv1Enum,idlDefEnum,idlDefOtherType,idlDefAttributes,idlError
176
177 if !exists('idl_no_extensions')
178 syn keyword idlTypedefOtherTypeQualifier contained struct enum interface nextgroup=idlDefBaseType,idlDefBaseTypeInt,idlDefSeqType,idlDefv1Enum,idlDefEnum,idlDefOtherType,idlDefAttributes,idlError skipwhite
179
180 syn region idlDefAttributes contained start="\[" end="\]" contains=idlAttribute,idlAttributeParam,idlErrorBracket,idlErrorBrace skipempty skipwhite nextgroup=idlDefBaseType,idlDefBaseTypeInt,idlDefSeqType,idlDefv1Enum,idlDefEnum,idlDefOtherType,idlError
181
182 syn keyword idlDefBaseType contained float double char boolean octet any skipempty skipwhite nextgroup=idlTypedefDecl,idlError
183 syn keyword idlDefBaseTypeInt contained short long skipempty skipwhite nextgroup=idlTypedefDecl,idlError
184 syn match idlDefOtherType contained +\<\k\+\>+ skipempty nextgroup=idlTypedefDecl,idlError
185 " syn keyword idlDefSeqType contained sequence skipempty skipwhite nextgroup=idlD4
186
187 " Enum typedef
188 syn keyword idlDefEnum contained enum skipempty skipwhite nextgroup=idlDefEnumName,idlDefEnumContents
189 syn match idlDefEnumName contained "[a-zA-Z0-9_]\+" skipempty skipwhite nextgroup=idlDefEnumContents,idlTypedefDecl
190 syn region idlDefEnumContents contained start="{" end="}" skipempty skipwhite nextgroup=idlError,idlTypedefDecl contains=idlId,idlAttributes
191
192 syn match idlTypedefDecl contained "[a-zA-Z0-9_]\+" skipempty skipwhite nextgroup=idlError,idlSemiColon
193 endif
194
195 " Struct
196 syn region idlStructContent contained start="{" end="}" skipempty skipwhite nextgroup=idlError,idlSemiColon,idlSimpDecl contains=idlBaseType,idlBaseTypeInt,idlSeqType,@idlCommentable,idlEnum,idlUnion
197 syn match idlStructName contained "[a-zA-Z0-9_]\+" skipempty skipwhite nextgroup=idlStructContent
198 syn keyword idlStruct struct skipempty skipwhite nextgroup=idlStructName
199
200 " Exception
201 syn keyword idlException exception skipempty skipwhite nextgroup=idlStructName
202
203 " Union
204 syn match idlColon contained ":" skipempty skipwhite nextgroup=idlCase,idlSeqType,idlBaseType,idlBaseTypeInt
205 syn region idlCaseLabel contained start="" skip="::" end=":"me=e-1 skipempty skipwhite nextgroup=idlColon contains=idlLiteral,idlString
206 syn keyword idlCase contained case skipempty skipwhite nextgroup=idlCaseLabel
207 syn keyword idlCase contained default skipempty skipwhite nextgroup=idlColon
208 syn region idlUnionContent contained start="{" end="}" skipempty skipwhite nextgroup=idlError,idlSemiColon,idlSimpDecl contains=idlCase
209 syn region idlSwitchType contained start="(" end=")" skipempty skipwhite nextgroup=idlUnionContent
210 syn keyword idlUnionSwitch contained switch skipempty skipwhite nextgroup=idlSwitchType
211 syn match idlUnionName contained "[a-zA-Z0-9_]\+" skipempty skipwhite nextgroup=idlUnionSwitch
212 syn keyword idlUnion union skipempty skipwhite nextgroup=idlUnionName
213
214 if !exists('idl_no_extensions')
215 syn sync match idlInterfaceSync grouphere idlInterfaceContent "\<\(disp\)\=interface\>\s\+\k\+\s*:\s*\k\+\_s*{" skipempty skipwhite nextgroup=idlError,idlSemiColon contains=@idlContentCluster,@idlCommentable
216 syn sync maxlines=1000 minlines=100
217 else
218 syn sync lines=200
219 endif
220 " syn sync fromstart
221
222 if !exists("did_idl_syntax_inits")
223 let did_idl_syntax_inits = 1
224 " The default methods for highlighting. Can be overridden later
225 command -nargs=+ HiLink hi def link <args>
226
227 HiLink idlInclude Include
228 HiLink idlPreProc PreProc
229 HiLink idlPreCondit PreCondit
230 HiLink idlDefine Macro
231 HiLink idlIncluded String
232 HiLink idlString String
233 HiLink idlComment Comment
234 HiLink idlTodo Todo
235 HiLink idlLiteral Number
236 HiLink idlUuid Number
237 HiLink idlType Type
238 HiLink idlVariantType idlType
239
240 HiLink idlModule Keyword
241 HiLink idlInterface Keyword
242 HiLink idlEnum Keyword
243 HiLink idlStruct Keyword
244 HiLink idlUnion Keyword
245 HiLink idlTypedef Keyword
246 HiLink idlException Keyword
247 HiLink idlTypedefOtherTypeQualifier keyword
248
249 HiLink idlModuleName Typedef
250 HiLink idlInterfaceName Typedef
251 HiLink idlEnumName Typedef
252 HiLink idlStructName Typedef
253 HiLink idlUnionName Typedef
254
255 HiLink idlBaseTypeInt idlType
256 HiLink idlBaseType idlType
257 HiLink idlSeqType idlType
258 HiLink idlD1 Paren
259 HiLink idlD2 Paren
260 HiLink idlD3 Paren
261 HiLink idlD4 Paren
262 "HiLink idlArraySize Paren
263 "HiLink idlArraySize1 Paren
264 HiLink idlModuleContent Paren
265 HiLink idlUnionContent Paren
266 HiLink idlStructContent Paren
267 HiLink idlEnumContents Paren
268 HiLink idlInterfaceContent Paren
269
270 HiLink idlSimpDecl Identifier
271 HiLink idlROAttr StorageClass
272 HiLink idlAttr Keyword
273 HiLink idlConst StorageClass
274
275 HiLink idlOneWayOp StorageClass
276 HiLink idlOp idlType
277 HiLink idlParmType idlType
278 HiLink idlOpName Function
279 HiLink idlOpParms SpecialComment
280 HiLink idlParmName Identifier
281 HiLink idlInheritFrom Identifier
282 HiLink idlAttribute SpecialComment
283
284 HiLink idlId Constant
285 "HiLink idlCase Keyword
286 HiLink idlCaseLabel Constant
287
288 HiLink idlErrorBracket Error
289 HiLink idlErrorBrace Error
290 HiLink idlErrorSquareBracket Error
291
292 HiLink idlImport Keyword
293 HiLink idlImportString idlString
294 HiLink idlCoclassAttribute StorageClass
295 HiLink idlLibrary Keyword
296 HiLink idlImportlib Keyword
297 HiLink idlCoclass Keyword
298 HiLink idlLibraryName Typedef
299 HiLink idlCoclassName Typedef
300 " hi idlLibraryContent guifg=red
301 HiLink idlTypedefDecl Typedef
302 HiLink idlDefEnum Keyword
303 HiLink idlDefv1Enum Keyword
304 HiLink idlDefEnumName Typedef
305 HiLink idlDefEnumContents Paren
306 HiLink idlDefBaseTypeInt idlType
307 HiLink idlDefBaseType idlType
308 HiLink idlDefSeqType idlType
309 HiLink idlInterfaceSections Label
310
311 if exists("idlsyntax_showerror")
312 if exists("idlsyntax_showerror_soft")
313 hi default idlError guibg=#d0ffd0
314 else
315 HiLink idlError Error
316 endif
317 endif
318 delcommand HiLink
319 endif
320
321 let b:current_syntax = "idl"
322finally
323 let &cpo = s:cpo_save
324 unlet s:cpo_save
325endtry
Bram Moolenaar5eb86f92004-07-26 12:53:41 +0000326" vim: sw=2 et