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