<?xml version="1.0"?>

<!DOCTYPE MODE SYSTEM "xmode.dtd">

<!--
	Haskell mode by Stephen Blackheath
-->

<MODE>

	<PROPS>
		<PROPERTY NAME="commentStart" VALUE="{-" />
		<PROPERTY NAME="commentEnd" VALUE="-}" />
		<PROPERTY NAME="lineComment" VALUE="--" />
		<!-- apparently, this is required... -->
		<PROPERTY NAME="tabSize" VALUE="8" />
		<PROPERTY NAME="indentSize" VALUE="8" />
	</PROPS>

	<RULES IGNORE_CASE="FALSE" HIGHLIGHT_DIGITS="FALSE">
		<!-- Pragmas. -->
		<SPAN TYPE="COMMENT2">
			<BEGIN>{-#</BEGIN>
			<END>#-}</END>
		</SPAN>

		<SPAN TYPE="COMMENT1">
			<BEGIN>{-</BEGIN>
			<END>-}</END>
		</SPAN>

		<EOL_SPAN TYPE="COMMENT1">--</EOL_SPAN>

		<SPAN TYPE="LITERAL1" ESCAPE="\" NO_LINE_BREAK="TRUE">
			<BEGIN>"</BEGIN>
			<END>"</END>
		</SPAN>

		<SPAN TYPE="LITERAL2" NO_WORD_BREAK="TRUE">
			<BEGIN>'</BEGIN>
			<END>'</END>
		</SPAN>

                <!-- Reserved words. -->
                <SEQ_REGEXP TYPE="KEYWORD1">case(?![a-z_A-Z0-9'])</SEQ_REGEXP>
                <SEQ_REGEXP TYPE="KEYWORD1">class(?![a-z_A-Z0-9'])</SEQ_REGEXP>
                <SEQ_REGEXP TYPE="KEYWORD1">data(?![a-z_A-Z0-9'])</SEQ_REGEXP>
                <SEQ_REGEXP TYPE="KEYWORD1">default(?![a-z_A-Z0-9'])</SEQ_REGEXP>
                <SEQ_REGEXP TYPE="KEYWORD1">deriving(?![a-z_A-Z0-9'])</SEQ_REGEXP>
                <SEQ_REGEXP TYPE="KEYWORD1">do(?![a-z_A-Z0-9'])</SEQ_REGEXP>
                <SEQ_REGEXP TYPE="KEYWORD1">else(?![a-z_A-Z0-9'])</SEQ_REGEXP>
                <SEQ_REGEXP TYPE="KEYWORD1">if(?![a-z_A-Z0-9'])</SEQ_REGEXP>
                <SEQ_REGEXP TYPE="KEYWORD1">import(?![a-z_A-Z0-9'])</SEQ_REGEXP>
                <SEQ_REGEXP TYPE="KEYWORD1">in(?![a-z_A-Z0-9'])</SEQ_REGEXP>
                <SEQ_REGEXP TYPE="KEYWORD1">infix(?![a-z_A-Z0-9'])</SEQ_REGEXP>
                <SEQ_REGEXP TYPE="KEYWORD1">infixl(?![a-z_A-Z0-9'])</SEQ_REGEXP>
                <SEQ_REGEXP TYPE="KEYWORD1">infixr(?![a-z_A-Z0-9'])</SEQ_REGEXP>
                <SEQ_REGEXP TYPE="KEYWORD1">instance(?![a-z_A-Z0-9'])</SEQ_REGEXP>
                <SEQ_REGEXP TYPE="KEYWORD1">let(?![a-z_A-Z0-9'])</SEQ_REGEXP>
                <SEQ_REGEXP TYPE="KEYWORD1">module(?![a-z_A-Z0-9'])</SEQ_REGEXP>
                <SEQ_REGEXP TYPE="KEYWORD1">newtype(?![a-z_A-Z0-9'])</SEQ_REGEXP>
                <SEQ_REGEXP TYPE="KEYWORD1">of(?![a-z_A-Z0-9'])</SEQ_REGEXP>
                <SEQ_REGEXP TYPE="KEYWORD1">then(?![a-z_A-Z0-9'])</SEQ_REGEXP>
                <SEQ_REGEXP TYPE="KEYWORD1">type(?![a-z_A-Z0-9'])</SEQ_REGEXP>
                <SEQ_REGEXP TYPE="KEYWORD1">where(?![a-z_A-Z0-9'])</SEQ_REGEXP>
                <SEQ_REGEXP TYPE="KEYWORD1">_(?![a-z_A-Z0-9'])</SEQ_REGEXP>
                <SEQ_REGEXP TYPE="KEYWORD1">as(?![a-z_A-Z0-9'])</SEQ_REGEXP>
                <SEQ_REGEXP TYPE="KEYWORD1">qualified(?![a-z_A-Z0-9'])</SEQ_REGEXP>
                <SEQ_REGEXP TYPE="KEYWORD1">hiding(?![a-z_A-Z0-9'])</SEQ_REGEXP>
                <!-- Non-Haskell-98 keywords -->
                <SEQ_REGEXP TYPE="KEYWORD1">foreign(?![a-z_A-Z0-9'])</SEQ_REGEXP>
                <SEQ_REGEXP TYPE="KEYWORD1">family(?![a-z_A-Z0-9'])</SEQ_REGEXP>

                <SEQ_REGEXP TYPE="DIGIT">0[xXoO][0-9a-fA-F]+</SEQ_REGEXP>
                <SEQ_REGEXP TYPE="DIGIT">[0-9]+(\.[0-9]+)?([eE][+-]?[0-9]+)?</SEQ_REGEXP>
                
                <!-- Reserved operators -->
                <SEQ_REGEXP TYPE="KEYWORD4">\.\.(?![!#$%&amp;\*+\./&lt;=&gt;?@\\\^\|\-~:])</SEQ_REGEXP>
                <SEQ_REGEXP TYPE="KEYWORD4">:(?![!#$%&amp;\*+\./&lt;=&gt;?@\\\^\|\-~:])</SEQ_REGEXP>
                <SEQ_REGEXP TYPE="KEYWORD4">::(?![!#$%&amp;\*+\./&lt;=&gt;?@\\\^\|\-~:])</SEQ_REGEXP>
                <SEQ_REGEXP TYPE="KEYWORD4">=(?![!#$%&amp;\*+\./&lt;=&gt;?@\\\^\|\-~:])</SEQ_REGEXP>
                <SEQ TYPE="KEYWORD4">\</SEQ>
                <SEQ_REGEXP TYPE="KEYWORD4">\|(?![!#$%&amp;\*+\./&lt;=&gt;?@\\\^\|\-~:])</SEQ_REGEXP>
                <SEQ_REGEXP TYPE="KEYWORD4">&lt;-(?![!#$%&amp;\*+\./&lt;=&gt;?@\\\^\|\-~:])</SEQ_REGEXP>
                <SEQ_REGEXP TYPE="KEYWORD4">-&gt;(?![!#$%&amp;\*+\./&lt;=&gt;?@\\\^\|\-~:])</SEQ_REGEXP>
                <SEQ_REGEXP TYPE="KEYWORD4">@(?![!#$%&amp;\*+\./&lt;=&gt;?@\\\^\|\-~:])</SEQ_REGEXP>
                <SEQ_REGEXP TYPE="KEYWORD4">~(?![!#$%&amp;\*+\./&lt;=&gt;?@\\\^\|\-~:])</SEQ_REGEXP>
                <SEQ_REGEXP TYPE="KEYWORD4">=&gt;(?![!#$%&amp;\*+\./&lt;=&gt;?@\\\^\|\-~:])</SEQ_REGEXP>
                
                <!-- Normal operators, backquoted operators -->
                <SEQ_REGEXP TYPE="OPERATOR">([A-Z][a-z_A-Z0-9']*\.)*[!#$%&amp;\*+\./&lt;=&gt;?@\\\^\|\-~][!#$%&amp;\*+\./&lt;=&gt;?@\\\^\|\-~:]*</SEQ_REGEXP>
                <SEQ_REGEXP TYPE="OPERATOR">`([A-Z][a-z_A-Z0-9']*\.)*[a-z_][a-z_A-Z0-9']*`</SEQ_REGEXP>

                <!-- variable/function (qualified or not) -->
                <SEQ_REGEXP TYPE="NULL">([A-Z][a-z_A-Z0-9']*\.)*[a-z_][a-z_A-Z0-9']*</SEQ_REGEXP>
                <!-- contructor/type (qualified or not) -->
                <SEQ_REGEXP TYPE="KEYWORD2">[A-Z][a-z_A-Z0-9']*(\.[A-Z][a-z_A-Z0-9']*)*</SEQ_REGEXP>

                <!-- Operators in parentheses appear like functions, but this
                    doesn't match the special case of (..) used for imports -->
                <SEQ_REGEXP TYPE="NULL">\(\s*([A-Z][a-z_A-Z0-9']*\.)*[!#$%&amp;\*+\./&lt;=&gt;?@\\\^\|\-~]\s*\)</SEQ_REGEXP>
                <SEQ_REGEXP TYPE="NULL">\(\s*([A-Z][a-z_A-Z0-9']*\.)*[!#$%&amp;\*+\./&lt;=&gt;?@\\\^\|\-~][!#$%&amp;\*+/&lt;=&gt;?@\\\^\|\-~:][!#$%&amp;\*+\./&lt;=&gt;?@\\\^\|\-~:]*\s*\)</SEQ_REGEXP>
                <SEQ_REGEXP TYPE="NULL">\(\s*([A-Z][a-z_A-Z0-9']*\.)*[!#$%&amp;\*+/&lt;=&gt;?@\\\^\|\-~][!#$%&amp;\*+\./&lt;=&gt;?@\\\^\|\-~:][!#$%&amp;\*+\./&lt;=&gt;?@\\\^\|\-~:]*\s*\)</SEQ_REGEXP>
                <SEQ_REGEXP TYPE="NULL">\(\s*([A-Z][a-z_A-Z0-9']*\.)*[!#$%&amp;\*+\./&lt;=&gt;?@\\\^\|\-~][!#$%&amp;\*+\./&lt;=&gt;?@\\\^\|\-~:]{2,}\)</SEQ_REGEXP>

                <!-- Infix constructors -->
                <SEQ_REGEXP TYPE="KEYWORD2">([A-Z][a-z_A-Z0-9']*\.)*:[!#$%&amp;\*+\./&lt;=&gt;?@\\\^\|\-~:]*</SEQ_REGEXP>
                <!-- Infix constructors in parentheses -->
                <SEQ_REGEXP TYPE="KEYWORD2">\(\s*([A-Z][a-z_A-Z0-9']*\.)*:[!#$%&amp;\*+\./&lt;=&gt;?@\\\^\|\-~:]*\s*\)</SEQ_REGEXP>

                <!-- (, including the specific case of (..) but excluding all other cases
                    where it's an operator in parentheses -->
                <SEQ_REGEXP TYPE="KEYWORD3">\((?!\s*([!#$%&amp;\*+\./&lt;=&gt;?@\\\^\|\-~]\s*\)|[!#$%&amp;\*+\./&lt;=&gt;?@\\\^\|\-~][!#$%&amp;\*+/&lt;=&gt;?@\\\^\|\-~:][!#$%&amp;\*+\./&lt;=&gt;?@\\\^\|\-~:]*\s*\)|[!#$%&amp;\*+/&lt;=&gt;?@\\\^\|\-~][!#$%&amp;\*+\./&lt;=&gt;?@\\\^\|\-~:][!#$%&amp;\*+\./&lt;=&gt;?@\\\^\|\-~:]*\s*\)|[!#$%&amp;\*+\./&lt;=&gt;?@\\\^\|\-~][!#$%&amp;\*+\./&lt;=&gt;?@\\\^\|\-~:]{2,}\s*\)))</SEQ_REGEXP>
                <SEQ TYPE="KEYWORD3">)</SEQ>
                <SEQ TYPE="KEYWORD3">,</SEQ>
                <SEQ TYPE="KEYWORD3">[</SEQ>
                <SEQ TYPE="KEYWORD3">]</SEQ>
	</RULES>

</MODE>
