From e7aa6b7cb621eb3c4c2356586c74f8624886c28d Mon Sep 17 00:00:00 2001 From: Nicolas BACQUEY Date: Wed, 18 Oct 2023 18:26:14 +0200 Subject: [PATCH] [ocaml] fix and simplify sequence softline/spacing --- topiary-queries/queries/ocaml.scm | 26 ++----------------------- topiary/tests/samples/expected/ocaml.ml | 8 ++++++++ topiary/tests/samples/input/ocaml.ml | 8 ++++++++ 3 files changed, 18 insertions(+), 24 deletions(-) diff --git a/topiary-queries/queries/ocaml.scm b/topiary-queries/queries/ocaml.scm index b7c682ea..2b6d9a85 100644 --- a/topiary-queries/queries/ocaml.scm +++ b/topiary-queries/queries/ocaml.scm @@ -1506,38 +1506,16 @@ ; top-level one: it is the one that is not preceded by a ";" (or ";%foo" for ppx sequences). ( ";"? @do_nothing - . (sequence_expression - . - _ - . ";" - . - "%"? @do_nothing ) @prepend_begin_scope @append_end_scope (#scope_id! "sequence_expression") ) (sequence_expression ";" @append_spaced_scoped_softline - (#scope_id! "sequence_expression") -) - -( - ";"? . "%"? @do_nothing - . - (attribute_id)? - . - (sequence_expression - . - _ - . - ";" - . - "%" - ) @prepend_begin_scope @append_end_scope - (#scope_id! "ppx_sequence_expression") + (#scope_id! "sequence_expression") ) (sequence_expression ";" @@ -1545,7 +1523,7 @@ "%" . (attribute_id) @append_spaced_scoped_softline - (#scope_id! "ppx_sequence_expression") + (#scope_id! "sequence_expression") ) ; Allow softlines in or patterns in matches, such as diff --git a/topiary/tests/samples/expected/ocaml.ml b/topiary/tests/samples/expected/ocaml.ml index 9d5b4c68..c743ba6c 100644 --- a/topiary/tests/samples/expected/ocaml.ml +++ b/topiary/tests/samples/expected/ocaml.ml @@ -1125,6 +1125,14 @@ let _ = | F -> bar +(* #642: interleaving regular sequence with PPX sequence *) +let () = + foo; + bar;%lwt + baz + +let () = foo; bar;%lwt baz + (* #644: softlines before module definition in a module type *) module type F = sig module G: sig val h : string end diff --git a/topiary/tests/samples/input/ocaml.ml b/topiary/tests/samples/input/ocaml.ml index 13a77624..f594ec57 100644 --- a/topiary/tests/samples/input/ocaml.ml +++ b/topiary/tests/samples/input/ocaml.ml @@ -1056,6 +1056,14 @@ let _ = | A | B | C | D | E | F -> bar +(* #642: interleaving regular sequence with PPX sequence *) +let () = + foo; + bar;%lwt + baz + +let () = foo; bar;%lwt baz + (* #644: softlines before module definition in a module type *) module type F = sig module G : sig val h : string end