From 4e1483df7318dc03d0ec457d0825f1d1140b5d26 Mon Sep 17 00:00:00 2001 From: Danila Danko Date: Thu, 28 Nov 2024 19:50:15 +0300 Subject: [PATCH 1/2] fix(eo-phi-normalizer): correctly handle empty parentheses --- eo-phi-normalizer/src/Language/EO/Phi/Syntax.hs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/eo-phi-normalizer/src/Language/EO/Phi/Syntax.hs b/eo-phi-normalizer/src/Language/EO/Phi/Syntax.hs index b3af68c1f..498fe50b7 100644 --- a/eo-phi-normalizer/src/Language/EO/Phi/Syntax.hs +++ b/eo-phi-normalizer/src/Language/EO/Phi/Syntax.hs @@ -63,7 +63,12 @@ render d = rend 0 False (map ($ "") $ d []) "" ShowS rend i p = \case "[" : "]" : ts -> showString "[]" . rend i False ts - "(" : ")" : ts -> showString "()" . rend i False ts + "(" : ")" : (t : ts) -> + (pending . showString "()") + . ( case t of + "," -> showChar ',' . new i ts + _ -> rend i False (t : ts) + ) "⟦" : "⟧" : ts -> showString "⟦ ⟧" . rend i False ts "[" : ts -> char '[' . rend i False ts "(" : ts -> char '(' . new (i + 1) ts From 57df3f466b89888e60ed8b071022c53e1ffb774d Mon Sep 17 00:00:00 2001 From: Danila Danko Date: Thu, 28 Nov 2024 19:50:35 +0300 Subject: [PATCH 2/2] feat(eo-phi-normalizer): add test for empty parentheses --- eo-phi-normalizer/test/eo/phi/from-eo/as-phi.yaml | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/eo-phi-normalizer/test/eo/phi/from-eo/as-phi.yaml b/eo-phi-normalizer/test/eo/phi/from-eo/as-phi.yaml index 979b11eb0..786a52a38 100644 --- a/eo-phi-normalizer/test/eo/phi/from-eo/as-phi.yaml +++ b/eo-phi-normalizer/test/eo/phi/from-eo/as-phi.yaml @@ -62,3 +62,17 @@ tests: ⟧ ⟧ } + - name: "Prints empty parentheses" + input: | + {⟦ m ↦ ⟦ x ↦ ⟦ ⟧ ⟧() ⟧} + normalized: | + {⟦ m ↦ ⟦ x ↦ ⟦ ⟧ ⟧() ⟧} + prettified: | + { + ⟦ + m ↦ ⟦ + x ↦ ⟦ ⟧ + ⟧ + () + ⟧ + }