[gtksourceview/gnome-3-24] haskell.lang: multiple fixes



commit 221d02bfc36672802273f0c306b0bde0cac21e98
Author: Shane <me+code shane sh>
Date:   Thu Jun 7 22:01:56 2018 +0000

    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

 data/language-specs/haskell.lang | 124 +++++++++++++++++++++------------------
 1 file changed, 68 insertions(+), 56 deletions(-)
---
diff --git a/data/language-specs/haskell.lang b/data/language-specs/haskell.lang
index 3dffbc06..d15de72b 100644
--- a/data/language-specs/haskell.lang
+++ b/data/language-specs/haskell.lang
@@ -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"/>


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]