| 1 |
<?xml version="1.0" encoding="UTF-8"?> |
| 2 |
<!DOCTYPE language |
| 3 |
[ |
| 4 |
<!ENTITY tab "	"> |
| 5 |
<!ENTITY white "&tab; "> <!-- first is tab --> |
| 6 |
<!ENTITY eocommand "&white;<>^"> <!-- end of command separator --> |
| 7 |
<!ENTITY separator "&white;|&;<>()'""> <!-- token separator as char list --> |
| 8 |
<!ENTITY commandsep "|&;"> <!-- command separator as char list --> |
| 9 |
<!ENTITY special "{}*/.?\\$&"> <!-- not allowed in function names --> |
| 10 |
<!ENTITY portable_filename "A-Za-z0-9\._-"> |
| 11 |
<!ENTITY funcname_first "a-zA-Z+:=!.@_`"> |
| 12 |
<!ENTITY funcname_last "a-zA-Z0-9+,-:=!.@#%^_`~"> |
| 13 |
<!ENTITY funcname "[&funcname_first;](?:[&funcname_last;]|\\ )*"> |
| 14 |
<!ENTITY varname "[A-Za-z0-9_]+"> |
| 15 |
<!ENTITY alnumdash "[A-Za-z0-9-]"> <!-- option chars, dashes for GNU long opts --> |
| 16 |
<!ENTITY testoptsfile "[bcdefgGkLOprsStuwx]"> <!-- test operators for file testing --> |
| 17 |
<!ENTITY testoptsother "[nzao]"> <!-- other test operators --> |
| 18 |
<!ENTITY braceelement "[!#%+\-\./0-9:=@A-Z^_`a-z~]"> |
| 19 |
<!ENTITY escapechars "[abefnrtv $\\*?~%#(){}[\]<>\^&;"']"> <!-- escape chars --> |
| 20 |
<!ENTITY white_or_eol "(?:[&white;]|$)"> |
| 21 |
<!ENTITY homedir "~[&portable_filename;]*"> |
| 22 |
<!ENTITY pathdetect "(?:(?:\.\.?|&homedir;)&white_or_eol;|(?:[^$\\{}&separator;/\*\?]|\\&escapechars;)*(:?[/?]|\*\*?))"> |
| 23 |
<!ENTITY pathpart "(?:[^&separator;/]|\\&escapechars;)*(?:/|(?=["']))"> |
| 24 |
]> |
| 25 |
|
| 26 |
|
| 27 |
<language name="Fish" version="8" kateversion="5.72" section="Scripts" extensions="*.fish;fishd.*" mimetype="application/x-fish" casesensitive="1" author="Arnd Diestelhorst ([email protected])" license="LGPL"> |
| 28 |
|
| 29 |
|
| 30 |
<highlighting> |
| 31 |
|
| 32 |
<list name= "commands"> |
| 33 |
<item>abbr</item> |
| 34 |
<item>alias</item> |
| 35 |
<item>argparse</item> |
| 36 |
<item>bg</item> |
| 37 |
<item>bind</item> |
| 38 |
<item>block</item> |
| 39 |
<item>cd</item> |
| 40 |
<item>cdh</item> |
| 41 |
<item>commandline</item> |
| 42 |
<item>complete</item> |
| 43 |
<item>contains</item> |
| 44 |
<item>count</item> |
| 45 |
<item>dirs</item> |
| 46 |
<item>disown</item> |
| 47 |
<item>echo</item> |
| 48 |
<item>emit</item> |
| 49 |
<item>end</item> |
| 50 |
<item>exit</item> |
| 51 |
<item>fg</item> |
| 52 |
<item>fish</item> |
| 53 |
<item>fish_config</item> |
| 54 |
<item>fish_indent</item> |
| 55 |
<item>fish_key_reader</item> |
| 56 |
<item>fish_mode_prompt</item> |
| 57 |
<item>fish_opt</item> |
| 58 |
<item>fish_prompt</item> |
| 59 |
<item>fish_right_prompt</item> |
| 60 |
<item>fish_update_completions</item> |
| 61 |
<item>fish_vi_mode</item> |
| 62 |
<item>funced</item> |
| 63 |
<item>funcsave</item> |
| 64 |
<item>functions</item> |
| 65 |
<item>help</item> |
| 66 |
<item>history</item> |
| 67 |
<item>isatty</item> |
| 68 |
<item>jobs</item> |
| 69 |
<item>math</item> |
| 70 |
<item>nextd</item> |
| 71 |
<item>open</item> |
| 72 |
<item>prevd</item> |
| 73 |
<item>printf</item> |
| 74 |
<item>psub</item> |
| 75 |
<item>pushd</item> |
| 76 |
<item>random</item> |
| 77 |
<item>realpath</item> |
| 78 |
<item>return</item> |
| 79 |
<item>set_color</item> |
| 80 |
<item>source</item> |
| 81 |
<item>status</item> |
| 82 |
<item>suspend</item> |
| 83 |
<item>trap</item> |
| 84 |
<item>type</item> |
| 85 |
<item>ulimit</item> |
| 86 |
<item>umask</item> |
| 87 |
<item>vared</item> |
| 88 |
</list> |
| 89 |
|
| 90 |
<list name="commandsnoargs"> |
| 91 |
<item>break</item> |
| 92 |
<item>breakpoint</item> |
| 93 |
<item>continue</item> |
| 94 |
<item>dirh</item> |
| 95 |
<item>false</item> |
| 96 |
<item>popd</item> |
| 97 |
<item>prompt_pwd</item> |
| 98 |
<item>pwd</item> |
| 99 |
<item>true</item> |
| 100 |
</list> |
| 101 |
|
| 102 |
<list name="commandsstay"> |
| 103 |
<item>and</item> |
| 104 |
<item>not</item> |
| 105 |
<item>or</item> |
| 106 |
</list> |
| 107 |
|
| 108 |
<list name="stringsubcommands"> |
| 109 |
<item>escape</item> |
| 110 |
<item>join</item> |
| 111 |
<item>length</item> |
| 112 |
<item>lower</item> |
| 113 |
<item>match</item> |
| 114 |
<item>repeat</item> |
| 115 |
<item>replace</item> |
| 116 |
<item>split</item> |
| 117 |
<item>sub</item> |
| 118 |
<item>trim</item> |
| 119 |
<item>unescape</item> |
| 120 |
<item>upper</item> |
| 121 |
</list> |
| 122 |
|
| 123 |
<list name="unixcommands"> |
| 124 |
<include>unixcommands##Bash</include> |
| 125 |
<item>command</item> |
| 126 |
<item>kill</item> |
| 127 |
<item>test</item> |
| 128 |
</list> |
| 129 |
|
| 130 |
|
| 131 |
|
| 132 |
<contexts> |
| 133 |
<context name="Start" attribute="Normal Text" lineEndContext="#stay" fallthroughContext="Root"> |
| 134 |
<DetectChar attribute="Error" context="DropRestOfLine" char=")"/> |
| 135 |
</context> |
| 136 |
|
| 137 |
<context name="DropRestOfLine" attribute="Normal Text" lineEndContext="#pop"> |
| 138 |
<DetectChar attribute="Comment" context="Comment" char="#"/> |
| 139 |
<RegExpr attribute="Normal Text" String="[^#]*" /> |
| 140 |
</context> |
| 141 |
|
| 142 |
<!-- Root starts at a new line (not continuation) --> |
| 143 |
<context name="Root" attribute="Normal Text" lineEndContext="#pop"> |
| 144 |
<LineContinue attribute="Escape" /> |
| 145 |
<DetectChar attribute="Comment" context="Comment" char="#"/> |
| 146 |
<DetectChar context="#pop" char=")" lookAhead="true" /> |
| 147 |
<IncludeRules context="FindCommands" /> |
| 148 |
</context> |
| 149 |
|
| 150 |
<!-- |
| 151 |
fish interprets closing parenthesis inside comments as end of command substitution, if the comment starts |
| 152 |
inside of a command substitution! |
| 153 |
|
| 154 |
fish does not interpret them this way, when |
| 155 |
they are escaped by a \ or |
| 156 |
they are matched by an earlier opening parenthesis inside the same comment. |
| 157 |
This behaviour is replicated here. |
| 158 |
|
| 159 |
Command substitutions may span several lines, so the closing parenthesis may be on a different line, |
| 160 |
than the opening one. In the interactive shell you need a continuation line for this, not so in scripts. |
| 161 |
Blocks of code with multiline command substitutions may be commented out. This should not lead to visual artifacts. |
| 162 |
|
| 163 |
There is one case, where the following solution fails: a lonely closing ")", which is marked as an error. |
| 164 |
--> |
| 165 |
<context name="Comment" attribute="Comment" lineEndContext="#pop"> |
| 166 |
<Detect2Chars attribute="Comment" char="\" char1="(" /> |
| 167 |
<Detect2Chars attribute="Comment" char="\" char1=")" /> |
| 168 |
<DetectChar context="CommentParenSub" char="(" /> |
| 169 |
<DetectChar context="#pop" char=")" lookAhead="true" /> |
| 170 |
<IncludeRules context="##Comments" /> |
| 171 |
</context> |
| 172 |
|
| 173 |
<context name="CommentParenSub" attribute="Comment" lineEndContext="BlockComment"> |
| 174 |
<DetectChar attribute="Comment" context="#pop" char=")" /> |
| 175 |
<IncludeRules context="Comment" /> |
| 176 |
</context> |
| 177 |
|
| 178 |
<context name="BlockComment" attribute="Comment" fallthroughContext="#pop#pop#pop" lineEndContext="#stay"> |
| 179 |
<DetectChar attribute="Comment" context="#pop" char="#" firstNonSpace="true"/> |
| 180 |
</context> |
| 181 |
|
| 182 |
<!-- FindCommands matches Fish and Unix commands --> |
| 183 |
<!-- order is important, factor out common rules did'nt work because of order of rules--> |
| 184 |
<context name="FindCommands" attribute="Command" lineEndContext="#stay"> |
| 185 |
<DetectSpaces attribute="Normal Text" /> |
| 186 |
<AnyChar attribute="Error" context="#pop!DropRestOfLine" String="(<>"/> |
| 187 |
<AnyChar attribute="Separator" String="&commandsep;" /> |
| 188 |
<keyword attribute="Builtin" context="Arguments" String="commands" /> <!--simple commands first--> |
| 189 |
<keyword attribute="Builtin" context="ArgumentsNone" String="commandsnoargs" /> |
| 190 |
<keyword attribute="Control Flow" String="commandsstay" /> |
| 191 |
<Detect2Chars attribute="Builtin" context="Arguments" char="." char1=" " /> |
| 192 |
<RegExpr attribute="CommandPath" context="CommandPart" String="&pathdetect;" /> |
| 193 |
<IncludeRules context="FindSpecialCommands" /> <!--before unixcommands, because f test, but after path detection--> |
| 194 |
<keyword attribute="UnixCommand" context="Arguments" String="unixcommands"/> |
| 195 |
<RegExpr attribute="Command" context="CommandPart" String="&funcname;" /> |
| 196 |
<DetectChar context="CommandPart" char=""" lookAhead="true"/> |
| 197 |
</context> |
| 198 |
|
| 199 |
<context name="CommandPart" attribute="Command" lineEndContext="#pop"> |
| 200 |
<LineContinue attribute="Escape" /> |
| 201 |
<AnyChar context="#pop" String=")#" lookAhead="true"/> |
| 202 |
<AnyChar attribute="Separator" context="#pop" String="&commandsep;" /> |
| 203 |
<AnyChar context="#pop!Arguments" String="&eocommand;" lookAhead="true"/> |
| 204 |
<RegExpr attribute="CommandPath" String="&pathpart;" /> |
| 205 |
<keyword attribute="UnixCommand" String="unixcommands"/> |
| 206 |
<RegExpr attribute="Command" String="&funcname;" /> |
| 207 |
<IncludeRules context="FindStrings" /> |
| 208 |
<RegExpr attribute="Error" String="." /> |
| 209 |
</context> |
| 210 |
|
| 211 |
<context name="FindSpecialCommands" attribute="Builtin" lineEndContext="#stay"> |
| 212 |
<WordDetect attribute="Builtin" String="command" context="command_builtin" /> |
| 213 |
<WordDetect attribute="Builtin" String="builtin" context="command_builtin" /> |
| 214 |
<WordDetect attribute="Builtin" String="eval" context="eval_exec" /> |
| 215 |
<WordDetect attribute="Builtin" String="exec" context="eval_exec" /> |
| 216 |
<WordDetect attribute="Builtin" String="set" context="set" /> |
| 217 |
<WordDetect attribute="Builtin" String="string" context="string" /> |
| 218 |
<WordDetect attribute="Builtin" String="read" context="read_vared" /> |
| 219 |
<WordDetect attribute="Builtin" String="vared" context="read_vared" /> |
| 220 |
<WordDetect attribute="Builtin" String="test" context="ArgumentsTest" /> |
| 221 |
<Detect2Chars attribute="Builtin" char="[" char1="&tab;" context="ArgumentsTestBrack" /> |
| 222 |
<Detect2Chars attribute="Builtin" char="[" char1=" " context="ArgumentsTestBrack" /> |
| 223 |
<WordDetect attribute="Control Flow" String="begin" context="begin" beginRegion="begin" /> |
| 224 |
<WordDetect attribute="Control Flow" String="for" context="for" beginRegion="for" /> |
| 225 |
<WordDetect attribute="Control Flow" String="function" context="function" beginRegion="function" /> |
| 226 |
<WordDetect attribute="Control Flow" String="if" context="if" beginRegion="if" /> |
| 227 |
<WordDetect attribute="Control Flow" String="switch" context="switch" beginRegion="switch" /> |
| 228 |
<WordDetect attribute="Control Flow" String="while" context="while" beginRegion="while" /> |
| 229 |
</context> |
| 230 |
|
| 231 |
<context name="command_builtin" attribute="Normal Text" lineEndContext="#pop"> |
| 232 |
<LineContinue attribute="Escape" /> |
| 233 |
<RegExpr attribute="Option" String="-&alnumdash;*" /> |
| 234 |
<AnyChar attribute="Separator" context="#pop" String="&commandsep;" /> |
| 235 |
<IncludeRules context="Root" /> |
| 236 |
</context> |
| 237 |
|
| 238 |
<context name="eval_exec" attribute="Normal Text" lineEndContext="#pop"> |
| 239 |
<DetectChar context="#pop" char=")" lookAhead="true"/> |
| 240 |
<AnyChar attribute="Separator" context="#pop" String="&commandsep;" /> |
| 241 |
<IncludeRules context="FindStrings" /> |
| 242 |
<IncludeRules context="FindVarExpansion" /> |
| 243 |
<IncludeRules context="FindSubstitutions" /> |
| 244 |
<IncludeRules context="FindBraceExpansion" /> |
| 245 |
<IncludeRules context="FindPaths" /> |
| 246 |
<IncludeRules context="FindEscapes" /> |
| 247 |
<IncludeRules context="Root" /> |
| 248 |
</context> |
| 249 |
|
| 250 |
<context name="set" attribute="Normal Text" lineEndContext="#pop"> |
| 251 |
<LineContinue attribute="Escape" /> |
| 252 |
<AnyChar attribute="Separator" context="#pop" String="&commandsep;" /> |
| 253 |
<RegExpr attribute="Option" String="-&alnumdash;*" /> |
| 254 |
<RegExpr attribute="Variable" String="&varname;" context="Arguments" /> |
| 255 |
<IncludeRules context="FindVarExpansion" /> |
| 256 |
</context> |
| 257 |
|
| 258 |
<context name="string" attribute="Normal Text" lineEndContext="#pop"> |
| 259 |
<LineContinue attribute="Escape" /> |
| 260 |
<DetectSpaces attribute="Normal Text" /> |
| 261 |
<keyword attribute="Builtin" context="#pop!Arguments" String="stringsubcommands" /> |
| 262 |
<RegExpr attribute="Error" String="." /> |
| 263 |
</context> |
| 264 |
|
| 265 |
<context name="read_vared" attribute="Normal Text" lineEndContext="#pop"> |
| 266 |
<LineContinue attribute="Escape" /> |
| 267 |
<RegExpr attribute="Option" String="-&alnumdash;*" /> |
| 268 |
<DetectChar attribute="Comment" context="Comment" char="#"/> |
| 269 |
<AnyChar attribute="Separator" context="#pop" String="&commandsep;" /> |
| 270 |
<DetectChar context="#pop" char=")" lookAhead="true"/> |
| 271 |
<IncludeRules context="FindStrings" /> |
| 272 |
<IncludeRules context="FindVarExpansion" /> |
| 273 |
<IncludeRules context="FindSubstitutions" /> |
| 274 |
<IncludeRules context="FindBraceExpansion" /> |
| 275 |
<IncludeRules context="FindEscapes" /> |
| 276 |
<RegExpr attribute="Variable" String="&varname;" /> |
| 277 |
</context> |
| 278 |
|
| 279 |
<context name="ArgumentsTestBrack" attribute="Normal Text" lineEndContext="#pop"> |
| 280 |
<LineContinue attribute="Escape" /> |
| 281 |
<Detect2Chars attribute="Builtin" char=" " char1="]" context="#pop!ArgumentsNonePre" /> |
| 282 |
<AnyChar attribute="Error" context="#pop!DropRestOfLine" String="#&commandsep;&"/> |
| 283 |
<IncludeRules context="ArgumentsTest" /> |
| 284 |
</context> |
| 285 |
|
| 286 |
<context name="ArgumentsTest" attribute="Normal Text" lineEndContext="#pop"> |
| 287 |
<LineContinue attribute="Escape" /> |
| 288 |
<DetectChar context="#pop" char="#" lookAhead="true" /> |
| 289 |
<IncludeRules context="ArgumentsTest_common" /> |
| 290 |
</context> |
| 291 |
|
| 292 |
<context name="ArgumentsTest_common" attribute="Normal Text" lineEndContext="#pop"> |
| 293 |
<RegExpr attribute="Operator" context="DirectPath" String="-&testoptsfile; " /> |
| 294 |
<RegExpr attribute="Operator" String="-&testoptsother; |!=?|=| -eq | -ne | -gt | -ge | -lt | -le "/> |
| 295 |
<AnyChar context="#pop" String="&commandsep;" lookAhead="true"/> |
| 296 |
<IncludeRules context="FindArgumentsCommon" /> |
| 297 |
</context> |
| 298 |
|
| 299 |
<context name="begin" attribute="Normal Text" lineEndContext="beginbody"> |
| 300 |
<DetectSpaces attribute="Normal Text" /> |
| 301 |
<DetectChar attribute="Separator" context="beginbody" char=";" /> |
| 302 |
<IncludeRules context="Root" /> |
| 303 |
</context> |
| 304 |
|
| 305 |
<context name="beginbody" attribute="Normal Text" lineEndContext="#stay"> |
| 306 |
<LineContinue attribute="Escape" /> |
| 307 |
<WordDetect attribute="Control Flow" String="end" context="#pop#pop" endRegion="begin" /> |
| 308 |
<IncludeRules context="Root" /> |
| 309 |
</context> |
| 310 |
|
| 311 |
<context name="for" attribute="Normal Text" lineEndContext="#stay"> |
| 312 |
<LineContinue attribute="Escape" /> |
| 313 |
<DetectSpaces attribute="Normal Text" /> |
| 314 |
<WordDetect attribute="Control Flow" String="in" context="forargs" /> |
| 315 |
<RegExpr attribute="Variable" String="&varname;" /> |
| 316 |
<IncludeRules context="FindVarExpansion" /> |
| 317 |
<RegExpr attribute="Error" String="."/> |
| 318 |
</context> |
| 319 |
|
| 320 |
<context name="forargs" attribute="Normal Text" lineEndContext="forbody"> |
| 321 |
<DetectChar attribute="Separator" context="forbody" char=";" /> |
| 322 |
<DetectChar attribute="Comment" context="Comment" char="#"/> |
| 323 |
<IncludeRules context="FindArgumentsCommon" /> |
| 324 |
</context> |
| 325 |
|
| 326 |
<context name="forbody" attribute="Normal Text" lineEndContext="#stay"> |
| 327 |
<LineContinue attribute="Escape" /> |
| 328 |
<WordDetect attribute="Control Flow" String="end" context="#pop#pop#pop" endRegion="for" /> |
| 329 |
<IncludeRules context="Root" /> |
| 330 |
</context> |
| 331 |
|
| 332 |
<context name="function" attribute="Normal Text" lineEndContext="funcbody"> |
| 333 |
<LineContinue attribute="Escape" /> |
| 334 |
<DetectSpaces attribute="Normal Text" /> |
| 335 |
<DetectChar attribute="Comment" context="func_comment" char="#"/> |
| 336 |
<DetectChar context="funcopts" char="-" lookAhead="true" /> |
| 337 |
<DetectChar attribute="Separator" context="funcbody" char=";" /> |
| 338 |
<RegExpr attribute="Command" String="&funcname;" /> |
| 339 |
<IncludeRules context="FindVarExpansion" /> |
| 340 |
<RegExpr attribute="Error" String="."/> |
| 341 |
</context> |
| 342 |
|
| 343 |
<context name="func_comment" attribute="Comment" lineEndContext="#pop!funcbody"> |
| 344 |
</context> |
| 345 |
|
| 346 |
<context name="funcopts" attribute="Normal Text" lineEndContext="#pop!funcbody"> |
| 347 |
<DetectChar attribute="Comment" context="#pop!func_comment" char="#"/> |
| 348 |
<RegExpr attribute="Option" String="(?:-d[&white;]*|--description=)(?=["'])" context="funcdesc" beginRegion="doc"/> |
| 349 |
<RegExpr attribute="Option" String="-&alnumdash;*" /> |
| 350 |
<DetectChar attribute="Separator" context="#pop!funcbody" char=";" /> |
| 351 |
<IncludeRules context="FindArgumentsCommon" /> |
| 352 |
</context> |
| 353 |
|
| 354 |
<context name="funcdesc" attribute="Function Doc" lineEndContext="#stay"> |
| 355 |
<DetectChar context="DocstringSQ" char="'" /> |
| 356 |
<DetectChar context="DocstringDQ" char=""" /> |
| 357 |
</context> |
| 358 |
|
| 359 |
<!-- StringSQ consumes anything till ' --> |
| 360 |
<context name="DocstringSQ" attribute="Function Doc" lineEndContext="#stay"> |
| 361 |
<!--no line continuation here--> |
| 362 |
<Detect2Chars attribute="Escape" char="\" char1="'" /> |
| 363 |
<Detect2Chars attribute="Escape" char="\" char1="\" /> |
| 364 |
<DetectChar attribute="Function Doc" context="#pop#pop" char="'" endRegion="doc"/> |
| 365 |
</context> |
| 366 |
|
| 367 |
<!-- StringDQ consumes anything till ", substitutes vars and expressions --> |
| 368 |
<context name="DocstringDQ" attribute="Function Doc" lineEndContext="#stay"> |
| 369 |
<LineContinue attribute="Escape" /> |
| 370 |
<Detect2Chars attribute="Escape" char="\" char1=""" /> |
| 371 |
<Detect2Chars attribute="Escape" char="\" char1="$" /> |
| 372 |
<Detect2Chars attribute="Escape" char="\" char1="\" /> |
| 373 |
<IncludeRules context="FindVarExpansion" /> |
| 374 |
<DetectChar attribute="Function Doc" context="#pop#pop" char=""" endRegion="doc"/> |
| 375 |
</context> |
| 376 |
|
| 377 |
<context name="funcbody" attribute="Normal Text" lineEndContext="#stay"> |
| 378 |
<LineContinue attribute="Escape" /> |
| 379 |
<WordDetect attribute="Control Flow" String="end" context="#pop#pop" endRegion="function" /> |
| 380 |
<IncludeRules context="Root" /> |
| 381 |
</context> |
| 382 |
|
| 383 |
<context name="if" attribute="Normal Text" lineEndContext="#stay"> |
| 384 |
<LineContinue attribute="Escape"/> |
| 385 |
<WordDetect attribute="Control Flow" String="else" context="else" endRegion="if" beginRegion="if"/> |
| 386 |
<WordDetect attribute="Control Flow" String="end" context="#pop" endRegion="if"/> |
| 387 |
<IncludeRules context="Root" /> |
| 388 |
</context> |
| 389 |
|
| 390 |
<context name="else" attribute="Normal Text" lineEndContext="#stay" fallthroughContext="#pop"> |
| 391 |
<DetectSpaces attribute="Normal Text" context="#stay"/> |
| 392 |
<LineContinue attribute="Escape" context="#stay"/> |
| 393 |
<WordDetect attribute="Control Flow" String="if" context="#pop"/> |
| 394 |
</context> |
| 395 |
|
| 396 |
<context name="switch" attribute="Normal Text" lineEndContext="switchbody"> |
| 397 |
<DetectChar attribute="Separator" context="switchbody" char=";" /> |
| 398 |
<DetectChar attribute="Comment" context="Comment" char="#"/> |
| 399 |
<IncludeRules context="FindArgumentsCommon" /> |
| 400 |
</context> |
| 401 |
|
| 402 |
<context name="switchbody" attribute="Normal Text" lineEndContext="#stay"> |
| 403 |
<LineContinue attribute="Escape" /> |
| 404 |
<WordDetect attribute="Control Flow" String="case" context="case" beginRegion="case" /> |
| 405 |
<WordDetect attribute="Control Flow" String="end" context="#pop#pop" endRegion="switch"/> |
| 406 |
<IncludeRules context="Root" /> |
| 407 |
</context> |
| 408 |
|
| 409 |
<context name="case" attribute="Normal Text" lineEndContext="casebody"> |
| 410 |
<DetectChar attribute="Separator" context="casebody" char=";" /> |
| 411 |
<DetectChar attribute="Comment" context="Comment" char="#"/> |
| 412 |
<IncludeRules context="FindArgumentsCommon" /> |
| 413 |
</context> |
| 414 |
|
| 415 |
<context name="casebody" attribute="Normal Text" lineEndContext="#stay"> |
| 416 |
<LineContinue attribute="Escape" /> |
| 417 |
<WordDetect attribute="Control Flow" String="case" context="#pop" endRegion="case" beginRegion="case" /> |
| 418 |
<WordDetect attribute="Control Flow" String="end" context="#pop#pop" endRegion="case" lookAhead="1"/> |
| 419 |
<IncludeRules context="Root" /> |
| 420 |
</context> |
| 421 |
|
| 422 |
<context name="while" attribute="Normal Text" lineEndContext="#stay"> |
| 423 |
<LineContinue attribute="Escape" /> |
| 424 |
<WordDetect attribute="Control Flow" String="end" context="#pop" endRegion="while"/> |
| 425 |
<IncludeRules context="Root" /> |
| 426 |
</context> |
| 427 |
|
| 428 |
<!--Argument Rules match the items after a command |
| 429 |
this one is a collection with the common part for inclusion--> |
| 430 |
<context name="Arguments" attribute="Normal Text" lineEndContext="#pop"> |
| 431 |
<DetectChar attribute="Comment" context="Comment" char="#"/> |
| 432 |
<AnyChar context="#pop" String="&commandsep;)" lookAhead="true"/> |
| 433 |
<IncludeRules context="FindArgumentsCommon" /> |
| 434 |
</context> |
| 435 |
|
| 436 |
<context name="FindArgumentsCommon" attribute="Normal Text" lineEndContext="#stay"> |
| 437 |
<LineContinue attribute="Escape" /> |
| 438 |
<DetectSpaces attribute="Normal Text" /> |
| 439 |
<RegExpr attribute="Option" String="-&alnumdash;*" /> |
| 440 |
<RegExpr attribute="Redirection" context="Redirect" String="[0-9]*(?:>{1,2}|<|\^{1,2})" /> |
| 441 |
<DetectChar attribute="Operator" char="="/> |
| 442 |
<DetectChar attribute="Index" context="Subscript" char="["/> |
| 443 |
<IncludeRules context="FindStrings" /> |
| 444 |
<IncludeRules context="FindVarExpansion" /> |
| 445 |
<IncludeRules context="FindSubstitutions" /> |
| 446 |
<IncludeRules context="FindBraceExpansion" /> |
| 447 |
<IncludeRules context="FindProcessExpansion" /> |
| 448 |
<IncludeRules context="FindPaths" /> |
| 449 |
<IncludeRules context="FindEscapes" /> |
| 450 |
<RegExpr attribute="Normal Text" String="[^&separator;&special;]*" /> <!--unknown token--> |
| 451 |
</context> |
| 452 |
|
| 453 |
<context name="ArgumentsNonePre" attribute="Normal Text" lineEndContext="#pop"> |
| 454 |
<LineContinue attribute="Escape" /> |
| 455 |
<DetectSpaces attribute="Normal Text" context="#pop!ArgumentsNone" /> |
| 456 |
<AnyChar context="#pop" String="&commandsep;" lookAhead="true"/> <!--consumed on the "Find"-Level--> |
| 457 |
<RegExpr attribute="Error" String="."/> |
| 458 |
</context> |
| 459 |
|
| 460 |
<context name="ArgumentsNone" attribute="Normal Text" lineEndContext="#pop"> |
| 461 |
<LineContinue attribute="Escape" /> |
| 462 |
<DetectSpaces attribute="Normal Text" /> |
| 463 |
<DetectChar attribute="Comment" context="Comment" char="#"/> |
| 464 |
<RegExpr attribute="Redirection" context="Redirect" String="[0-9]*(?:>{1,2}|<|\^{1,2})" /> |
| 465 |
<AnyChar context="#pop" String="&commandsep;)" lookAhead="true"/> <!--consumed on the "Find"-Level--> |
| 466 |
<RegExpr attribute="Error" String="[^&commandsep;#]*"/> |
| 467 |
</context> |
| 468 |
|
| 469 |
<context name="TokEnd" attribute="Normal Text" lineEndContext="#pop"> |
| 470 |
<LineContinue attribute="Escape" /> |
| 471 |
<DetectSpaces attribute="Normal Text" context="#pop"/> |
| 472 |
<AnyChar context="#pop" String="&commandsep;" lookAhead="true"/> <!--consumed on the "Find"-Level--> |
| 473 |
<RegExpr attribute="Error" String="." context="#pop"/> |
| 474 |
</context> |
| 475 |
|
| 476 |
<context name="Redirect" attribute="Redirection" fallthroughContext="#pop!DirectPath" lineEndContext="#stay"> |
| 477 |
<LineContinue attribute="Escape" /> |
| 478 |
<DetectChar attribute="Redirection" context="#pop!DirectPath" char="?"/> |
| 479 |
<DetectChar attribute="Redirection" context="#pop#pop" char="|"/> |
| 480 |
<RegExpr attribute="Redirection" context="#pop!TokEnd" String="&(?:[0-9]+|-)" /> |
| 481 |
</context> |
| 482 |
|
| 483 |
<context name="Subscript" attribute="Index" lineEndContext="#pop"> |
| 484 |
<LineContinue attribute="Escape" /> |
| 485 |
<Detect2Chars char="]" char1="[" /> |
| 486 |
<DetectChar attribute="Index" context="#pop" char="]" /> |
| 487 |
<Detect2Chars char="." char1="." /> |
| 488 |
<RegExpr attribute="Index" String=" *-?\d+" /> |
| 489 |
<IncludeRules context="FindVarExpansion" /> |
| 490 |
<IncludeRules context="FindSubstitutions" /> |
| 491 |
<DetectSpaces attribute="Normal Text" /> |
| 492 |
<RegExpr attribute="Error" String="[^\]]" /> |
| 493 |
</context> |
| 494 |
|
| 495 |
<!-- FindStrings looks for single and double quoted strings --> |
| 496 |
<context name="FindStrings" attribute="Normal Text" lineEndContext="#stay"> |
| 497 |
<DetectChar context="StringSQ" char="'" /> |
| 498 |
<DetectChar context="StringDQ" char=""" /> |
| 499 |
</context> |
| 500 |
|
| 501 |
<!-- StringSQ consumes anything till ' --> |
| 502 |
<context name="StringSQ" attribute="String SingleQ" lineEndContext="#stay"> |
| 503 |
<!--no line continuation here--> |
| 504 |
<Detect2Chars attribute="Escape" char="\" char1="'" /> |
| 505 |
<Detect2Chars attribute="Escape" char="\" char1="\" /> |
| 506 |
<DetectChar attribute="String SingleQ" context="#pop" char="'" /> |
| 507 |
</context> |
| 508 |
|
| 509 |
<!-- StringDQ consumes anything till ", substitutes vars and expressions --> |
| 510 |
<context name="StringDQ" attribute="String DoubleQ" lineEndContext="#stay"> |
| 511 |
<LineContinue attribute="Escape" /> |
| 512 |
<Detect2Chars attribute="Escape" char="\" char1=""" /> |
| 513 |
<Detect2Chars attribute="Escape" char="\" char1="$" /> |
| 514 |
<Detect2Chars attribute="Escape" char="\" char1="\" /> |
| 515 |
<IncludeRules context="FindVarExpansion" /> |
| 516 |
<DetectChar attribute="String DoubleQ" context="#pop" char=""" /> |
| 517 |
</context> |
| 518 |
|
| 519 |
<!-- FindVarExpansion goes after anything starting with $ and and their escapes --> |
| 520 |
<context name="FindVarExpansion" attribute="Normal Text" lineEndContext="#stay"> |
| 521 |
<RegExpr attribute="Variable" context="CheckSubscript" String="\$+&varname;" /> |
| 522 |
</context> |
| 523 |
|
| 524 |
<!-- Subscript consumes anything till ], marks as Variable --> |
| 525 |
<context name="CheckSubscript" attribute="Index" lineEndContext="#pop" fallthroughContext="#pop"> |
| 526 |
<LineContinue attribute="Escape" /> |
| 527 |
<DetectChar attribute="Index" context="Subscript" char="["/> |
| 528 |
</context> |
| 529 |
|
| 530 |
<!-- Command Substitution --> |
| 531 |
<context name="FindSubstitutions" attribute="Normal Text" lineEndContext="#stay"> |
| 532 |
<DetectChar attribute="Keychar" context="CommandSubstitution" char="(" /> |
| 533 |
</context> |
| 534 |
|
| 535 |
<context name="CommandSubstitution" attribute="Normal Text" fallthroughContext="Root" lineEndContext="#stay"> |
| 536 |
<LineContinue attribute="Escape" /> |
| 537 |
<DetectChar attribute="Keychar" context="#pop" char=")" /> |
| 538 |
</context> |
| 539 |
|
| 540 |
<!-- Brace Expansion consumes anything till } --> |
| 541 |
<context name="FindBraceExpansion" attribute="Normal Text" lineEndContext="#stay"> |
| 542 |
<DetectChar attribute="Keychar" context="BraceList" char="{" /> |
| 543 |
<DetectChar attribute="Error" char="}" /> |
| 544 |
</context> |
| 545 |
|
| 546 |
<context name="BraceList" attribute="Normal Text" lineEndContext="#pop"> |
| 547 |
<LineContinue attribute="Escape" /> |
| 548 |
<DetectChar attribute="Keychar" context="#pop" char="}" /> |
| 549 |
<DetectChar attribute="Separator" char="," /> |
| 550 |
<RegExpr attribute="Normal Text" String="&braceelement;*"/> |
| 551 |
<IncludeRules context="FindStrings" /> |
| 552 |
<IncludeRules context="FindVarExpansion" /> |
| 553 |
<IncludeRules context="FindSubstitutions" /> |
| 554 |
<IncludeRules context="FindBraceExpansion" /> |
| 555 |
<IncludeRules context="FindPaths" /> |
| 556 |
<IncludeRules context="FindEscapes" /> |
| 557 |
<RegExpr attribute="Error" String="."/> |
| 558 |
</context> |
| 559 |
|
| 560 |
<!-- Process Expansion --> |
| 561 |
<context name="FindProcessExpansion" attribute="Normal Text" lineEndContext="#pop"> |
| 562 |
<DetectChar attribute="Keychar" context="ProcessArg" char="%" /> |
| 563 |
</context> |
| 564 |
|
| 565 |
<context name="ProcessArg" attribute="Process" lineEndContext="#pop"> |
| 566 |
<LineContinue attribute="Escape" /> |
| 567 |
<AnyChar context="#pop" String="&white;" /> |
| 568 |
<AnyChar context="#pop" String="&separator;" lookAhead="true" /> |
| 569 |
<DetectChar attribute="Comment" context="Comment" char="#"/> |
| 570 |
<IncludeRules context="FindStrings" /> |
| 571 |
<IncludeRules context="FindVarExpansion" /> |
| 572 |
<IncludeRules context="FindSubstitutions" /> |
| 573 |
<IncludeRules context="FindBraceExpansion" /> |
| 574 |
<IncludeRules context="FindEscapes" /> |
| 575 |
</context> |
| 576 |
|
| 577 |
<!-- FindPaths for parts which might be a path. Uses the matching of a / as heuristic --> |
| 578 |
<!-- Might be fooled with quotes --> |
| 579 |
<context name="FindPaths" attribute="Path" lineEndContext="#stay"> |
| 580 |
<RegExpr context="DirectPath" String="&pathdetect;" lookAhead="true" minimal="1"/> |
| 581 |
</context> |
| 582 |
|
| 583 |
<!-- DirectPath is used at places where the next part is definitely a path --> |
| 584 |
<context name="DirectPath" attribute="Path" lineEndContext="#pop" fallthroughContext="#pop!PathHead" > |
| 585 |
<LineContinue attribute="Escape" /> |
| 586 |
<DetectSpaces attribute="Normal Text" /> |
| 587 |
<AnyChar attribute="Error" context="#pop" String="#&commandsep;<>^" /> |
| 588 |
</context> |
| 589 |
|
| 590 |
<context name="PathHead" attribute="Path" lineEndContext="#pop" fallthroughContext="#pop!Path" > |
| 591 |
<LineContinue attribute="Escape" /> |
| 592 |
<RegExpr attribute="HomeDir" context="#pop!Path" String="&homedir;" /> |
| 593 |
</context> |
| 594 |
|
| 595 |
<context name="Path" attribute="Path" lineEndContext="#pop"> |
| 596 |
<LineContinue attribute="Escape" /> |
| 597 |
<DetectSpaces context="#pop" lookAhead="true" /> |
| 598 |
<AnyChar context="#pop" String="#&commandsep;<>^)" lookAhead="true" /> |
| 599 |
<AnyChar attribute="Glob" String="*?" /> |
| 600 |
<DetectChar attribute="Path" char="/" /> |
| 601 |
<DetectChar attribute="Keychar" context="PathBrace" char="{" /> |
| 602 |
<DetectChar attribute="Error" context="#pop" char="}" /> |
| 603 |
<IncludeRules context="FindStrings" /> |
| 604 |
<IncludeRules context="FindVarExpansion" /> |
| 605 |
<IncludeRules context="FindSubstitutions" /> |
| 606 |
<IncludeRules context="FindEscapes" /> |
| 607 |
<RegExpr attribute="Path" String="[^$\*\?\\{}&separator;/]*" /> <!--consume everything until next special--> |
| 608 |
</context> |
| 609 |
|
| 610 |
<context name="PathBrace" attribute="Path" lineEndContext="#pop"> |
| 611 |
<LineContinue attribute="Escape" /> |
| 612 |
<DetectChar attribute="Keychar" context="#pop" char="}" /> |
| 613 |
<DetectChar attribute="Separator" char="," /> |
| 614 |
<AnyChar attribute="Error" String=" #&commandsep;<>^)" /> |
| 615 |
<AnyChar attribute="Glob" String="*?" /> |
| 616 |
<DetectChar attribute="Path" char="/" /> |
| 617 |
<DetectChar attribute="Keychar" context="PathBrace" char="{" /> |
| 618 |
<IncludeRules context="FindStrings" /> |
| 619 |
<IncludeRules context="FindVarExpansion" /> |
| 620 |
<IncludeRules context="FindSubstitutions" /> |
| 621 |
<IncludeRules context="FindEscapes" /> |
| 622 |
<RegExpr attribute="Path" String="[^$\*\?\\,{}&separator;/]*" /> |
| 623 |
</context> |
| 624 |
|
| 625 |
<!-- FindEscapes contains various rules to mark different shell input --> |
| 626 |
<context name="FindEscapes" attribute="Normal Text" lineEndContext="#stay"> |
| 627 |
<RegExpr attribute="Escape" String="\\(?:&escapechars;|[0-7]{1,3}|[xX][A-Fa-f0-9]{1,2}|u[A-Fa-f0-9]{1,4}|U[A-Fa-f0-9]{1,8}|c.)" /> |
| 628 |
</context> |
| 629 |
|
| 630 |
</contexts> |
| 631 |
|
| 632 |
<itemDatas> |
| 633 |
<itemData name="Normal Text" defStyleNum="dsNormal" /> |
| 634 |
<itemData name="Path" defStyleNum="dsNormal" /> |
| 635 |
<itemData name="Option" defStyleNum="dsNormal" /> |
| 636 |
<itemData name="Escape" defStyleNum="dsKeyword" /> |
| 637 |
<itemData name="Separator" defStyleNum="dsKeyword" /> |
| 638 |
<itemData name="Glob" defStyleNum="dsKeyword" /> |
| 639 |
<itemData name="HomeDir" defStyleNum="dsKeyword" /> |
| 640 |
<itemData name="Keychar" defStyleNum="dsSpecialChar" /> |
| 641 |
<itemData name="Command" defStyleNum="dsFunction" /> |
| 642 |
<itemData name="UnixCommand" defStyleNum="dsFunction" /> |
| 643 |
<itemData name="CommandPath" defStyleNum="dsExtension" /> |
| 644 |
<itemData name="Variable" defStyleNum="dsVariable" /> |
| 645 |
<itemData name="Control Flow" defStyleNum="dsControlFlow" /> |
| 646 |
<itemData name="Operator" defStyleNum="dsOperator" /> |
| 647 |
<itemData name="Redirection" defStyleNum="dsOperator" /> |
| 648 |
<itemData name="Builtin" defStyleNum="dsBuiltIn" /> |
| 649 |
<itemData name="Index" defStyleNum="dsAttribute" /> |
| 650 |
|
| 651 |
<itemData name="String SingleQ" defStyleNum="dsString" /> |
| 652 |
<itemData name="String DoubleQ" defStyleNum="dsString" /> |
| 653 |
<itemData name="Process" defStyleNum="dsImport" /> |
| 654 |
|
| 655 |
|
| 656 |
<itemData name="Comment" defStyleNum="dsComment" /> |
| 657 |
<itemData name="Function Doc" defStyleNum="dsDocumentation" /> |
| 658 |
|
| 659 |
<itemData name="Error" defStyleNum="dsError" /> |
| 660 |
</itemDatas> |
| 661 |
</highlighting> |
| 662 |
<general> |
| 663 |
<!-- no / as weakDeliminator, otherwwise in /usr/bin/ls ls is not recognized as UnixCommand --> |
| 664 |
<keywords casesensitive="1" weakDeliminator="\+,-:=!.@#%^_`~" wordWrapDeliminator="&separator;"/> |
| 665 |
<comments> |
| 666 |
<comment name="singleLine" start="#"/> |
| 667 |
</comments> |
| 668 |
</general> |
| 669 |
</language> |