Files
RedBear-OS/local/recipes/kde/kf6-syntaxhighlighting/source/data/syntax/fish.xml
T

711 lines
34 KiB
XML

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE language
[
<!ENTITY tab "&#x9;">
<!ENTITY white "&tab; "> <!-- first is tab -->
<!ENTITY eocommand "&white;&lt;&gt;^"> <!-- end of command separator -->
<!ENTITY separator "&white;|&amp;;&lt;&gt;()'&quot;"> <!-- token separator as char list -->
<!ENTITY commandsep "|&amp;;"> <!-- command separator as char list -->
<!ENTITY special "{}*/.?\\$&amp;"> <!-- not allowed in function names -->
<!ENTITY portable_filename "A-Za-z0-9\._-">
<!ENTITY funcname_first "a-zA-Z+:=!.@_`">
<!ENTITY funcname_last "a-zA-Z0-9+,-:=!.@#&#37;^_`~">
<!ENTITY funcname "[&funcname_first;](?:[&funcname_last;]|\\ )*">
<!ENTITY varname "[A-Za-z0-9_]+">
<!ENTITY alnumdash "[A-Za-z0-9-]"> <!-- option chars, dashes for GNU long opts -->
<!ENTITY testoptsfile "[bcdefgGkLOprsStuwx]"> <!-- test operators for file testing -->
<!ENTITY testoptsother "[nzao]"> <!-- other test operators -->
<!ENTITY braceelement "[!#&#37;+\-\./0-9:=@A-Z^_`a-z~]">
<!ENTITY escapechars "[abefnrtv $\\*?~&#37;#(){}[\]&lt;&gt;\^&amp;;&quot;&apos;]"> <!-- escape chars -->
<!ENTITY white_or_eol "(?:[&white;]|$)">
<!ENTITY homedir "~[&portable_filename;]*">
<!ENTITY pathdetect "(?:(?:\.\.?|&homedir;)&white_or_eol;|(?:[^$\\{}&separator;/\*\?]|\\&escapechars;)*(:?[/?]|\*\*?))">
<!ENTITY pathpart "(?:[^&separator;/]|\\&escapechars;)*(?:/|(?=[&quot;']))">
<!ENTITY command "([-\w+,-:=!.@#&#37;^_`~]+|\\ )+">
]>
<language name="Fish" version="9" kateversion="5.72" section="Scripts" extensions="*.fish;fishd.*" mimetype="application/x-fish" casesensitive="1" author="Arnd Diestelhorst (adiestelhorst@m-xchg.de)" license="LGPL">
<highlighting>
<list name= "commands">
<item>abbr</item>
<item>alias</item>
<item>argparse</item>
<item>bg</item>
<item>bind</item>
<item>block</item>
<item>cd</item>
<item>cdh</item>
<item>commandline</item>
<item>complete</item>
<item>contains</item>
<item>count</item>
<item>dirs</item>
<item>disown</item>
<item>echo</item>
<item>emit</item>
<item>end</item>
<item>exit</item>
<item>fg</item>
<item>fish</item>
<item>fish_config</item>
<item>fish_indent</item>
<item>fish_key_reader</item>
<item>fish_mode_prompt</item>
<item>fish_opt</item>
<item>fish_prompt</item>
<item>fish_right_prompt</item>
<item>fish_update_completions</item>
<item>fish_vi_mode</item>
<item>funced</item>
<item>funcsave</item>
<item>functions</item>
<item>help</item>
<item>history</item>
<item>isatty</item>
<item>jobs</item>
<item>math</item>
<item>nextd</item>
<item>open</item>
<item>prevd</item>
<item>printf</item>
<item>psub</item>
<item>pushd</item>
<item>random</item>
<item>realpath</item>
<item>return</item>
<item>set_color</item>
<item>source</item>
<item>status</item>
<item>suspend</item>
<item>trap</item>
<item>type</item>
<item>ulimit</item>
<item>umask</item>
<item>vared</item>
</list>
<list name="commandsnoargs">
<item>break</item>
<item>breakpoint</item>
<item>continue</item>
<item>dirh</item>
<item>false</item>
<item>popd</item>
<item>prompt_pwd</item>
<item>pwd</item>
<item>true</item>
</list>
<list name="commandsstay">
<item>and</item>
<item>not</item>
<item>or</item>
</list>
<list name="stringsubcommands">
<item>escape</item>
<item>join</item>
<item>length</item>
<item>lower</item>
<item>match</item>
<item>repeat</item>
<item>replace</item>
<item>split</item>
<item>sub</item>
<item>trim</item>
<item>unescape</item>
<item>upper</item>
</list>
<list name="unixcommands">
<include>unixcommands##Bash</include>
<item>command</item>
<item>kill</item>
<item>test</item>
</list>
<contexts>
<context name="Start" attribute="Normal Text" lineEndContext="#stay" fallthroughContext="Root">
<DetectChar attribute="Error" context="DropRestOfLine" char=")"/>
</context>
<context name="DropRestOfLine" attribute="Normal Text" lineEndContext="#pop">
<DetectChar attribute="Comment" context="Comment" char="#"/>
<RegExpr attribute="Normal Text" String="[^#]*" />
</context>
<!-- Root starts at a new line (not continuation) -->
<context name="Root" attribute="Normal Text" lineEndContext="#pop">
<LineContinue attribute="Escape" />
<DetectChar attribute="Comment" context="Comment" char="#"/>
<DetectChar context="#pop" char=")" lookAhead="true" />
<IncludeRules context="FindCommands" />
</context>
<!--
fish interprets closing parenthesis inside comments as end of command substitution, if the comment starts
inside of a command substitution!
fish does not interpret them this way, when
they are escaped by a \ or
they are matched by an earlier opening parenthesis inside the same comment.
This behaviour is replicated here.
Command substitutions may span several lines, so the closing parenthesis may be on a different line,
than the opening one. In the interactive shell you need a continuation line for this, not so in scripts.
Blocks of code with multiline command substitutions may be commented out. This should not lead to visual artifacts.
There is one case, where the following solution fails: a lonely closing ")", which is marked as an error.
-->
<context name="Comment" attribute="Comment" lineEndContext="#pop">
<Detect2Chars attribute="Comment" char="\" char1="(" />
<Detect2Chars attribute="Comment" char="\" char1=")" />
<DetectChar context="CommentParenSub" char="(" />
<DetectChar context="#pop" char=")" lookAhead="true" />
<IncludeRules context="##Comments" />
</context>
<context name="CommentParenSub" attribute="Comment" lineEndContext="BlockComment">
<DetectChar attribute="Comment" context="#pop" char=")" />
<IncludeRules context="Comment" />
</context>
<context name="BlockComment" attribute="Comment" fallthroughContext="#pop#pop#pop" lineEndContext="#stay">
<DetectChar attribute="Comment" context="#pop" char="#" firstNonSpace="true"/>
</context>
<!-- FindCommands matches Fish and Unix commands -->
<!-- order is important, factor out common rules did'nt work because of order of rules-->
<context name="FindCommands" attribute="Command" lineEndContext="#stay">
<DetectSpaces attribute="Normal Text" />
<AnyChar attribute="Error" context="#pop!DropRestOfLine" String="(&lt;&gt;"/>
<AnyChar attribute="Separator" String="&commandsep;" />
<keyword attribute="Builtin" context="Arguments" String="commands" /> <!--simple commands first-->
<keyword attribute="Builtin" context="ArgumentsNone" String="commandsnoargs" />
<keyword attribute="Control Flow" String="commandsstay" />
<Detect2Chars attribute="Builtin" context="Arguments" char="." char1=" " />
<RegExpr attribute="CommandPath" context="CommandPart" String="&pathdetect;" />
<IncludeRules context="FindSpecialCommands" /> <!--before unixcommands, because f test, but after path detection-->
<keyword attribute="UnixCommand" context="Arguments" String="unixcommands"/>
<RegExpr attribute="Command" context="CommandPart" String="&command;" />
<DetectChar context="CommandPart" char="&quot;" lookAhead="true"/>
</context>
<context name="CommandPart" attribute="Command" lineEndContext="#pop">
<LineContinue attribute="Escape" />
<AnyChar context="#pop" String=")#" lookAhead="true"/>
<AnyChar attribute="Separator" context="#pop" String="&commandsep;" />
<AnyChar context="#pop!Arguments" String="&eocommand;" lookAhead="true"/>
<RegExpr attribute="CommandPath" String="&pathpart;" />
<keyword attribute="UnixCommand" String="unixcommands"/>
<RegExpr attribute="Command" String="&command;" />
<IncludeRules context="FindStrings" />
<RegExpr attribute="Error" String="." />
</context>
<context name="FindSpecialCommands" attribute="Builtin" lineEndContext="#stay">
<WordDetect attribute="Builtin" String="command" context="command_builtin" />
<WordDetect attribute="Builtin" String="builtin" context="command_builtin" />
<WordDetect attribute="Builtin" String="eval" context="eval_exec" />
<WordDetect attribute="Builtin" String="exec" context="eval_exec" />
<WordDetect attribute="Builtin" String="set" context="set" />
<WordDetect attribute="Builtin" String="string" context="string" />
<WordDetect attribute="Builtin" String="read" context="read_vared" />
<WordDetect attribute="Builtin" String="vared" context="read_vared" />
<WordDetect attribute="Builtin" String="test" context="ArgumentsTest" />
<Detect2Chars attribute="Builtin" char="[" char1="&tab;" context="ArgumentsTestBrack" />
<Detect2Chars attribute="Builtin" char="[" char1=" " context="ArgumentsTestBrack" />
<WordDetect attribute="Control Flow" String="begin" context="begin" beginRegion="begin" />
<WordDetect attribute="Control Flow" String="for" context="for" beginRegion="for" />
<WordDetect attribute="Control Flow" String="function" context="function" beginRegion="function" />
<WordDetect attribute="Control Flow" String="if" context="if" beginRegion="if" />
<WordDetect attribute="Control Flow" String="switch" context="switch" beginRegion="switch" />
<WordDetect attribute="Control Flow" String="while" context="while" beginRegion="while" />
</context>
<context name="command_builtin" attribute="Normal Text" lineEndContext="#pop">
<LineContinue attribute="Escape" />
<RegExpr attribute="Option" String="-&alnumdash;*" />
<AnyChar attribute="Separator" context="#pop" String="&commandsep;" />
<IncludeRules context="Root" />
</context>
<context name="eval_exec" attribute="Normal Text" lineEndContext="#pop">
<DetectChar context="#pop" char=")" lookAhead="true"/>
<AnyChar attribute="Separator" context="#pop" String="&commandsep;" />
<IncludeRules context="FindStrings" />
<IncludeRules context="FindVarExpansion" />
<IncludeRules context="FindSubstitutions" />
<IncludeRules context="FindBraceExpansion" />
<IncludeRules context="FindPaths" />
<IncludeRules context="FindEscapes" />
<IncludeRules context="Root" />
</context>
<context name="set" attribute="Normal Text" lineEndContext="#pop">
<LineContinue attribute="Escape" />
<AnyChar attribute="Separator" context="#pop" String="&commandsep;" />
<RegExpr attribute="Option" String="-&alnumdash;*" />
<RegExpr attribute="Variable" String="&varname;" context="set_CheckSubscript" />
<IncludeRules context="FindVarExpansion" />
</context>
<!-- check set var[1] -->
<context name="set_CheckSubscript" attribute="Normal Text" fallthroughContext="#pop!Arguments" lineEndContext="#pop#pop">
<LineContinue attribute="Escape" context="set_CheckSubscript2"/>
<DetectChar attribute="Index" context="set_Subscript" char="["/>
</context>
<!-- check set var\
[1] -->
<context name="set_CheckSubscript2" attribute="Normal Text" fallthroughContext="#pop#pop!Arguments" lineEndContext="#pop#pop#pop">
<DetectChar attribute="Index" context="#pop!set_Subscript" char="["/>
</context>
<context name="set_Subscript" attribute="Index" lineEndContext="#pop#pop#pop">
<DetectChar attribute="Index" context="#pop#pop!Arguments" char="]" />
<IncludeRules context="InSubscript" />
</context>
<context name="string" attribute="Normal Text" lineEndContext="#pop">
<LineContinue attribute="Escape" />
<DetectSpaces attribute="Normal Text" />
<keyword attribute="Builtin" context="#pop!Arguments" String="stringsubcommands" />
<RegExpr attribute="Error" String="." />
</context>
<context name="read_vared" attribute="Normal Text" lineEndContext="#pop">
<LineContinue attribute="Escape" />
<RegExpr attribute="Option" String="-&alnumdash;*" />
<DetectChar attribute="Comment" context="Comment" char="#"/>
<AnyChar attribute="Separator" context="#pop" String="&commandsep;" />
<DetectChar context="#pop" char=")" lookAhead="true"/>
<IncludeRules context="FindStrings" />
<IncludeRules context="FindVarExpansion" />
<IncludeRules context="FindSubstitutions" />
<IncludeRules context="FindBraceExpansion" />
<IncludeRules context="FindEscapes" />
<RegExpr attribute="Variable" String="&varname;" />
</context>
<context name="ArgumentsTestBrack" attribute="Normal Text" lineEndContext="#pop">
<LineContinue attribute="Escape" />
<Detect2Chars attribute="Builtin" char=" " char1="]" context="#pop!ArgumentsNonePre" />
<AnyChar attribute="Error" context="#pop!DropRestOfLine" String="#&commandsep;&amp;"/>
<IncludeRules context="ArgumentsTest" />
</context>
<context name="ArgumentsTest" attribute="Normal Text" lineEndContext="#pop">
<LineContinue attribute="Escape" />
<RegExpr attribute="Operator" context="DirectPath" String="-&testoptsfile; " />
<RegExpr attribute="Operator" String="-&testoptsother; |!=?|=| -eq | -ne | -gt | -ge | -lt | -le "/>
<AnyChar context="#pop" String="&commandsep;#" lookAhead="true"/>
<IncludeRules context="FindArgumentsCommon" />
</context>
<context name="begin" attribute="Normal Text" lineEndContext="beginbody">
<DetectSpaces attribute="Normal Text" />
<DetectChar attribute="Separator" context="beginbody" char=";" />
<IncludeRules context="Root" />
</context>
<context name="beginbody" attribute="Normal Text" lineEndContext="#stay">
<LineContinue attribute="Escape" />
<WordDetect attribute="Control Flow" String="end" context="#pop#pop" endRegion="begin" />
<IncludeRules context="Root" />
</context>
<context name="for" attribute="Normal Text" lineEndContext="#stay">
<LineContinue attribute="Escape" />
<DetectSpaces attribute="Normal Text" />
<WordDetect attribute="Control Flow" String="in" context="forargs" />
<RegExpr attribute="Variable" String="&varname;" />
<IncludeRules context="FindVarExpansion" />
<RegExpr attribute="Error" String="."/>
</context>
<context name="forargs" attribute="Normal Text" lineEndContext="forbody">
<DetectChar attribute="Separator" context="forbody" char=";" />
<DetectChar attribute="Comment" context="Comment" char="#"/>
<IncludeRules context="FindArgumentsCommon" />
</context>
<context name="forbody" attribute="Normal Text" lineEndContext="#stay">
<LineContinue attribute="Escape" />
<WordDetect attribute="Control Flow" String="end" context="#pop#pop#pop" endRegion="for" />
<IncludeRules context="Root" />
</context>
<context name="function" attribute="Normal Text" lineEndContext="funcbody">
<LineContinue attribute="Escape" />
<DetectSpaces attribute="Normal Text" />
<DetectChar attribute="Comment" context="func_comment" char="#"/>
<DetectChar context="funcopts" char="-" lookAhead="true" />
<DetectChar attribute="Separator" context="funcbody" char=";" />
<RegExpr attribute="Command" String="&funcname;" />
<IncludeRules context="FindVarExpansion" />
<RegExpr attribute="Error" String="."/>
</context>
<context name="func_comment" attribute="Comment" lineEndContext="#pop!funcbody">
</context>
<context name="funcopts" attribute="Normal Text" lineEndContext="#pop!funcbody">
<DetectChar attribute="Comment" context="#pop!func_comment" char="#"/>
<RegExpr attribute="Option" String="(?:-d[&white;]*|--description=)(?=[&quot;'])" context="funcdesc" beginRegion="doc"/>
<RegExpr attribute="Option" String="-&alnumdash;*" />
<DetectChar attribute="Separator" context="#pop!funcbody" char=";" />
<IncludeRules context="FindArgumentsCommon" />
</context>
<context name="funcdesc" attribute="Function Doc" lineEndContext="#stay">
<DetectChar context="DocstringSQ" char="'" />
<DetectChar context="DocstringDQ" char="&quot;" />
</context>
<!-- StringSQ consumes anything till ' -->
<context name="DocstringSQ" attribute="Function Doc" lineEndContext="#stay">
<!--no line continuation here-->
<Detect2Chars attribute="Escape" char="\" char1="'" />
<Detect2Chars attribute="Escape" char="\" char1="\" />
<DetectChar attribute="Function Doc" context="#pop#pop" char="'" endRegion="doc"/>
</context>
<!-- StringDQ consumes anything till ", substitutes vars and expressions -->
<context name="DocstringDQ" attribute="Function Doc" lineEndContext="#stay">
<LineContinue attribute="Escape" />
<Detect2Chars attribute="Escape" char="\" char1="&quot;" />
<Detect2Chars attribute="Escape" char="\" char1="$" />
<Detect2Chars attribute="Escape" char="\" char1="\" />
<IncludeRules context="FindVarExpansion" />
<DetectChar attribute="Function Doc" context="#pop#pop" char="&quot;" endRegion="doc"/>
</context>
<context name="funcbody" attribute="Normal Text" lineEndContext="#stay">
<LineContinue attribute="Escape" />
<WordDetect attribute="Control Flow" String="end" context="#pop#pop" endRegion="function" />
<IncludeRules context="Root" />
</context>
<context name="if" attribute="Normal Text" lineEndContext="#stay">
<LineContinue attribute="Escape"/>
<WordDetect attribute="Control Flow" String="else" context="else" endRegion="if" beginRegion="if"/>
<WordDetect attribute="Control Flow" String="end" context="#pop" endRegion="if"/>
<IncludeRules context="Root" />
</context>
<context name="else" attribute="Normal Text" lineEndContext="#stay" fallthroughContext="#pop">
<DetectSpaces attribute="Normal Text" context="#stay"/>
<LineContinue attribute="Escape" context="#stay"/>
<WordDetect attribute="Control Flow" String="if" context="#pop"/>
</context>
<context name="switch" attribute="Normal Text" lineEndContext="switchbody">
<DetectChar attribute="Separator" context="switchbody" char=";" />
<DetectChar attribute="Comment" context="Comment" char="#"/>
<IncludeRules context="FindArgumentsCommon" />
</context>
<context name="switchbody" attribute="Normal Text" lineEndContext="#stay">
<LineContinue attribute="Escape" />
<WordDetect attribute="Control Flow" String="case" context="case" beginRegion="case" />
<WordDetect attribute="Control Flow" String="end" context="#pop#pop" endRegion="switch"/>
<IncludeRules context="Root" />
</context>
<context name="case" attribute="Normal Text" lineEndContext="casebody">
<DetectChar attribute="Separator" context="casebody" char=";" />
<DetectChar attribute="Comment" context="Comment" char="#"/>
<IncludeRules context="FindArgumentsCommon" />
</context>
<context name="casebody" attribute="Normal Text" lineEndContext="#stay">
<LineContinue attribute="Escape" />
<WordDetect attribute="Control Flow" String="case" context="#pop" endRegion="case" beginRegion="case" />
<WordDetect attribute="Control Flow" String="end" context="#pop#pop" endRegion="case" lookAhead="1"/>
<IncludeRules context="Root" />
</context>
<context name="while" attribute="Normal Text" lineEndContext="#stay">
<LineContinue attribute="Escape" />
<WordDetect attribute="Control Flow" String="end" context="#pop" endRegion="while"/>
<IncludeRules context="Root" />
</context>
<!--Argument Rules match the items after a command
this one is a collection with the common part for inclusion-->
<context name="Arguments" attribute="Normal Text" lineEndContext="#pop">
<AnyChar context="#pop" String="&commandsep;)" lookAhead="true"/>
<DetectChar attribute="Comment" context="Comment" char="#"/>
<IncludeRules context="FindArgumentsCommon" />
</context>
<context name="FindArgumentsCommon" attribute="Normal Text" lineEndContext="#stay">
<LineContinue context="ArgumentPotentialMultiLineComment" lookAhead="1"/>
<DetectSpaces attribute="Normal Text" />
<RegExpr attribute="Option" String="-&alnumdash;*" />
<RegExpr attribute="Redirection" context="Redirect" String="[0-9]*(?:&gt;{1,2}|&lt;|\^{1,2})" />
<DetectChar attribute="Operator" char="="/>
<IncludeRules context="FindStrings" />
<IncludeRules context="FindVarExpansion" />
<IncludeRules context="FindSubstitutions" />
<IncludeRules context="FindBraceExpansion" />
<IncludeRules context="FindProcessExpansion" />
<IncludeRules context="FindPaths" />
<IncludeRules context="FindEscapes" />
<RegExpr attribute="Normal Text" String="[^&separator;&special;]*" /> <!--unknown token-->
</context>
<!-- check \ preceded by a space -->
<context name="ArgumentPotentialMultiLineComment" attribute="Comment">
<RegExpr attribute="Escape" context="ArgumentComment" String="(?&lt;=\s)\\$" />
<LineContinue attribute="Escape" context="#pop"/>
</context>
<context name="ArgumentComment" attribute="Comment" fallthroughContext="#pop#pop">
<DetectSpaces attribute="Normal Text"/>
<DetectChar context="Comment" char="#"/>
</context>
<context name="ArgumentsNonePre" attribute="Normal Text" lineEndContext="#pop">
<LineContinue attribute="Escape" />
<DetectSpaces attribute="Normal Text" context="#pop!ArgumentsNone" />
<AnyChar context="#pop" String="&commandsep;" lookAhead="true"/> <!--consumed on the "Find"-Level-->
<RegExpr attribute="Error" String="."/>
</context>
<context name="ArgumentsNone" attribute="Normal Text" lineEndContext="#pop">
<LineContinue attribute="Escape" />
<DetectSpaces attribute="Normal Text" />
<DetectChar attribute="Comment" context="Comment" char="#"/>
<RegExpr attribute="Redirection" context="Redirect" String="[0-9]*(?:&gt;{1,2}|&lt;|\^{1,2})" />
<AnyChar context="#pop" String="&commandsep;)" lookAhead="true"/> <!--consumed on the "Find"-Level-->
<RegExpr attribute="Error" String="[^&commandsep;#]*"/>
</context>
<context name="TokEnd" attribute="Normal Text" lineEndContext="#pop">
<LineContinue attribute="Escape" />
<DetectSpaces attribute="Normal Text" context="#pop"/>
<AnyChar context="#pop" String="&commandsep;" lookAhead="true"/> <!--consumed on the "Find"-Level-->
<RegExpr attribute="Error" String="." context="#pop"/>
</context>
<context name="Redirect" attribute="Redirection" fallthroughContext="#pop!DirectPath" lineEndContext="#stay">
<LineContinue attribute="Escape" />
<DetectChar attribute="Redirection" context="#pop!DirectPath" char="?"/>
<DetectChar attribute="Redirection" context="#pop#pop" char="|"/>
<RegExpr attribute="Redirection" context="#pop!TokEnd" String="&amp;(?:[0-9]+|-)" />
</context>
<context name="InSubscript" attribute="Index" lineEndContext="#pop">
<Detect2Chars char="." char1="." />
<LineContinue attribute="Escape" />
<RegExpr attribute="Index" String=" *-?\d+" />
<IncludeRules context="FindVarExpansion" />
<IncludeRules context="FindSubstitutions" />
<DetectSpaces attribute="Normal Text" />
<RegExpr attribute="Error" String="[^\]]" />
</context>
<context name="Subscript" attribute="Index" lineEndContext="#pop">
<DetectChar attribute="Index" context="#pop" char="]" />
<IncludeRules context="InSubscript" />
</context>
<!-- FindStrings looks for single and double quoted strings -->
<context name="FindStrings" attribute="Normal Text" lineEndContext="#stay">
<DetectChar context="StringSQ" char="'" />
<DetectChar context="StringDQ" char="&quot;" />
</context>
<!-- StringSQ consumes anything till ' -->
<context name="StringSQ" attribute="String SingleQ" lineEndContext="#stay">
<!--no line continuation here-->
<Detect2Chars attribute="Escape" char="\" char1="'" />
<Detect2Chars attribute="Escape" char="\" char1="\" />
<DetectChar attribute="String SingleQ" context="#pop" char="'" />
</context>
<!-- StringDQ consumes anything till ", substitutes vars and expressions -->
<context name="StringDQ" attribute="String DoubleQ" lineEndContext="#stay">
<LineContinue attribute="Escape" />
<Detect2Chars attribute="Escape" char="\" char1="&quot;" />
<Detect2Chars attribute="Escape" char="\" char1="$" />
<Detect2Chars attribute="Escape" char="\" char1="\" />
<IncludeRules context="FindVarExpansion" />
<DetectChar attribute="String DoubleQ" context="#pop" char="&quot;" />
</context>
<!-- FindVarExpansion goes after anything starting with $ and and their escapes -->
<context name="FindVarExpansion" attribute="Normal Text" lineEndContext="#stay">
<RegExpr attribute="Variable" context="CheckSubscript" String="\$+&varname;" />
</context>
<!-- Subscript consumes anything till ], marks as Variable -->
<context name="CheckSubscript" attribute="Index" lineEndContext="#pop" fallthroughContext="#pop">
<LineContinue attribute="Escape" />
<DetectChar attribute="Index" context="Subscript" char="["/>
</context>
<!-- Command Substitution -->
<context name="FindSubstitutions" attribute="Normal Text" lineEndContext="#stay">
<DetectChar attribute="Keychar" context="CommandSubstitution" char="(" />
</context>
<context name="CommandSubstitution" attribute="Normal Text" fallthroughContext="Root" lineEndContext="#stay">
<LineContinue attribute="Escape" />
<DetectChar attribute="Keychar" context="CommandSubstitutionCheckSubscript" char=")" />
</context>
<!-- check (...)[1] -->
<context name="CommandSubstitutionCheckSubscript" attribute="Normal Text" fallthroughContext="#pop#pop" lineEndContext="#pop#pop">
<LineContinue attribute="Escape" context="CommandSubstitutionCheckSubscript2"/>
<DetectChar attribute="Index" context="CommandSubstitutionSubscript" char="["/>
</context>
<!-- check (...)\
[1] -->
<context name="CommandSubstitutionCheckSubscript2" attribute="Normal Text" fallthroughContext="#pop#pop#pop" lineEndContext="#pop#pop#pop">
<DetectChar attribute="Index" context="#pop!CommandSubstitutionSubscript" char="["/>
</context>
<context name="CommandSubstitutionSubscript" attribute="Index" lineEndContext="#pop#pop#pop">
<DetectChar attribute="Index" context="#pop#pop#pop" char="]" />
<IncludeRules context="InSubscript" />
</context>
<!-- Brace Expansion consumes anything till } -->
<context name="FindBraceExpansion" attribute="Normal Text" lineEndContext="#stay">
<DetectChar attribute="Keychar" context="BraceList" char="{" />
<DetectChar attribute="Error" char="}" />
</context>
<context name="BraceList" attribute="Normal Text" lineEndContext="#pop">
<LineContinue attribute="Escape" />
<DetectChar attribute="Keychar" context="#pop" char="}" />
<DetectChar attribute="Separator" char="," />
<RegExpr attribute="Normal Text" String="&braceelement;*"/>
<IncludeRules context="FindStrings" />
<IncludeRules context="FindVarExpansion" />
<IncludeRules context="FindSubstitutions" />
<IncludeRules context="FindBraceExpansion" />
<IncludeRules context="FindPaths" />
<IncludeRules context="FindEscapes" />
<RegExpr attribute="Error" String="."/>
</context>
<!-- Process Expansion -->
<context name="FindProcessExpansion" attribute="Normal Text" lineEndContext="#pop">
<DetectChar attribute="Keychar" context="ProcessArg" char="%" />
</context>
<context name="ProcessArg" attribute="Process" lineEndContext="#pop">
<LineContinue attribute="Escape" />
<AnyChar context="#pop" String="&white;" />
<AnyChar context="#pop" String="&separator;" lookAhead="true" />
<DetectChar attribute="Comment" context="Comment" char="#"/>
<IncludeRules context="FindStrings" />
<IncludeRules context="FindVarExpansion" />
<IncludeRules context="FindSubstitutions" />
<IncludeRules context="FindBraceExpansion" />
<IncludeRules context="FindEscapes" />
</context>
<!-- FindPaths for parts which might be a path. Uses the matching of a / as heuristic -->
<!-- Might be fooled with quotes -->
<context name="FindPaths" attribute="Path" lineEndContext="#stay">
<RegExpr context="DirectPath" String="&pathdetect;" lookAhead="true" minimal="1"/>
</context>
<!-- DirectPath is used at places where the next part is definitely a path -->
<context name="DirectPath" attribute="Path" lineEndContext="#pop" fallthroughContext="#pop!PathHead" >
<LineContinue attribute="Escape" />
<DetectSpaces attribute="Normal Text" />
<AnyChar attribute="Error" context="#pop" String="#&commandsep;&lt;&gt;^" />
</context>
<context name="PathHead" attribute="Path" lineEndContext="#pop" fallthroughContext="#pop!Path" >
<LineContinue attribute="Escape" />
<RegExpr attribute="HomeDir" context="#pop!Path" String="&homedir;" />
</context>
<context name="Path" attribute="Path" lineEndContext="#pop">
<LineContinue attribute="Escape" />
<DetectSpaces context="#pop" lookAhead="true" />
<AnyChar context="#pop" String="#&commandsep;&lt;&gt;^)" lookAhead="true" />
<AnyChar attribute="Glob" String="*?" />
<DetectChar attribute="Path" char="/" />
<DetectChar attribute="Keychar" context="PathBrace" char="{" />
<DetectChar attribute="Error" context="#pop" char="}" />
<IncludeRules context="FindStrings" />
<IncludeRules context="FindVarExpansion" />
<IncludeRules context="FindSubstitutions" />
<IncludeRules context="FindEscapes" />
<RegExpr attribute="Path" String="[^$\*\?\\{}&separator;/]*" /> <!--consume everything until next special-->
</context>
<context name="PathBrace" attribute="Path" lineEndContext="#pop">
<LineContinue attribute="Escape" />
<DetectChar attribute="Keychar" context="#pop" char="}" />
<DetectChar attribute="Separator" char="," />
<AnyChar attribute="Error" String=" #&commandsep;&lt;&gt;^)" />
<AnyChar attribute="Glob" String="*?" />
<DetectChar attribute="Path" char="/" />
<DetectChar attribute="Keychar" context="PathBrace" char="{" />
<IncludeRules context="FindStrings" />
<IncludeRules context="FindVarExpansion" />
<IncludeRules context="FindSubstitutions" />
<IncludeRules context="FindEscapes" />
<RegExpr attribute="Path" String="[^$\*\?\\,{}&separator;/]*" />
</context>
<!-- FindEscapes contains various rules to mark different shell input -->
<context name="FindEscapes" attribute="Normal Text" lineEndContext="#stay">
<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.)" />
</context>
</contexts>
<itemDatas>
<itemData name="Normal Text" defStyleNum="dsNormal" />
<itemData name="Path" defStyleNum="dsNormal" />
<itemData name="Option" defStyleNum="dsNormal" />
<itemData name="Escape" defStyleNum="dsKeyword" />
<itemData name="Separator" defStyleNum="dsKeyword" />
<itemData name="Glob" defStyleNum="dsKeyword" />
<itemData name="HomeDir" defStyleNum="dsKeyword" />
<itemData name="Keychar" defStyleNum="dsSpecialChar" />
<itemData name="Command" defStyleNum="dsFunction" />
<itemData name="UnixCommand" defStyleNum="dsFunction" />
<itemData name="CommandPath" defStyleNum="dsExtension" />
<itemData name="Variable" defStyleNum="dsVariable" />
<itemData name="Control Flow" defStyleNum="dsControlFlow" />
<itemData name="Operator" defStyleNum="dsOperator" />
<itemData name="Redirection" defStyleNum="dsOperator" />
<itemData name="Builtin" defStyleNum="dsBuiltIn" />
<itemData name="Index" defStyleNum="dsAttribute" />
<itemData name="String SingleQ" defStyleNum="dsString" />
<itemData name="String DoubleQ" defStyleNum="dsString" />
<itemData name="Process" defStyleNum="dsImport" />
<itemData name="Comment" defStyleNum="dsComment" />
<itemData name="Function Doc" defStyleNum="dsDocumentation" />
<itemData name="Error" defStyleNum="dsError" />
</itemDatas>
</highlighting>
<general>
<!-- no / as weakDeliminator, otherwwise in /usr/bin/ls ls is not recognized as UnixCommand -->
<keywords casesensitive="1" weakDeliminator="\+,-:=!.@#&#37;^_`~" wordWrapDeliminator="&separator;"/>
<comments>
<comment name="singleLine" start="#"/>
</comments>
</general>
</language>