2 <!-- $Id: sh.xml,v 1.2 2007-06-14 00:15:50 ssttoo Exp $ -->
4 <highlight lang="sh" case = "yes">
7 <author name="Noah Spurrier" email="noah@noah.org" />
10 <comment>This highlighter is EXPERIMENTAL. It may work incorrectly.
11 It is a crude hack of the perl syntax, which itself wasn't so good.
12 But this seems to work OK.
15 <default innerClass="code"/>
17 <block name="interpreter" match="/^(#!)(.*)/m" innerClass="special">
18 <partClass index="1" innerClass="special" />
19 <partClass index="2" innerClass="string" />
25 <region name="block" delimClass="brackets" innerClass="code" start="\{" end="\}">
29 <region name="brackets" delimClass="brackets" innerClass="code" start="\(" end="\)">
33 <region name="sqbrackets" delimClass="brackets" innerClass="code" start="\[" end="\]">
40 <block name="usestatement" match="(use)\s+([\w:]*)" innerClass="special">
41 <partClass index="1" innerClass="reserved" />
42 <partClass index="2" innerClass="special" />
46 <region name="q-w-q-statement"
47 start="/\b(q[wq]\s*((\{)|(\()|(\[)|(\<)|([\W\S])))(?=(.*)((?(3)\})(?(4)\))(?(5)\])(?(6)\>)(?(7)\7)))/Us"
49 innerClass="string" delimClass="quotes" remember="yes">
51 <contains block="containedvar"/>
52 <contains block="specialvar"/>
53 <contains block="curlyvar"/>
57 <region name="qstatement"
58 start="/\b(q\s*((\{)|(\()|(\[)|(\<)|([\W\S])))(?=(.*)((?(3)\})(?(4)\))(?(5)\])(?(6)\>)(?(7)\7)))/Us"
60 innerClass="string" delimClass="quotes" remember="yes">
67 <block name="comment" match="#.*" innerClass="comment" />
72 FIXME: this should be rewritten
74 <block name="dblregexprver1" match="/(s|tr) ([|#~`!@$%^&*-+=\\;:'",.\/?]) ((\\.|[^\\])*?) (\2)((\\.|[^\\])*?)(\2[ecgimosx]*)/x" innerClass="string">
75 <partClass index="1" innerClass="quotes" />
76 <partClass index="2" innerClass="quotes" />
77 <partClass index="3" innerClass="string" />
78 <partClass index="5" innerClass="quotes" />
79 <partClass index="6" innerClass="string" />
80 <partClass index="8" innerClass="quotes" />
83 <block name="dblregexprver2" match="/(m) ([|#~`!@$%^&*-+=\\;:'",.\/?]) ((\\.|[^\\])*?) (\2[ecgimosx]*)/x" innerClass="string">
84 <partClass index="1" innerClass="quotes" />
85 <partClass index="2" innerClass="quotes" />
86 <partClass index="3" innerClass="string" />
87 <partClass index="5" innerClass="quotes" />
91 <region name="regexp" start=" \/" end="\/[cgimosx]*" innerClass="string" delimClass="quotes" case="yes">
92 <contains block="reescaped"/>
95 <block name="reescaped" match="\\\/" innerClass="string" contained="yes">
96 <onlyin region="regexp"/>
103 <block name="bracketsvars" match="([a-z1-9_]+)(\s*=>)" innerClass="string" contained="yes" case="no">
104 <partClass index="1" innerClass="string" />
105 <partClass index="2" innerClass="code" />
106 <onlyin region="brackets"/>
109 <block name="specialvar" match="\$#?[1-9'`@!]" innerClass="var"/>
111 <block name="var" match="(\$#?|[@%*])([a-z1-9_]+::)*([a-z1-9_]+|\^(?-i)[A-Z]?(?i))" innerClass="var" case="no"/>
112 <block name="containedvar" match="\$([a-z1-9_]+|\^(?-i)[A-Z]?(?i))" innerClass="var" case="no"/>
114 <block name="classvar" match="(\{)([a-z1-9]+)(\})" innerClass="var" case="no">
115 <partClass index="1" innerClass="brackets" />
116 <partClass index="2" innerClass="var" />
117 <partClass index="3" innerClass="brackets" />
120 <block name="curlyvar" match="[\$@%]#?\{[a-z1-9]+\}" innerClass="var" case="no"/>
125 <region name="exec" delimClass="quotes" innerClass="string" start="`" end="`">
126 <contains block="containedvar"/>
127 <contains block="specialvar"/>
128 <contains block="curlyvar"/>
131 <region name="strsingle" delimClass="quotes" innerClass="string" start="'" end="'"/>
133 <block name="escaped" match="\\\\|\\"|\\'|\\`" innerClass="special" contained="yes">
134 <onlyin region="qstatement"/>
135 <onlyin region="strsingle"/>
136 <onlyin region="exec"/>
139 <region name="strdouble" delimClass="quotes" innerClass="string" start=""" end=""">
140 <contains block="containedvar"/>
141 <contains block="specialvar"/>
142 <contains block="curlyvar"/>
145 <block name="descaped" match="\\[\\"'`tnr\$\{@]" innerClass="special" contained="yes">
146 <onlyin region="strdouble"/>
147 <onlyin region="q-w-q-statement"/>
151 <block name="logic" match="\|\||&&" innerClass="reserved" contained="yes"/>-->
156 <block name="identifier" match="[a-z_]\w*" innerClass="identifier" case="no"/>
161 <block name="number" match="\d*\.?\d+" innerClass="number"/>
164 GNU and posix standard shell utilities here.
166 <keywords name="reserved" inherits="identifier" innerClass="reserved" case = "yes">
167 <keyword match="cd"/>
168 <keyword match="cp"/>
169 <keyword match="rm"/>
170 <keyword match="echo"/>
171 <keyword match="printf"/>
172 <keyword match="exit"/>
173 <keyword match="cut"/>
174 <keyword match="join"/>
175 <keyword match="comm"/>
176 <keyword match="fmt"/>
177 <keyword match="grep"/>
178 <keyword match="egrep"/>
179 <keyword match="fgrep"/>
180 <keyword match="sed"/>
181 <keyword match="awk"/>
182 <keyword match="yes"/>
183 <keyword match="false"/>
184 <keyword match="true"/>
185 <keyword match="test"/>
186 <keyword match="expr"/>
187 <keyword match="tee"/>
188 <keyword match="basename"/>
189 <keyword match="dirname"/>
190 <keyword match="pathchk"/>
191 <keyword match="pwd"/>
192 <keyword match="stty"/>
193 <keyword match="tty"/>
194 <keyword match="env"/>
195 <keyword match="printenv"/>
196 <keyword match="id"/>
197 <keyword match="logname"/>
198 <keyword match="whoami"/>
199 <keyword match="groups"/>
200 <keyword match="users"/>
201 <keyword match="who"/>
202 <keyword match="date"/>
203 <keyword match="uname"/>
204 <keyword match="hostname"/>
205 <keyword match="chroot"/>
206 <keyword match="nice"/>
207 <keyword match="nohup"/>
208 <keyword match="sleep"/>
209 <keyword match="factor"/>
210 <keyword match="seq"/>
211 <keyword match="getopt"/>
212 <keyword match="getopts"/>
213 <keyword match="options"/>
214 <keyword match="shift"/>
217 <keywords name="flowcontrol" inherits="identifier" innerClass="reserved" case = "yes">
218 <keyword match="if"/>
219 <keyword match="fi"/>
220 <keyword match="then"/>
221 <keyword match="else"/>
222 <keyword match="elif"/>
223 <keyword match="case"/>
224 <keyword match="esac"/>
225 <keyword match="while"/>
226 <keyword match="done"/>
227 <keyword match="for"/>
228 <keyword match="in"/>
229 <keyword match="function"/>
230 <keyword match="until"/>
231 <keyword match="do"/>
232 <keyword match="select"/>
233 <keyword match="time"/>
235 <keyword match="[["/>
236 <keyword match="]]"/>
238 <keyword match="read"/>
239 <keyword match="set"/>