From 5398e5b8f943b7d4f93cb683a6d3cf1edc866757 Mon Sep 17 00:00:00 2001 From: Pierre Roux Date: Sun, 6 Jul 2025 11:28:17 +0200 Subject: [PATCH] Warn about recovery mechanism forgotten in #17876 --- gramlib/grammar.ml | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/gramlib/grammar.ml b/gramlib/grammar.ml index 9ab066028a94..7a1a745df9e1 100644 --- a/gramlib/grammar.ml +++ b/gramlib/grammar.ml @@ -1320,11 +1320,15 @@ and parser_of_symbol : type s tr a. let al = try ps gstate strm__ :: al with Stream.Failure -> + if not gstate.recover then raise Stream.Failure else + let bp = LStream.count strm__ in let a = try parse_top_symb entry symb gstate strm__ with Stream.Failure -> raise (Error (symb_failed entry v sep symb)) in + let ep = LStream.count strm__ in + let () = warn_recover_continuation bp ep strm__ in a :: al in kont gstate al strm__ @@ -1344,11 +1348,16 @@ and parser_of_symbol : type s tr a. with Some al -> kont gstate al strm__ | _ -> + if not gstate.recover then al else + let bp = LStream.count strm__ in match try Some (parse_top_symb entry symb gstate strm__) with Stream.Failure -> None with - Some a -> kont gstate (a :: al) strm__ + Some a -> + let ep = LStream.count strm__ in + let () = warn_recover_continuation bp ep strm__ in + kont gstate (a :: al) strm__ | _ -> al end | _ -> al