Skip to content

Commit 599d0d9

Browse files
committed
Merge pull request #1281 from gracjan/pr-char-literals
Add escape sequences to char literals
2 parents cff017b + 7e10eb5 commit 599d0d9

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

haskell-lexeme.el

+4-1
Original file line numberDiff line numberDiff line change
@@ -107,13 +107,16 @@ Note that (match-string 1) returns the unqualified part.")
107107
Note that negative sign char is not part of a number.")
108108

109109
(defconst haskell-lexeme-char-literal-inside
110-
(rx (| (regexp "[^\n'\\]")
110+
(rx (| (not (any "\n'\\"))
111111
(: "\\"
112112
(| "a" "b" "f" "n" "r" "t" "v" "\\" "\"" "'"
113113
"NUL" "SOH" "STX" "ETX" "EOT" "ENQ" "ACK"
114114
"BEL" "BS" "HT" "LF" "VT" "FF" "CR" "SO" "SI" "DLE"
115115
"DC1" "DC2" "DC3" "DC4" "NAK" "SYN" "ETB" "CAN"
116116
"EM" "SUB" "ESC" "FS" "GS" "RS" "US" "SP" "DEL"
117+
(regexp "[0-9]+")
118+
(: "x" (regexp "[0-9a-fA-F]+"))
119+
(: "o" (regexp "[0-7]+"))
117120
(: "^" (regexp "[]A-Z@^_\\[]"))))))
118121
"Regexp matching an inside of a character literal.")
119122

tests/haskell-font-lock-tests.el

+5
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,11 @@
3636
("_f" "w" haskell-symbol-face)
3737
("_'''" "w" haskell-symbol-face))))
3838

39+
(ert-deftest haskell-syntactic-test-character-literal-escapes ()
40+
(check-properties
41+
'("'\\000' '\\x01'")
42+
'(("'\\000'" t font-lock-string-face)
43+
("'\\x01'" t font-lock-string-face))))
3944

4045
(ert-deftest haskell-syntactic-test-7 ()
4146
"Take quotes and double quotes under control."

0 commit comments

Comments
 (0)