<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE language SYSTEM "language.dtd">
<!--
  ====================================================================
  KAlgebra syntax highlighting file for the KDE editors Kate and Kwrite
  ====================================================================
      based on KAlgebra 0.1.0

  Change log:
  22-Apr-10  Initial version

  Author: Adria Arrufat
  -->


<language name="KAlgebra" version="1.0" kateversion="3.4" section="Scientific" extensions="*.kal" mimetype="text/KAlgebra Script" casesensitive="1" license="GPL" author="Adria Arrufat">

  <highlighting>

    <!-- Reserved keywords in KAlgebra -->
    <list name="keywords">
      <item> piecewise </item>
      <item> list </item>
      <item> vector </item>
      <item> ? </item>
      </list>

    <list name="builtin">
      <item> e </item>
      <item> euler </item>
      <item> false </item>
      <item> pi </item>
      <item> true </item>
      <item> ans </item>
    </list>

    <list name="operations">
      <item> @ </item>
      <item> abs </item>
      <item> and </item>
      <item> approx </item>
      <item> arccos </item>
      <item> arccosh </item>
      <item> arccot </item>
      <item> arcsc </item>
      <item> arcsch </item>
      <item> arcsec </item>
      <item> arcsech </item>
      <item> arcsin </item>
      <item> arcsinh </item>
      <item> arctan </item>
      <item> arctanh </item>
      <item> card </item>
      <item> ceiling </item>
      <item> cos </item>
      <item> cosh </item>
      <item> cot </item>
      <item> coth </item>
      <item> csc </item>
      <item> csch </item>
      <item> diff </item>
      <item> divide </item>
      <item> eq </item>
      <item> exp </item>
      <item> factorial </item>
      <item> factorof </item>
      <item> floor </item>
      <item> fmod </item>
      <item> gcd </item>
      <item> geq </item>
      <item> gt </item>
      <item> implies </item>
      <item> lcm </item>
      <item> leq </item>
      <item> ln </item>
      <item> log </item>
      <item> lt </item>
      <item> max </item>
      <item> min </item>
      <item> minus </item>
      <item> neq </item>
      <item> not </item>
      <item> or </item>
      <item> plus </item>
      <item> power </item>
      <item> product </item>
      <item> quotient </item>
      <item> rem </item>
      <item> root </item>
      <item> scalarprod </item>
      <item> sec </item>
      <item> sech </item>
      <item> selector </item>
      <item> sin </item>
      <item> sinh </item>
      <item> sum </item>em>
      <item> tan </item>
      <item> tanh </item>
      <item> times </item>
      <item> union </item>
      <item> xor </item>
    </list>


    <contexts>

      <context name="_normal" attribute="Normal Text" lineEndContext="#stay">

        <!-- Look-ahead for adjoint ' after variable, number literal, closing braces and .' -->
        <RegExpr context="_adjoint" attribute="Variable" String="[a-zA-Z]\w*(?=')" />
        <RegExpr context="_adjoint" attribute="Number" String="(\d+(\.\d+)?|\.\d+)([eE][+-]?\d+)?[ij]?(?=')" />
        <RegExpr context="_adjoint" attribute="Delimiter" String="[\)\]}](?=')" />
        <RegExpr context="_adjoint" attribute="Operator" String="\.'(?=')" />

        <!-- If ' is not the adjoint operator, it starts a string or an unterminated string;
        strings can be also with ", and accept the respective delimiter in them either
        by doubling it ('', "") or by escaping it (\', \") -->

        <!-- Handling of keywords, comments, functions, identifiers, numbers and braces -->
        <keyword context="#stay" attribute="Keyword" String="keywords" />
        <keyword context="#stay" attribute="Operations" String="operations" />
        <keyword context="#stay" attribute="Builtin" String="builtin"/>
        <RegExpr context="#stay" attribute="Variable" String="[a-zA-Z]\w*" />
        <RegExpr context="#stay" attribute="Number" String="(\d+(\.\d+)?|\.\d+)([eE][+-]?\d+)?[ij]?" />
        <AnyChar context="#stay" attribute="Delimiter" String="(){}"/>

        <!-- operators -->
        <StringDetect context="#stay" attribute="Operator" String="+"/>
        <StringDetect context="#stay" attribute="Operator" String="-"/>
        <StringDetect context="#stay" attribute="Operator" String="*"/>
        <StringDetect context="#stay" attribute="Operator" String="/"/>
        <StringDetect context="#stay" attribute="Operator" String="^"/>
        <StringDetect context="#stay" attribute="Operator" String=","/>
        <StringDetect context="#stay" attribute="Operator" String=":"/>
        <StringDetect context="#stay" attribute="Operator" String="&lt;"/>
        <StringDetect context="#stay" attribute="Operator" String="&gt;"/>
        <StringDetect context="#stay" attribute="Operator" String="="/>

      </context>

   <!--Context entered after encountering an ' adjoint operator -->
      <context name="_adjoint" attribute="Operator" lineEndContext="#pop">
        <RegExpr context="#pop" attribute="Operator" String="'+" />
      </context>



    </contexts>

    <itemDatas>
      <itemData name="Normal Text" defStyleNum="dsNormal"/>
      <itemData name="Variable" defStyleNum="dsNormal" color="#AC0008" />
      <itemData name="Operator" defStyleNum="dsNormal" bold="1"/>
      <itemData name="Number" defStyleNum="dsFloat" color="#2b74c7"/>
      <itemData name="Delimiter" defStyleNum="dsNormal" bold="1"/>
      <itemData name="String" defStyleNum="dsString" color="#b20000"/>
      <itemData name="Keyword"  defStyleNum="dsNormal" color="#AC0008"/>
      <itemData name="Comment" defStyleNum="dsComment" color="#009900"/>
      <itemData name="Operations" defStyleNum="dsFunction" color="#AC0008" selColor="#00ff00"/>
      <itemData name="Builtin" defStyleNum="dsBaseN" color="#b28c00" />
      </itemDatas>

  </highlighting>

  <general>
   <keywords casesensitive="1"/>
  </general>

</language>
<!-- kate: space-indent on; indent-width 2; replace-tabs on; -->
