1. <lexer>
    
  2.   <config>
    
  3.     <name>Tcl</name>
    
  4.     <alias>tcl</alias>
    
  5.     <filename>*.tcl</filename>
    
  6.     <filename>*.rvt</filename>
    
  7.     <mime_type>text/x-tcl</mime_type>
    
  8.     <mime_type>text/x-script.tcl</mime_type>
    
  9.     <mime_type>application/x-tcl</mime_type>
    
  10.   </config>
    
  11.   <rules>
    
  12.     <state name="command-in-bracket">
    
  13.       <rule pattern="\b(namespace|continue|variable|uplevel|foreach|return|update|elseif|global|rename|switch|upvar|error|vwait|catch|break|unset|array|apply|trace|after|while|then|else|expr|eval|proc|for|set|if)\b">
    
  14.         <token type="Keyword"/>
    
  15.         <push state="params-in-bracket"/>
    
  16.       </rule>
    
  17.       <rule pattern="\b(platform::shell|pkg::create|pkg_mkIndex|fconfigure|re_syntax|fileevent|platform|fblocked|lreverse|mathfunc|encoding|registry|lreplace|history|bgerror|llength|lsearch|linsert|lassign|lappend|refchan|unknown|package|lrepeat|msgcat|mathop|format|interp|lrange|string|source|lindex|socket|concat|regsub|regexp|loadTk|memory|binary|append|unload|subst|split|lsort|clock|close|flush|fcopy|chan|glob|time|gets|http|dict|file|puts|tell|join|read|exit|exec|open|list|scan|seek|incr|info|lset|load|dde|pwd|pid|eof|tm|cd)\b">
    
  18.         <token type="NameBuiltin"/>
    
  19.         <push state="params-in-bracket"/>
    
  20.       </rule>
    
  21.       <rule pattern="([\w.-]+)">
    
  22.         <token type="NameVariable"/>
    
  23.         <push state="params-in-bracket"/>
    
  24.       </rule>
    
  25.       <rule pattern="#">
    
  26.         <token type="Comment"/>
    
  27.         <push state="comment"/>
    
  28.       </rule>
    
  29.     </state>
    
  30.     <state name="command-in-paren">
    
  31.       <rule pattern="\b(namespace|continue|variable|uplevel|foreach|return|update|elseif|global|rename|switch|upvar|error|vwait|catch|break|unset|array|apply|trace|after|while|then|else|expr|eval|proc|for|set|if)\b">
    
  32.         <token type="Keyword"/>
    
  33.         <push state="params-in-paren"/>
    
  34.       </rule>
    
  35.       <rule pattern="\b(platform::shell|pkg::create|pkg_mkIndex|fconfigure|re_syntax|fileevent|platform|fblocked|lreverse|mathfunc|encoding|registry|lreplace|history|bgerror|llength|lsearch|linsert|lassign|lappend|refchan|unknown|package|lrepeat|msgcat|mathop|format|interp|lrange|string|source|lindex|socket|concat|regsub|regexp|loadTk|memory|binary|append|unload|subst|split|lsort|clock|close|flush|fcopy|chan|glob|time|gets|http|dict|file|puts|tell|join|read|exit|exec|open|list|scan|seek|incr|info|lset|load|dde|pwd|pid|eof|tm|cd)\b">
    
  36.         <token type="NameBuiltin"/>
    
  37.         <push state="params-in-paren"/>
    
  38.       </rule>
    
  39.       <rule pattern="([\w.-]+)">
    
  40.         <token type="NameVariable"/>
    
  41.         <push state="params-in-paren"/>
    
  42.       </rule>
    
  43.       <rule pattern="#">
    
  44.         <token type="Comment"/>
    
  45.         <push state="comment"/>
    
  46.       </rule>
    
  47.     </state>
    
  48.     <state name="command-in-brace">
    
  49.       <rule pattern="\b(namespace|continue|variable|uplevel|foreach|return|update|elseif|global|rename|switch|upvar|error|vwait|catch|break|unset|array|apply|trace|after|while|then|else|expr|eval|proc|for|set|if)\b">
    
  50.         <token type="Keyword"/>
    
  51.         <push state="params-in-brace"/>
    
  52.       </rule>
    
  53.       <rule pattern="\b(platform::shell|pkg::create|pkg_mkIndex|fconfigure|re_syntax|fileevent|platform|fblocked|lreverse|mathfunc|encoding|registry|lreplace|history|bgerror|llength|lsearch|linsert|lassign|lappend|refchan|unknown|package|lrepeat|msgcat|mathop|format|interp|lrange|string|source|lindex|socket|concat|regsub|regexp|loadTk|memory|binary|append|unload|subst|split|lsort|clock|close|flush|fcopy|chan|glob|time|gets|http|dict|file|puts|tell|join|read|exit|exec|open|list|scan|seek|incr|info|lset|load|dde|pwd|pid|eof|tm|cd)\b">
    
  54.         <token type="NameBuiltin"/>
    
  55.         <push state="params-in-brace"/>
    
  56.       </rule>
    
  57.       <rule pattern="([\w.-]+)">
    
  58.         <token type="NameVariable"/>
    
  59.         <push state="params-in-brace"/>
    
  60.       </rule>
    
  61.       <rule pattern="#">
    
  62.         <token type="Comment"/>
    
  63.         <push state="comment"/>
    
  64.       </rule>
    
  65.     </state>
    
  66.     <state name="basic">
    
  67.       <rule pattern="\(">
    
  68.         <token type="Keyword"/>
    
  69.         <push state="paren"/>
    
  70.       </rule>
    
  71.       <rule pattern="\[">
    
  72.         <token type="Keyword"/>
    
  73.         <push state="bracket"/>
    
  74.       </rule>
    
  75.       <rule pattern="\{">
    
  76.         <token type="Keyword"/>
    
  77.         <push state="brace"/>
    
  78.       </rule>
    
  79.       <rule pattern="&#34;">
    
  80.         <token type="LiteralStringDouble"/>
    
  81.         <push state="string"/>
    
  82.       </rule>
    
  83.       <rule pattern="(eq|ne|in|ni)\b">
    
  84.         <token type="OperatorWord"/>
    
  85.       </rule>
    
  86.       <rule pattern="!=|==|&lt;&lt;|&gt;&gt;|&lt;=|&gt;=|&amp;&amp;|\|\||\*\*|[-+~!*/%&lt;&gt;&amp;^|?:]">
    
  87.         <token type="Operator"/>
    
  88.       </rule>
    
  89.     </state>
    
  90.     <state name="params-in-bracket">
    
  91.       <rule pattern="\]">
    
  92.         <token type="Keyword"/>
    
  93.         <push state="#pop" state="#pop"/>
    
  94.       </rule>
    
  95.       <rule>
    
  96.         <include state="params"/>
    
  97.       </rule>
    
  98.     </state>
    
  99.     <state name="data">
    
  100.       <rule pattern="\s+">
    
  101.         <token type="Text"/>
    
  102.       </rule>
    
  103.       <rule pattern="0x[a-fA-F0-9]+">
    
  104.         <token type="LiteralNumberHex"/>
    
  105.       </rule>
    
  106.       <rule pattern="0[0-7]+">
    
  107.         <token type="LiteralNumberOct"/>
    
  108.       </rule>
    
  109.       <rule pattern="\d+\.\d+">
    
  110.         <token type="LiteralNumberFloat"/>
    
  111.       </rule>
    
  112.       <rule pattern="\d+">
    
  113.         <token type="LiteralNumberInteger"/>
    
  114.       </rule>
    
  115.       <rule pattern="\$([\w.:-]+)">
    
  116.         <token type="NameVariable"/>
    
  117.       </rule>
    
  118.       <rule pattern="([\w.:-]+)">
    
  119.         <token type="Text"/>
    
  120.       </rule>
    
  121.     </state>
    
  122.     <state name="command">
    
  123.       <rule pattern="\b(namespace|continue|variable|uplevel|foreach|return|update|elseif|global|rename|switch|upvar|error|vwait|catch|break|unset|array|apply|trace|after|while|then|else|expr|eval|proc|for|set|if)\b">
    
  124.         <token type="Keyword"/>
    
  125.         <push state="params"/>
    
  126.       </rule>
    
  127.       <rule pattern="\b(platform::shell|pkg::create|pkg_mkIndex|fconfigure|re_syntax|fileevent|platform|fblocked|lreverse|mathfunc|encoding|registry|lreplace|history|bgerror|llength|lsearch|linsert|lassign|lappend|refchan|unknown|package|lrepeat|msgcat|mathop|format|interp|lrange|string|source|lindex|socket|concat|regsub|regexp|loadTk|memory|binary|append|unload|subst|split|lsort|clock|close|flush|fcopy|chan|glob|time|gets|http|dict|file|puts|tell|join|read|exit|exec|open|list|scan|seek|incr|info|lset|load|dde|pwd|pid|eof|tm|cd)\b">
    
  128.         <token type="NameBuiltin"/>
    
  129.         <push state="params"/>
    
  130.       </rule>
    
  131.       <rule pattern="([\w.-]+)">
    
  132.         <token type="NameVariable"/>
    
  133.         <push state="params"/>
    
  134.       </rule>
    
  135.       <rule pattern="#">
    
  136.         <token type="Comment"/>
    
  137.         <push state="comment"/>
    
  138.       </rule>
    
  139.     </state>
    
  140.     <state name="params-in-brace">
    
  141.       <rule pattern="\}">
    
  142.         <token type="Keyword"/>
    
  143.         <push state="#pop" state="#pop"/>
    
  144.       </rule>
    
  145.       <rule>
    
  146.         <include state="params"/>
    
  147.       </rule>
    
  148.     </state>
    
  149.     <state name="string-square">
    
  150.       <rule pattern="\[">
    
  151.         <token type="LiteralStringDouble"/>
    
  152.         <push state="string-square"/>
    
  153.       </rule>
    
  154.       <rule pattern="(?s)(\\\\|\\[0-7]+|\\.|\\\n|[^\]\\])">
    
  155.         <token type="LiteralStringDouble"/>
    
  156.       </rule>
    
  157.       <rule pattern="\]">
    
  158.         <token type="LiteralStringDouble"/>
    
  159.         <pop depth="1"/>
    
  160.       </rule>
    
  161.     </state>
    
  162.     <state name="bracket">
    
  163.       <rule pattern="\]">
    
  164.         <token type="Keyword"/>
    
  165.         <pop depth="1"/>
    
  166.       </rule>
    
  167.       <rule>
    
  168.         <include state="command-in-bracket"/>
    
  169.       </rule>
    
  170.       <rule>
    
  171.         <include state="basic"/>
    
  172.       </rule>
    
  173.       <rule>
    
  174.         <include state="data"/>
    
  175.       </rule>
    
  176.     </state>
    
  177.     <state name="params-in-paren">
    
  178.       <rule pattern="\)">
    
  179.         <token type="Keyword"/>
    
  180.         <push state="#pop" state="#pop"/>
    
  181.       </rule>
    
  182.       <rule>
    
  183.         <include state="params"/>
    
  184.       </rule>
    
  185.     </state>
    
  186.     <state name="paren">
    
  187.       <rule pattern="\)">
    
  188.         <token type="Keyword"/>
    
  189.         <pop depth="1"/>
    
  190.       </rule>
    
  191.       <rule>
    
  192.         <include state="command-in-paren"/>
    
  193.       </rule>
    
  194.       <rule>
    
  195.         <include state="basic"/>
    
  196.       </rule>
    
  197.       <rule>
    
  198.         <include state="data"/>
    
  199.       </rule>
    
  200.     </state>
    
  201.     <state name="comment">
    
  202.       <rule pattern=".*[^\\]\n">
    
  203.         <token type="Comment"/>
    
  204.         <pop depth="1"/>
    
  205.       </rule>
    
  206.       <rule pattern=".*\\\n">
    
  207.         <token type="Comment"/>
    
  208.       </rule>
    
  209.     </state>
    
  210.     <state name="root">
    
  211.       <rule>
    
  212.         <include state="command"/>
    
  213.       </rule>
    
  214.       <rule>
    
  215.         <include state="basic"/>
    
  216.       </rule>
    
  217.       <rule>
    
  218.         <include state="data"/>
    
  219.       </rule>
    
  220.       <rule pattern="\}">
    
  221.         <token type="Keyword"/>
    
  222.       </rule>
    
  223.     </state>
    
  224.     <state name="brace">
    
  225.       <rule pattern="\}">
    
  226.         <token type="Keyword"/>
    
  227.         <pop depth="1"/>
    
  228.       </rule>
    
  229.       <rule>
    
  230.         <include state="command-in-brace"/>
    
  231.       </rule>
    
  232.       <rule>
    
  233.         <include state="basic"/>
    
  234.       </rule>
    
  235.       <rule>
    
  236.         <include state="data"/>
    
  237.       </rule>
    
  238.     </state>
    
  239.     <state name="params">
    
  240.       <rule pattern=";">
    
  241.         <token type="Keyword"/>
    
  242.         <pop depth="1"/>
    
  243.       </rule>
    
  244.       <rule pattern="\n">
    
  245.         <token type="Text"/>
    
  246.         <pop depth="1"/>
    
  247.       </rule>
    
  248.       <rule pattern="(else|elseif|then)\b">
    
  249.         <token type="Keyword"/>
    
  250.       </rule>
    
  251.       <rule>
    
  252.         <include state="basic"/>
    
  253.       </rule>
    
  254.       <rule>
    
  255.         <include state="data"/>
    
  256.       </rule>
    
  257.     </state>
    
  258.     <state name="string">
    
  259.       <rule pattern="\[">
    
  260.         <token type="LiteralStringDouble"/>
    
  261.         <push state="string-square"/>
    
  262.       </rule>
    
  263.       <rule pattern="(?s)(\\\\|\\[0-7]+|\\.|[^&#34;\\])">
    
  264.         <token type="LiteralStringDouble"/>
    
  265.       </rule>
    
  266.       <rule pattern="&#34;">
    
  267.         <token type="LiteralStringDouble"/>
    
  268.         <pop depth="1"/>
    
  269.       </rule>
    
  270.     </state>
    
  271.   </rules>
    
  272. </lexer>