Skip to content
Snippets Groups Projects
Commit 0d3e88fd authored by Wilke Pierre's avatar Wilke Pierre
Browse files

small bugfix

parent ae855e53
No related branches found
No related tags found
No related merge requests found
...@@ -111,7 +111,7 @@ let list_regexp = ...@@ -111,7 +111,7 @@ let list_regexp =
fun s -> fun s ->
match String.get s 1 with match String.get s 1 with
| a -> Some (SYM_CHARACTER a) | 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_regexp '\'', Cat (char_regexp '\\',
Cat (char_range (char_list_of_string "\\tn0"), Cat (char_range (char_list_of_string "\\tn0"),
...@@ -120,9 +120,9 @@ let list_regexp = ...@@ -120,9 +120,9 @@ let list_regexp =
| '\\' -> Some (SYM_CHARACTER '\\') | '\\' -> Some (SYM_CHARACTER '\\')
| 'n' -> Some (SYM_CHARACTER '\n') | 'n' -> Some (SYM_CHARACTER '\n')
| 't' -> Some (SYM_CHARACTER '\t') | 't' -> Some (SYM_CHARACTER '\t')
| '0' -> Some (SYM_CHARACTER '\x00') | '0' -> Some (SYM_CHARACTER 'a')
| _ -> None | _ -> None
| exception _ -> Some (SYM_CHARACTER '\x00') | exception _ -> Some (SYM_CHARACTER 'a')
); );
(Cat (char_regexp '"', (Cat (char_regexp '"',
Cat (Star ( Cat (Star (
......
...@@ -349,10 +349,14 @@ let char_list_to_char_ranges s = ...@@ -349,10 +349,14 @@ let char_list_to_char_ranges s =
) )
in in
let l = recognize_range (List.sort Stdlib.compare (List.map Char.code s)) [] None 0 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) -> List.fold_left (fun acc (c,n) ->
if n = 0 if n = 0
then Printf.sprintf "%c%s" (Char.chr c) acc then Printf.sprintf "%s%s" (escape_char (Char.chr c)) acc
else Printf.sprintf "%c-%c%s" (Char.chr c) (Char.chr (c + n)) acc else Printf.sprintf "%s-%s%s" (escape_char (Char.chr c))
(escape_char (Char.chr (c + n))) acc
) "" l ) "" l
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment