2 " Language: KixTart 95, Kix2001 Windows script language http://kixtart.org/
3 " Maintainer: Richard Howarth <rhowarth@sgb.co.uk>
4 " Last Change: 2003 May 11
5 " URL: http://www.howsoft.demon.co.uk/
7 " KixTart files identified by *.kix extension.
11 " Removed development comments from distro version
12 " Renamed "Kix*" to "kix*" for consistancy
13 " Changes made in preperation for VIM version 5.8/6.00
16 " Handle arrays highlighting
17 " Handle object highlighting
18 " The next two may not be possible:
19 " Work out how to error too many "(", i.e. (() should be an error.
20 " Similarly, "if" without "endif" and similar constructs should error.
22 " Clear legacy syntax rules for version 5.x, exit if already processed for version 6+
25 elseif exists("b:current_syntax")
30 syn keyword kixTODO TODO FIX XXX contained
32 " Case insensitive language.
36 syn match kixStatement "?"
37 syn keyword kixStatement beep big break
38 syn keyword kixStatement call cd cls color cookie1 copy
39 syn keyword kixStatement del dim display
40 syn keyword kixStatement exit
41 syn keyword kixStatement flushkb
42 syn keyword kixStatement get gets global go gosub goto
43 syn keyword kixStatement md
44 syn keyword kixStatement password play
45 syn keyword kixStatement quit
46 syn keyword kixStatement rd return run
47 syn keyword kixStatement set setl setm settime shell sleep small
48 syn keyword kixStatement use
51 syn keyword kixStatement debug function endfunction redim
54 syn match kixNotVar "\$\$\|@@\|%%" transparent contains=NONE
55 syn match kixLocalVar "\$\w\+"
56 syn match kixMacro "@\w\+"
57 syn match kixEnvVar "%\w\+"
60 syn match kixLabel ":\w\+\>"
62 " Identify strings, trap unterminated strings
63 syn match kixStringError +".*\|'.*+
64 syn region kixDoubleString oneline start=+"+ skip=+\\\\\|\\"+ end=+"+ contains=kixLocalVar,kixMacro,kixEnvVar,kixNotVar
65 syn region kixSingleString oneline start=+'+ skip=+\\\\\|\\'+ end=+'+ contains=kixLocalVar,kixMacro,kixEnvVar,kixNotVar
68 syn match kixOperator "+\|-\|\*\|/\|=\|&\||"
69 syn keyword kixOperator and or
71 syn match kixOperator "=="
72 syn keyword kixOperator not
75 syn match kixInteger "-\=\<\d\+\>" contains=NONE
76 syn match kixFloat "-\=\.\d\+\>\|-\=\<\d\+\.\d\+\>" contains=NONE
78 " Hex numeric constants
79 syn match kixHex "\&\x\+\>" contains=NONE
83 syn keyword kixConstant on off
86 syn match kixComment ";.*$" contains=kixTODO
88 " Trap unmatched parenthesis
89 syn match kixParenCloseError ")"
90 syn region kixParen oneline transparent start="(" end=")" contains=ALLBUT,kixParenCloseError
92 " Functions (Builtin + UDF)
93 syn match kixFunction "\w\+("he=e-1,me=e-1 contains=ALL
95 " Trap unmatched brackets
96 syn match kixBrackCloseError "\]"
97 syn region kixBrack transparent start="\[" end="\]" contains=ALLBUT,kixBrackCloseError
99 " Clusters for ALLBUT shorthand
100 syn cluster kixIfBut contains=kixIfError,kixSelectOK,kixDoOK,kixWhileOK,kixForEachOK,kixForNextOK
101 syn cluster kixSelectBut contains=kixSelectError,kixIfOK,kixDoOK,kixWhileOK,kixForEachOK,kixForNextOK
102 syn cluster kixDoBut contains=kixDoError,kixSelectOK,kixIfOK,kixWhileOK,kixForEachOK,kixForNextOK
103 syn cluster kixWhileBut contains=kixWhileError,kixSelectOK,kixIfOK,kixDoOK,kixForEachOK,kixForNextOK
104 syn cluster kixForEachBut contains=kixForEachError,kixSelectOK,kixIfOK,kixDoOK,kixForNextOK,kixWhileOK
105 syn cluster kixForNextBut contains=kixForNextError,kixSelectOK,kixIfOK,kixDoOK,kixForEachOK,kixWhileOK
106 " Condtional construct errors.
107 syn match kixIfError "\<if\>\|\<else\>\|\<endif\>"
108 syn match kixIfOK contained "\<if\>\|\<else\>\|\<endif\>"
109 syn region kixIf transparent matchgroup=kixIfOK start="\<if\>" end="\<endif\>" contains=ALLBUT,@kixIfBut
110 syn match kixSelectError "\<select\>\|\<case\>\|\<endselect\>"
111 syn match kixSelectOK contained "\<select\>\|\<case\>\|\<endselect\>"
112 syn region kixSelect transparent matchgroup=kixSelectOK start="\<select\>" end="\<endselect\>" contains=ALLBUT,@kixSelectBut
114 " Program control constructs.
115 syn match kixDoError "\<do\>\|\<until\>"
116 syn match kixDoOK contained "\<do\>\|\<until\>"
117 syn region kixDo transparent matchgroup=kixDoOK start="\<do\>" end="\<until\>" contains=ALLBUT,@kixDoBut
118 syn match kixWhileError "\<while\>\|\<loop\>"
119 syn match kixWhileOK contained "\<while\>\|\<loop\>"
120 syn region kixWhile transparent matchgroup=kixWhileOK start="\<while\>" end="\<loop\>" contains=ALLBUT,@kixWhileBut
121 syn match kixForNextError "\<for\>\|\<to\>\|\<step\>\|\<next\>"
122 syn match kixForNextOK contained "\<for\>\|\<to\>\|\<step\>\|\<next\>"
123 syn region kixForNext transparent matchgroup=kixForNextOK start="\<for\>" end="\<next\>" contains=ALLBUT,@kixForBut
124 syn match kixForEachError "\<for each\>\|\<in\>\|\<next\>"
125 syn match kixForEachOK contained "\<for each\>\|\<in\>\|\<next\>"
126 syn region kixForEach transparent matchgroup=kixForEachOK start="\<for each\>" end="\<next\>" contains=ALLBUT,@kixForEachBut
129 syn match kixExpression "<\|>\|<=\|>=\|<>"
132 " Default highlighting.
133 " Version < 5.8 set default highlight if file not already processed.
134 " Version >= 5.8 set default highlight only if it doesn't already have a value.
135 if version > 508 || !exists("did_kix_syn_inits")
137 let did_kix_syn_inits=1
138 command -nargs=+ HiLink hi link <args>
140 command -nargs=+ HiLink hi def link <args>
143 HiLink kixDoubleString String
144 HiLink kixSingleString String
145 HiLink kixStatement Statement
146 HiLink kixRepeat Repeat
147 HiLink kixComment Comment
148 HiLink kixBuiltin Function
149 HiLink kixLocalVar Special
150 HiLink kixMacro Special
151 HiLink kixEnvVar Special
153 HiLink kixFunction Function
154 HiLink kixInteger Number
156 HiLink kixFloat Number
157 HiLink kixOperator Operator
158 HiLink kixExpression Operator
160 HiLink kixParenCloseError Error
161 HiLink kixBrackCloseError Error
162 HiLink kixStringError Error
164 HiLink kixWhileError Error
165 HiLink kixWhileOK Conditional
166 HiLink kixDoError Error
167 HiLink kixDoOK Conditional
168 HiLink kixIfError Error
169 HiLink kixIfOK Conditional
170 HiLink kixSelectError Error
171 HiLink kixSelectOK Conditional
172 HiLink kixForNextError Error
173 HiLink kixForNextOK Conditional
174 HiLink kixForEachError Error
175 HiLink kixForEachOK Conditional
180 let b:current_syntax = "kix"