|
@@ -28,7 +28,7 @@ type error_msg =
|
|
|
| Unterminated_regexp
|
|
|
| Unclosed_comment
|
|
|
| Unclosed_code
|
|
|
- | Invalid_escape of char
|
|
|
+ | Invalid_escape of char * (string option)
|
|
|
| Invalid_option
|
|
|
| Unterminated_markup
|
|
|
|
|
@@ -47,7 +47,8 @@ let error_msg = function
|
|
|
| Unterminated_regexp -> "Unterminated regular expression"
|
|
|
| Unclosed_comment -> "Unclosed comment"
|
|
|
| Unclosed_code -> "Unclosed code string"
|
|
|
- | Invalid_escape c -> Printf.sprintf "Invalid escape sequence \\%s" (Char.escaped c)
|
|
|
+ | Invalid_escape (c,None) -> Printf.sprintf "Invalid escape sequence \\%s" (Char.escaped c)
|
|
|
+ | Invalid_escape (c,Some msg) -> Printf.sprintf "Invalid escape sequence \\%s. %s" (Char.escaped c) msg
|
|
|
| Invalid_option -> "Invalid regular expression option"
|
|
|
| Unterminated_markup -> "Unterminated markup literal"
|
|
|
|
|
@@ -370,13 +371,13 @@ let rec token lexbuf =
|
|
|
reset();
|
|
|
let pmin = lexeme_start lexbuf in
|
|
|
let pmax = (try string lexbuf with Exit -> error Unterminated_string pmin) in
|
|
|
- let str = (try unescape (contents()) with Invalid_escape_sequence(c,i) -> error (Invalid_escape c) (pmin + i)) in
|
|
|
+ let str = (try unescape (contents()) with Invalid_escape_sequence(c,i,msg) -> error (Invalid_escape (c,msg)) (pmin + i)) in
|
|
|
mk_tok (Const (String str)) pmin pmax;
|
|
|
| "'" ->
|
|
|
reset();
|
|
|
let pmin = lexeme_start lexbuf in
|
|
|
let pmax = (try string2 lexbuf with Exit -> error Unterminated_string pmin) in
|
|
|
- let str = (try unescape (contents()) with Invalid_escape_sequence(c,i) -> error (Invalid_escape c) (pmin + i)) in
|
|
|
+ let str = (try unescape (contents()) with Invalid_escape_sequence(c,i,msg) -> error (Invalid_escape (c,msg)) (pmin + i)) in
|
|
|
let t = mk_tok (Const (String str)) pmin pmax in
|
|
|
fast_add_fmt_string (snd t);
|
|
|
t
|