From f3ceb046f97db2313c390030b3dc12dfe7b7f9b7 Mon Sep 17 00:00:00 2001 From: Mylloon Date: Tue, 24 Oct 2023 15:32:22 +0200 Subject: [PATCH] escapes --- flap/src/hopix/hopixLexer.mll | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/flap/src/hopix/hopixLexer.mll b/flap/src/hopix/hopixLexer.mll index 3ecb07c..b5aa893 100644 --- a/flap/src/hopix/hopixLexer.mll +++ b/flap/src/hopix/hopixLexer.mll @@ -25,9 +25,11 @@ let taille = String.length charac in match charac with | "\\n" -> Some '\n' + | "\\b" -> Some '\b' | "\\r" -> Some '\r' | "\\t" -> Some '\t' - | "\\\'" -> Some '\'' + | "\\'" -> Some '\'' + | "\\\"" -> Some '"' | "\\\\" -> Some '\\' | _ -> ( let s2 = String.get charac 1 in @@ -55,7 +57,7 @@ let octa = "0o" ['0'-'7'] let ascii_table = ['\000'-'\255'] let ascii_hex = "\\0x" hex_dig hex_dig let printable = ['\032'-'\038' '\040'-'\127'] -let escapes = "\\\\" | "\\'" | "\\n" | "\\t" | "\\b" | "\\r" +let escapes = "\\n" | "\\b" | "\\r" | "\\t" | "\\'" | "\\\"" | "\\\\" let atom = ascii_table | ascii_hex | printable | escapes (* On ne peut pas différencier au niveau du lexer var_id label_id et type_con, @@ -184,6 +186,7 @@ and read_string buffer = parse | "\\n" { Buffer.add_char buffer '\n'; read_string buffer lexbuf } | "\\b" { Buffer.add_char buffer '\b'; read_string buffer lexbuf } | "\\r" { Buffer.add_char buffer '\r'; read_string buffer lexbuf } + | "\\t" { Buffer.add_char buffer '\r'; read_string buffer lexbuf } | "\\'" { Buffer.add_char buffer '\''; read_string buffer lexbuf } | "\\\"" { Buffer.add_char buffer '"'; read_string buffer lexbuf } | "\\\\" { Buffer.add_char buffer '\\'; read_string buffer lexbuf }