<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE language SYSTEM "language.dtd">
<!--
    LUA (www.lua.org) syntax highlighting for Kate

    CHANGES

    [ Version 1.03 (2007-09-12) by Bruno Massa ]

    - [=[ ]=] comment and string style is now working (thanks to Dominik and Sebastian)
    - it uses DoxygenLua.xml to format the comments in a Doxygen style

    [ Version 1.02 (2007-07-15) by Bruno Massa ]

    - based on Lua 5.1
    - highlight the Kepler function (cgilua, luasql, lfs, luazip)
    - true, false and nil are highlighted in black
    - table.foreach and foreachi are marked as alerts

    [ Version 1.01 (2007-01-01) by Bruno Massa ]

    - highlighting similar to PHP
    - error detection on one-line strings and common mistakes from other languages like using "!=" "++"
    - uppercase-only variables are highlighted as constants
    - { } now is collapsable

    [ Version 1.00 (2006-12-05) by Bruno Massa ]

    - based on Lua 5.0.2 syntax
    - strings "[[ ]]" and single quoted strings
    - block comments
    - function, if/elseif/else, do-end chunks, comment blocks, strings using [[ ]] collapsable
    - nil, false and true consided pseudo-variables (displayed as numbers)
    - NOTE, FIXME, TODO alerts added on comments
    - improved highlighting

    -->
