1" Vim syntax file 2" Language: TADS 3" Maintainer: Amir Karger <[email protected]> 4" $Date: 2004/06/13 19:28:45 $ 5" $Revision: 1.1 $ 6" Stolen from: Bram Moolenaar's C language file 7" Newest version at: http://www.hec.utah.edu/~karger/vim/syntax/tads.vim 8" History info at the bottom of the file 9 10" TODO lots more keywords 11" global, self, etc. are special *objects*, not functions. They should 12" probably be a different color than the special functions 13" Actually, should cvtstr etc. be functions?! (change tadsFunction) 14" Make global etc. into Identifiers, since we don't have regular variables? 15 16" For version 5.x: Clear all syntax items 17" For version 6.x: Quit when a syntax file was already loaded 18if version < 600 19 syntax clear 20elseif exists("b:current_syntax") 21 finish 22endif 23 24" A bunch of useful keywords 25syn keyword tadsStatement goto break return continue pass 26syn keyword tadsLabel case default 27syn keyword tadsConditional if else switch 28syn keyword tadsRepeat while for do 29syn keyword tadsStorageClass local compoundWord formatstring specialWords 30syn keyword tadsBoolean nil true 31 32" TADS keywords 33syn keyword tadsKeyword replace modify 34syn keyword tadsKeyword global self inherited 35" builtin functions 36syn keyword tadsKeyword cvtstr cvtnum caps lower upper substr 37syn keyword tadsKeyword say length 38syn keyword tadsKeyword setit setscore 39syn keyword tadsKeyword datatype proptype 40syn keyword tadsKeyword car cdr 41syn keyword tadsKeyword defined isclass 42syn keyword tadsKeyword find firstobj nextobj 43syn keyword tadsKeyword getarg argcount 44syn keyword tadsKeyword input yorn askfile 45syn keyword tadsKeyword rand randomize 46syn keyword tadsKeyword restart restore quit save undo 47syn keyword tadsException abort exit exitobj 48 49syn keyword tadsTodo contained TODO FIXME XXX 50 51" String and Character constants 52" Highlight special characters (those which have a backslash) differently 53syn match tadsSpecial contained "\\." 54syn region tadsDoubleString start=+"+ skip=+\\\\\|\\"+ end=+"+ contains=tadsSpecial,tadsEmbedded 55syn region tadsSingleString start=+'+ skip=+\\\\\|\\'+ end=+'+ contains=tadsSpecial 56" Embedded expressions in strings 57syn region tadsEmbedded contained start="<<" end=">>" contains=tadsKeyword 58 59" TADS doesn't have \xxx, right? 60"syn match cSpecial contained "\\[0-7][0-7][0-7]\=\|\\." 61"syn match cSpecialCharacter "'\\[0-7][0-7]'" 62"syn match cSpecialCharacter "'\\[0-7][0-7][0-7]'" 63 64"catch errors caused by wrong parenthesis 65"syn region cParen transparent start='(' end=')' contains=ALLBUT,cParenError,cIncluded,cSpecial,cTodo,cUserCont,cUserLabel 66"syn match cParenError ")" 67"syn match cInParen contained "[{}]" 68syn region tadsBrace transparent start='{' end='}' contains=ALLBUT,tadsBraceError,tadsIncluded,tadsSpecial,tadsTodo 69syn match tadsBraceError "}" 70 71"integer number (TADS has no floating point numbers) 72syn case ignore 73syn match tadsNumber "\<[0-9]\+\>" 74"hex number 75syn match tadsNumber "\<0x[0-9a-f]\+\>" 76syn match tadsIdentifier "\<[a-z][a-z0-9_$]*\>" 77syn case match 78" flag an octal number with wrong digits 79syn match tadsOctalError "\<0[0-7]*[89]" 80 81" Removed complicated c_comment_strings 82syn region tadsComment start="/\*" end="\*/" contains=tadsTodo 83syn match tadsComment "//.*" contains=tadsTodo 84syntax match tadsCommentError "\*/" 85 86syn region tadsPreCondit start="^\s*#\s*\(if\>\|ifdef\>\|ifndef\>\|elif\>\|else\>\|endif\>\)" skip="\\$" end="$" contains=tadsComment,tadsString,tadsNumber,tadsCommentError 87syn region tadsIncluded contained start=+"+ skip=+\\\\\|\\"+ end=+"+ 88syn match tadsIncluded contained "<[^>]*>" 89syn match tadsInclude "^\s*#\s*include\>\s*["<]" contains=tadsIncluded 90syn region tadsDefine start="^\s*#\s*\(define\>\|undef\>\)" skip="\\$" end="$" contains=ALLBUT,tadsPreCondit,tadsIncluded,tadsInclude,tadsDefine,tadsInBrace,tadsIdentifier 91 92syn region tadsPreProc start="^\s*#\s*\(pragma\>\|line\>\|warning\>\|warn\>\|error\>\)" skip="\\$" end="$" contains=ALLBUT,tadsPreCondit,tadsIncluded,tadsInclude,tadsDefine,tadsInParen,tadsIdentifier 93 94" Highlight User Labels 95" TODO labels for gotos? 96"syn region cMulti transparent start='?' end=':' contains=ALLBUT,cIncluded,cSpecial,cTodo,cUserCont,cUserLabel,cBitField 97" Avoid matching foo::bar() in C++ by requiring that the next char is not ':' 98"syn match cUserCont "^\s*\I\i*\s*:$" contains=cUserLabel 99"syn match cUserCont ";\s*\I\i*\s*:$" contains=cUserLabel 100"syn match cUserCont "^\s*\I\i*\s*:[^:]" contains=cUserLabel 101"syn match cUserCont ";\s*\I\i*\s*:[^:]" contains=cUserLabel 102 103"syn match cUserLabel "\I\i*" contained 104 105" identifier: class-name [, class-name [...]] [property-list] ; 106" Don't highlight comment in class def 107syn match tadsClassDef "\<class\>[^/]*" contains=tadsObjectDef,tadsClass 108syn match tadsClass contained "\<class\>" 109syn match tadsObjectDef "\<[a-zA-Z][a-zA-Z0-9_$]*\s*:\s*[a-zA-Z0-9_$]\+\(\s*,\s*[a-zA-Z][a-zA-Z0-9_$]*\)*\(\s*;\)\=" 110syn keyword tadsFunction contained function 111syn match tadsFunctionDef "\<[a-zA-Z][a-zA-Z0-9_$]*\s*:\s*function[^{]*" contains=tadsFunction 112"syn region tadsObject transparent start = '[a-zA-Z][\i$]\s*:\s*' end=";" contains=tadsBrace,tadsObjectDef 113 114" How far back do we go to find matching groups 115if !exists("tads_minlines") 116 let tads_minlines = 15 117endif 118exec "syn sync ccomment tadsComment minlines=" . tads_minlines 119if !exists("tads_sync_dist") 120 let tads_sync_dist = 100 121endif 122execute "syn sync maxlines=" . tads_sync_dist 123 124" Define the default highlighting. 125" For version 5.7 and earlier: only when not done already 126" For version 5.8 and later: only when an item doesn't have highlighting yet 127if version >= 508 || !exists("did_tads_syn_inits") 128 if version < 508 129 let did_tads_syn_inits = 1 130 command -nargs=+ HiLink hi link <args> 131 else 132 command -nargs=+ HiLink hi def link <args> 133 endif 134 135 " The default methods for highlighting. Can be overridden later 136 HiLink tadsFunctionDef Function 137 HiLink tadsFunction Structure 138 HiLink tadsClass Structure 139 HiLink tadsClassDef Identifier 140 HiLink tadsObjectDef Identifier 141" no highlight for tadsEmbedded, so it prints as normal text w/in the string 142 143 HiLink tadsOperator Operator 144 HiLink tadsStructure Structure 145 HiLink tadsTodo Todo 146 HiLink tadsLabel Label 147 HiLink tadsConditional Conditional 148 HiLink tadsRepeat Repeat 149 HiLink tadsException Exception 150 HiLink tadsStatement Statement 151 HiLink tadsStorageClass StorageClass 152 HiLink tadsKeyWord Keyword 153 HiLink tadsSpecial SpecialChar 154 HiLink tadsNumber Number 155 HiLink tadsBoolean Boolean 156 HiLink tadsDoubleString tadsString 157 HiLink tadsSingleString tadsString 158 159 HiLink tadsOctalError tadsError 160 HiLink tadsCommentError tadsError 161 HiLink tadsBraceError tadsError 162 HiLink tadsInBrace tadsError 163 HiLink tadsError Error 164 165 HiLink tadsInclude Include 166 HiLink tadsPreProc PreProc 167 HiLink tadsDefine Macro 168 HiLink tadsIncluded tadsString 169 HiLink tadsPreCondit PreCondit 170 171 HiLink tadsString String 172 HiLink tadsComment Comment 173 174 delcommand HiLink 175endif 176 177 178let b:current_syntax = "tads" 179 180" Changes: 181" 11/18/99 Added a bunch of TADS functions, tadsException 182" 10/22/99 Misspelled Moolenaar (sorry!), c_minlines to tads_minlines 183" 184" vim: ts=8 185