This commit is contained in:
Mylloon 2023-10-24 15:38:57 +02:00
parent 41fa9baedc
commit abcbd1754c
Signed by: Anri
GPG key ID: A82D63DFF8D1317F

View file

@ -21,9 +21,8 @@
(* Fonction qui convertie une chaîne de caractère ascii en vrai caractère. (* Fonction qui convertie une chaîne de caractère ascii en vrai caractère.
* Notamment les escapes : "\n" ou "\000" *) * Notamment les escapes : "\n" ou "\000" *)
let recup_char charac lexbuf = let recup_char data lexbuf =
let taille = String.length charac in match data with
match charac with
| "\\n" -> Some '\n' | "\\n" -> Some '\n'
| "\\b" -> Some '\b' | "\\b" -> Some '\b'
| "\\r" -> Some '\r' | "\\r" -> Some '\r'
@ -31,13 +30,14 @@
| "\\'" -> Some '\'' | "\\'" -> Some '\''
| "\\\"" -> Some '"' | "\\\"" -> Some '"'
| "\\\\" -> Some '\\' | "\\\\" -> Some '\\'
| _ -> ( | _ ->
let s2 = String.get charac 1 in (match String.get data 1 with
if s2 = '0' || s2 = '1' || s2 = '2' then ( | '0' | '1' | '2' ->
let s = String.sub charac 1 (taille - 1) in let caractere = String.sub data 1 (String.length data - 1) in
let i = int_of_string s in let ascii_code = int_of_string caractere in
Some (Char.chr i)) Some (Char.chr ascii_code)
else None ) | _ -> None)
;;
} }