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