blob: 7eab1d48ae111b889b1c069850a9169cc3430677 [file] [log] [blame]
Bram Moolenaar071d4272004-06-13 20:20:40 +00001" Vim syntax file
2" Language: UnrealScript
3" Maintainer: Mark Ferrell <major@chaoticdreams.org>
4" URL: ftp://ftp.chaoticdreams.org/pub/ut/vim/uc.vim
5" Credits: Based on the java.vim syntax file by Claudio Fleiner
6" Last change: 2003 May 31
7
8" Please check :help uc.vim for comments on some of the options available.
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" some characters that cannot be in a UnrealScript program (outside a string)
19syn match ucError "[\\@`]"
20syn match ucError "<<<\|\.\.\|=>\|<>\|||=\|&&=\|[^-]->\|\*\/"
21
22" we define it here so that included files can test for it
23if !exists("main_syntax")
24 let main_syntax='uc'
25endif
26
27syntax case ignore
28
29" keyword definitions
30syn keyword ucBranch break continue
31syn keyword ucConditional if else switch
32syn keyword ucRepeat while for do foreach
33syn keyword ucBoolean true false
34syn keyword ucConstant null
35syn keyword ucOperator new instanceof
36syn keyword ucType boolean char byte short int long float double
37syn keyword ucType void Pawn sound state auto exec function ipaddr
38syn keyword ucType ELightType actor ammo defaultproperties bool
39syn keyword ucType native noexport var out vector name local string
40syn keyword ucType event
41syn keyword ucStatement return
42syn keyword ucStorageClass static synchronized transient volatile final
43syn keyword ucMethodDecl synchronized throws
44
45" UnrealScript defines classes in sorta fscked up fashion
46syn match ucClassDecl "^[Cc]lass[\s$]*\S*[\s$]*expands[\s$]*\S*;" contains=ucSpecial,ucSpecialChar,ucClassKeys
47syn keyword ucClassKeys class expands extends
48syn match ucExternal "^\#exec.*" contains=ucCommentString,ucNumber
49syn keyword ucScopeDecl public protected private abstract
50
51" UnrealScript Functions
52syn match ucFuncDef "^.*function\s*[\(]*" contains=ucType,ucStorageClass
53syn match ucEventDef "^.*event\s*[\(]*" contains=ucType,ucStorageClass
54syn match ucClassLabel "[a-zA-Z0-9]*\'[a-zA-Z0-9]*\'" contains=ucCharacter
55
56syn region ucLabelRegion transparent matchgroup=ucLabel start="\<case\>" matchgroup=NONE end=":" contains=ucNumber
57syn match ucUserLabel "^\s*[_$a-zA-Z][_$a-zA-Z0-9_]*\s*:"he=e-1 contains=ucLabel
58syn keyword ucLabel default
59
60" The following cluster contains all java groups except the contained ones
61syn cluster ucTop contains=ucExternal,ucError,ucError,ucBranch,ucLabelRegion,ucLabel,ucConditional,ucRepeat,ucBoolean,ucConstant,ucTypedef,ucOperator,ucType,ucType,ucStatement,ucStorageClass,ucMethodDecl,ucClassDecl,ucClassDecl,ucClassDecl,ucScopeDecl,ucError,ucError2,ucUserLabel,ucClassLabel
62
63" Comments
64syn keyword ucTodo contained TODO FIXME XXX
65syn region ucCommentString contained start=+"+ end=+"+ end=+\*/+me=s-1,he=s-1 contains=ucSpecial,ucCommentStar,ucSpecialChar
66syn region ucComment2String contained start=+"+ end=+$\|"+ contains=ucSpecial,ucSpecialChar
67syn match ucCommentCharacter contained "'\\[^']\{1,6\}'" contains=ucSpecialChar
68syn match ucCommentCharacter contained "'\\''" contains=ucSpecialChar
69syn match ucCommentCharacter contained "'[^\\]'"
70syn region ucComment start="/\*" end="\*/" contains=ucCommentString,ucCommentCharacter,ucNumber,ucTodo
71syn match ucCommentStar contained "^\s*\*[^/]"me=e-1
72syn match ucCommentStar contained "^\s*\*$"
73syn match ucLineComment "//.*" contains=ucComment2String,ucCommentCharacter,ucNumber,ucTodo
74hi link ucCommentString ucString
75hi link ucComment2String ucString
76hi link ucCommentCharacter ucCharacter
77
78syn cluster ucTop add=ucComment,ucLineComment
79
80" match the special comment /**/
81syn match ucComment "/\*\*/"
82
83" Strings and constants
84syn match ucSpecialError contained "\\."
85"syn match ucSpecialCharError contained "[^']"
86syn match ucSpecialChar contained "\\\([4-9]\d\|[0-3]\d\d\|[\"\\'ntbrf]\|u\x\{4\}\)"
87syn region ucString start=+"+ end=+"+ contains=ucSpecialChar,ucSpecialError
88syn match ucStringError +"\([^"\\]\|\\.\)*$+
89syn match ucCharacter "'[^']*'" contains=ucSpecialChar,ucSpecialCharError
90syn match ucCharacter "'\\''" contains=ucSpecialChar
91syn match ucCharacter "'[^\\]'"
92syn match ucNumber "\<\(0[0-7]*\|0[xX]\x\+\|\d\+\)[lL]\=\>"
93syn match ucNumber "\(\<\d\+\.\d*\|\.\d\+\)\([eE][-+]\=\d\+\)\=[fFdD]\="
94syn match ucNumber "\<\d\+[eE][-+]\=\d\+[fFdD]\=\>"
95syn match ucNumber "\<\d\+\([eE][-+]\=\d\+\)\=[fFdD]\>"
96
97" unicode characters
98syn match ucSpecial "\\u\d\{4\}"
99
100syn cluster ucTop add=ucString,ucCharacter,ucNumber,ucSpecial,ucStringError
101
102" catch errors caused by wrong parenthesis
103syn region ucParen transparent start="(" end=")" contains=@ucTop,ucParen
104syn match ucParenError ")"
105hi link ucParenError ucError
106
107if !exists("uc_minlines")
108 let uc_minlines = 10
109endif
110exec "syn sync ccomment ucComment minlines=" . uc_minlines
111
112" Define the default highlighting.
113" For version 5.7 and earlier: only when not done already
114" For version 5.8 and later: only when an item doesn't have highlighting yet
115if version >= 508 || !exists("did_uc_syntax_inits")
116 if version < 508
117 let did_uc_syntax_inits = 1
118 command -nargs=+ HiLink hi link <args>
119 else
120 command -nargs=+ HiLink hi def link <args>
121 endif
122
123 HiLink ucFuncDef Conditional
124 HiLink ucEventDef Conditional
125 HiLink ucBraces Function
126 HiLink ucBranch Conditional
127 HiLink ucLabel Label
128 HiLink ucUserLabel Label
129 HiLink ucConditional Conditional
130 HiLink ucRepeat Repeat
131 HiLink ucStorageClass StorageClass
132 HiLink ucMethodDecl ucStorageClass
133 HiLink ucClassDecl ucStorageClass
134 HiLink ucScopeDecl ucStorageClass
135 HiLink ucBoolean Boolean
136 HiLink ucSpecial Special
137 HiLink ucSpecialError Error
138 HiLink ucSpecialCharError Error
139 HiLink ucString String
140 HiLink ucCharacter Character
141 HiLink ucSpecialChar SpecialChar
142 HiLink ucNumber Number
143 HiLink ucError Error
144 HiLink ucStringError Error
145 HiLink ucStatement Statement
146 HiLink ucOperator Operator
147 HiLink ucOverLoaded Operator
148 HiLink ucComment Comment
149 HiLink ucDocComment Comment
150 HiLink ucLineComment Comment
151 HiLink ucConstant ucBoolean
152 HiLink ucTypedef Typedef
153 HiLink ucTodo Todo
154
155 HiLink ucCommentTitle SpecialComment
156 HiLink ucDocTags Special
157 HiLink ucDocParam Function
158 HiLink ucCommentStar ucComment
159
160 HiLink ucType Type
161 HiLink ucExternal Include
162
163 HiLink ucClassKeys Conditional
164 HiLink ucClassLabel Conditional
165
166 HiLink htmlComment Special
167 HiLink htmlCommentPart Special
168
169 delcommand HiLink
170endif
171
172let b:current_syntax = "uc"
173
174if main_syntax == 'uc'
175 unlet main_syntax
176endif
177
178" vim: ts=8