Skip to content

Commit

Permalink
Point to error message file non-default errors
Browse files Browse the repository at this point in the history
  • Loading branch information
dc-mak committed Jun 29, 2023
1 parent 7b2d0a6 commit 8a6b4a5
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
5 changes: 3 additions & 2 deletions backend/cn/parse.ml
Original file line number Diff line number Diff line change
Expand Up @@ -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 "<YOUR SYNTAX ERROR MESSAGE HERE>\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 *)
Expand Down
5 changes: 3 additions & 2 deletions parsers/c/c_parser_driver.ml
Original file line number Diff line number Diff line change
Expand Up @@ -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 "<YOUR SYNTAX ERROR MESSAGE HERE>\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
Expand Down

0 comments on commit 8a6b4a5

Please sign in to comment.