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