1" Vim syntax file 2" Language: ibasic 3" Maintainer: Mark Manning <markem@airmail.net> 4" Originator: Allan Kelly <Allan.Kelly@ed.ac.uk> 5" Created: 10/1/2006 6" Updated: 10/21/2006 7" Description: A vim file to handle the IBasic file format. 8" Notes: 9" Updated by Mark Manning <markem@airmail.net> 10" Applied IBasic support to the already excellent support for standard 11" basic syntax (like QB). 12" 13" First version based on Micro$soft QBASIC circa 1989, as documented in 14" 'Learn BASIC Now' by Halvorson&Rygmyr. Microsoft Press 1989. 15" This syntax file not a complete implementation yet. 16" Send suggestions to the maintainer. 17" 18" This version is based upon the commands found in IBasic (www.pyxia.com). 19" MEM 10/6/2006 20" 21" Quit when a (custom) syntax file was already loaded (Taken from c.vim) 22" 23if exists("b:current_syntax") 24 finish 25endif 26" 27" Be sure to turn on the "case ignore" since current versions of basic 28" support both upper as well as lowercase letters. 29" 30syn case ignore 31" 32" A bunch of useful BASIC keywords 33" 34syn keyword ibasicStatement beep bload bsave call absolute chain chdir circle 35syn keyword ibasicStatement clear close cls color com common const data 36syn keyword ibasicStatement loop draw end environ erase error exit field 37syn keyword ibasicStatement files function get gosub goto 38syn keyword ibasicStatement input input# ioctl key kill let line locate 39syn keyword ibasicStatement lock unlock lprint using lset mkdir name 40syn keyword ibasicStatement on error open option base out paint palette pcopy 41syn keyword ibasicStatement pen play pmap poke preset print print# using pset 42syn keyword ibasicStatement put randomize read redim reset restore resume 43syn keyword ibasicStatement return rmdir rset run seek screen 44syn keyword ibasicStatement shared shell sleep sound static stop strig sub 45syn keyword ibasicStatement swap system timer troff tron type unlock 46syn keyword ibasicStatement view wait width window write 47syn keyword ibasicStatement date$ mid$ time$ 48" 49" Do the basic variables names first. This is because it 50" is the most inclusive of the tests. Later on we change 51" this so the identifiers are split up into the various 52" types of identifiers like functions, basic commands and 53" such. MEM 9/9/2006 54" 55syn match ibasicIdentifier "\<[a-zA-Z_][a-zA-Z0-9_]*\>" 56syn match ibasicGenericFunction "\<[a-zA-Z_][a-zA-Z0-9_]*\>\s*("me=e-1,he=e-1 57" 58" Function list 59" 60syn keyword ibasicBuiltInFunction abs asc atn cdbl cint clng cos csng csrlin cvd cvdmbf 61syn keyword ibasicBuiltInFunction cvi cvl cvs cvsmbf eof erdev erl err exp fileattr 62syn keyword ibasicBuiltInFunction fix fre freefile inp instr lbound len loc lof 63syn keyword ibasicBuiltInFunction log lpos mod peek pen point pos rnd sadd screen seek 64syn keyword ibasicBuiltInFunction setmem sgn sin spc sqr stick strig tab tan ubound 65syn keyword ibasicBuiltInFunction val valptr valseg varptr varseg 66syn keyword ibasicBuiltInFunction chr\$ command$ date$ environ$ erdev$ hex$ inkey$ 67syn keyword ibasicBuiltInFunction input$ ioctl$ lcases$ laft$ ltrim$ mid$ mkdmbf$ mkd$ 68syn keyword ibasicBuiltInFunction mki$ mkl$ mksmbf$ mks$ oct$ right$ rtrim$ space$ 69syn keyword ibasicBuiltInFunction str$ string$ time$ ucase$ varptr$ 70syn keyword ibasicTodo contained TODO 71syn cluster ibasicFunctionCluster contains=ibasicBuiltInFunction,ibasicGenericFunction 72 73syn keyword Conditional if else then elseif endif select case endselect 74syn keyword Repeat for do while next enddo endwhile wend 75 76syn keyword ibasicTypeSpecifier single double defdbl defsng 77syn keyword ibasicTypeSpecifier int integer uint uinteger int64 uint64 defint deflng 78syn keyword ibasicTypeSpecifier byte char string istring defstr 79syn keyword ibasicDefine dim def declare 80" 81"catch errors caused by wrong parenthesis 82" 83syn cluster ibasicParenGroup contains=ibasicParenError,ibasicIncluded,ibasicSpecial,ibasicTodo,ibasicUserCont,ibasicUserLabel,ibasicBitField 84syn region ibasicParen transparent start='(' end=')' contains=ALLBUT,@bParenGroup 85syn match ibasicParenError ")" 86syn match ibasicInParen contained "[{}]" 87" 88"integer number, or floating point number without a dot and with "f". 89" 90syn region ibasicHex start="&h" end="\W" 91syn region ibasicHexError start="&h\x*[g-zG-Z]" end="\W" 92syn match ibasicInteger "\<\d\+\(u\=l\=\|lu\|f\)\>" 93" 94"floating point number, with dot, optional exponent 95" 96syn match ibasicFloat "\<\d\+\.\d*\(e[-+]\=\d\+\)\=[fl]\=\>" 97" 98"floating point number, starting with a dot, optional exponent 99" 100syn match ibasicFloat "\.\d\+\(e[-+]\=\d\+\)\=[fl]\=\>" 101" 102"floating point number, without dot, with exponent 103" 104syn match ibasicFloat "\<\d\+e[-+]\=\d\+[fl]\=\>" 105" 106"hex number 107" 108syn match ibasicIdentifier "\<[a-zA-Z_][a-zA-Z0-9_]*\>" 109syn match ibasicFunction "\<[a-zA-Z_][a-zA-Z0-9_]*\>\s*("me=e-1,he=e-1 110syn case match 111syn match ibasicOctalError "\<0\o*[89]" 112" 113" String and Character contstants 114" 115syn region ibasicString start='"' end='"' contains=ibasicSpecial,ibasicTodo 116syn region ibasicString start="'" end="'" contains=ibasicSpecial,ibasicTodo 117" 118" Comments 119" 120syn match ibasicSpecial contained "\\." 121syn region ibasicComment start="^rem" end="$" contains=ibasicSpecial,ibasicTodo 122syn region ibasicComment start=":\s*rem" end="$" contains=ibasicSpecial,ibasicTodo 123syn region ibasicComment start="\s*'" end="$" contains=ibasicSpecial,ibasicTodo 124syn region ibasicComment start="^'" end="$" contains=ibasicSpecial,ibasicTodo 125" 126" Now do the comments and labels 127" 128syn match ibasicLabel "^\d" 129syn region ibasicLineNumber start="^\d" end="\s" 130" 131" Pre-compiler options : FreeBasic 132" 133syn region ibasicPreCondit start="^\s*#\s*\(if\>\|ifdef\>\|ifndef\>\|elif\>\|else\>\|endif\>\)" skip="\\$" end="$" contains=ibasicString,ibasicCharacter,ibasicNumber,ibasicCommentError,ibasicSpaceError 134syn match ibasicInclude "^\s*#\s*include\s*" 135" 136" Create the clusters 137" 138syn cluster ibasicNumber contains=ibasicHex,ibasicInteger,ibasicFloat 139syn cluster ibasicError contains=ibasicHexError 140" 141" Used with OPEN statement 142" 143syn match ibasicFilenumber "#\d\+" 144" 145"syn sync ccomment ibasicComment 146" 147syn match ibasicMathOperator "[\+\-\=\|\*\/\>\<\%\()[\]]" contains=ibasicParen 148" 149" The default methods for highlighting. Can be overridden later 150" 151hi def link ibasicLabel Label 152hi def link ibasicConditional Conditional 153hi def link ibasicRepeat Repeat 154hi def link ibasicHex Number 155hi def link ibasicInteger Number 156hi def link ibasicFloat Number 157hi def link ibasicError Error 158hi def link ibasicHexError Error 159hi def link ibasicStatement Statement 160hi def link ibasicString String 161hi def link ibasicComment Comment 162hi def link ibasicLineNumber Comment 163hi def link ibasicSpecial Special 164hi def link ibasicTodo Todo 165hi def link ibasicGenericFunction Function 166hi def link ibasicBuiltInFunction Function 167hi def link ibasicTypeSpecifier Type 168hi def link ibasicDefine Type 169hi def link ibasicInclude Include 170hi def link ibasicIdentifier Identifier 171hi def link ibasicFilenumber ibasicTypeSpecifier 172hi def link ibasicMathOperator Operator 173 174let b:current_syntax = "ibasic" 175 176" vim: ts=8 177