From 6084599153b0f19802250830dcf8ba3090341c75 Mon Sep 17 00:00:00 2001 From: Nathan Rebours Date: Fri, 2 Feb 2024 12:29:52 +0100 Subject: [PATCH] Make Context_free.map_top_down embed_errors arg optional This extra argument that was added in #453 caused breakage in `ocsigen-i18n` that was using `Context_free.map_top_down`. Although it's undocumented, this function is still part of the public API. Adding an extra optional argument is not strictly speaking non-breaking but is good enough of an effort considering the status of this function and in particular, the fact that it only has a single public external user for which it prevents breakage. Signed-off-by: Nathan Rebours --- CHANGES.md | 4 ++++ src/context_free.ml | 3 ++- src/context_free.mli | 2 +- 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index 17473390..758cfac8 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,6 +1,10 @@ unreleased ------------------- +- Add an optional `embed_errors` argument to `Context_free.map_top_down` that + controls how to deal with exceptions thrown by context-free rules. + (#, @NathanReb) + - Fix `Longident.parse` so it properly handles unparenthesized dotted operators such as `+.` or `*.`. (#111, @rgrinberg, @NathanReb) diff --git a/src/context_free.ml b/src/context_free.ml index b99b48e6..e7622933 100644 --- a/src/context_free.ml +++ b/src/context_free.ml @@ -401,7 +401,8 @@ module Expect_mismatch_handler = struct end class map_top_down ?(expect_mismatch_handler = Expect_mismatch_handler.nop) - ?(generated_code_hook = Generated_code_hook.nop) rules ~embed_errors = + ?(generated_code_hook = Generated_code_hook.nop) ?(embed_errors = false) rules + = let hook = generated_code_hook in let special_functions = diff --git a/src/context_free.mli b/src/context_free.mli index d6872761..38265c6f 100644 --- a/src/context_free.mli +++ b/src/context_free.mli @@ -149,8 +149,8 @@ class map_top_down : Expect_mismatch_handler.t (* default: Expect_mismatch_handler.nop *) -> ?generated_code_hook: Generated_code_hook.t (* default: Generated_code_hook.nop *) -> + ?embed_errors:bool -> Rule.t list -> - embed_errors:bool -> object inherit Ast_traverse.map_with_expansion_context_and_errors end