blob: 84cf08b59dd8dbe32d94ab48ca9b24fdf5ea89c6 [file] [log] [blame]
Bram Moolenaar071d4272004-06-13 20:20:40 +00001" Vim syntax file
2" Language: IDL (Interface Description Language)
3" Maintainer: Jody Goldberg <jgoldberg@home.com>
4" Last Change: 2001 May 09
5
6" This is an experiment. IDL's structure is simple enough to permit a full
7" grammar based approach to rather than using a few heuristics. The result
8" is large and somewhat repetative but seems to work.
9
10" For version 5.x: Clear all syntax items
11" For version 6.x: Quit when a syntax file was already loaded
12if version < 600
13 syntax clear
14elseif exists("b:current_syntax")
15 finish
16endif
17
18" Misc basic
19syn match idlId contained "[a-zA-Z][a-zA-Z0-9_]*"
20syn match idlSemiColon contained ";"
21syn match idlCommaArg contained "," skipempty skipwhite nextgroup=idlSimpDecl
22syn region idlArraySize1 contained start=:\[: end=:\]: skipempty skipwhite nextgroup=idlArraySize1,idlSemiColon,idlCommaArg contains=idlArraySize1,idlLiteral
23syn match idlSimpDecl contained "[a-zA-Z][a-zA-Z0-9_]*" skipempty skipwhite nextgroup=idlSemiColon,idlCommaArg,idlArraySize1
24syn region idlSting contained start=+"+ skip=+\\\(\\\\\)*"+ end=+"+
25syn match idlLiteral contained "[1-9]\d*\(\.\d*\)\="
26syn match idlLiteral contained "\.\d\+"
27syn keyword idlLiteral contained TRUE FALSE
28
29" Comments
30syn keyword idlTodo contained TODO FIXME XXX
31syn region idlComment start="/\*" end="\*/" contains=idlTodo
32syn match idlComment "//.*" contains=idlTodo
33syn match idlCommentError "\*/"
34
35" C style Preprocessor
36syn region idlIncluded contained start=+"+ skip=+\\\(\\\\\)*"+ end=+"+
37syn match idlIncluded contained "<[^>]*>"
38syn match idlInclude "^[ \t]*#[ \t]*include\>[ \t]*["<]" contains=idlIncluded,idlString
39syn region idlPreCondit start="^[ \t]*#[ \t]*\(if\>\|ifdef\>\|ifndef\>\|elif\>\|else\>\|endif\>\)" skip="\\$" end="$" contains=idlComment,idlCommentError
40syn region idlDefine start="^[ \t]*#[ \t]*\(define\>\|undef\>\)" skip="\\$" end="$" contains=idlLiteral, idlString
41
42" Constants
43syn keyword idlConst const skipempty skipwhite nextgroup=idlBaseType,idlBaseTypeInt
44
45" Attribute
46syn keyword idlROAttr readonly skipempty skipwhite nextgroup=idlAttr
47syn keyword idlAttr attribute skipempty skipwhite nextgroup=idlBaseTypeInt,idlBaseType
48
49" Types
50syn region idlD4 contained start="<" end=">" skipempty skipwhite nextgroup=idlSimpDecl contains=idlSeqType,idlBaseTypeInt,idlBaseType,idlLiteral
51syn keyword idlSeqType contained sequence skipempty skipwhite nextgroup=idlD4
52syn keyword idlBaseType contained float double char boolean octet any skipempty skipwhite nextgroup=idlSimpDecl
53syn keyword idlBaseTypeInt contained short long skipempty skipwhite nextgroup=idlSimpDecl
54syn keyword idlBaseType contained unsigned skipempty skipwhite nextgroup=idlBaseTypeInt
55syn region idlD1 contained start="<" end=">" skipempty skipwhite nextgroup=idlSimpDecl contains=idlString,idlLiteral
56syn keyword idlBaseType contained string skipempty skipwhite nextgroup=idlD1,idlSimpDecl
57syn match idlBaseType contained "[a-zA-Z0-9_]\+[ \t]*\(::[ \t]*[a-zA-Z0-9_]\+\)*" skipempty skipwhite nextgroup=idlSimpDecl
58
59" Modules
60syn region idlModuleContent contained start="{" end="}" skipempty skipwhite nextgroup=idlSemiColon contains=idlUnion,idlStruct,idlEnum,idlInterface,idlComment,idlTypedef,idlConst,idlException,idlModule
61syn match idlModuleName contained "[a-zA-Z0-9_]\+" skipempty skipwhite nextgroup=idlModuleContent,idlSemiColon
62syn keyword idlModule module skipempty skipwhite nextgroup=idlModuleName
63
64" Interfaces
65syn region idlInterfaceContent contained start="{" end="}" skipempty skipwhite nextgroup=idlSemiColon contains=idlUnion,idlStruct,idlEnum,idlComment,idlROAttr,idlAttr,idlOp,idlOneWayOp,idlException,idlConst,idlTypedef
66syn match idlInheritFrom2 contained "," skipempty skipwhite nextgroup=idlInheritFrom
67syn match idlInheritFrom contained "[a-zA-Z0-9_]\+[ \t]*\(::[ \t]*[a-zA-Z0-9_]\+\)*" skipempty skipwhite nextgroup=idlInheritFrom2,idlInterfaceContent
68syn match idlInherit contained ":" skipempty skipwhite nextgroup=idlInheritFrom
69syn match idlInterfaceName contained "[a-zA-Z0-9_]\+" skipempty skipwhite nextgroup=idlInterfaceContent,idlInherit,idlSemiColon
70syn keyword idlInterface interface skipempty skipwhite nextgroup=idlInterfaceName
71
72
73" Raises
74syn keyword idlRaises contained raises skipempty skipwhite nextgroup=idlRaises,idlContext,idlSemiColon
75
76" Context
77syn keyword idlContext contained context skipempty skipwhite nextgroup=idlRaises,idlContext,idlSemiColon
78
79" Operation
80syn match idlParmList contained "," skipempty skipwhite nextgroup=idlOpParms
81syn region idlArraySize contained start="\[" end="\]" skipempty skipwhite nextgroup=idlArraySize,idlParmList contains=idlArraySize,idlLiteral
82syn match idlParmName contained "[a-zA-Z0-9_]\+" skipempty skipwhite nextgroup=idlParmList,idlArraySize
83syn keyword idlParmInt contained short long skipempty skipwhite nextgroup=idlParmName
84syn keyword idlParmType contained unsigned skipempty skipwhite nextgroup=idlParmInt
85syn region idlD3 contained start="<" end=">" skipempty skipwhite nextgroup=idlParmName contains=idlString,idlLiteral
86syn keyword idlParmType contained string skipempty skipwhite nextgroup=idlD3,idlParmName
87syn keyword idlParmType contained void float double char boolean octet any skipempty skipwhite nextgroup=idlParmName
88syn match idlParmType contained "[a-zA-Z0-9_]\+[ \t]*\(::[ \t]*[a-zA-Z0-9_]\+\)*" skipempty skipwhite nextgroup=idlParmName
89syn keyword idlOpParms contained in out inout skipempty skipwhite nextgroup=idlParmType
90
91syn region idlOpContents contained start="(" end=")" skipempty skipwhite nextgroup=idlRaises,idlContext,idlSemiColon contains=idlOpParms
92syn match idlOpName contained "[a-zA-Z0-9_]\+" skipempty skipwhite nextgroup=idlOpContents
93syn keyword idlOpInt contained short long skipempty skipwhite nextgroup=idlOpName
94syn region idlD2 contained start="<" end=">" skipempty skipwhite nextgroup=idlOpName contains=idlString,idlLiteral
95syn keyword idlOp contained unsigned skipempty skipwhite nextgroup=idlOpInt
96syn keyword idlOp contained string skipempty skipwhite nextgroup=idlD2,idlOpName
97syn keyword idlOp contained void float double char boolean octet any skipempty skipwhite nextgroup=idlOpName
98syn match idlOp contained "[a-zA-Z0-9_]\+[ \t]*\(::[ \t]*[a-zA-Z0-9_]\+\)*" skipempty skipwhite nextgroup=idlOpName
99syn keyword idlOp contained void skipempty skipwhite nextgroup=idlOpName
100syn keyword idlOneWayOp contained oneway skipempty skipwhite nextgroup=idOp
101
102" Enum
103syn region idlEnumContents contained start="{" end="}" skipempty skipwhite nextgroup=idlSemiColon, idlSimpDecl contains=idlId,idlComment
104syn match idlEnumName contained "[a-zA-Z0-9_]\+" skipempty skipwhite nextgroup=idlEnumContents
105syn keyword idlEnum enum skipempty skipwhite nextgroup=idlEnumName
106
107" Typedef
108syn keyword idlTypedef typedef skipempty skipwhite nextgroup=idlBaseType, idlBaseTypeInt, idlSeqType
109
110" Struct
111syn region idlStructContent contained start="{" end="}" skipempty skipwhite nextgroup=idlSemiColon, idlSimpDecl contains=idlBaseType, idlBaseTypeInt, idlSeqType,idlComment, idlEnum, idlUnion
112syn match idlStructName contained "[a-zA-Z0-9_]\+" skipempty skipwhite nextgroup=idlStructContent
113syn keyword idlStruct struct skipempty skipwhite nextgroup=idlStructName
114
115" Exception
116syn keyword idlException exception skipempty skipwhite nextgroup=idlStructName
117
118" Union
119syn match idlColon contained ":" skipempty skipwhite nextgroup=idlCase,idlSeqType,idlBaseType,idlBaseTypeInt
120syn region idlCaseLabel contained start="" skip="::" end=":"me=e-1 skipempty skipwhite nextgroup=idlColon contains=idlLiteral,idlString
121syn keyword idlCase contained case skipempty skipwhite nextgroup=idlCaseLabel
122syn keyword idlCase contained default skipempty skipwhite nextgroup=idlColon
123syn region idlUnionContent contained start="{" end="}" skipempty skipwhite nextgroup=idlSemiColon,idlSimpDecl contains=idlCase
124syn region idlSwitchType contained start="(" end=")" skipempty skipwhite nextgroup=idlUnionContent
125syn keyword idlUnionSwitch contained switch skipempty skipwhite nextgroup=idlSwitchType
126syn match idlUnionName contained "[a-zA-Z0-9_]\+" skipempty skipwhite nextgroup=idlUnionSwitch
127syn keyword idlUnion union skipempty skipwhite nextgroup=idlUnionName
128
129syn sync lines=200
130
131" Define the default highlighting.
132" For version 5.7 and earlier: only when not done already
133" For version 5.8 and later: only when an item doesn't have highlighting yet
134if version >= 508 || !exists("did_idl_syntax_inits")
135 if version < 508
136 let did_idl_syntax_inits = 1
137 command -nargs=+ HiLink hi link <args>
138 else
139 command -nargs=+ HiLink hi def link <args>
140 endif
141
142 HiLink idlInclude Include
143 HiLink idlPreProc PreProc
144 HiLink idlPreCondit PreCondit
145 HiLink idlDefine Macro
146 HiLink idlIncluded String
147 HiLink idlString String
148 HiLink idlComment Comment
149 HiLink idlTodo Todo
150 HiLink idlLiteral Number
151
152 HiLink idlModule Keyword
153 HiLink idlInterface Keyword
154 HiLink idlEnum Keyword
155 HiLink idlStruct Keyword
156 HiLink idlUnion Keyword
157 HiLink idlTypedef Keyword
158 HiLink idlException Keyword
159
160 HiLink idlModuleName Typedef
161 HiLink idlInterfaceName Typedef
162 HiLink idlEnumName Typedef
163 HiLink idlStructName Typedef
164 HiLink idlUnionName Typedef
165
166 HiLink idlBaseTypeInt idlType
167 HiLink idlBaseType idlType
168 HiLink idlSeqType idlType
169 HiLink idlD1 Paren
170 HiLink idlD2 Paren
171 HiLink idlD3 Paren
172 HiLink idlD4 Paren
173 "HiLink idlArraySize Paren
174 "HiLink idlArraySize1 Paren
175 HiLink idlModuleContent Paren
176 HiLink idlUnionContent Paren
177 HiLink idlStructContent Paren
178 HiLink idlEnumContents Paren
179 HiLink idlInterfaceContent Paren
180
181 HiLink idlSimpDecl Identifier
182 HiLink idlROAttr StorageClass
183 HiLink idlAttr Keyword
184 HiLink idlConst StorageClass
185
186 HiLink idlOneWayOp StorageClass
187 HiLink idlOp idlType
188 HiLink idlParmType idlType
189 HiLink idlOpName Function
190 HiLink idlOpParms StorageClass
191 HiLink idlParmName Identifier
192 HiLink idlInheritFrom Identifier
193
194 HiLink idlId Constant
195 "HiLink idlCase Keyword
196 HiLink idlCaseLabel Constant
197
198 delcommand HiLink
199endif
200
201let b:current_syntax = "idl"
202
203" vim: ts=8