<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE language SYSTEM "language.dtd" [ <!ENTITY hexit "[0-9a-fA-F]"> ]>

<language name="quox" section="Sources" extensions="*.quox"
          version="1" kateversion="5.53">
  <highlighting>
    <list name="load"> <item>load</item> </list>

    <list name="types">
      <item>String</item>
      <item>IOState</item>
      <item>ℕ</item> <item>Nat</item>
      <item>Eq</item>
      <item>Type</item>
    </list>

    <list name="exprs">
      <item>fst</item> <item>snd</item>
      <item>coe</item> <item>comp</item>
      <item>λ</item> <item>fun</item>
      <item>δ</item> <item>dfun</item>
      <item>case</item> <item>return</item> <item>of</item>
      <item>zero</item> <item>succ</item>
      <item>let</item> <item>in</item>
    </list>

    <list name="attrs">
      <item>fail</item>
      <item>main</item>
      <item>compile-scheme</item>
    </list>

    <contexts>
      <context attribute="default" lineEndContext="#stay" name="Default">
        <keyword attribute="load" context="#stay" String="load" />

        <RegExpr attribute="defs" context="qty_suffix"
          String="\b(def|postulate)(?=([01#]|ω)?\b)" />

        <keyword attribute="types" context="#stay" String="types" />
        <DetectChar attribute="types" context="#stay" char="★" />
        <DetectChar attribute="types" context="#stay" char="×" />
        <Detect2Chars attribute="types" context="#stay" char="*" char1="*" />
        <DetectChar attribute="types" context="#stay" char="→" />
        <Detect2Chars attribute="types" context="#stay" char="-" char1=">" />
        <DetectChar attribute="types" context="#stay" char="≡" />
        <Detect2Chars attribute="types" context="#stay" char="=" char1="=" />

        <keyword attribute="exprs" context="#stay" String="exprs" />
        <DetectChar attribute="exprs" context="#stay" char="∷" />
        <Detect2Chars attribute="exprs" context="#stay" char=":" char1=":" />
        <DetectChar attribute="exprs" context="#stay" char="," />
        <DetectChar attribute="exprs" context="#stay" char="⇒" />
        <Detect2Chars attribute="exprs" context="#stay" char="=" char1=">" />

        <RegExpr attribute="exprs" context="qty_suffix"
          String="\b(case|let)(?=([01#]|ω)?\b)" />

        <RegExpr attribute="hex_nat" context="#stay"
          String="\b0[xX]&hexit;((&hexit;|_)*&hexit;)?\b(?!\.)" />

        <RegExpr attribute="dec_nat" context="#stay"
          String="\b\d((\d|_)*\d)?\b(?!\.)" />

        <DetectChar attribute="string" context="String" char="&quot;" />

        <Detect2Chars attribute="tag" context="Tag"
          char="'" char1="&quot;" />
        <RegExpr attribute="tag" context="#stay"
          String="(?&lt;!\w|-|')'(\w|-|')+" />

        <RegExpr attribute="qty" context="#stay"
          String="(\b[01]|#|ω)\.(?!\d)" />

        <DetectChar attribute="punc" context="#stay" char="=" />
        <DetectChar attribute="punc" context="#stay" char="@" />

        <Detect2Chars attribute="attr" context="attr" char="#" char1="[" />

        <Detect2Chars attribute="comment" context="comment_s"
          char="-" char1="-" />
        <Detect2Chars attribute="comment" context="comment_m"
          char="{" char1="-" />

        <RegExpr attribute="displace" context="#stay"
          String="[⁰¹²³⁴⁵⁶⁷⁸⁹]|\^\d+" />
      </context>

      <context attribute="qty" lineEndContext="#pop" name="qty_suffix">
        <RegExpr attribute="qty" context="#stay" String="([01#]|ω)?\b" />
        <RegExpr attribute="normal" context="#pop" String="\s|$" />
      </context>

      <context attribute="string" lineEndContext="#stay" name="String">
        <Detect2Chars attribute="string_esc" context="#stay"
                      char="\" char1="&quot;" />
        <Detect2Chars attribute="string_esc" context="#stay"
                      char="\" char1="\" />
        <Detect2Chars attribute="string_esc" context="#stay"
                      char="\" char1="n" />
        <Detect2Chars attribute="string_esc" context="#stay"
                      char="\" char1="t" />

        <RegExpr attribute="string_esc" context="#stay"
          String="\\x&hexit;+;" />

        <DetectChar attribute="string" context="#pop" char="&quot;" />
      </context>

      <context attribute="tag" lineEndContext="#stay" name="Tag">
        <Detect2Chars attribute="tag_esc" context="#stay"
                      char="\" char1="&quot;" />
        <Detect2Chars attribute="tag_esc" context="#stay"
                      char="\" char1="\" />
        <Detect2Chars attribute="tag_esc" context="#stay"
                      char="\" char1="n" />
        <Detect2Chars attribute="tag_esc" context="#stay"
                      char="\" char1="t" />

        <RegExpr attribute="tag_esc" context="#stay"
          String="\\x&hexit;+;" />

        <DetectChar attribute="tag" context="#pop" char="&quot;" />
      </context>

      <context attribute="attr" lineEndContext="#stay" name="attr">
        <DetectChar attribute="string" context="String" char="&quot;" />
        <DetectChar attribute="attr" context="attr" char="[" />
        <DetectChar attribute="attr" context="#pop" char="]" />
        <keyword attribute="attr_name" context="#stay" String="attrs" />
      </context>

      <context attribute="comment" lineEndContext="#pop" name="comment_s" />

      <context attribute="comment" lineEndContext="#stay" name="comment_m">
        <Detect2Chars attribute="comment" context="comment_m"
          char="{" char1="-" />
        <Detect2Chars attribute="comment" context="#pop"
          char="-" char1="}" />
      </context>
    </contexts>

    <itemDatas>
      <itemData name="default" defStyleNum="dsNormal" />
      <itemData name="load" defStyleNum="dsPreprocessor" />
      <itemData name="defs" defStyleNum="dsFunction" />
      <itemData name="types" defStyleNum="dsDataType" />
      <itemData name="exprs" defStyleNum="dsControlFlow" />
      <itemData name="dec_nat" defStyleNum="dsDecVal" />
      <itemData name="hex_nat" defStyleNum="dsBaseN" />
      <itemData name="string" defStyleNum="dsString" />
      <itemData name="string_esc" defStyleNum="dsSpecialChar" />
      <itemData name="tag" defStyleNum="dsSpecialString" />
      <itemData name="tag_esc" defStyleNum="dsSpecialChar" />
      <itemData name="qty" defStyleNum="dsBuiltIn" />
      <itemData name="punc" defStyleNum="dsNormal" />
      <itemData name="displace" defStyleNum="dsBuiltIn" />
      <itemData name="attr" defStyleNum="dsNormal" />
      <itemData name="attr_name" defStyleNum="dsAttribute" />
      <itemData name="comment" defStyleNum="dsComment" />
    </itemDatas>
  </highlighting>

  <general>
    <keywords casesensitive="true" weakDeliminator="-'" />
  </general>
</language>