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