@@ -217,24 +217,15 @@ Regexp match data 0 points to the chars."
217
217
(varid " \\ b[[:lower:]_][[:alnum:]'_]*\\ b" )
218
218
; ; We allow ' preceding conids because of DataKinds/PolyKinds
219
219
(conid " \\ b'?[[:upper:]][[:alnum:]'_]*\\ b" )
220
- (modid (concat " \\ b" conid " \\ (\\ ." conid " \\ )*\\ b" ))
221
- (qvarid (concat modid " \\ ." varid))
222
- (qconid (concat modid " \\ ." conid))
223
220
(sym " \\ s.+" )
224
-
225
- ; ; Reserved identifiers
226
- (reservedid
227
- (concat " \\ <"
228
- ; ; `as' , `hiding' , and `qualified' are part of the import
229
- ; ; spec syntax, but they are not reserved.
230
- ; ; `_' can go in here since it has temporary word syntax.
231
- ; ; (regexp-opt
232
- ; ; '("case" "class" "data" "default" "deriving" "do"
233
- ; ; "else" "if" "import" "in" "infix" "infixl"
234
- ; ; "infixr" "instance" "let" "module" "newtype" "of"
235
- ; ; "then" "type" "where" "_") t)
236
- " \\ (_\\ |c\\ (ase\\ |lass\\ )\\ |d\\ (ata\\ |e\\ (fault\\ |riving\\ )\\ |o\\ )\\ |else\\ |i\\ (mport\\ |n\\ (fix[lr]?\\ |stance\\ )\\ |[fn]\\ )\\ |let\\ |module\\ |mdo\\ |newtype\\ |of\\ |rec\\ |proc\\ |t\\ (hen\\ |ype\\ )\\ |where\\ )"
237
- " \\ >" ))
221
+ (reservedids
222
+ ; ; `as' , `hiding' , and `qualified' are part of the import
223
+ ; ; spec syntax, but they are not reserved.
224
+ ; ; `_' can go in here since it has temporary word syntax.
225
+ '(" case" " class" " data" " default" " deriving" " do"
226
+ " else" " if" " import" " in" " infix" " infixl"
227
+ " infixr" " instance" " let" " module" " mdo" " newtype" " of"
228
+ " rec" " proc" " then" " type" " where" " _" ))
238
229
239
230
; ; Top-level declarations
240
231
(topdecl-var
@@ -263,8 +254,6 @@ Regexp match data 0 points to the chars."
263
254
264
255
,@(haskell-font-lock-symbols-keywords)
265
256
266
- (, reservedid 1 'haskell-keyword-face )
267
-
268
257
; ; Special case for `as' , `hiding' , `safe' and `qualified' , which are
269
258
; ; keywords in import statements but are not otherwise reserved.
270
259
(" \\ <import[ \t ]+\\ (?:\\ (safe\\ >\\ )[ \t ]*\\ )?\\ (?:\\ (qualified\\ >\\ )[ \t ]*\\ )?\\ (?:\" [^\" ]*\" [\t ]*\\ )?[^ \t\n ()]+[ \t ]*\\ (?:\\ (\\ <as\\ >\\ )[ \t ]*[^ \t\n ()]+[ \t ]*\\ )?\\ (\\ <hiding\\ >\\ )?"
@@ -302,9 +291,12 @@ Regexp match data 0 points to the chars."
302
291
303
292
; ; Toplevel Declarations.
304
293
; ; Place them *before* generic id-and-op highlighting.
305
- (, topdecl-var (1 'haskell-definition-face ))
306
- (, topdecl-var2 (2 'haskell-definition-face ))
307
- (, topdecl-bangpat (1 'haskell-definition-face ))
294
+ (, topdecl-var (1 (unless (member (match-string 1 ) ', reservedids )
295
+ 'haskell-definition-face )))
296
+ (, topdecl-var2 (2 (unless (member (match-string 2 ) ', reservedids )
297
+ 'haskell-definition-face )))
298
+ (, topdecl-bangpat (1 (unless (member (match-string 1 ) ', reservedids )
299
+ 'haskell-definition-face )))
308
300
(, topdecl-sym (2 (unless (member (match-string 2 ) '(" \\ " " =" " ->" " →" " <-" " ←" " ::" " ∷" " ," " ;" " `" ))
309
301
'haskell-definition-face )))
310
302
(, topdecl-sym2 (1 (unless (member (match-string 1 ) '(" \\ " " =" " ->" " →" " <-" " ←" " ::" " ∷" " ," " ;" " `" ))
@@ -314,19 +306,26 @@ Regexp match data 0 points to the chars."
314
306
(" (\\ (,*\\ |->\\ ))" 0 'haskell-constructor-face )
315
307
(" \\ [\\ ]" 0 'haskell-constructor-face )
316
308
317
- (,(concat " `" varid " `" ) 0 'haskell-operator-face )
318
- (,(concat " `" conid " `" ) 0 'haskell-operator-face )
319
- (,(concat " `" qvarid " `" ) 0 'haskell-operator-face )
320
- (,(concat " `" qconid " `" ) 0 'haskell-operator-face )
321
-
322
- (, qconid 0 'haskell-constructor-face )
323
-
324
- (, conid 0 'haskell-constructor-face )
325
-
326
- (, sym 0 (if (and (eq (char-after (match-beginning 0 )) ?: )
327
- (not (member (match-string 0 ) '(" ::" " ∷" ))))
328
- 'haskell-constructor-face
329
- 'haskell-operator-face ))))
309
+ (,(concat " `" haskell-lexeme-qid-or-qsym " `" ) 0 'haskell-operator-face )
310
+
311
+ (, haskell-lexeme-qid-or-qsym
312
+ 0 (cl-case (haskell-lexeme-classify-by-first-char (char-after (match-beginning 1 )))
313
+ (varid (when (member (match-string 0 ) ', reservedids )
314
+ ; ; Note: keywords parse as keywords only when not qualified.
315
+ ; ; GHC parses Control.let as a single but illegal lexeme.
316
+ 'haskell-keyword-face ))
317
+ (conid 'haskell-constructor-face )
318
+ (varsym (when (and (not (member (match-string 0 ) '(" -" " +" " ." )))
319
+ (not (save-excursion
320
+ (goto-char (match-beginning 1 ))
321
+ (looking-at-p " \\ sw" ))))
322
+ ; ; We need to protect against the case of
323
+ ; ; plus, minus or dot inside a floating
324
+ ; ; point number.
325
+ 'haskell-operator-face ))
326
+ (consym (if (not (member (match-string 1 ) '(" ::" " ∷" )))
327
+ 'haskell-constructor-face
328
+ 'haskell-operator-face ))))))
330
329
keywords))
331
330
332
331
@@ -456,7 +455,8 @@ Regexp match data 0 points to the chars."
456
455
(font-lock-syntactic-face-function
457
456
. haskell-syntactic-face-function)
458
457
; ; Get help from font-lock-syntactic-keywords.
459
- (parse-sexp-lookup-properties . t ))))
458
+ (parse-sexp-lookup-properties . t )
459
+ (font-lock-extra-managed-props . (composition)))))
460
460
461
461
(defun haskell-fontify-as-mode (text mode )
462
462
" Fontify TEXT as MODE, returning the fontified text."
0 commit comments