<language name="Lua" version="1.03" kateversion="2.4" section="Scripts" extensions="*.lua" mimetype="text/x-lua">
  <highlighting>
    <list name="keywords">
      <item> and </item>
      <item> function </item>
      <item> in </item>
      <item> local </item>
      <item> not </item>
      <item> or </item>
    </list>
    <list name="control">
      <item> break </item>
      <item> do </item>
      <item> else </item>
      <item> elseif </item>
      <item> end </item>
      <item> for </item>
      <item> if </item>
      <item> repeat </item>
      <item> return </item>
      <item> then </item>
      <item> until </item>
      <item> while </item>
    </list>
    <list name="pseudo-variables">
      <item> nil </item>
      <item> false </item>
      <item> true </item>
    </list>
    <list name="basefunc">
      <item> string.byte </item>  <item> string.char </item>
      <item> string.find </item>  <item> string.len </item>
      <item> string.lower </item> <item> string.rep </item>
      <item> string.sub </item>   <item> string.upper </item>
      <item> string.format </item><item> string.gfind </item>
      <item> string.gsub </item>  <item> table.concat </item>
      <item> table.getn </item>   <item> table.sort </item>
      <item> table.insert </item> <item> table.remove </item>
      <item> table.setn </item>   <item> math.abs </item>
      <item> math.sin </item>     <item> math.cos </item>
      <item> math.tan </item>     <item> math.asin </item>
      <item> math.acos </item>    <item> math.atan </item>
      <item> math.atan2 </item>   <item> math.ceil </item>
      <item> math.floor </item>   <item> math.mod </item>
      <item> math.frexp </item>   <item> math.ldexp </item>
      <item> math.squrt </item>   <item> math.min </item>
      <item> math.max </item>     <item> math.log </item>
      <item> math.log10 </item>   <item> math.exp </item>
      <item> math.deg </item>     <item> math.rad </item>
      <item> math.random </item>  <item> math.randomseed </item>
      <item> io.close </item>     <item> io.flush </item>
      <item> io.input </item>     <item> io.lines </item>
      <item> io.open </item>      <item> io.output </item>
      <item> io.read </item>      <item> io.stderr </item>
      <item> io.stdin </item>     <item> io.stdout </item>
      <item> io.tmpfile </item>   <item> io.write </item>
      <item> os.clock </item>     <item> os.date </item>
      <item> os.difftime </item>  <item> os.execute </item>
      <item> os.exit </item>      <item> os.getenv </item>
      <item> os.remove </item>    <item> os.rename </item>
      <item> os.setlocale </item> <item> os.time </item>
      <item> os.tmpname </item>   <item> debug.getinfo </item>
      <item> debug.getlocal </item><item> debug.setlocal </item>
      <item> debug.sethook </item><item> debug.gethook </item>
      <item> assert </item>      <item> collectgarbage </item>
      <item> dofile </item>      <item> error </item>
      <item> next </item>        <item> print </item>
      <item> rawget </item>      <item> rawset </item>
      <item> tonumber </item>    <item> tostring </item>
      <item> type </item>        <item> _ALERT </item>
      <item> _ERRORMESSAGE </item><item> call </item>
      <item> getmetatable </item><item> gcinfo </item>
      <item> ipairs </item>      <item> loadfile </item>
      <item> loadstring </item>  <item> pairs </item>
      <item> pcall </item>       <item> require </item>
      <item> LUA_PATH </item>    <item> setmetatable </item>
      <item> _LOADED </item>     <item> _VERSION </item>
      <item> gettagmethod </item><item> globals </item>
      <item> newtag </item>      <item> setglobal </item>
      <item> settag </item>      <item> settagmethod </item>
      <item> setlinehook </item> <item> getglobals </item>
      <item> copytagmethods </item><item> dostring </item>
      <item> getglobal </item>   <item> tag </item>
      <item> setglobals </item>  <item> unpack </item>
      <item> exit </item>        <item> readfrom </item>
      <item> writeto </item>     <item> appendto </item>
      <item> read </item>        <item> write </item>
      <item> getinfo </item>     <item> getlocal </item>
      <item> setlocal </item>    <item> setcallhook </item>
      <item> tinsert </item>     <item> tremove </item>
      <item> flush </item>       <item> seek </item>
      <item> setlocale </item>   <item> execute </item>
      <item> remove </item>      <item> rename </item>
      <item> tmpname </item>     <item> getenv </item>
      <item> getn </item>        <item> sort </item>
      <item> table.foreach </item> <item> table.foreachi </item>
      <item> foreach </item>     <item> foreachi </item>
      <item> abs </item>         <item> sin </item>
      <item> cos </item>         <item> tan </item>
      <item> asin </item>        <item> acos </item>
      <item> atan </item>        <item> atan2 </item>
      <item> ceil </item>        <item> floor </item>
      <item> mod </item>         <item> frexp </item>
      <item> ldexp </item>       <item> squrt </item>
      <item> min </item>         <item> max </item>
      <item> log </item>         <item> log10 </item>
      <item> exp </item>         <item> deg </item>
      <item> rad </item>         <item> random </item>
      <item> randomseed </item>  <item> strlen </item>
      <item> strsub </item>      <item> strlower </item>
      <item> strupper </item>    <item> strchar </item>
      <item> strrep </item>      <item> ascii </item>
      <item> strbyte </item>     <item> format </item>
      <item> strfind </item>     <item> gsub </item>
      <item> openfile </item>    <item> closefile </item>
      <item> date </item>        <item> clock </item>


      <item> cgilua </item>                     <item> cgilua.lp.translate </item>
      <item> cgilua.contentheader </item>       <item> cgilua.script_file </item>
      <item> cgilua.header </item>              <item> cgilua.script_path </item>
      <item> cgilua.htmlheader </item>          <item> cgilua.script_pdir </item>
      <item> cgilua.redirect </item>            <item> cgilua.script_vdir </item>
      <item> cgilua.mkabsoluteurl </item>       <item> cgilua.script_vpath </item>
      <item> cgilua.mkurlpath </item>           <item> cgilua.servervariable </item>
      <item> cgilua.put </item>                 <item> cgilua.urlpath </item>
      <item> cgilua.handlelp </item>            <item> cgilua.errorlog </item>
      <item> cgilua.lp.compile </item>          <item> cgilua.seterrorhandler </item>
      <item> cgilua.lp.include </item>          <item> cgilua.seterroroutput </item>
      <item> cgilua.lp.setcompatmode </item>    <item> cgilua.addclosefunction </item>
      <item> cgilua.lp.setoutfunc </item>       <item> cgilua.addopenfunction </item>
      <item> cgilua.addscripthandler </item>    <item> cgilua.addscripthandler </item>
      <item> cgilua.buildprocesshandler </item> <item> cgilua.setmaxfilesize </item>
      <item> cgilua.setmaxinput </item>         <item> cgilua.urlcode.encodetable </item>
      <item> cgilua.urlcode.escape </item>      <item> cgilua.urlcode.parsequery </item>
      <item> cgilua.urlcode.unescape </item>    <item> cgilua.urlcode.insertfield </item>
      <item> cgilua.setoutfunc </item>          <item> cgilua.addopenfunction </item>
      <item> cgilua.doif </item>                <item> cgilua.doscript </item>
      <item> cgilua.pack </item>                <item> cgilua.splitpath </item>
      <item> cgilua.cookies.get </item>         <item> cgilua.cookies.set </item>
      <item> cgilua.cookies.sethtml </item>     <item> cgilua.cookies.delete </item>
      <item> cgilua.serialize </item>           <item> cgilua.session.close </item>
      <item> cgilua.session.data </item>        <item> cgilua.session.load </item>
      <item> cgilua.session.new </item>         <item> cgilua.session.open </item>
      <item> cgilua.session.save </item>        <item> cgilua.session.setsessiondir </item>
      <item> cgilua.session.delete </item>      <item> cgilua.session </item>
      <item> cgilua.cookies </item>

      <item> numrows </item>                    <item> connect </item>
      <item> close </item>                      <item> fetch </item>
      <item> getcolnames </item>                <item> getcoltypes </item>
      <item> commit </item>                     <item> rollback </item>
      <item> setautocommit </item>

      <item> lfs </item>                        <item> lfs.attributes </item>
      <item> lfs.chdir </item>                  <item> lfs.currentdir </item>
      <item> lfs.dir </item>                    <item> lfs.lock </item>
      <item> lfs.mkdir </item>                  <item> lfs.rmdir </item>
      <item> lfs.touch </item>                  <item> lfs.unlock </item>

      <item> zip </item>                        <item> zip.open </item>
      <item> zip.openfile </item>               <item> files </item>
      <item> seek </item>                       <item> close </item>
      <item> lines </item>


    </list>
    <list name="attention">
      <item> TODO </item>
      <item> FIXME </item>
      <item> NOTE </item>
    </list>
    <list name="deprecated">
      <item> table.foreach </item> <item> table.foreachi </item>
      <item> foreach </item>       <item> foreachi </item>
    </list>

    <contexts>
      <context name="Normal"        attribute="Normal Text" lineEndContext="#stay">
        <IncludeRules context="##DoxygenLua" />
        <keyword      attribute="Error"  context="#stay" String="deprecated" />
        <DetectSpaces />
        <RegExpr      attribute="Comment"  context="Block Comment" beginRegion="block comment"  String="--\[(=*)\[" dynamic="true" />
        <Detect2Chars attribute="Comment"  context="Comment"       char="-" char1="-"/>
        <RegExpr      attribute="Strings"  context="String_block"  String="\[(=*)\[" dynamic="true" />
        <DetectChar   attribute="Strings"  context="String_single" char="'"/>
        <DetectChar   attribute="Strings"  context="String_double" char="&quot;"/>
        <keyword      attribute="BFunc"    context="#stay"         String="basefunc"/>

        <RegExpr      attribute="Keyword"  context="#stay" beginRegion="chunk" String="\bfunction\b" />
        <keyword      attribute="Keyword"  context="#stay" String="keywords" />
        <keyword      attribute="Keyword"  context="#stay"  String="pseudo-variables" />
        <RegExpr      attribute="Control"  context="#stay" endRegion="chunk"   beginRegion="chunk" String="\belse\b" />
        <RegExpr      attribute="Control"  context="#stay" endRegion="chunk"   beginRegion="chunk" String="\belseif\b" />
        <RegExpr      attribute="Control"  context="#stay" beginRegion="chunk" String="\bdo\b" />
        <RegExpr      attribute="Control"  context="#stay" beginRegion="chunk" String="\bif\b" />
        <RegExpr      attribute="Control"  context="#stay" endRegion="chunk"   String="\bend\b" />
        <keyword      attribute="Control"  context="#stay" String="control" />

        <DetectChar   attribute="Symbols"  context="#stay" beginRegion="table" char="{" />
        <DetectChar   attribute="Symbols"  context="#stay" endRegion="table"   char="}" />

        <RegExpr      attribute="Numbers"  context="#stay"  String="\b\d*\.?\d*(e|e\-|e\+)?\d+\b"/>
        <RegExpr      attribute="Numbers"  context="#stay"  String="\b-?0[xX][0-9a-fA-F]+\b"/>

        <RegExpr      attribute="Normal Text" context="#stay" String="\b[a-zA-Z_][a-zA-Z0-9_]*(?=\s*([({'&quot;]|\[\[))\b" />
        <RegExpr      attribute="Constant" context="#stay" String="\b[A-Z_][A-Z0-9_]*\b" />
        <RegExpr      attribute="Variable" context="#stay" String="\b[a-zA-Z_][a-zA-Z0-9_]*\b" />

        <Detect2Chars attribute="Error"    context="#stay" char="!" char1="="/>
        <Detect2Chars attribute="Error"    context="#stay" char="-" char1="="/>
        <Detect2Chars attribute="Error"    context="#stay" char="+" char1="="/>
        <Detect2Chars attribute="Error"    context="#stay" char="+" char1="+"/>
        <Detect2Chars attribute="Error"    context="#stay" char="." char1="="/>
        <AnyChar      attribute="Symbols"  context="#stay" String="[]().=~+-*/^&gt;&lt;#;" />
      </context>
      <context name="Comment"       attribute="Comment"     lineEndContext="#pop">
        <Detect2Chars attribute="Alerts"   context="#stay" char="-" char1="-" />
        <keyword      attribute="Alerts"   context="#stay" String="attention"/>
      </context>
      <context name="Block Comment" attribute="Comment"     lineEndContext="#stay" dynamic="true" >
        <RegExpr attribute="Comment"  context="#pop"  endRegion="block comment" String="\]%1\]" dynamic="true" />
        <Detect2Chars attribute="Alerts"   context="#stay" char="-" char1="-" />
        <keyword      attribute="Alerts"   context="#stay" String="attention" />
      </context>
      <context name="String_single" attribute="Strings"     lineEndContext="Error">
        <RegExpr      attribute="Symbols"  context="#stay" String="\\(a|b|f|n|r|t|v|\\|&quot;|\'|[|])" />
        <DetectChar   attribute="Strings"  context="#pop"  char="'"/>
      </context>
      <context name="String_double" attribute="Strings"     lineEndContext="Error">
        <RegExpr      attribute="Symbols"  context="#stay" String="\\[abfnrtv'&quot;\\\[\]]" />
        <DetectChar   attribute="Strings"  context="#pop"  char="&quot;"/>
      </context>
      <context name="String_block"  attribute="Strings"     lineEndContext="#stay" dynamic="true">
        <RegExpr      attribute="Symbols"  context="#stay" String="\\(a|b|f|n|r|t|v|\\|&quot;|\'|[|])" />
        <RegExpr      attribute="Strings"  context="#pop"  String="\]%1\]" dynamic="true" />
      </context>
      <context name="Error"         attribute="Error"       lineEndContext="#stay">
      </context>
    </contexts>
    <itemDatas>
      <itemData name="Alerts"          defStyleNum="dsAlert" />
      <itemData name="BFunc"           defStyleNum="dsFunction"/>
      <itemData name="Comment"         defStyleNum="dsComment"/>
      <itemData name="Constant"        defStyleNum="dsKeyword"/>
      <itemData name="Control"         defStyleNum="dsKeyword" color="#A1A100" selColor="#ffffff" bold="0" italic="0"/>
      <itemData name="Error"           defStyleNum="dsError"/>
      <itemData name="Keyword"         defStyleNum="dsKeyword"/>
      <itemData name="Normal Text"     defStyleNum="dsNormal"/>
      <itemData name="Numbers"         defStyleNum="dsDecVal"/>
      <itemData name="Strings"         defStyleNum="dsString"/>
      <itemData name="Symbols"         defStyleNum="dsOthers"/>
      <itemData name="Variable"        defStyleNum="dsKeyword" color="#5555FF" selColor="#ffffff" bold="0" italic="0" />
    </itemDatas>
  </highlighting>
  <general>
    <comments>
      <comment name="singleLine" start="--" />
      <comment name="multiLine" start="--[[" end="]]" />
    </comments>
    <keywords casesensitive="1" weakDeliminator="&#46;" additionalDeliminator="&quot;"/>
  </general>
</language>