escapes
This commit is contained in:
parent
27696ecf09
commit
f3ceb046f9
1 changed files with 5 additions and 2 deletions
|
@ -25,9 +25,11 @@
|
||||||
let taille = String.length charac in
|
let taille = String.length charac in
|
||||||
match charac with
|
match charac with
|
||||||
| "\\n" -> Some '\n'
|
| "\\n" -> Some '\n'
|
||||||
|
| "\\b" -> Some '\b'
|
||||||
| "\\r" -> Some '\r'
|
| "\\r" -> Some '\r'
|
||||||
| "\\t" -> Some '\t'
|
| "\\t" -> Some '\t'
|
||||||
| "\\\'" -> Some '\''
|
| "\\'" -> Some '\''
|
||||||
|
| "\\\"" -> Some '"'
|
||||||
| "\\\\" -> Some '\\'
|
| "\\\\" -> Some '\\'
|
||||||
| _ -> (
|
| _ -> (
|
||||||
let s2 = String.get charac 1 in
|
let s2 = String.get charac 1 in
|
||||||
|
@ -55,7 +57,7 @@ let octa = "0o" ['0'-'7']
|
||||||
let ascii_table = ['\000'-'\255']
|
let ascii_table = ['\000'-'\255']
|
||||||
let ascii_hex = "\\0x" hex_dig hex_dig
|
let ascii_hex = "\\0x" hex_dig hex_dig
|
||||||
let printable = ['\032'-'\038' '\040'-'\127']
|
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
|
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,
|
(* 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 }
|
| "\\n" { Buffer.add_char buffer '\n'; read_string buffer lexbuf }
|
||||||
| "\\b" { Buffer.add_char buffer '\b'; read_string buffer lexbuf }
|
| "\\b" { Buffer.add_char buffer '\b'; read_string buffer lexbuf }
|
||||||
| "\\r" { Buffer.add_char buffer '\r'; 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 }
|
| "\\\"" { Buffer.add_char buffer '"'; read_string buffer lexbuf }
|
||||||
| "\\\\" { Buffer.add_char buffer '\\'; read_string buffer lexbuf }
|
| "\\\\" { Buffer.add_char buffer '\\'; read_string buffer lexbuf }
|
||||||
|
|
Reference in a new issue