|
@@ -27,7 +27,7 @@ type error_msg =
|
|
| Unterminated_regexp
|
|
| Unterminated_regexp
|
|
| Unclosed_comment
|
|
| Unclosed_comment
|
|
| Unclosed_code
|
|
| Unclosed_code
|
|
- | Invalid_escape
|
|
|
|
|
|
+ | Invalid_escape of char
|
|
| Invalid_option
|
|
| Invalid_option
|
|
|
|
|
|
exception Error of error_msg * pos
|
|
exception Error of error_msg * pos
|
|
@@ -39,7 +39,7 @@ let error_msg = function
|
|
| Unterminated_regexp -> "Unterminated regular expression"
|
|
| Unterminated_regexp -> "Unterminated regular expression"
|
|
| Unclosed_comment -> "Unclosed comment"
|
|
| Unclosed_comment -> "Unclosed comment"
|
|
| Unclosed_code -> "Unclosed code string"
|
|
| Unclosed_code -> "Unclosed code string"
|
|
- | Invalid_escape -> "Invalid escape sequence"
|
|
|
|
|
|
+ | Invalid_escape c -> Printf.sprintf "Invalid escape sequence \\%s" (Char.escaped c)
|
|
| Invalid_option -> "Invalid regular expression option"
|
|
| Invalid_option -> "Invalid regular expression option"
|
|
|
|
|
|
type lexer_file = {
|
|
type lexer_file = {
|
|
@@ -303,14 +303,14 @@ and token = parse
|
|
reset();
|
|
reset();
|
|
let pmin = lexeme_start lexbuf in
|
|
let pmin = lexeme_start lexbuf in
|
|
let pmax = (try string lexbuf with Exit -> error Unterminated_string pmin) in
|
|
let pmax = (try string lexbuf with Exit -> error Unterminated_string pmin) in
|
|
- let str = (try unescape (contents()) with Exit -> error Invalid_escape pmin) in
|
|
|
|
|
|
+ let str = (try unescape (contents()) with Invalid_escape_sequence(c,i) -> error (Invalid_escape c) (pmin + i)) in
|
|
mk_tok (Const (String str)) pmin pmax;
|
|
mk_tok (Const (String str)) pmin pmax;
|
|
}
|
|
}
|
|
| "'" {
|
|
| "'" {
|
|
reset();
|
|
reset();
|
|
let pmin = lexeme_start lexbuf in
|
|
let pmin = lexeme_start lexbuf in
|
|
let pmax = (try string2 lexbuf with Exit -> error Unterminated_string pmin) in
|
|
let pmax = (try string2 lexbuf with Exit -> error Unterminated_string pmin) in
|
|
- let str = (try unescape (contents()) with Exit -> error Invalid_escape pmin) in
|
|
|
|
|
|
+ let str = (try unescape (contents()) with Invalid_escape_sequence(c,i) -> error (Invalid_escape c) (pmin + i)) in
|
|
let t = mk_tok (Const (String str)) pmin pmax in
|
|
let t = mk_tok (Const (String str)) pmin pmax in
|
|
fast_add_fmt_string (snd t);
|
|
fast_add_fmt_string (snd t);
|
|
t
|
|
t
|