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