Commit 0d3e88fd authored by Wilke Pierre's avatar Wilke Pierre
Browse files

small bugfix

parent ae855e53
......@@ -111,7 +111,7 @@ let list_regexp =
fun s ->
match String.get s 1 with
| a -> Some (SYM_CHARACTER a)
| exception Invalid_argument _ -> Some (SYM_CHARACTER '\x00')
| exception Invalid_argument _ -> Some (SYM_CHARACTER 'a')
);
(Cat (char_regexp '\'', Cat (char_regexp '\\',
Cat (char_range (char_list_of_string "\\tn0"),
......@@ -120,9 +120,9 @@ let list_regexp =
| '\\' -> Some (SYM_CHARACTER '\\')
| 'n' -> Some (SYM_CHARACTER '\n')
| 't' -> Some (SYM_CHARACTER '\t')
| '0' -> Some (SYM_CHARACTER '\x00')
| '0' -> Some (SYM_CHARACTER 'a')
| _ -> None
| exception _ -> Some (SYM_CHARACTER '\x00')
| exception _ -> Some (SYM_CHARACTER 'a')
);
(Cat (char_regexp '"',
Cat (Star (
......
......@@ -349,10 +349,14 @@ let char_list_to_char_ranges s =
)
in
let l = recognize_range (List.sort Stdlib.compare (List.map Char.code s)) [] None 0 in
let escape_char c =
if c = '"'
then "\\\"" else Printf.sprintf "%c" c in
List.fold_left (fun acc (c,n) ->
if n = 0
then Printf.sprintf "%c%s" (Char.chr c) acc
else Printf.sprintf "%c-%c%s" (Char.chr c) (Char.chr (c + n)) acc
then Printf.sprintf "%s%s" (escape_char (Char.chr c)) acc
else Printf.sprintf "%s-%s%s" (escape_char (Char.chr c))
(escape_char (Char.chr (c + n))) acc
) "" l
......
Supports Markdown
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