<?xml version="1.0" encoding="UTF-8"?>
<!--
  ====================================================================
  Julia syntax highlighting file for the KDE editors Kate and Kwrite
  ====================================================================

  This was adapted from the Matlab syntax highlighting file

  Most of this XML file is straightforward. Only the character ' (&apos;)
  needs nontrivial treatment, since it is both a postfix operator indicating
  complex conjugate transpose (adjoint) and a character delimiter. It is an
  adjoint operator in the following positions:
  1) immediately after an identifier (variable, function, but not keyword)
  2) immediately after a number literal
  3) immediately after the closing parenthesis ), ] and }
  4) immediately after a simple transpose operator .'
  5) immediately after another adjoint operator '
  Otherwise it is a character delimiter.

  This is implemented using look-ahead regexps. If one of the entities in the
  above cases 1-4 (identifier, number literal, ...) matches and look-ahead
  shows that it is followed by a ', the entity is highlighted and control is
  passed to the special context _adjoint, whose sole purpose is to correctly
  highlight a series of ' (thus covering case 5 as well). _adjoint immediately
  returns to the default context _normal.

  Author: Timothy E. Holy, Washington University in St. Louis
-->

<!DOCTYPE language SYSTEM "language.dtd">

<language name="Julia" section="Sources" version="0.3" kateversion="2.4" extensions="*.jl" casesensitive="1" priority="5" license="MIT">

  <highlighting>
    <list name="block_begin">
      <item> begin </item>
      <item> do </item>
      <item> for </item>
      <item> function </item>
      <item> if </item>
      <item> immutable </item>
      <item> let </item>
      <item> quote </item>
      <item> try </item>
      <item> type </item>
      <item> while </item>
    </list>
    <list name="block_eb">
      <item> catch </item>
      <item> finally </item>
      <item> else </item>
      <item> elseif </item>
    </list>
    <list name="block_end">
      <item> end </item>
    </list>
    <list name="keywords">
      <item> abstract </item>
      <item> bitstype </item>
      <item> break </item>
      <item> ccall </item>
      <item> const </item>
      <item> continue </item>
      <item> export </item>
      <item> global </item>
      <item> import </item>
      <item> importall </item>
      <item> in </item>
      <item> local </item>
      <item> macro </item>
      <item> module </item>
      <item> baremodule </item>
      <item> return </item>
      <item> typealias </item>
      <item> using </item>
    </list>
    <list name="types">
      <item> AbstractArray </item>
      <item> AbstractMatrix </item>
      <item> AbstractSparseMatrix </item>
      <item> AbstractVector </item>
      <item> Any </item>
      <item> Array </item>
      <item> ASCIIString </item>
      <item> Associative </item>
      <item> AsyncStream </item>
      <item> Bidiagonal </item>
      <item> BitArray </item>
      <item> BigFloat </item>
      <item> BigInt </item>
      <item> BitMatrix </item>
      <item> BitVector </item>
      <item> Bool </item>
      <item> ByteString </item>
      <item> Char </item>
      <item> CharString </item>
      <item> Cholesky </item>
      <item> CholeskyPivoted </item>
      <item> Cmd </item>
      <item> Colon </item>
      <item> Complex </item>
      <item> Complex64 </item>
      <item> Complex128 </item>
      <item> ComplexPair </item>
      <item> DArray </item>
      <item> Diagonal </item>
      <item> Dict </item>
      <item> Dims </item>
      <item> EachLine </item>
      <item> Eigen </item>
      <item> Enumerate </item>
      <item> EnvHash </item>
      <item> Exception </item>
      <item> Expr </item>
      <item> FileMonitor </item>
      <item> FileOffset </item>
      <item> Filter </item>
      <item> FloatingPoint </item>
      <item> Float16 </item>
      <item> Float32 </item>
      <item> Float64 </item>
      <item> Function </item>
      <item> GeneralizedSchur </item>
      <item> GeneralizedSVD </item>
      <item> HeapSort </item>
      <item> Hermitian </item>
      <item> Hessenberg </item>
      <item> Int </item>
      <item> Int8 </item>
      <item> Int16 </item>
      <item> Int32 </item>
      <item> Int64 </item>
      <item> Int128 </item>
      <item> Integer </item>
      <item> IntSet </item>
      <item> ImaginaryUnit </item>
      <item> IO </item>
      <item> IOBuffer </item>
      <item> IOStream </item>
      <item> LocalProcess </item>
      <item> LU </item>
      <item> MathConst </item>
      <item> Matrix </item>
      <item> Nothing </item>
      <item> None </item>
      <item> NTuple </item>
      <item> Number </item>
      <item> ObjectIdDict </item>
      <item> PollingFileWatcher </item>
      <item> QR </item>
      <item> QRPivoted </item>
      <item> OrdinalRange </item>
      <item> PipeBuffer </item>
      <item> ProcessGroup </item>
      <item> Ptr </item>
      <item> Range </item>
      <item> Range1 </item>
      <item> RangeIndex </item>
      <item> Ranges </item>
      <item> Rational </item>
      <item> Real </item>
      <item> Regex </item>
      <item> RegexMatch </item>
      <item> RegexMatchIterator </item>
      <item> RemoteRef </item>
      <item> RepString </item>
      <item> RevString </item>
      <item> Reverse </item>
      <item> RopeString </item>
      <item> Schur </item>
      <item> Set </item>
      <item> Signed </item>
      <item> SparseMatrixCSC </item>
      <item> SpawnNullStream </item>
      <item> StridedArray </item>
      <item> StridedMatrix </item>
      <item> StridedVecOrMat </item>
      <item> StridedVector </item>
      <item> String </item>
      <item> SubArray </item>
      <item> SubDArray </item>
      <item> SubOrDArray </item>
      <item> SubString </item>
      <item> SVD </item>
      <item> Symbol </item>
      <item> Symmetric </item>
      <item> SymTridiagonal </item>
      <item> Task </item>
      <item> TcpSocket </item>
      <item> TimeoutAsyncWork </item>
      <item> TmStruct </item>
      <item> Triangular </item>
      <item> Tridiagonal </item>
      <item> Tuple </item>
      <item> Type </item>
      <item> Uint </item>
      <item> Uint8 </item>
      <item> Uint16 </item>
      <item> Uint32 </item>
      <item> Uint64 </item>
      <item> Uint128 </item>
      <item> Union </item>
      <item> Unsigned </item>
      <item> UTF8String </item>
      <item> UVError </item>
      <item> VecOrMat </item>
      <item> Vector </item>
      <item> VersionNumber </item>
      <item> Void </item>
      <item> WeakKeyDict </item>
      <item> WeakRef </item>
      <item> Woodbury </item>
      <item> Zip </item>
      <item> AbstractRNG </item>
      <item> MersenneTwister </item>
      <item> Condition </item>
      <item> IPv4 </item>
      <item> IPv6 </item>
      <item> ClusterManager </item>
      <item> RawFD </item>
      <item> WindowsRawSocket </item>
      <item> PipeBuffer </item>
      <item> UV_READABLE </item>
      <item> UV_WRITEABLE </item>

      <item> Stat </item>
      <item> Factorization </item>
      <item> BunchKaufman </item>
      <item> CholeskyDense </item>
      <item> CholeskyPivotedDense </item>
      <item> LUDense </item>
      <item> LUTridiagonal </item>
      <item> LDLTTridiagonal </item>
      <item> QRDense </item>
      <item> QRPivotedDense </item>
      <item> SVDDense </item>
      <item> GSVDDense </item>
      <item> InsertionSort </item>
      <item> QuickSort </item>
      <item> MergeSort </item>
      <item> TimSort </item>

      <item> Cchar </item>
      <item> Cuchar </item>
      <item> Cshort </item>
      <item> Cushort </item>
      <item> Cint </item>
      <item> Cuint </item>
      <item> Clong </item>
      <item> Culong </item>
      <item> Cptrdiff_t </item>
      <item> Csize_t </item>
      <item> Cssize_t </item>
      <item> Clonglong </item>
      <item> Culonglong </item>
      <item> Coff_t </item>
      <item> Cfloat </item>
      <item> Cdouble </item>
      <item> Cwchar_t </item>

      <item> ArgumentError </item>
      <item> ProcessExitedException </item>
      <item> DisconnectException </item>
      <item> EOFError </item>
      <item> ErrorException </item>
      <item> KeyError </item>
      <item> LoadError </item>
      <item> MethodError </item>
      <item> ParseError </item>
      <item> SystemError </item>
      <item> TypeError </item>

      <item> Collections </item>
      <item> FFTW </item>
      <item> Order </item>
      <item> Sys </item>
      <item> Test </item>
      <item> Pkg </item>
      <item> Pkg2 </item>
      <item> Operators </item>
      <item> Meta </item>
      <item> Graphics </item>
      <item> Profile </item>
    </list>
    <list name="constants">
      <item> ARGS </item>
      <item> C_NULL </item>
      <item> CPU_CORES </item>
      <item> DL_LOAD_PATH </item>
      <item> OS_NAME </item>
      <item> ENDIAN_BOM </item>
      <item> ENV </item>
      <item> Inf </item>
      <item> Inf32 </item>
      <item> LOAD_PATH </item>
      <item> MS_ASYNC </item>
      <item> MS_INVALIDATE </item>
      <item> MS_SYNC </item>
      <item> NaN </item>
      <item> NaN32 </item>
      <item> RTLD_LOCAL </item>
      <item> RTLD_GLOBAL </item>
      <item> RTLD_LAZY </item>
      <item> RTLD_NOW </item>
      <item> RTLD_NOLOAD </item>
      <item> RTLD_NODELETE </item>
      <item> RTLD_DEEPBIND </item>
      <item> RTLD_FIRST </item>
      <item> STDERR </item>
      <item> STDIN </item>
      <item> STDOUT </item>
      <item> VERSION </item>
      <item> WORD_SIZE </item>
    </list>
    <list name="math-constants">
      <item> im </item>
      <item> π </item>
      <item> pi </item>
      <item> e </item>
      <item> eu </item>
      <item> γ </item>
      <item> eulergamma </item>
      <item> catalan </item>
      <item> φ </item>
      <item> golden </item>
    </list>
    <contexts>

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

        <DetectSpaces />

        <!-- Blocks -->
        <keyword context="#stay" attribute="Keyword" String="block_begin" beginRegion="block" />
        <keyword context="#stay" attribute="Keyword" String="block_eb" endRegion="block" beginRegion="block" />
        <keyword context="#stay" attribute="Keyword" String="block_end" endRegion="block" />
        <StringDetect String="#BEGIN" context="region_marker" attribute="FoldingComment" beginRegion="user_region" />
        <StringDetect String="#END" context="region_marker" attribute="FoldingComment" endRegion="user_region" />

        <!-- Keywords, types, and comments -->
        <keyword context="#stay" attribute="Keyword" String="keywords" />
        <keyword context="#stay" attribute="Data Type" String="types" />
        <keyword context="#stay" attribute="Constant" String="constants" />
        <keyword context="#stay" attribute="Math Constant" String="math-constants" />
        <Detect2Chars char="#" char1="=" context="multiline-comment" attribute="Comment"/>
        <DetectChar char="#" context="1-comment" attribute="Comment"/>

        <!-- Lists and arrays -->
        <!-- <DetectChar char="(" context="nested" beginRegion="nested" attribute="Delimiter" />
        <DetectChar char="[" context="squared" beginRegion="squared" attribute="Delimiter" />
        <DetectChar char="{" context="curly" beginRegion="curly" attribute="Delimiter" /> -->

        <!-- Strings -->
        <DetectChar attribute="String" context="String" char="&quot;"/>

        <!-- Multi-character operators -->
        <StringDetect context="#stay" attribute="Operator" String="..."/>
        <StringDetect context="#stay" attribute="Operator" String="::"/>
        <StringDetect context="#stay" attribute="Operator" String="&gt;&gt;&gt;"/>
        <StringDetect context="#stay" attribute="Operator" String="&gt;&gt;"/>
        <StringDetect context="#stay" attribute="Operator" String="&lt;&lt;"/>
        <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="&amp;&amp;"/>
        <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="*="/>
        <StringDetect context="#stay" attribute="Operator" String="/="/>
        <StringDetect context="#stay" attribute="Operator" String="&amp;="/>
        <StringDetect context="#stay" attribute="Operator" String="|="/>
        <StringDetect context="#stay" attribute="Operator" String="$="/>
        <StringDetect context="#stay" attribute="Operator" String="&gt;&gt;&gt;="/>
        <StringDetect context="#stay" attribute="Operator" String="&gt;&gt;="/>
        <StringDetect context="#stay" attribute="Operator" String="&lt;&lt;="/>

        <!-- 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="Float" String="(\d+(\.\d+)?|\.\d+)([eE][+-]?\d+)?(im)?(?=')" />
        <RegExpr context="_adjoint" attribute="Delimiter" String="[\)\]}](?=')" />
        <RegExpr context="_adjoint" attribute="Operator" String="\.'(?=')" />

        <!-- If ' is not the adjoint operator, it starts a character or an unterminated char -->
        <RegExpr context="#stay" attribute="Char" String="'[^']*(''[^']*)*'(?=[^']|$)" />
        <RegExpr context="#stay" attribute="Incomplete Char" String="'[^']*(''[^']*)*" />

        <!-- Identifiers, numbers and braces -->
        <!-- We can't use HlCHex, Int, and Float because we need to allow the "im" at the end of complex numbers -->
        <DetectIdentifier context="#stay" attribute="Variable" />
        <RegExpr context="#stay" attribute="Hex" String="0x[0-9a-fA-F]+(im)?" />
        <RegExpr context="#stay" attribute="Float" String="(\d+(\.\d+)?|\.\d+)([eE][+-]?\d+)?(im)?" />
        <AnyChar context="#stay" attribute="Delimiter" String="()[]{}"/>

        <!-- Single-character operators -->
        <AnyChar context="#stay" attribute="Operator" String="*+-/\&amp;|&lt;&gt;~$!^=,;:@"/>

      </context>

      <!-- Context for user block (#BEGIN...#END) -->
      <context name="region_marker" lineEndContext="#pop" attribute="FoldingComment" >
        <IncludeRules context="1-comment" />
      </context>

      <!-- Contexts entered after beginning a list or array -->
      <context name="nested" attribute="Normal text" lineEndContext="#stay">
        <DetectChar char=")" context="#pop" endRegion="nested" attribute="Delimiter" />
      </context>
      <context name="squared" attribute="Normal text" lineEndContext="#stay">
        <DetectChar char="]" context="#pop" endRegion="squared" attribute="Delimiter" />
      </context>
      <context name="curly" attribute="Normal text" lineEndContext="#stay">
        <DetectChar char="}" context="#pop" endRegion="curly" attribute="Delimiter" />
      </context>

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

      <!-- Context entered after encountering an " (string) -->
      <context attribute="String" lineEndContext="#pop" name="String">
        <DetectSpaces />
        <DetectIdentifier />
        <LineContinue attribute="String" context="#stay"/>
        <HlCStringChar attribute="String Char" context="#stay"/>
        <DetectChar attribute="String" context="#pop" char="&quot;"/>
      </context>

      <!-- 1-line comment: #pop@EOL  -->
      <context name="1-comment" lineEndContext="#pop" attribute="Comment">
        <IncludeRules context="##Alerts" />
        <DetectSpaces />
        <DetectIdentifier />
      </context>

      <!-- multi-line comment: -->
      <context name="multiline-comment" lineEndContext="#stay" attribute="Comment">
        <Detect2Chars attribute="Comment" context="#pop" char="=" char1="#" endRegion="Comment"/>
        <IncludeRules context="##Alerts" />
        <DetectSpaces />
        <DetectIdentifier />
      </context>

    </contexts>

    <itemDatas>
      <itemData name="Normal Text" defStyleNum="dsNormal" />
      <itemData name="Variable" defStyleNum="dsNormal" />
      <itemData name="Operator" defStyleNum="dsNormal"/>
      <itemData name="Math Constant" defStyleNum="dsDecVal" />
      <itemData name="Decimal" defStyleNum="dsDecVal" />
      <itemData name="Float" defStyleNum="dsFloat" />
      <itemData name="Hex" defStyleNum="dsBaseN" />
      <itemData name="Delimiter" defStyleNum="dsNormal" />
      <itemData name="String" defStyleNum="dsString"/>
      <itemData name="Char" defStyleNum="dsChar"/>
      <itemData name="Incomplete Char" defStyleNum="dsChar"/>
      <itemData name="System" defStyleNum="dsBaseN"/>
      <itemData name="Keyword" defStyleNum="dsKeyword"/>
      <itemData name="Constant" defStyleNum="dsKeyword"/>
      <itemData name="Data Type" defStyleNum="dsDataType"/>
      <itemData name="Comment" defStyleNum="dsComment"/>
      <itemData name="FoldingComment" defStyleNum="dsComment" />
    </itemDatas>

  </highlighting>

  <general>
    <comments>
      <comment name="singleLine" start="#" />
      <comment name="multiLine" start="#=" end="=#" />
    </comments>
    <keywords casesensitive="1" weakDeliminator=""/>
  </general>

</language>

<!-- It's recommended to put the following line in the Variables field under Settings->Configure Kate->Open/Save->Modes&Filetypes -->
<!-- kate: space-indent on; indent-width 4; mixed-indent off; indent-mode cstyle; -->
