| 1 |
<?xml version="1.0" encoding="UTF-8"?> |
| 2 |
<!DOCTYPE language |
| 3 |
[ |
| 4 |
<!ENTITY label "[a-zA-Z_][a-zA-Z_0-9]*"> <!-- so sehen Labels aus --> |
| 5 |
<!ENTITY varname "(?:[a-z_]\w*|[0-9]*[&])"> <!-- valid character in a variable name --> |
| 6 |
<!ENTITY pathpart "[^"*=/:<>?\\[\]\|]"> <!-- valid character in a file name --> |
| 7 |
<!ENTITY tasten "(?:(?:Strg|Alt|Shift)-)?(?:[a-z0-9]|F[1-9]|F1[0-2]|Esc|Bksp|Tab|Enter|Up|Down|Left|Right|PgUp|PgDn|Home|End|Ins|Del)"> |
| 8 |
]> |
| 9 |
<language name="4DOS BatchToMemory" kateversion="5.0" version="10" section="Scripts" extensions="*.btm" casesensitive="0" indenter="cstyle" author="Stefan Huebner ([email protected])" license="LGPL"> |
| 10 |
<!--DONE: |
| 11 |
- comments are there |
| 12 |
- substitutions are there |
| 13 |
- basic variable function handling, distinguishing the function result between numerical and string |
| 14 |
- variables are there (somehow) |
| 15 |
- numbers will be found |
| 16 |
- escape characters are found and highlit |
| 17 |
- jumps, gosubs and labels |
| 18 |
- command grouping |
| 19 |
- conditions |
| 20 |
- redirection |
| 21 |
- many different command handlings |
| 22 |
- iff |
| 23 |
- echo |
| 24 |
- text/endtext |
| 25 |
- set/unset |
| 26 |
- input/inkey |
| 27 |
- do |
| 28 |
- for |
| 29 |
- switch |
| 30 |
- internal commands of 4DOS |
| 31 |
TODO: |
| 32 |
- if someone finds that PATH-detection makes sense: create it... |
| 33 |
- whatever doesn't seem to be correctly lit after all the preceeding stuff ... |
| 34 |
- follow the TODO-Marks |
| 35 |
--> |
| 36 |
<highlighting> |
| 37 |
<list name="HighlightInsideComment"> |
| 38 |
<item>todo</item> |
| 39 |
<item>attention</item> |
| 40 |
<item>attn</item> |
| 41 |
<item>fixme</item> |
| 42 |
<item>achtung</item> |
| 43 |
<item>info</item> |
| 44 |
</list> |
| 45 |
<list name="IntFunctions"> |
| 46 |
<item>DOSMEM</item> <!-- b|k|m--> |
| 47 |
<item>EMS</item> <!-- b|k|m--> |
| 48 |
<item>EXTENDED</item> <!-- b|k|m--> |
| 49 |
<item>XMS</item> <!-- b|k|m--> |
| 50 |
<item>CDROM</item> <!--string--> |
| 51 |
<item>CLUSTSIZE</item> <!--string--> |
| 52 |
<item>CODEPAGE</item> <!--string--> |
| 53 |
<item>COM</item> <!-- int--> |
| 54 |
<item>DEVICE</item> <!--string--> |
| 55 |
<item>DISKFREE</item> <!--string, b|k|m--> |
| 56 |
<item>DISKTOTAL</item> <!--string, b|k|m--> |
| 57 |
<item>DISKUSED</item> <!--string, b|k|m--> |
| 58 |
<item>DRIVETYPE</item> <!--string--> |
| 59 |
<item>HDDSIZE</item> <!--string, b|k|m--> |
| 60 |
<item>LPT</item> <!-- int--> |
| 61 |
<item>READY</item> <!--string--> |
| 62 |
<item>REMOTE</item> <!--string--> |
| 63 |
<item>REMOVABLE</item> <!--string--> |
| 64 |
<item>ATTRIB</item> <!--string,-n|r|h|s|a|d,p]--><!--ATTENTION : nur mit 2 Parametern wird ein Int returned--> |
| 65 |
<item>COMPARE</item> <!--string--> |
| 66 |
<item>FILEAGE</item> <!--string,a|c|w]--> |
| 67 |
<item>FILECLOSE</item> <!-- int--> |
| 68 |
<item>FILEOPEN</item> <!--string, r|w|a,b|t]--> |
| 69 |
<item>FILEREAD</item> <!-- int, int]--> |
| 70 |
<item>FILEREADB</item> <!-- int, int--> |
| 71 |
<item>FILES</item> <!--string,-n|r|h|s|a|d]--> |
| 72 |
<item>FILESEEK</item> <!-- int, int, int--> |
| 73 |
<item>FILESEEKL</item> <!-- int, int--> |
| 74 |
<item>FILESIZE</item> <!--string,char,char]]--> |
| 75 |
<item>FILEWRITE</item> <!-- int,string--> |
| 76 |
<item>FILEWRITEB</item> <!-- int, int,string--> |
| 77 |
<item>FINDCLOSE</item> <!--string--> |
| 78 |
<item>LINES</item> <!--string--> |
| 79 |
<item>ASCII</item> <!-- char--> |
| 80 |
<item>COUNT</item> <!-- char,string--> |
| 81 |
<item>FIELDS</item> <!--"string",]string--> |
| 82 |
<item>INDEX</item> <!--string,string,int]--> |
| 83 |
<item>ISALNUM</item> <!--string--> |
| 84 |
<item>ISALPHA</item> <!--string--> |
| 85 |
<item>ISASCII</item> <!--string--> |
| 86 |
<item>ISCNTRL</item> <!--string--> |
| 87 |
<item>ISDIGIT</item> <!--string--> |
| 88 |
<item>ISLOWER</item> <!--string--> |
| 89 |
<item>ISPRINT</item> <!--string--> |
| 90 |
<item>ISPUNCT</item> <!--string--> |
| 91 |
<item>ISSPACE</item> <!--string--> |
| 92 |
<item>ISUPPER</item> <!--string--> |
| 93 |
<item>ISXDIGIT</item> <!--string--> |
| 94 |
<item>LEN</item> <!--string--> |
| 95 |
<item>SIMILAR</item> <!--string,string--> |
| 96 |
<item>WILD</item> <!--string,string--> |
| 97 |
<item>WORDS</item> <!--"string",]string--> |
| 98 |
<item>ABS</item> <!-- float--> |
| 99 |
<item>AVERAGE</item> <!-- float,float,float...]]]--> |
| 100 |
<item>CEILING</item> <!-- float--> |
| 101 |
<item>CONVERT</item> <!-- int, int, int--> |
| 102 |
<item>DEC</item> <!--expression--> |
| 103 |
<item>DECIMAL</item> <!-- float--> |
| 104 |
<item>DIGITS</item> <!--string--> |
| 105 |
<item>EVAL</item> <!--expression--> |
| 106 |
<item>FLOOR</item> <!-- float--> |
| 107 |
<item>INC</item> <!--expression--> |
| 108 |
<item>INT</item> <!-- float--> |
| 109 |
<item>MAX</item> <!-- float,float,float...]]]--> |
| 110 |
<item>MIN</item> <!-- float,float,float...]]]--> |
| 111 |
<item>NUMERIC</item> <!--string--> |
| 112 |
<item>RANDOM</item> <!-- float,float--> |
| 113 |
<item>DATE</item> <!-- date--> |
| 114 |
<item>DAY</item> <!-- date--> |
| 115 |
<item>DOWI</item> <!-- date--> |
| 116 |
<item>DOY</item> <!-- date--> |
| 117 |
<item>ISODOWI</item> <!-- date--> |
| 118 |
<item>ISOWEEK</item> <!-- date--> |
| 119 |
<item>ISOWYEAR</item> <!-- date--> |
| 120 |
<item>MAKEAGE</item> <!-- date,time]--> |
| 121 |
<item>MONTH</item> <!-- date--> |
| 122 |
<item>TIME</item> <!-- time--> |
| 123 |
<item>YEAR</item> <!-- date--> |
| 124 |
<item>EXEC</item> <!--expression--> |
| 125 |
<item>INIWRITE</item> <!--string,string,string,string--> |
| 126 |
</list> |
| 127 |
<list name="StringFunctions"> |
| 128 |
<item>DDCSTR</item> <!-- int--> |
| 129 |
<item>MASTER</item> <!--string--> |
| 130 |
<item>READSCR</item> <!-- int, int, int--> |
| 131 |
<item>SMBSTR</item> <!-- int, int--> |
| 132 |
<item>CWD</item> <!--string--> |
| 133 |
<item>CWDS</item> <!--string--> |
| 134 |
<item>FSTYPE</item> <!--string--> |
| 135 |
<item>LABEL</item> <!--string--> |
| 136 |
<item>SERIAL</item> <!--string--> |
| 137 |
<item>ATTRIB</item> <!--string--><!--ATTENTION : nur mit 1 Parameter wird ein String returned--> |
| 138 |
<item>FILEDATE</item> <!--string,acw],n]]--> |
| 139 |
<item>FILETIME</item> <!--string,acw],s]]--> |
| 140 |
<item>FINDFIRST</item> <!--string,-n|r|h|s|a|d]--> |
| 141 |
<item>FINDNEXT</item> <!--string,-n|r|h|s|a|d]--> |
| 142 |
<item>LINE</item> <!--string, int--> |
| 143 |
<item>MD5</item> <!--string--> |
| 144 |
<item>SEARCH</item> <!--string,string]--> |
| 145 |
<item>SHA1</item> <!--string--> |
| 146 |
<item>TRUENAME</item> <!--string--> |
| 147 |
<item>UNIQUE</item> <!--string--> |
| 148 |
<item>ALTNAME</item> <!--string--> |
| 149 |
<item>EXPAND</item> <!--string,-n|r|h|s|a|d]--> |
| 150 |
<item>EXT</item> <!--string--> |
| 151 |
<item>FILENAME</item> <!--string--> |
| 152 |
<item>FULL</item> <!--string--> |
| 153 |
<item>LFN</item> <!--string--> |
| 154 |
<item>NAME</item> <!--string--> |
| 155 |
<item>PATH</item> <!--string--> |
| 156 |
<item>QUOTE</item> <!--string--> |
| 157 |
<item>SFN</item> <!--string--> |
| 158 |
<item>UNQUOTE</item> <!--string--> |
| 159 |
<item>UNQUOTES</item> <!--string--> |
| 160 |
<item>ASCII</item> <!--string--> |
| 161 |
<item>CAPS</item> <!--"string",string--> |
| 162 |
<item>CHAR</item> <!--space-delimited list of int--> |
| 163 |
<item>FIELD</item> <!--"string",] int,string--> |
| 164 |
<item>FORMAT</item> <!--string,string--> |
| 165 |
<item>INSERT</item> <!-- int,string,string--> |
| 166 |
<item>INSTR</item> <!-- int, int,string--> |
| 167 |
<item>LCS</item> <!--string,string--> |
| 168 |
<item>LEFT</item> <!-- int,string--> |
| 169 |
<item>LOWER</item> <!--string--> |
| 170 |
<item>LTRIM</item> <!--string,string--> |
| 171 |
<item>REPEAT</item> <!-- char, int--> |
| 172 |
<item>REPLACE</item> <!--string,string,string--> |
| 173 |
<item>RIGHT</item> <!-- int,string--> |
| 174 |
<item>RTRIM</item> <!--string,string--> |
| 175 |
<item>REVERSE</item> <!--string--> |
| 176 |
<item>STRIP</item> <!--string,string--> |
| 177 |
<item>SUBST</item> <!-- int,string,string--> |
| 178 |
<item>SUBSTR</item> <!-- int, int,string--> |
| 179 |
<item>TRIM</item> <!--string--> |
| 180 |
<item>UPPER</item> <!--string--> |
| 181 |
<item>WORD</item> <!--"string",]n,string--> |
| 182 |
<item>COMMA</item> <!-- float--> |
| 183 |
<item>AGEDATE</item> <!-- int,format]--> |
| 184 |
<item>DATECONV</item> <!--string,format]--> |
| 185 |
<item>DOW</item> <!-- date--> |
| 186 |
<item>DOWF</item> <!-- date--> |
| 187 |
<item>MAKEDATE</item> <!-- int--> |
| 188 |
<item>MAKETIME</item> <!-- int--> |
| 189 |
<item>MONTHF</item> <!-- date--> |
| 190 |
<item>ALIAS</item> <!--string--> |
| 191 |
<item>CLIP</item> <!--string--> |
| 192 |
<item>CLIPW</item> <!--string--> |
| 193 |
<item>EXECSTR</item> <!--string--> |
| 194 |
<item>FUNCTION</item> <!--string--> |
| 195 |
<item>HISTORY</item> <!-- int, int]--> |
| 196 |
<item>IF</item> <!--condition,string,string--> |
| 197 |
<item>INIREAD</item> <!--string,string,string--> |
| 198 |
<item>SELECT</item> <!--string, int, int, int, int,string--> |
| 199 |
<item>TIMER</item> <!-- int--> |
| 200 |
</list> |
| 201 |
<list name="IfCommand"> <item>if</item> </list> |
| 202 |
<list name="IffCommand"> <item>iff</item> </list> |
| 203 |
<list name="TextCommand"> <item>text</item> </list> |
| 204 |
<list name="InputCommand"> <item>input</item> </list> |
| 205 |
<list name="InkeyCommand"> <item>inkey</item> </list> |
| 206 |
<list name="DoCommand"> <item>do</item> </list> |
| 207 |
<list name="EnddoCommand"> <item>enddo</item> </list> |
| 208 |
<list name="SkipdoCommand"> |
| 209 |
<item>iterate</item> |
| 210 |
<item>leave</item> |
| 211 |
</list> |
| 212 |
<list name="SwitchCommand"> <item>switch</item> </list> |
| 213 |
<list name="TestErrorlevel"><item>errorlevel</item></list> |
| 214 |
<list name="TestStatusVarname"> |
| 215 |
<item>defined</item> |
| 216 |
<item>isalias</item> |
| 217 |
<item>isfunction</item> |
| 218 |
<item>isinternal</item> |
| 219 |
<item>islabel</item> |
| 220 |
</list> |
| 221 |
<list name="SetCommand"> |
| 222 |
<item>set</item> |
| 223 |
<item>function</item> |
| 224 |
<item>alias</item> |
| 225 |
</list> |
| 226 |
<list name="UnsetCommand"> |
| 227 |
<item>ENDLOCAL</item> |
| 228 |
<item>UNALIAS</item> |
| 229 |
<item>UNFUNCTION</item> |
| 230 |
<item>UNSET</item> |
| 231 |
</list> |
| 232 |
<list name="BadCommands"> |
| 233 |
<item>for</item> |
| 234 |
<item>else</item> |
| 235 |
<item>elseiff</item> |
| 236 |
<item>endiff</item> |
| 237 |
<item>enddo</item> |
| 238 |
<item>endtext</item> |
| 239 |
<item>case</item> |
| 240 |
<item>endswitch</item> |
| 241 |
<item>default</item> |
| 242 |
<!-- the following is only valid within a do-loop. But obviously I didn't think about it twice: |
| 243 |
if inside a do-loop we enter an iff/endiff construct, we switch contexts and the "leave" will |
| 244 |
not be found by the "insideDo" context. There would need to be a way to create a dynamic list |
| 245 |
of keywords that can be shorted or expanded by a specific context, so that the above wouldn't |
| 246 |
happen. --> |
| 247 |
<!--item> iterate </item> |
| 248 |
<item> leave </item--> |
| 249 |
</list> |
| 250 |
<list name="NeedOnOffCommands"> |
| 251 |
<item>BREAK</item> |
| 252 |
<item>IDLE</item> |
| 253 |
<item>LFNFOR</item> |
| 254 |
<item>LOADBTM</item> |
| 255 |
<item>SWAPPING</item> |
| 256 |
<item>TRANSIENT</item> |
| 257 |
<item>VERIFY</item> |
| 258 |
</list> |
| 259 |
<list name="TakeAFileNameCommands"> |
| 260 |
<item>CALL</item> |
| 261 |
<item>CD</item> |
| 262 |
<item>CHDIR</item> |
| 263 |
<item>CDD</item> |
| 264 |
<item>DIR</item> |
| 265 |
<item>ERASE</item> |
| 266 |
<item>DEL</item> |
| 267 |
<item>DESCRIBE</item> |
| 268 |
<item>HEAD</item> |
| 269 |
<item>MD</item> |
| 270 |
<item>MKDIR</item> |
| 271 |
<item>RD</item> |
| 272 |
<item>RMDIR</item> |
| 273 |
<item>PUSHD</item> |
| 274 |
<item>REN</item> |
| 275 |
<item>RENAME</item> |
| 276 |
<item>TOUCH</item> |
| 277 |
</list> |
| 278 |
<list name="simpleNoChecksCommands"> |
| 279 |
<item>BEEP</item> |
| 280 |
<item>CANCEL</item> |
| 281 |
<item>DATE</item> |
| 282 |
<item>FREE</item> |
| 283 |
<item>KEYBD</item> |
| 284 |
<item>ELSE</item> |
| 285 |
<item>PAUSE</item> |
| 286 |
<item>POPD</item> |
| 287 |
<item>QUIT</item> |
| 288 |
<item>SETDOS</item> |
| 289 |
<item>SHIFT</item> |
| 290 |
<item>TAIL</item> |
| 291 |
<item>TEE</item> |
| 292 |
<item>TIME</item> |
| 293 |
<item>TIMER</item> |
| 294 |
<item>TYPE</item> |
| 295 |
</list> |
| 296 |
<list name="NeedAnIntegerCommands"> |
| 297 |
<item>CHCP</item> |
| 298 |
<item>DELAY</item> |
| 299 |
<item>COUNTRY</item> |
| 300 |
<item>SETERROR</item> |
| 301 |
</list> |
| 302 |
<list name="TakeColorsCommands"> |
| 303 |
<item>CLS</item> |
| 304 |
<item>COLOR</item> |
| 305 |
</list> |
| 306 |
<list name="FilesystemOperationCommands"> |
| 307 |
<item>ATTRIB</item> |
| 308 |
<item>COPY</item> |
| 309 |
<item>FFIND</item> |
| 310 |
<item>MOVE</item> |
| 311 |
</list> |
| 312 |
<list name="DrawCommands"> |
| 313 |
<item>DRAWBOX</item> |
| 314 |
<item>DRAWHLINE</item> |
| 315 |
<item>DRAWVLINE</item> |
| 316 |
<item>SCREEN</item> |
| 317 |
<item>SCRPUT</item> |
| 318 |
<item>VSCRPUT</item> |
| 319 |
</list> |
| 320 |
<list name="NeedsACommandCommands"> |
| 321 |
<item>EXCEPT</item> |
| 322 |
<item>GLOBAL</item> |
| 323 |
</list> |
| 324 |
<list name="NoParametersAtAllCommands"> |
| 325 |
<item>SETLOCAL</item> |
| 326 |
</list> |
| 327 |
<list name="OnOff"> |
| 328 |
<item>on</item> |
| 329 |
<item>off</item> |
| 330 |
</list> |
| 331 |
<contexts> |
| 332 |
<context name="base" attribute="Normal" lineEndContext="#stay"> |
| 333 |
<IncludeRules context="findComments"/> |
| 334 |
<IncludeRules context="findCommands"/> |
| 335 |
<IncludeRules context="findCommandSeparator"/> |
| 336 |
<IncludeRules context="findStrings"/> <!-- includes "findSubstitution"--> |
| 337 |
</context> |
| 338 |
<!-- |
| 339 |
the following contexts are meant to be included in other contexts. |
| 340 |
--> |
| 341 |
<!-- find any comments (we were even keen enough to highlight things like TODO/FIXME and so on)--> |
| 342 |
<context name="findComments" attribute="Normal" lineEndContext="#stay"> |
| 343 |
<Detect2Chars attribute="Comment" context="foundComment" char=":" char1=":" column="0"/> |
| 344 |
<WordDetect attribute="Comment" context="foundComment" String="rem" insensitive="true"/> |
| 345 |
</context> |
| 346 |
|
| 347 |
<!-- whereever there should be a command start, the following should match in some way or another --> |
| 348 |
<context name="findCommands" attribute="Normal" lineEndContext="#stay"> |
| 349 |
<!-- Highlight command groups and start/end corresponding folding region --> |
| 350 |
<DetectChar attribute="Label" context="CommandGroup" char="(" beginRegion="true"/> |
| 351 |
<!-- find Labels and jmp/jsr/rts commands --> |
| 352 |
<IncludeRules context="findSpaghetti"/> |
| 353 |
<!-- find commands that need special handling--> |
| 354 |
<!-- TODO: replace single-item keyword lists with WordDetect as soon as WordDetect works properly again--> |
| 355 |
<keyword attribute="Keyword" context="conditionLeft" String="IfCommand"/> |
| 356 |
<keyword attribute="Keyword" context="cmdIff" String="IffCommand"/> |
| 357 |
<!-- find all "echo"-variations --> |
| 358 |
<RegExpr attribute="Keyword" String="[@]?echo\s+(?:on|off)(?=\s*($|\%\+|\)|\]))" insensitive="true"/> |
| 359 |
<RegExpr attribute="Keyword" context="cmdEcho" String="\becho[s]?(?:err)?[\.]?" insensitive="true"/> |
| 360 |
<!-- special treatment for Text and EndText --> |
| 361 |
<keyword attribute="Keyword" context="cmdText" String="TextCommand" insensitive="true" beginRegion="true"/> |
| 362 |
<!-- Set und Unset-Befehle --> |
| 363 |
<keyword attribute="Keyword" context="cmdSet" String="SetCommand"/> |
| 364 |
<keyword attribute="Keyword" context="cmdUnset" String="UnsetCommand"/> |
| 365 |
<!-- inkey/input --> |
| 366 |
<keyword attribute="Keyword" context="cmdInput" String="InputCommand"/> |
| 367 |
<keyword attribute="Keyword" context="cmdInkey" String="InkeyCommand"/> |
| 368 |
<!-- do loops --> |
| 369 |
<keyword attribute="Keyword" context="cmdDo" String="DoCommand" beginRegion="true"/> |
| 370 |
<!-- switch constructs --> |
| 371 |
<keyword attribute="Keyword" context="cmdSwitch" String="SwitchCommand" beginRegion="true"/> |
| 372 |
<!-- all the other internal 4DOS commands (with as little processing, as time permits) --> |
| 373 |
<keyword attribute="Keyword" context="cmdNeedOnOff" String="NeedOnOffCommands"/> |
| 374 |
<keyword attribute="Keyword" context="cmdTakeAFileName" String="TakeAFileNameCommands"/> |
| 375 |
<keyword attribute="Keyword" context="cmdsimpleNoChecks" String="simpleNoChecksCommands"/> |
| 376 |
<keyword attribute="Keyword" context="cmdNeedAnInteger" String="NeedAnIntegerCommands"/> |
| 377 |
<keyword attribute="Keyword" context="cmdTakeColors" String="TakeColorsCommands"/> |
| 378 |
<keyword attribute="Keyword" context="cmdFilesystemOperation" String="FilesystemOperationCommands"/> |
| 379 |
<keyword attribute="Keyword" context="cmdDraw" String="DrawCommands"/> |
| 380 |
<keyword attribute="Keyword" context="cmdNeedsACommand" String="NeedsACommandCommands"/> |
| 381 |
<keyword attribute="Keyword" context="popNeedEndOfCommand" String="NoParametersAtAllCommands"/> |
| 382 |
<!-- BAD COMMANDS: |
| 383 |
for :: if someone codes for 4DOS, he shall not use for-loops. The way to go is using do-loops, |
| 384 |
for-loops were just included into 4DOS to have M$-DOS command.com compatibility |
| 385 |
any other bad commands: are not available outside of their respective scopes, or it's the same |
| 386 |
as with "for" |
| 387 |
--> |
| 388 |
<keyword attribute="Error" context="Error" String="BadCommands"/> |
| 389 |
</context> |
| 390 |
|
| 391 |
<!-- find jumps, labels and subroutine calls --> |
| 392 |
<context name="findSpaghetti" attribute="Normal" lineEndContext="#stay"> |
| 393 |
<RegExpr attribute="Label" context="foundLabel" String="^:&label;" beginRegion="true" insensitive="true" column="0"/> |
| 394 |
<RegExpr attribute="Label" context="foundSpagetti" String="(?:goto|gosub)\s+&label;" insensitive="true"/> |
| 395 |
<WordDetect attribute="Label" String="return" insensitive="true" endRegion="true"/> |
| 396 |
</context> |
| 397 |
|
| 398 |
<!-- find any variable substitution--> |
| 399 |
<context name="findSubstitution" attribute="Normal" lineEndContext="#stay"> |
| 400 |
<DetectChar context="substitutionFound" char="%" lookAhead="true"/> |
| 401 |
</context> |
| 402 |
|
| 403 |
<!-- findVariables just finds variable substitutions WITHOUT variable functions!!!--> |
| 404 |
<context name="findVariables" attribute="Normal" lineEndContext="#stay"> |
| 405 |
<Detect2Chars attribute="VariableBold" context="substitutionIndirect" char="%" char1="["/> |
| 406 |
<RegExpr attribute="Variable" String="%(?:[a-z_][a-z_0-9]*%?|[0-9]+&?|&|\?+|_\?|#)" insensitive="true"/> |
| 407 |
</context> |
| 408 |
|
| 409 |
<!-- findNumbers finds Numbers and variableSubstitutions that may well be numbers--> |
| 410 |
<context name="findNumbers" attribute="Normal" lineEndContext="#stay"> |
| 411 |
<RegExpr attribute="Number" String="\s*[+-]?\d*[,.]?\d+"/> |
| 412 |
<Detect2Chars attribute="Function" context="substitutionFindIntFunction" char="%" char1="@"/> |
| 413 |
<IncludeRules context="findVariables"/> |
| 414 |
</context> |
| 415 |
|
| 416 |
<!-- findStrings should skip over Strings, highlighting any substitution inside--> |
| 417 |
<context name="findStrings" attribute="Normal" lineEndContext="#stay"> |
| 418 |
<DetectChar attribute="Escape" context="foundStringBackQuote" char="`"/> |
| 419 |
<DetectChar attribute="String" context="foundStringQuote" char="""/> |
| 420 |
<IncludeRules context="findEscapes"/> |
| 421 |
<IncludeRules context="findSubstitution"/> |
| 422 |
<!-- a Number may well be interpreted as a string in 4dos, also --> |
| 423 |
<RegExpr attribute="Number" String="\s*[+-]?\d*[,.]?\d+"/> |
| 424 |
<!-- the following highlights ANSI-Escape-Sequences --> |
| 425 |
<RegExpr attribute="Escape" String="\x1b\[.*[fhlmpsuABCDHJKR]" minimal="true"/> |
| 426 |
<!-- |
| 427 |
we shall find strings - so why don't we find at least literal words? |
| 428 |
|
| 429 |
There is one simple answer: if we are inside a context that shall highlight strings, |
| 430 |
then "findStrings" is included, to find things that evaluate to some kind of string. |
| 431 |
Normal plaintext strings shall be lit by the context itself. |
| 432 |
--> |
| 433 |
</context> |
| 434 |
|
| 435 |
<!-- highlight escaped characters --> |
| 436 |
<context name="findEscapes" attribute="Normal" lineEndContext="#stay"> |
| 437 |
<RegExpr attribute="Escape" context="foundANSIEscape" String="%=e\[(?=.*[fhlmpsuABCDHJKR])" minimal="true"/> |
| 438 |
<RegExpr attribute="Escape" String="\x18.|%=."/> |
| 439 |
</context> |
| 440 |
|
| 441 |
<!-- highlight the command seperator without changing contexts --> |
| 442 |
<context name="findCommandSeparator" attribute="Normal" lineEndContext="#stay"> |
| 443 |
<Detect2Chars attribute="Keyword" char="%" char1="+"/> |
| 444 |
</context> |
| 445 |
|
| 446 |
<!-- highlight the command seperator and pop a context --> |
| 447 |
<context name="popNeedEndOfCommand" attribute="Error" lineEndContext="#pop"> |
| 448 |
<Detect2Chars attribute="Keyword" context="#pop" char="%" char1="+"/> |
| 449 |
<DetectSpaces attribute="Normal"/> |
| 450 |
</context> |
| 451 |
|
| 452 |
<!-- Entry Point for finding conditions --> |
| 453 |
<context name="findCondition" attribute="Normal" lineEndContext="#stay"> |
| 454 |
<RegExpr attribute="Error" context="conditionLeft" String="(?:not\s+)*(?:(?:(?:dir)?exist|isdir|defined|is(?:alias|function|label|internal)|errorlevel)|(?:.+(?:(?:\s*(==|!=)\s*)|(?:\s+(?:eq|ne|gt|ge|lt|le|eqc)\s+)).))" lookAhead="true" insensitive="true" minimal="true"/> |
| 455 |
</context> |
| 456 |
|
| 457 |
<!-- find redirections --> |
| 458 |
<context name="findRedirection" attribute="Error" lineEndContext="#stay"> |
| 459 |
<DetectChar attribute="Keyword" context="RedirectionInput1st" char="<"/> |
| 460 |
<RegExpr attribute="Keyword" context="RedirectionOutput1st" String="[>]{1,2}[&]?[>]?"/> |
| 461 |
</context> |
| 462 |
|
| 463 |
<!-- find any Option --> |
| 464 |
<context name="findOption" attribute="Option" lineEndContext="#stay"> |
| 465 |
<DetectChar attribute="Option" context="Option" char="/"/> |
| 466 |
</context> |
| 467 |
|
| 468 |
|
| 469 |
<!-- |
| 470 |
Here we start with functional contexts. These actually do something more than just find something and should not be sourced directly |
| 471 |
--> |
| 472 |
<context name="CommandGroup" attribute="Normal" lineEndContext="#stay"> |
| 473 |
<DetectChar attribute="Label" context="#pop" char=")" endRegion="true"/> |
| 474 |
<IncludeRules context="base"/> |
| 475 |
</context> |
| 476 |
|
| 477 |
<!-- Highlight ANSI Escap-Sequences - the "%=e[" are already eaten up --> |
| 478 |
<context name="foundANSIEscape" attribute="String" lineEndContext="#pop"> |
| 479 |
<IncludeRules context="findStrings"/> |
| 480 |
<AnyChar attribute="Escape" context="#pop" String="fhlmpsuABCDHJKR"/> |
| 481 |
</context> |
| 482 |
|
| 483 |
<!-- if any substitution was found, we get here ... --> |
| 484 |
<context name="substitutionFound" attribute="Error" lineEndContext="#pop"> |
| 485 |
<Detect2Chars attribute="Function" context="#pop!substitutionFindFunction" char="%" char1="@"/> |
| 486 |
<Detect2Chars attribute="VariableBold" context="#pop!substitutionIndirect" char="%" char1="["/> |
| 487 |
<RegExpr attribute="Variable" context="#pop" String="%(?:[a-z_][a-z_0-9]*%?|[0-9]+&?|&|\?+|_\?|#)" insensitive="true"/> |
| 488 |
<!-- in @EVAL there is the modulo-operator %% - we'll have to filter it out! |
| 489 |
TODO: give eval a special handler and remove the following rule. --> |
| 490 |
<Detect2Chars attribute="Operator" context="#pop" char="%" char1="%"/> |
| 491 |
</context> |
| 492 |
|
| 493 |
<context name="substitutionFindFunction" attribute="Error" lineEndContext="#pop"> |
| 494 |
<!-- TODO: add special function handlers for |
| 495 |
execstr |
| 496 |
if |
| 497 |
--> |
| 498 |
<keyword attribute="Function" context="#pop!substitutionFunctionFound" String="StringFunctions"/> |
| 499 |
<IncludeRules context="substitutionFindIntFunction"/> |
| 500 |
</context> |
| 501 |
|
| 502 |
<context name="substitutionFindIntFunction" attribute="Error" lineEndContext="#pop"> |
| 503 |
<!-- TODO: add special function handlers for |
| 504 |
eval |
| 505 |
--> |
| 506 |
<keyword attribute="Function" context="#pop!substitutionFunctionFound" String="IntFunctions"/> |
| 507 |
<RegExpr attribute="Function" context="#pop!substitutionFunctionFound" String="&label;(?=\[)" insensitive="true"/> |
| 508 |
</context> |
| 509 |
|
| 510 |
<!-- Variable Functions - the Masterpower of 4DOS -> we'll make this more complex later on!--> |
| 511 |
<context name="substitutionFunctionFound" attribute="Error" lineEndContext="Error"> |
| 512 |
<DetectChar attribute="Function" context="#pop!findFunctionParameters" beginRegion="true" char="["/> |
| 513 |
</context> |
| 514 |
|
| 515 |
<context name="findFunctionParameters" attribute="String" lineEndContext="Error"> |
| 516 |
<DetectChar attribute="Function" char=","/> |
| 517 |
<DetectChar attribute="Function" context="#pop" endRegion="true" char="]"/> |
| 518 |
<IncludeRules context="findStrings"/> |
| 519 |
</context> |
| 520 |
|
| 521 |
<!-- indirect Substitutions - they need to find their ending braces--> |
| 522 |
<context name="substitutionIndirect" attribute="Variable" lineEndContext="Error"> |
| 523 |
<DetectChar attribute="VariableBold" context="#pop" endRegion="true" char="]"/> |
| 524 |
<IncludeRules context="findStrings"/> |
| 525 |
</context> |
| 526 |
|
| 527 |
<!-- Strings within quotes --> |
| 528 |
<context name="foundStringBackQuote" attribute="String" lineEndContext="#pop"> |
| 529 |
<DetectChar attribute="Escape" context="#pop" char="`"/> |
| 530 |
</context> |
| 531 |
|
| 532 |
<context name="foundStringQuote" attribute="String" lineEndContext="#pop"> |
| 533 |
<DetectChar attribute="String" context="#pop" char="""/> |
| 534 |
<IncludeRules context="findStrings"/> |
| 535 |
</context> |
| 536 |
|
| 537 |
<!-- stuff inside comments ... (a comment always runs until EOL) --> |
| 538 |
<context name="foundComment" attribute="Comment" lineEndContext="#pop"> |
| 539 |
<IncludeRules context="##Comments"/> |
| 540 |
<keyword attribute="Alert" String="HighlightInsideComment"/> |
| 541 |
</context> |
| 542 |
|
| 543 |
<!-- Label definitions including parameter definitions for Gosub--> |
| 544 |
<context name="foundLabel" attribute="Error" lineEndContext="#pop"> |
| 545 |
<!-- Wir suchen nach Parameterdefinitionen für GOSUBs, alles andere sind Fehler! --> |
| 546 |
<DetectChar attribute="Label" context="#pop!foundLabelParameters" char="["/> |
| 547 |
<DetectSpaces attribute="Normal"/> |
| 548 |
</context> |
| 549 |
|
| 550 |
<context name="foundLabelParameters" attribute="Error" lineEndContext="#pop"> |
| 551 |
<DetectIdentifier attribute="Variable" context="#stay"/> |
| 552 |
<DetectChar attribute="Label" context="#pop" char="]"/> |
| 553 |
<DetectSpaces attribute="Normal"/> |
| 554 |
</context> |
| 555 |
|
| 556 |
<!-- highlight gosubs and gotos with additional parameters (only valid with gosub, actually)--> |
| 557 |
<context name="foundSpagetti" attribute="Normal" lineEndContext="#pop"> |
| 558 |
<IncludeRules context="popNeedEndOfCommand"/> |
| 559 |
<IncludeRules context="findStrings"/> |
| 560 |
</context> |
| 561 |
|
| 562 |
<!-- Rules that highlight conditions (include the entry point "findCondition" to start this as a context that pops behind the condition(s))--> |
| 563 |
<context name="conditionLeft" attribute="Normal" lineEndContext="#pop" fallthrough="true" fallthroughContext="#pop!conditionLeftStandard"> |
| 564 |
<RegExpr attribute="Normal" context="conditionNot" String="\bnot\b" lookAhead="true" insensitive="true"/> |
| 565 |
<keyword attribute="Label" context="#pop!conditionVarname" String="TestStatusVarname"/> |
| 566 |
<!-- the end of a filename comes with any non-quoted space - so we need to eat up the first space after exist etc.--> |
| 567 |
<RegExpr attribute="Label" context="#pop!conditionFileTest" String="(?:(?:dir)?exist|isdir)\s+" insensitive="true"/> |
| 568 |
<keyword attribute="Label" context="#pop!conditionErrorlevel" String="TestErrorlevel"/> |
| 569 |
<DetectSpaces/> |
| 570 |
</context> |
| 571 |
|
| 572 |
<context name="conditionNot" attribute="Error" lineEndContext="#pop#pop"> |
| 573 |
<!-- the context itself highlights everything as Error - just this rule finds the last not --> |
| 574 |
<RegExpr attribute="Alert" context="#pop" String="\bnot\b(?!\s*not\b)" insensitive="true"/> |
| 575 |
</context> |
| 576 |
|
| 577 |
<context name="conditionVarname" attribute="Normal" lineEndContext="#pop"> |
| 578 |
<!-- basic variable name check just finds an identifier --> |
| 579 |
<DetectIdentifier attribute="Variable" context="#pop!conditionEnd"/> |
| 580 |
<!-- TODO: further checking, as a varname can also be calculated --> |
| 581 |
</context> |
| 582 |
|
| 583 |
<context name="conditionFileTest" attribute="String" lineEndContext="#pop"> |
| 584 |
<IncludeRules context="findStrings"/> |
| 585 |
<DetectSpaces context="#pop!conditionEnd"/> |
| 586 |
</context> |
| 587 |
|
| 588 |
<context name="conditionErrorlevel" attribute="Normal" lineEndContext="#pop"> |
| 589 |
<DetectSpaces/> |
| 590 |
<RegExpr attribute="Operator" String="==|!=|eq|ne|gt|ge|lt|le" insensitive="true"/> |
| 591 |
<RegExpr attribute="Number" context="#pop!conditionEnd" String="\s*[+-]?\d*[,.]?\d+"/> |
| 592 |
<!-- TODO: actually errorlevel-test can also take calculated numbers or int variables to test agains - but would we want to duplicate a lot of the functionality above again?--> |
| 593 |
</context> |
| 594 |
|
| 595 |
<context name="conditionEnd" attribute="Normal" lineEndContext="#pop" fallthrough="true" fallthroughContext="#pop"> |
| 596 |
<RegExpr attribute="Operator" context="#pop!conditionLeft" String="\.(?:and|x?or)\." insensitive="true"/> |
| 597 |
<!--DetectSpaces/--> |
| 598 |
</context> |
| 599 |
|
| 600 |
<context name="conditionLeftStandard" attribute="Normal" lineEndContext="#pop"> |
| 601 |
<!--DetectSpaces/--> |
| 602 |
<RegExpr attribute="Operator" context="#pop!conditionLeftEval" String="\s*(?:==|!=|eq|ne|gt|ge|lt|le)" lookAhead="true" insensitive="true"/> |
| 603 |
<IncludeRules context="findStrings"/> |
| 604 |
</context> |
| 605 |
|
| 606 |
<context name="conditionLeftEval" attribute="Normal" lineEndContext="#pop" fallthrough="true" fallthroughContext="#pop!conditionRight"> |
| 607 |
<DetectSpaces/> |
| 608 |
<RegExpr attribute="Operator" String="==|!=|eq|ne|gt|ge|lt|le|eqc" insensitive="true"/> |
| 609 |
</context> |
| 610 |
|
| 611 |
<context name="conditionRight" attribute="Normal" lineEndContext="#pop"> |
| 612 |
<IncludeRules context="findStrings"/> |
| 613 |
<DetectSpaces context="#pop!conditionEnd"/> |
| 614 |
</context> |
| 615 |
|
| 616 |
<!-- Handle Iff correctly: condition, then, wait for possible else/handle elseiff find endiff--> |
| 617 |
<context name="cmdIff" attribute="Normal" lineEndContext="#pop"> |
| 618 |
<IncludeRules context="findCondition"/> |
| 619 |
<DetectSpaces/> |
| 620 |
<!-- TODO: replace with WordDetect as soon as WordDetect works right--> |
| 621 |
<RegExpr attribute="Keyword" context="#pop!cmdIffThen" beginRegion="true" String="\bthen\b\s*(?:$|%\+)" insensitive="true"/> |
| 622 |
<!-- should the above regex not match, there is an error... --> |
| 623 |
<StringDetect attribute="Keyword" context="Error" String="then" insensitive="true"/> |
| 624 |
</context> |
| 625 |
|
| 626 |
<context name="cmdIffThen" attribute="Normal" lineEndContext="#stay"> |
| 627 |
<!-- TODO: replace with WordDetect as soon as WordDetect works right--> |
| 628 |
<RegExpr attribute="Keyword" context="popNeedEndOfCommand" String="\belse\b" insensitive="true"/> |
| 629 |
<RegExpr attribute="Keyword" context="cmdElseiff" String="\belseiff\b" insensitive="true"/> |
| 630 |
<RegExpr attribute="Keyword" context="#pop!popNeedEndOfCommand" endRegion="true" String="\bendiff\b" insensitive="true"/> |
| 631 |
<IncludeRules context="base"/> |
| 632 |
</context> |
| 633 |
|
| 634 |
<context name="cmdElseiff" attribute="Normal" lineEndContext="#pop"> |
| 635 |
<IncludeRules context="findCondition"/> |
| 636 |
<DetectSpaces/> |
| 637 |
<!-- TODO: replace with WordDetect as soon as WordDetect works right--> |
| 638 |
<RegExpr attribute="Keyword" context="#pop" String="\bthen\b\s*(?:$|%\+)" insensitive="true"/> |
| 639 |
<!-- should the above regex not match, there is an error... --> |
| 640 |
<StringDetect attribute="Keyword" context="Error" String="then" insensitive="true"/> |
| 641 |
</context> |
| 642 |
|
| 643 |
<!-- echo --> |
| 644 |
<context name="cmdEcho" attribute="String" lineEndContext="#pop"> |
| 645 |
<IncludeRules context="findStrings"/> |
| 646 |
<IncludeRules context="findRedirection"/> |
| 647 |
<RegExpr attribute="Normal" context="#pop" String="\s*(?:$|\%\+|\)|\])" lookAhead="true"/> |
| 648 |
</context> |
| 649 |
|
| 650 |
<!-- Redirection: kann ja auch mehrfach auftreten --> |
| 651 |
<context name="Redirection" attribute="String" lineEndContext="#pop"> |
| 652 |
<DetectSpaces attribute="Normal" context="#stay"/> |
| 653 |
<IncludeRules context="findStrings"/> |
| 654 |
<IncludeRules context="popNeedEndOfCommand"/> |
| 655 |
</context> |
| 656 |
|
| 657 |
<context name="RedirectionOutput1st" attribute="String" lineEndContext="#pop"> |
| 658 |
<IncludeRules context="Redirection"/> |
| 659 |
<DetectChar attribute="Redirection" context="#pop!Redirection" char="<"/> |
| 660 |
</context> |
| 661 |
|
| 662 |
<context name="RedirectionInput1st" attribute="String" lineEndContext="#pop"> |
| 663 |
<IncludeRules context="Redirection"/> |
| 664 |
<RegExpr attribute="Redirection" context="#pop!Redirection" String="[>]{1,2}[&]?[>]?"/> |
| 665 |
</context> |
| 666 |
|
| 667 |
<!-- special treatment of text and endtext --> |
| 668 |
<context name="cmdText" attribute="Error" lineEndContext="#pop!cmdEndText"> |
| 669 |
<DetectSpaces attribute="Normal" context="#stay"/> |
| 670 |
<RegExpr attribute="Keyword" context="Redirection" String="[>]{1,2}"/> |
| 671 |
</context> |
| 672 |
|
| 673 |
<context name="cmdEndText" attribute="String" lineEndContext="#stay"> |
| 674 |
<RegExpr attribute="Keyword" context="#pop" String="^\s*endtext\s*$" insensitive="true" column="0"/> |
| 675 |
<!-- As we are pretty 31337, we also highlight ANSI-Escapes in Textblocks. |
| 676 |
We're just not 1337 enough to also provide a syntactic checking for |
| 677 |
those sequences...--> |
| 678 |
<RegExpr attribute="Escape" String="\x1b\[.*[fhlmpsuABCDHJKR]" minimal="true"/> |
| 679 |
</context> |
| 680 |
|
| 681 |
<!-- Set/Unset commands --> |
| 682 |
<context name="cmdUnset" attribute="Normal" lineEndContext="#pop"> |
| 683 |
<IncludeRules context="findOption"/> |
| 684 |
<DetectIdentifier attribute="Variable" context="#stay"/> |
| 685 |
<IncludeRules context="popNeedEndOfCommand"/> |
| 686 |
</context> |
| 687 |
|
| 688 |
<context name="cmdSet" attribute="Normal" lineEndContext="#pop"> |
| 689 |
<DetectChar attribute="Keyword" context="#pop" char="="/> |
| 690 |
<IncludeRules context="cmdUnset"/> |
| 691 |
</context> |
| 692 |
|
| 693 |
<!-- Highlight an Option, #pop on next space ...--> |
| 694 |
<context name="Option" attribute="Option" lineEndContext="#pop"> |
| 695 |
<IncludeRules context="findStrings"/> |
| 696 |
<DetectSpaces attribute="Normal" context="#pop"/> |
| 697 |
</context> |
| 698 |
|
| 699 |
<!-- input und inkey - testing allowed Options ... --> |
| 700 |
<context name="cmdInput" attribute="String" lineEndContext="#pop" |
| 701 |
fallthroughContext="#pop!inputMessage" fallthrough="true"> |
| 702 |
<IncludeRules context="input"/> |
| 703 |
<RegExpr attribute="Option" String="/(?:[en]|l[0-9]+)\s" insensitive="true"/> |
| 704 |
</context> |
| 705 |
|
| 706 |
<context name="cmdInkey" attribute="String" lineEndContext="#pop" |
| 707 |
fallthroughContext="#pop!inputMessage" fallthrough="true"> |
| 708 |
<StringDetect attribute="Option" context="inputKeysDP" String="/k:" insensitive="true"/> |
| 709 |
<StringDetect attribute="Option" context="inputKeysAZ" String="/k"" insensitive="true"/> |
| 710 |
<StringDetect attribute="Error" String="/k" insensitive="true"/> |
| 711 |
<StringDetect attribute="Option" String="/m" insensitive="true"/> |
| 712 |
<IncludeRules context="input"/> |
| 713 |
</context> |
| 714 |
|
| 715 |
<context name="input" attribute="Error" lineEndContext="#stay"> |
| 716 |
<RegExpr attribute="Option" String="/(?:[cdpx]|[w][0-9]+)\s" insensitive="true"/> |
| 717 |
<DetectSpaces attribute="Normal" context="#stay"/> |
| 718 |
</context> |
| 719 |
|
| 720 |
<context name="inputKeysDP" attribute="Error" lineEndContext="#pop#pop"> |
| 721 |
<DetectChar attribute="String" context="inputKeyDesc" char="["/> |
| 722 |
<DetectSpaces attribute="Normal" context="#pop"/> |
| 723 |
<RegExpr attribute="Function" String="\S"/> |
| 724 |
</context> |
| 725 |
|
| 726 |
<context name="inputKeysAZ" attribute="Error" lineEndContext="#pop#pop"> |
| 727 |
<DetectChar attribute="String" context="inputKeyDesc" char="["/> |
| 728 |
<DetectChar attribute="Option" context="#pop" char="""/> |
| 729 |
<RegExpr attribute="Function" String="\S"/> |
| 730 |
</context> |
| 731 |
|
| 732 |
<context name="inputKeyDesc" attribute="Error" lineEndContext="#pop#pop#pop"> |
| 733 |
<RegExpr attribute="Label" context="#pop!inputKeyDesc2" String="&tasten;"/> |
| 734 |
</context> |
| 735 |
|
| 736 |
<context name="inputKeyDesc2" attribute="Error" lineEndContext="#pop#pop#pop"> |
| 737 |
<DetectChar attribute="String" context="#pop" char="]"/> |
| 738 |
</context> |
| 739 |
|
| 740 |
<context name="inputMessage" attribute="String" lineEndContext="#pop"> |
| 741 |
<RegExpr attribute="Variable" context="#pop!popNeedEndOfCommand" String="%%[a-z_][a-z0-9_]*" insensitive="true"/> |
| 742 |
<IncludeRules context="findStrings"/> |
| 743 |
</context> |
| 744 |
|
| 745 |
<!-- special treatment of DO --> |
| 746 |
<context name="cmdDo" attribute="Error" lineEndContext="Error"> |
| 747 |
<!-- do n | forever--> |
| 748 |
<RegExpr attribute="Label" context="#pop!insideDo" String="\s*forever(?=\s*$)" insensitive="true"/> |
| 749 |
<RegExpr attribute="Variable" context="#pop!fixedDo" String="\s*[%0-9]" lookAhead="true"/> |
| 750 |
<!-- WHILE | UNTIL --> |
| 751 |
<RegExpr attribute="Label" context="#pop!conditionalDo" String="\s*(?:while|until)" insensitive="true"/> |
| 752 |
<!-- varname = start TO end [BY n] | varname in blubberkram --> |
| 753 |
<RegExpr attribute="Variable" context="#pop!countedDo" String="\s*&varname;" insensitive="true"/> |
| 754 |
</context> |
| 755 |
|
| 756 |
<context name="fixedDo" attribute="Error" lineEndContext="#pop!insideDo"> |
| 757 |
<DetectSpaces attribute="Normal"/> |
| 758 |
<IncludeRules context="findNumbers"/> |
| 759 |
</context> |
| 760 |
|
| 761 |
<context name="countedDo" attribute="Error" lineEndContext="Error"> |
| 762 |
<RegExpr attribute="Keyword" context="#pop!countedDoIn" String="\bin\b" insensitive="true"/> |
| 763 |
<DetectChar attribute="Keyword" context="#pop!countedDoStart" char="="/> |
| 764 |
<DetectSpaces attribute="Normal"/> |
| 765 |
</context> |
| 766 |
|
| 767 |
<context name="countedDoIn" attribute="String" lineEndContext="#pop!insideDo"> |
| 768 |
<DetectSpaces/> |
| 769 |
<IncludeRules context="findOption"/> |
| 770 |
<IncludeRules context="findStrings"/> |
| 771 |
</context> |
| 772 |
|
| 773 |
<context name="countedDoStart" attribute="Error" lineEndContext="Error"> |
| 774 |
<RegExpr attribute="Keyword" context="#pop!countedDoTo" String="\bto\b" insensitive="true"/> |
| 775 |
<IncludeRules context="findNumbers"/> |
| 776 |
<DetectSpaces attribute="Normal"/> |
| 777 |
</context> |
| 778 |
|
| 779 |
<context name="countedDoTo" attribute="Error" lineEndContext="#pop!insideDo"> |
| 780 |
<IncludeRules context="findNumbers"/> |
| 781 |
<DetectSpaces attribute="Normal"/> |
| 782 |
<RegExpr attribute="Keyword" context="#pop!countedDoBy" String="\bby\b" insensitive="true"/> |
| 783 |
</context> |
| 784 |
|
| 785 |
<context name="countedDoBy" attribute="Error" lineEndContext="#pop!insideDo"> |
| 786 |
<IncludeRules context="findNumbers"/> |
| 787 |
<DetectSpaces attribute="Normal"/> |
| 788 |
</context> |
| 789 |
|
| 790 |
<context name="conditionalDo" attribute="Error" lineEndContext="#pop!insideDo"> |
| 791 |
<IncludeRules context="findCondition"/> |
| 792 |
<DetectSpaces attribute="Normal"/> |
| 793 |
</context> |
| 794 |
|
| 795 |
<context name="insideDo" attribute="Normal" lineEndContext="#stay"> |
| 796 |
<keyword attribute="Keyword" String="SkipdoCommand"/> |
| 797 |
<keyword attribute="Keyword" endRegion="true" context="#pop!popNeedEndOfCommand" String="EnddoCommand"/> |
| 798 |
<IncludeRules context="base"/> |
| 799 |
</context> |
| 800 |
|
| 801 |
<!-- special treatment of switch statements --> |
| 802 |
<context name="cmdSwitch" attribute="Normal" lineEndContext="#pop!insideSwitch"> |
| 803 |
<IncludeRules context="findStrings"/> |
| 804 |
</context> |
| 805 |
|
| 806 |
<context name="insideSwitch" attribute="Normal" lineEndContext="#stay"> |
| 807 |
<RegExpr attribute="Keyword" context="#pop!switchDefault" String="\s*default\s*$" insensitive="true"/> |
| 808 |
<IncludeRules context="switchDefault"/> |
| 809 |
</context> |
| 810 |
<!-- "Default" may be used only once, that's why we change contexts when it was found --> |
| 811 |
<context name="switchDefault" attribute="Normal" lineEndContext="#stay"> |
| 812 |
<RegExpr attribute="Keyword" context="switchCase" String="\bcase\b" insensitive="true"/> |
| 813 |
<RegExpr attribute="Keyword" context="#pop!popNeedEndOfCommand" String="\bendswitch\b" insensitive="true" endRegion="true"/> |
| 814 |
<IncludeRules context="base"/> |
| 815 |
</context> |
| 816 |
|
| 817 |
<context name="switchCase" attribute="String" lineEndContext="#pop"> |
| 818 |
<DetectSpaces/> |
| 819 |
<StringDetect attribute="Operator" insensitive="true" String=".or."/> |
| 820 |
<IncludeRules context="findStrings"/> |
| 821 |
</context> |
| 822 |
|
| 823 |
<!-- internal commands of the 4DOS interpreter (TODO: make it even better, like integrated syntax checking) --> |
| 824 |
<context name="cmdNeedOnOff" attribute="Error" lineEndContext="#pop"> |
| 825 |
<keyword attribute="String" context="#pop!popNeedEndOfCommand" String="OnOff"/> |
| 826 |
<DetectSpaces attribute="Normal"/> |
| 827 |
</context> |
| 828 |
|
| 829 |
<context name="cmdNeedAnInteger" attribute="Error" lineEndContext="#pop"> |
| 830 |
<DetectSpaces attribute="Normal"/> |
| 831 |
<IncludeRules context="findOption"/> |
| 832 |
<IncludeRules context="findNumbers"/> |
| 833 |
<IncludeRules context="popNeedEndOfCommand"/> |
| 834 |
</context> |
| 835 |
|
| 836 |
<context name="cmdNeedsACommand" attribute="String" lineEndContext="#pop"> |
| 837 |
<IncludeRules context="findOption"/> |
| 838 |
<IncludeRules context="base"/> |
| 839 |
</context> |
| 840 |
|
| 841 |
<context name="cmdsimpleNoChecks" attribute="String" lineEndContext="#pop"> |
| 842 |
<IncludeRules context="findOption"/> |
| 843 |
<IncludeRules context="findStrings"/> |
| 844 |
<IncludeRules context="popNeedEndOfCommand"/> |
| 845 |
</context> |
| 846 |
|
| 847 |
<context name="cmdTakeAFileName" attribute="String" lineEndContext="#pop"> |
| 848 |
<IncludeRules context="findOption"/> |
| 849 |
<IncludeRules context="findStrings"/> |
| 850 |
<IncludeRules context="popNeedEndOfCommand"/> |
| 851 |
</context> |
| 852 |
|
| 853 |
<context name="cmdTakeColors" attribute="String" lineEndContext="#pop"> |
| 854 |
<RegExpr attribute="Operator" context="#pop!ColorHaveBrightFG" String="\bbri(?:ght)?\b" insensitive="true"/> |
| 855 |
<RegExpr attribute="Operator" context="#pop!ColorHaveBlinkFG" String="\bbli(?:nk)?\b" insensitive="true"/> |
| 856 |
<IncludeRules context="ColorHaveBlinkFG"/> |
| 857 |
</context> |
| 858 |
|
| 859 |
<context name="ColorHaveBrightFG" attribute="String" lineEndContext="Error"> |
| 860 |
<RegExpr attribute="Operator" context="#pop!ColorHaveBlinkFG" String="\bbli(?:nk)?\b" insensitive="true"/> |
| 861 |
<IncludeRules context="ColorHaveBlinkFG"/> |
| 862 |
</context> |
| 863 |
|
| 864 |
<context name="ColorHaveBlinkFG" attribute="String" lineEndContext="Error"> |
| 865 |
<RegExpr attribute="Option" context="#pop!ColorHaveFG" insensitive="true" String="\b(?:Bla(?:ck)?|Blue?|Gre(?:en)?|Red|Mag(?:enta)?|Cyan?|Yel(?:low)?|Whi(?:te)?)\b"/> |
| 866 |
<DetectSpaces/> |
| 867 |
</context> |
| 868 |
|
| 869 |
<context name="ColorHaveFG" attribute="String" lineEndContext="Error"> |
| 870 |
<RegExpr attribute="Keyword" context="#pop!ColorBG" insensitive="true" String="\s+on\s+"/> |
| 871 |
</context> |
| 872 |
|
| 873 |
<context name="ColorBG" attribute="String" lineEndContext="Error"> |
| 874 |
<RegExpr attribute="Operator" insensitive="true" String="\bbri(?:ght)?\b"/> |
| 875 |
<RegExpr attribute="Option" context="#pop!ColorHaveBG" insensitive="true" String="\b(?:Bla(?:ck)?|Blue?|Gre(?:en)?|Red|Mag(?:enta)?|Cyan?|Yel(?:low)?|Whi(?:te)?)\b"/> |
| 876 |
</context> |
| 877 |
|
| 878 |
<context name="ColorHaveBG" attribute="String" lineEndContext="#pop"> |
| 879 |
<RegExpr attribute="Operator" context="#pop!ColorNeedBordercol" insensitive="true" String="\bBOR(?:der)?\b"/> |
| 880 |
<IncludeRules context="popNeedEndOfCommand"/> |
| 881 |
</context> |
| 882 |
|
| 883 |
<context name="ColorNeedBordercol" attribute="String" lineEndContext="Error"> |
| 884 |
<RegExpr attribute="Option" context="#pop!popNeedEndOfCommand" insensitive="true" String="\s*(?:Bla(?:ck)?|Blue?|Gre(?:en)?|Red|Mag(?:enta)?|Cyan?|Yel(?:low)?|Whi(?:te)?)\b"/> |
| 885 |
</context> |
| 886 |
|
| 887 |
<context name="cmdDraw" attribute="String" lineEndContext="#pop"> |
| 888 |
<!-- ToDo: check if we'll have to split this into multiple contexts, add the highlighting for drawing commands --> |
| 889 |
</context> |
| 890 |
|
| 891 |
<context name="cmdFilesystemOperation" attribute="String" lineEndContext="#pop"> |
| 892 |
<IncludeRules context="findOption"/> |
| 893 |
<IncludeRules context="findStrings"/> |
| 894 |
<IncludeRules context="popNeedEndOfCommand"/> |
| 895 |
</context> |
| 896 |
|
| 897 |
<context name="Error" attribute="Error" lineEndContext="#stay"> |
| 898 |
</context> |
| 899 |
</contexts> |
| 900 |
<itemDatas> |
| 901 |
<itemData name="Normal" defStyleNum="dsNormal"/> |
| 902 |
<itemData name="Comment" defStyleNum="dsComment"/> |
| 903 |
<itemData name="Keyword" defStyleNum="dsKeyword"/> |
| 904 |
<itemData name="Number" defStyleNum="dsDecVal"/> |
| 905 |
<itemData name="Option" defStyleNum="dsDecVal"/> |
| 906 |
<itemData name="Label" defStyleNum="dsOthers"/> |
| 907 |
<itemData name="Function" defStyleNum="dsFunction"/> |
| 908 |
<itemData name="Redirection" defStyleNum="dsKeyword"/> |
| 909 |
<itemData name="String" defStyleNum="dsString"/> |
| 910 |
<itemData name="Escape" defStyleNum="dsSpecialChar"/> |
| 911 |
<itemData name="Variable" defStyleNum="dsVariable"/> |
| 912 |
<itemData name="VariableBold" defStyleNum="dsVariable" bold="true"/> |
| 913 |
<itemData name="Alert" defStyleNum="dsAlert"/> |
| 914 |
<itemData name="Error" defStyleNum="dsError"/> |
| 915 |
<itemData name="Operator" defStyleNum="dsOperator"/> |
| 916 |
</itemDatas> |
| 917 |
</highlighting> |
| 918 |
<general> |
| 919 |
<comments> |
| 920 |
<comment name="singleLine" start="rem "/> |
| 921 |
</comments> |
| 922 |
<keywords casesensitive="0" additionalDeliminator="@"/> |
| 923 |
</general> |
| 924 |
</language> |
| 925 |
<!-- kate: replace-tabs off; --> |