Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 1 | " Vim syntax file |
| 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/ |
| 6 | |
| 7 | " KixTart files identified by *.kix extension. |
| 8 | |
| 9 | " Amendment History: |
| 10 | " 26 April 2001: RMH |
| 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 |
| 14 | |
| 15 | " TODO: |
| 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. |
| 21 | |
Bram Moolenaar | 89bcfda | 2016-08-30 23:26:57 +0200 | [diff] [blame] | 22 | " quit when a syntax file was already loaded |
| 23 | if exists("b:current_syntax") |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 24 | finish |
| 25 | endif |
| 26 | |
| 27 | syn case match |
| 28 | syn keyword kixTODO TODO FIX XXX contained |
| 29 | |
| 30 | " Case insensitive language. |
| 31 | syn case ignore |
| 32 | |
| 33 | " Kix statements |
| 34 | syn match kixStatement "?" |
| 35 | syn keyword kixStatement beep big break |
| 36 | syn keyword kixStatement call cd cls color cookie1 copy |
| 37 | syn keyword kixStatement del dim display |
| 38 | syn keyword kixStatement exit |
| 39 | syn keyword kixStatement flushkb |
| 40 | syn keyword kixStatement get gets global go gosub goto |
| 41 | syn keyword kixStatement md |
| 42 | syn keyword kixStatement password play |
| 43 | syn keyword kixStatement quit |
| 44 | syn keyword kixStatement rd return run |
| 45 | syn keyword kixStatement set setl setm settime shell sleep small |
| 46 | syn keyword kixStatement use |
| 47 | |
| 48 | " Kix2001 |
| 49 | syn keyword kixStatement debug function endfunction redim |
| 50 | |
| 51 | " Simple variables |
| 52 | syn match kixNotVar "\$\$\|@@\|%%" transparent contains=NONE |
| 53 | syn match kixLocalVar "\$\w\+" |
| 54 | syn match kixMacro "@\w\+" |
| 55 | syn match kixEnvVar "%\w\+" |
| 56 | |
| 57 | " Destination labels |
| 58 | syn match kixLabel ":\w\+\>" |
| 59 | |
| 60 | " Identify strings, trap unterminated strings |
| 61 | syn match kixStringError +".*\|'.*+ |
| 62 | syn region kixDoubleString oneline start=+"+ skip=+\\\\\|\\"+ end=+"+ contains=kixLocalVar,kixMacro,kixEnvVar,kixNotVar |
| 63 | syn region kixSingleString oneline start=+'+ skip=+\\\\\|\\'+ end=+'+ contains=kixLocalVar,kixMacro,kixEnvVar,kixNotVar |
| 64 | |
| 65 | " Operators |
| 66 | syn match kixOperator "+\|-\|\*\|/\|=\|&\||" |
| 67 | syn keyword kixOperator and or |
| 68 | " Kix2001 |
| 69 | syn match kixOperator "==" |
| 70 | syn keyword kixOperator not |
| 71 | |
| 72 | " Numeric constants |
| 73 | syn match kixInteger "-\=\<\d\+\>" contains=NONE |
| 74 | syn match kixFloat "-\=\.\d\+\>\|-\=\<\d\+\.\d\+\>" contains=NONE |
| 75 | |
| 76 | " Hex numeric constants |
| 77 | syn match kixHex "\&\x\+\>" contains=NONE |
| 78 | |
| 79 | " Other contants |
| 80 | " Kix2001 |
| 81 | syn keyword kixConstant on off |
| 82 | |
| 83 | " Comments |
| 84 | syn match kixComment ";.*$" contains=kixTODO |
| 85 | |
| 86 | " Trap unmatched parenthesis |
| 87 | syn match kixParenCloseError ")" |
| 88 | syn region kixParen oneline transparent start="(" end=")" contains=ALLBUT,kixParenCloseError |
| 89 | |
| 90 | " Functions (Builtin + UDF) |
| 91 | syn match kixFunction "\w\+("he=e-1,me=e-1 contains=ALL |
| 92 | |
| 93 | " Trap unmatched brackets |
| 94 | syn match kixBrackCloseError "\]" |
| 95 | syn region kixBrack transparent start="\[" end="\]" contains=ALLBUT,kixBrackCloseError |
| 96 | |
| 97 | " Clusters for ALLBUT shorthand |
| 98 | syn cluster kixIfBut contains=kixIfError,kixSelectOK,kixDoOK,kixWhileOK,kixForEachOK,kixForNextOK |
| 99 | syn cluster kixSelectBut contains=kixSelectError,kixIfOK,kixDoOK,kixWhileOK,kixForEachOK,kixForNextOK |
| 100 | syn cluster kixDoBut contains=kixDoError,kixSelectOK,kixIfOK,kixWhileOK,kixForEachOK,kixForNextOK |
| 101 | syn cluster kixWhileBut contains=kixWhileError,kixSelectOK,kixIfOK,kixDoOK,kixForEachOK,kixForNextOK |
| 102 | syn cluster kixForEachBut contains=kixForEachError,kixSelectOK,kixIfOK,kixDoOK,kixForNextOK,kixWhileOK |
| 103 | syn cluster kixForNextBut contains=kixForNextError,kixSelectOK,kixIfOK,kixDoOK,kixForEachOK,kixWhileOK |
| 104 | " Condtional construct errors. |
| 105 | syn match kixIfError "\<if\>\|\<else\>\|\<endif\>" |
| 106 | syn match kixIfOK contained "\<if\>\|\<else\>\|\<endif\>" |
| 107 | syn region kixIf transparent matchgroup=kixIfOK start="\<if\>" end="\<endif\>" contains=ALLBUT,@kixIfBut |
| 108 | syn match kixSelectError "\<select\>\|\<case\>\|\<endselect\>" |
| 109 | syn match kixSelectOK contained "\<select\>\|\<case\>\|\<endselect\>" |
| 110 | syn region kixSelect transparent matchgroup=kixSelectOK start="\<select\>" end="\<endselect\>" contains=ALLBUT,@kixSelectBut |
| 111 | |
| 112 | " Program control constructs. |
| 113 | syn match kixDoError "\<do\>\|\<until\>" |
| 114 | syn match kixDoOK contained "\<do\>\|\<until\>" |
| 115 | syn region kixDo transparent matchgroup=kixDoOK start="\<do\>" end="\<until\>" contains=ALLBUT,@kixDoBut |
| 116 | syn match kixWhileError "\<while\>\|\<loop\>" |
| 117 | syn match kixWhileOK contained "\<while\>\|\<loop\>" |
| 118 | syn region kixWhile transparent matchgroup=kixWhileOK start="\<while\>" end="\<loop\>" contains=ALLBUT,@kixWhileBut |
| 119 | syn match kixForNextError "\<for\>\|\<to\>\|\<step\>\|\<next\>" |
| 120 | syn match kixForNextOK contained "\<for\>\|\<to\>\|\<step\>\|\<next\>" |
| 121 | syn region kixForNext transparent matchgroup=kixForNextOK start="\<for\>" end="\<next\>" contains=ALLBUT,@kixForBut |
| 122 | syn match kixForEachError "\<for each\>\|\<in\>\|\<next\>" |
| 123 | syn match kixForEachOK contained "\<for each\>\|\<in\>\|\<next\>" |
| 124 | syn region kixForEach transparent matchgroup=kixForEachOK start="\<for each\>" end="\<next\>" contains=ALLBUT,@kixForEachBut |
| 125 | |
| 126 | " Expressions |
| 127 | syn match kixExpression "<\|>\|<=\|>=\|<>" |
| 128 | |
| 129 | |
| 130 | " Default highlighting. |
Bram Moolenaar | 89bcfda | 2016-08-30 23:26:57 +0200 | [diff] [blame] | 131 | " Set default highlight only if it doesn't already have a value. |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 132 | |
Bram Moolenaar | f37506f | 2016-08-31 22:22:10 +0200 | [diff] [blame] | 133 | hi def link kixDoubleString String |
| 134 | hi def link kixSingleString String |
| 135 | hi def link kixStatement Statement |
| 136 | hi def link kixRepeat Repeat |
| 137 | hi def link kixComment Comment |
| 138 | hi def link kixBuiltin Function |
| 139 | hi def link kixLocalVar Special |
| 140 | hi def link kixMacro Special |
| 141 | hi def link kixEnvVar Special |
| 142 | hi def link kixLabel Type |
| 143 | hi def link kixFunction Function |
| 144 | hi def link kixInteger Number |
| 145 | hi def link kixHex Number |
| 146 | hi def link kixFloat Number |
| 147 | hi def link kixOperator Operator |
| 148 | hi def link kixExpression Operator |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 149 | |
Bram Moolenaar | f37506f | 2016-08-31 22:22:10 +0200 | [diff] [blame] | 150 | hi def link kixParenCloseError Error |
| 151 | hi def link kixBrackCloseError Error |
| 152 | hi def link kixStringError Error |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 153 | |
Bram Moolenaar | f37506f | 2016-08-31 22:22:10 +0200 | [diff] [blame] | 154 | hi def link kixWhileError Error |
| 155 | hi def link kixWhileOK Conditional |
| 156 | hi def link kixDoError Error |
| 157 | hi def link kixDoOK Conditional |
| 158 | hi def link kixIfError Error |
| 159 | hi def link kixIfOK Conditional |
| 160 | hi def link kixSelectError Error |
| 161 | hi def link kixSelectOK Conditional |
| 162 | hi def link kixForNextError Error |
| 163 | hi def link kixForNextOK Conditional |
| 164 | hi def link kixForEachError Error |
| 165 | hi def link kixForEachOK Conditional |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 166 | |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 167 | |
| 168 | let b:current_syntax = "kix" |
| 169 | |
| 170 | " vim: ts=8 sw=2 |