refactor
This commit is contained in:
parent
41fa9baedc
commit
abcbd1754c
1 changed files with 10 additions and 10 deletions
|
@ -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)
|
||||||
|
;;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Reference in a new issue