1" Vim syntax file 2" Language: 4Dos batch file 3" Maintainer: John Leo Spetz <[email protected]> 4" Last Change: 2001 May 09 5 6"//Issues to resolve: 7"//- Boolean operators surrounded by period are recognized but the 8"// periods are not highlighted. The only way to do that would 9"// be separate synmatches for each possibility otherwise a more 10"// general \.\i\+\. will highlight anything delimited by dots. 11"//- After unary operators like "defined" can assume token type. 12"// Should there be more of these? 13 14" quit when a syntax file was already loaded 15if exists("b:current_syntax") 16 finish 17endif 18 19syn case ignore 20 21syn keyword btmStatement call off 22syn keyword btmConditional if iff endiff then else elseiff not errorlevel 23syn keyword btmConditional gt lt eq ne ge le 24syn match btmConditional transparent "\.\i\+\." contains=btmDotBoolOp 25syn keyword btmDotBoolOp contained and or xor 26syn match btmConditional "==" 27syn match btmConditional "!=" 28syn keyword btmConditional defined errorlevel exist isalias 29syn keyword btmConditional isdir direxist isinternal islabel 30syn keyword btmRepeat for in do enddo 31 32syn keyword btmTodo contained TODO 33 34" String 35syn cluster btmVars contains=btmVariable,btmArgument,btmBIFMatch 36syn region btmString start=+"+ end=+"+ contains=@btmVars 37syn match btmNumber "\<\d\+\>" 38 39"syn match btmIdentifier "\<\h\w*\>" 40 41" If you don't like tabs 42"syn match btmShowTab "\t" 43"syn match btmShowTabc "\t" 44"syn match btmComment "^\ *rem.*$" contains=btmTodo,btmShowTabc 45 46" Some people use this as a comment line 47" In fact this is a Label 48"syn match btmComment "^\ *:\ \+.*$" contains=btmTodo 49 50syn match btmComment "^\ *rem.*$" contains=btmTodo 51syn match btmComment "^\ *::.*$" contains=btmTodo 52 53syn match btmLabelMark "^\ *:[0-9a-zA-Z_\-]\+\>" 54syn match btmLabelMark "goto [0-9a-zA-Z_\-]\+\>"lc=5 55syn match btmLabelMark "gosub [0-9a-zA-Z_\-]\+\>"lc=6 56 57" syn match btmCmdDivider ">[>&][>&]\=" 58syn match btmCmdDivider ">[>&]*" 59syn match btmCmdDivider ">>&>" 60syn match btmCmdDivider "|&\=" 61syn match btmCmdDivider "%+" 62syn match btmCmdDivider "\^" 63 64syn region btmEcho start="echo" skip="echo" matchgroup=btmCmdDivider end="%+" end="$" end="|&\=" end="\^" end=">[>&]*" contains=@btmEchos oneline 65syn cluster btmEchos contains=@btmVars,btmEchoCommand,btmEchoParam 66syn keyword btmEchoCommand contained echo echoerr echos echoserr 67syn keyword btmEchoParam contained on off 68 69" this is also a valid Label. I don't use it. 70"syn match btmLabelMark "^\ *:\ \+[0-9a-zA-Z_\-]\+\>" 71 72" //Environment variable can be expanded using notation %var in 4DOS 73syn match btmVariable "%[0-9a-z_\-]\+" contains=@btmSpecialVars 74" //Environment variable can be expanded using notation %var% 75syn match btmVariable "%[0-9a-z_\-]*%" contains=@btmSpecialVars 76" //The following are special variable in 4DOS 77syn match btmVariable "%[=#]" contains=@btmSpecialVars 78syn match btmVariable "%??\=" contains=@btmSpecialVars 79" //Environment variable can be expanded using notation %[var] in 4DOS 80syn match btmVariable "%\[[0-9a-z_\-]*\]" 81" //After some keywords next word should be an environment variable 82syn match btmVariable "defined\s\i\+"lc=8 83syn match btmVariable "set\s\i\+"lc=4 84" //Parameters to batchfiles take the format %<digit> 85syn match btmArgument "%\d\>" 86" //4DOS allows format %<digit>& meaning batchfile parameters digit and up 87syn match btmArgument "%\d\>&" 88" //Variable used by FOR loops sometimes use %%<letter> in batchfiles 89syn match btmArgument "%%\a\>" 90 91" //Show 4DOS built-in functions specially 92syn match btmBIFMatch "%@\w\+\["he=e-1 contains=btmBuiltInFunc 93syn keyword btmBuiltInFunc contained alias ascii attrib cdrom 94syn keyword btmBuiltInFunc contained char clip comma convert 95syn keyword btmBuiltInFunc contained date day dec descript 96syn keyword btmBuiltInFunc contained device diskfree disktotal 97syn keyword btmBuiltInFunc contained diskused dosmem dow dowi 98syn keyword btmBuiltInFunc contained doy ems eval exec execstr 99syn keyword btmBuiltInFunc contained expand ext extended 100syn keyword btmBuiltInFunc contained fileage fileclose filedate 101syn keyword btmBuiltInFunc contained filename fileopen fileread 102syn keyword btmBuiltInFunc contained files fileseek fileseekl 103syn keyword btmBuiltInFunc contained filesize filetime filewrite 104syn keyword btmBuiltInFunc contained filewriteb findclose 105syn keyword btmBuiltInFunc contained findfirst findnext format 106syn keyword btmBuiltInFunc contained full if inc index insert 107syn keyword btmBuiltInFunc contained instr int label left len 108syn keyword btmBuiltInFunc contained lfn line lines lower lpt 109syn keyword btmBuiltInFunc contained makeage makedate maketime 110syn keyword btmBuiltInFunc contained master month name numeric 111syn keyword btmBuiltInFunc contained path random readscr ready 112syn keyword btmBuiltInFunc contained remote removable repeat 113syn keyword btmBuiltInFunc contained replace right search 114syn keyword btmBuiltInFunc contained select sfn strip substr 115syn keyword btmBuiltInFunc contained time timer trim truename 116syn keyword btmBuiltInFunc contained unique upper wild word 117syn keyword btmBuiltInFunc contained words xms year 118 119syn cluster btmSpecialVars contains=btmBuiltInVar,btmSpecialVar 120 121" //Show specialized variables specially 122" syn match btmSpecialVar contained "+" 123syn match btmSpecialVar contained "=" 124syn match btmSpecialVar contained "#" 125syn match btmSpecialVar contained "??\=" 126syn keyword btmSpecialVar contained cmdline colordir comspec 127syn keyword btmSpecialVar contained copycmd dircmd temp temp4dos 128syn keyword btmSpecialVar contained filecompletion path prompt 129 130" //Show 4DOS built-in variables specially specially 131syn keyword btmBuiltInVar contained _4ver _alias _ansi 132syn keyword btmBuiltInVar contained _apbatt _aplife _apmac _batch 133syn keyword btmBuiltInVar contained _batchline _batchname _bg 134syn keyword btmBuiltInVar contained _boot _ci _cmdproc _co 135syn keyword btmBuiltInVar contained _codepage _column _columns 136syn keyword btmBuiltInVar contained _country _cpu _cwd _cwds _cwp 137syn keyword btmBuiltInVar contained _cwps _date _day _disk _dname 138syn keyword btmBuiltInVar contained _dos _dosver _dow _dowi _doy 139syn keyword btmBuiltInVar contained _dpmi _dv _env _fg _hlogfile 140syn keyword btmBuiltInVar contained _hour _kbhit _kstack _lastdisk 141syn keyword btmBuiltInVar contained _logfile _minute _monitor 142syn keyword btmBuiltInVar contained _month _mouse _ndp _row _rows 143syn keyword btmBuiltInVar contained _second _shell _swapping 144syn keyword btmBuiltInVar contained _syserr _time _transient 145syn keyword btmBuiltInVar contained _video _win _wintitle _year 146 147" //Commands in 4DOS and/or DOS 148syn match btmCommand "\s?" 149syn match btmCommand "^?" 150syn keyword btmCommand alias append assign attrib 151syn keyword btmCommand backup beep break cancel case 152syn keyword btmCommand cd cdd cdpath chcp chdir 153syn keyword btmCommand chkdsk cls color comp copy 154syn keyword btmCommand ctty date debug default defrag 155syn keyword btmCommand del delay describe dir 156syn keyword btmCommand dirhistory dirs diskcomp 157syn keyword btmCommand diskcopy doskey dosshell 158syn keyword btmCommand drawbox drawhline drawvline 159"syn keyword btmCommand echo echoerr echos echoserr 160syn keyword btmCommand edit edlin emm386 endlocal 161syn keyword btmCommand endswitch erase eset except 162syn keyword btmCommand exe2bin exit expand fastopen 163syn keyword btmCommand fc fdisk ffind find format 164syn keyword btmCommand free global gosub goto 165syn keyword btmCommand graftabl graphics help history 166syn keyword btmCommand inkey input join keyb keybd 167syn keyword btmCommand keystack label lh list loadbtm 168syn keyword btmCommand loadhigh lock log md mem 169syn keyword btmCommand memory mirror mkdir mode more 170syn keyword btmCommand move nlsfunc on option path 171syn keyword btmCommand pause popd print prompt pushd 172syn keyword btmCommand quit rd reboot recover ren 173syn keyword btmCommand rename replace restore return 174syn keyword btmCommand rmdir scandisk screen scrput 175syn keyword btmCommand select set setdos setlocal 176syn keyword btmCommand setver share shift sort subst 177syn keyword btmCommand swapping switch sys tee text 178syn keyword btmCommand time timer touch tree truename 179syn keyword btmCommand type unalias undelete unformat 180syn keyword btmCommand unlock unset ver verify vol 181syn keyword btmCommand vscrput y 182 183" Define the default highlighting. 184" Only when an item doesn't have highlighting yet 185 186hi def link btmLabel Special 187hi def link btmLabelMark Special 188hi def link btmCmdDivider Special 189hi def link btmConditional btmStatement 190hi def link btmDotBoolOp btmStatement 191hi def link btmRepeat btmStatement 192hi def link btmEchoCommand btmStatement 193hi def link btmEchoParam btmStatement 194hi def link btmStatement Statement 195hi def link btmTodo Todo 196hi def link btmString String 197hi def link btmNumber Number 198hi def link btmComment Comment 199hi def link btmArgument Identifier 200hi def link btmVariable Identifier 201hi def link btmEcho String 202hi def link btmBIFMatch btmStatement 203hi def link btmBuiltInFunc btmStatement 204hi def link btmBuiltInVar btmStatement 205hi def link btmSpecialVar btmStatement 206hi def link btmCommand btmStatement 207 208"optional highlighting 209"hi def link btmShowTab Error 210"hi def link btmShowTabc Error 211"hi def link btmIdentifier Identifier 212 213 214let b:current_syntax = "btm" 215 216" vim: ts=8 217