sh.xml 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242
  1. <?xml version="1.0"?>
  2. <!-- $Id: sh.xml,v 1.2 2007/06/14 00:15:50 ssttoo Exp $ -->
  3. <highlight lang="sh" case = "yes">
  4. <authors>
  5. <author name="Noah Spurrier" email="noah@noah.org" />
  6. </authors>
  7. <comment>This highlighter is EXPERIMENTAL. It may work incorrectly.
  8. It is a crude hack of the perl syntax, which itself wasn't so good.
  9. But this seems to work OK.
  10. </comment>
  11. <default innerClass="code"/>
  12. <block name="interpreter" match="/^(#!)(.*)/m" innerClass="special">
  13. <partClass index="1" innerClass="special" />
  14. <partClass index="2" innerClass="string" />
  15. </block>
  16. <!--
  17. brackets
  18. -->
  19. <region name="block" delimClass="brackets" innerClass="code" start="\{" end="\}">
  20. <contains all="yes"/>
  21. </region>
  22. <region name="brackets" delimClass="brackets" innerClass="code" start="\(" end="\)">
  23. <contains all="yes"/>
  24. </region>
  25. <region name="sqbrackets" delimClass="brackets" innerClass="code" start="\[" end="\]">
  26. <contains all="yes"/>
  27. </region>
  28. <!--
  29. use smth
  30. -->
  31. <block name="usestatement" match="(use)\s+([\w:]*)" innerClass="special">
  32. <partClass index="1" innerClass="reserved" />
  33. <partClass index="2" innerClass="special" />
  34. </block>
  35. <region name="q-w-q-statement"
  36. start="/\b(q[wq]\s*((\{)|(\()|(\[)|(\&lt;)|([\W\S])))(?=(.*)((?(3)\})(?(4)\))(?(5)\])(?(6)\&gt;)(?(7)\7)))/Us"
  37. end="%b2%"
  38. innerClass="string" delimClass="quotes" remember="yes">
  39. <contains block="containedvar"/>
  40. <contains block="specialvar"/>
  41. <contains block="curlyvar"/>
  42. </region>
  43. <region name="qstatement"
  44. start="/\b(q\s*((\{)|(\()|(\[)|(\&lt;)|([\W\S])))(?=(.*)((?(3)\})(?(4)\))(?(5)\])(?(6)\&gt;)(?(7)\7)))/Us"
  45. end="%b2%"
  46. innerClass="string" delimClass="quotes" remember="yes">
  47. </region>
  48. <!--
  49. comments
  50. -->
  51. <block name="comment" match="#.*" innerClass="comment" />
  52. <!--
  53. regexpr
  54. FIXME: this should be rewritten
  55. -->
  56. <block name="dblregexprver1" match="/(s|tr) ([|#~`!@$%^&amp;*-+=\\;:'&quot;,.\/?]) ((\\.|[^\\])*?) (\2)((\\.|[^\\])*?)(\2[ecgimosx]*)/x" innerClass="string">
  57. <partClass index="1" innerClass="quotes" />
  58. <partClass index="2" innerClass="quotes" />
  59. <partClass index="3" innerClass="string" />
  60. <partClass index="5" innerClass="quotes" />
  61. <partClass index="6" innerClass="string" />
  62. <partClass index="8" innerClass="quotes" />
  63. </block>
  64. <block name="dblregexprver2" match="/(m) ([|#~`!@$%^&amp;*-+=\\;:'&quot;,.\/?]) ((\\.|[^\\])*?) (\2[ecgimosx]*)/x" innerClass="string">
  65. <partClass index="1" innerClass="quotes" />
  66. <partClass index="2" innerClass="quotes" />
  67. <partClass index="3" innerClass="string" />
  68. <partClass index="5" innerClass="quotes" />
  69. </block>
  70. <region name="regexp" start=" \/" end="\/[cgimosx]*" innerClass="string" delimClass="quotes" case="yes">
  71. <contains block="reescaped"/>
  72. </region>
  73. <block name="reescaped" match="\\\/" innerClass="string" contained="yes">
  74. <onlyin region="regexp"/>
  75. </block>
  76. <!--
  77. variables
  78. FIXME: @{...}
  79. -->
  80. <block name="bracketsvars" match="([a-z1-9_]+)(\s*=>)" innerClass="string" contained="yes" case="no">
  81. <partClass index="1" innerClass="string" />
  82. <partClass index="2" innerClass="code" />
  83. <onlyin region="brackets"/>
  84. </block>
  85. <block name="specialvar" match="\$#?[1-9'`@!]" innerClass="var"/>
  86. <block name="var" match="(\$#?|[@%*])([a-z1-9_]+::)*([a-z1-9_]+|\^(?-i)[A-Z]?(?i))" innerClass="var" case="no"/>
  87. <block name="containedvar" match="\$([a-z1-9_]+|\^(?-i)[A-Z]?(?i))" innerClass="var" case="no"/>
  88. <block name="classvar" match="(\{)([a-z1-9]+)(\})" innerClass="var" case="no">
  89. <partClass index="1" innerClass="brackets" />
  90. <partClass index="2" innerClass="var" />
  91. <partClass index="3" innerClass="brackets" />
  92. </block>
  93. <block name="curlyvar" match="[\$@%]#?\{[a-z1-9]+\}" innerClass="var" case="no"/>
  94. <!--
  95. quotes
  96. -->
  97. <region name="exec" delimClass="quotes" innerClass="string" start="`" end="`">
  98. <contains block="containedvar"/>
  99. <contains block="specialvar"/>
  100. <contains block="curlyvar"/>
  101. </region>
  102. <region name="strsingle" delimClass="quotes" innerClass="string" start="'" end="'"/>
  103. <block name="escaped" match="\\\\|\\&quot;|\\'|\\`" innerClass="special" contained="yes">
  104. <onlyin region="qstatement"/>
  105. <onlyin region="strsingle"/>
  106. <onlyin region="exec"/>
  107. </block>
  108. <region name="strdouble" delimClass="quotes" innerClass="string" start="&quot;" end="&quot;">
  109. <contains block="containedvar"/>
  110. <contains block="specialvar"/>
  111. <contains block="curlyvar"/>
  112. </region>
  113. <block name="descaped" match="\\[\\&quot;'`tnr\$\{@]" innerClass="special" contained="yes">
  114. <onlyin region="strdouble"/>
  115. <onlyin region="q-w-q-statement"/>
  116. </block>
  117. <!-- logical op.
  118. <block name="logic" match="\|\||&amp;&amp;" innerClass="reserved" contained="yes"/>-->
  119. <!--
  120. identifiers
  121. -->
  122. <block name="identifier" match="[a-z_]\w*" innerClass="identifier" case="no"/>
  123. <!--
  124. numbers
  125. -->
  126. <block name="number" match="\d*\.?\d+" innerClass="number"/>
  127. <!--
  128. GNU and posix standard shell utilities here.
  129. -->
  130. <keywords name="reserved" inherits="identifier" innerClass="reserved" case = "yes">
  131. <keyword match="cd"/>
  132. <keyword match="cp"/>
  133. <keyword match="rm"/>
  134. <keyword match="echo"/>
  135. <keyword match="printf"/>
  136. <keyword match="exit"/>
  137. <keyword match="cut"/>
  138. <keyword match="join"/>
  139. <keyword match="comm"/>
  140. <keyword match="fmt"/>
  141. <keyword match="grep"/>
  142. <keyword match="egrep"/>
  143. <keyword match="fgrep"/>
  144. <keyword match="sed"/>
  145. <keyword match="awk"/>
  146. <keyword match="yes"/>
  147. <keyword match="false"/>
  148. <keyword match="true"/>
  149. <keyword match="test"/>
  150. <keyword match="expr"/>
  151. <keyword match="tee"/>
  152. <keyword match="basename"/>
  153. <keyword match="dirname"/>
  154. <keyword match="pathchk"/>
  155. <keyword match="pwd"/>
  156. <keyword match="stty"/>
  157. <keyword match="tty"/>
  158. <keyword match="env"/>
  159. <keyword match="printenv"/>
  160. <keyword match="id"/>
  161. <keyword match="logname"/>
  162. <keyword match="whoami"/>
  163. <keyword match="groups"/>
  164. <keyword match="users"/>
  165. <keyword match="who"/>
  166. <keyword match="date"/>
  167. <keyword match="uname"/>
  168. <keyword match="hostname"/>
  169. <keyword match="chroot"/>
  170. <keyword match="nice"/>
  171. <keyword match="nohup"/>
  172. <keyword match="sleep"/>
  173. <keyword match="factor"/>
  174. <keyword match="seq"/>
  175. <keyword match="getopt"/>
  176. <keyword match="getopts"/>
  177. <keyword match="options"/>
  178. <keyword match="shift"/>
  179. </keywords>
  180. <keywords name="flowcontrol" inherits="identifier" innerClass="reserved" case = "yes">
  181. <keyword match="if"/>
  182. <keyword match="fi"/>
  183. <keyword match="then"/>
  184. <keyword match="else"/>
  185. <keyword match="elif"/>
  186. <keyword match="case"/>
  187. <keyword match="esac"/>
  188. <keyword match="while"/>
  189. <keyword match="done"/>
  190. <keyword match="for"/>
  191. <keyword match="in"/>
  192. <keyword match="function"/>
  193. <keyword match="until"/>
  194. <keyword match="do"/>
  195. <keyword match="select"/>
  196. <keyword match="time"/>
  197. <!--
  198. <keyword match="[["/>
  199. <keyword match="]]"/>
  200. -->
  201. <keyword match="read"/>
  202. <keyword match="set"/>
  203. </keywords>
  204. </highlight>