From 8a6b4a5cb59c03c5fc215f27e89dd19b239453c5 Mon Sep 17 00:00:00 2001 From: Dhruv Makwana Date: Thu, 29 Jun 2023 12:40:30 +0100 Subject: [PATCH] Point to error message file non-default errors --- backend/cn/parse.ml | 5 +++-- parsers/c/c_parser_driver.ml | 5 +++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/backend/cn/parse.ml b/backend/cn/parse.ml index cbb5a5900..bce0a2ead 100644 --- a/backend/cn/parse.ml +++ b/backend/cn/parse.ml @@ -66,9 +66,10 @@ let parse parser_start (loc, string) = | C_parser.Error state -> let message = try - C_parser_error.message state + let msg = C_parser_error.message state in + if String.equal msg "\n" then raise Not_found else msg with Not_found -> - Printf.sprintf "Unknown syntax error (in state %d).\n" state + Printf.sprintf "Please add error message for state %d to parsers/c/c_parser_error.messages\n" state in let message = String.sub message 0 (String.length message - 1) in (* the two tokens between which the error occurred *) diff --git a/parsers/c/c_parser_driver.ml b/parsers/c/c_parser_driver.ml index 653ec2991..1a8eb5d8a 100644 --- a/parsers/c/c_parser_driver.ml +++ b/parsers/c/c_parser_driver.ml @@ -85,9 +85,10 @@ let parse lexbuf = let lexbuf = ! most_recent_lexbuf in let message = try - C_parser_error.message state + let msg = C_parser_error.message state in + if String.equal msg "\n" then raise Not_found else msg with Not_found -> - Printf.sprintf "Unknown syntax error (in state %d).\n" state + Printf.sprintf "Please add error message for state %d to parsers/c/c_parser_error.messages\n" state in let message = String.sub message 0 (String.length message - 1) in let tok = Lexing.lexeme lexbuf in