Commit 221d02bf authored by Shane's avatar Shane Committed by Christian Hergert

haskell.lang: multiple fixes

 * Qualified variables are highlighted as variables, not as types
 * Operators can be qualified
 * Unicode is now allowed in types, variables and operators
 * Operators prefixed with : will be highlighted as constructors
 * Support DataKinds (constructors prefixed with ')
 * Support for arrow notation (proc, -<)
 * OverloadedLabels-style #labels are highlighted
parent 5249f35d
......@@ -46,11 +46,9 @@
<definitions>
<!-- Spec: http://haskell.org/onlinereport/lexemes.html -->
<define-regex id="symbolchar">[!#$%&amp;*+./&gt;=&lt;?@:\\^|~-]</define-regex>
<context id="line-comment" style-ref="comment" end-at-line-end="true" class="comment" class-disabled="no-spell-check">
<start>(?&lt;!\%{symbolchar})--+(?!\%{symbolchar})</start>
<start>(?&lt;!\p{S})--+(?!\p{S})</start>
<include>
<context ref="def:in-comment"/>
<context ref="haddock:line-paragraph"/>
......@@ -74,24 +72,9 @@
<end>#-\}</end>
</context>
<context id="variable" style-ref="variable">
<match>\b[a-z_][0-9a-zA-Z_'#]*</match>
</context>
<context id="type-or-constructor" style-ref="type">
<match>\b[A-Z][0-9a-zA-Z._'#]*</match>
</context>
<!-- Must not extend parent context, or we end up matching
"\end{code}" as part of the Haskell context, but when in
literate haskell mode it should be terminating a code block. -->
<context id="symbol" style-ref="symbol" extend-parent="false">
<match>\%{symbolchar}+</match>
</context>
<context id="keysymbol" style-ref="keyword">
<prefix>(?&lt;!\%{symbolchar})</prefix>
<suffix>(?!\%{symbolchar})</suffix>
<context id="infix-keyword" style-ref="keyword">
<prefix>(?&lt;!\p{S})</prefix>
<suffix>(?!\p{S})</suffix>
<keyword>\.\.</keyword>
<keyword>::</keyword>
<keyword>=</keyword>
......@@ -99,11 +82,67 @@
<keyword>\</keyword>
<keyword>-&gt;</keyword>
<keyword>&lt;-</keyword>
<keyword>-&lt;</keyword>
<keyword>@</keyword>
<keyword>~</keyword>
<keyword>=&gt;</keyword>
</context>
<context id="prefix-keyword" style-ref="keyword">
<keyword>case</keyword>
<keyword>class</keyword>
<keyword>data</keyword>
<keyword>default</keyword>
<keyword>deriving</keyword>
<keyword>do</keyword>
<keyword>mdo</keyword>
<keyword>else</keyword>
<keyword>forall</keyword>
<keyword>foreign</keyword>
<keyword>hiding</keyword>
<keyword>if</keyword>
<keyword>import</keyword>
<keyword>in</keyword>
<keyword>infix</keyword>
<keyword>infixl</keyword>
<keyword>infixr</keyword>
<keyword>instance</keyword>
<keyword>let</keyword>
<keyword>module</keyword>
<keyword>newtype</keyword>
<keyword>of</keyword>
<keyword>proc</keyword>
<keyword>qualified</keyword>
<keyword>then</keyword>
<keyword>where</keyword>
<keyword>type</keyword>
</context>
<context id="label" style-ref="string">
<match>(?&lt;!\P{Z})#[\p{Ll}_][\p{N}\p{L}_']*</match>
</context>
<define-regex id="qualified">(?&lt;![\w.])(?:\p{Lu}[\p{N}\p{L}_'#]*\.)*</define-regex>
<context id="infix-constructor" style-ref="type">
<match>'?\%{qualified}(?&lt;!\p{S}):\p{S}+</match>
</context>
<!-- Must not extend parent context, or we end up matching
"\end{code}" as part of the Haskell context, but when in
literate haskell mode it should be terminating a code block. -->
<context id="infix-variable" style-ref="variable" extend-parent="false">
<match>\%{qualified}\p{S}+</match>
</context>
<context id="prefix-constructor" style-ref="type">
<match>(?:'(?=\p{Lu}[^']))?\%{qualified}\p{Lu}[\p{N}\p{L}_'#]*</match>
</context>
<context id="prefix-variable" style-ref="variable">
<match>\%{qualified}[\p{Ll}_][\p{N}\p{L}_'#]*</match>
</context>
<define-regex id="escaped-character" extended="true">
\\( # leading backslash
[abfnrtv\\"\'&amp;] | # escaped character
......@@ -165,45 +204,18 @@
<match>[0-9]+</match>
</context>
<context id="keyword" style-ref="keyword">
<keyword>case</keyword>
<keyword>class</keyword>
<keyword>data</keyword>
<keyword>default</keyword>
<keyword>deriving</keyword>
<keyword>do</keyword>
<keyword>mdo</keyword>
<keyword>else</keyword>
<keyword>forall</keyword>
<keyword>foreign</keyword>
<keyword>hiding</keyword>
<keyword>if</keyword>
<keyword>import</keyword>
<keyword>in</keyword>
<keyword>infix</keyword>
<keyword>infixl</keyword>
<keyword>infixr</keyword>
<keyword>instance</keyword>
<keyword>let</keyword>
<keyword>module</keyword>
<keyword>newtype</keyword>
<keyword>of</keyword>
<keyword>qualified</keyword>
<keyword>then</keyword>
<keyword>where</keyword>
<keyword>type</keyword>
</context>
<context id="body">
<include>
<context ref="line-comment"/>
<context ref="pragma"/>
<context ref="block-comment"/>
<context ref="keyword"/>
<context ref="variable"/>
<context ref="type-or-constructor"/>
<context ref="keysymbol"/>
<context ref="symbol"/>
<context ref="infix-keyword"/>
<context ref="prefix-keyword"/>
<context ref="label"/>
<context ref="infix-constructor"/>
<context ref="infix-variable"/>
<context ref="prefix-variable"/>
<context ref="prefix-constructor"/>
<context ref="string"/>
<context ref="char"/>
<context ref="float"/>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment