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