From 5a1c995c0b590045d2e8b617a5cf9025869c1acf Mon Sep 17 00:00:00 2001 From: Gabriel Bezerra Date: Mon, 14 Aug 2023 23:46:57 +0200 Subject: [PATCH 1/5] Use Longident.last_exn instead of lid_last --- src/Let_anything.re | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/src/Let_anything.re b/src/Let_anything.re index 91d2fdd..8b3fdfb 100644 --- a/src/Let_anything.re +++ b/src/Let_anything.re @@ -16,12 +16,6 @@ let mkloc = (txt, loc) => { {Location.txt, loc}; }; -let lid_last = fun - | Lident(s) => s - | Ldot(_, s) => s - | Lapply(_, _) => failwith("lid_last on functor application") - - let rec process_bindings = (bindings, ident) => Parsetree.( switch (bindings) { @@ -80,7 +74,7 @@ class mapper = { ]), )) => let ident = parseLongident(txt); - let last = lid_last(ident); + let last = Longident.last_exn(ident); if (last != String.capitalize_ascii(last)) { super#expression(expr); } else { @@ -116,7 +110,7 @@ class mapper = { ]), )) => let ident = parseLongident(txt); - let last = lid_last(ident); + let last = Longident.last_exn(ident); if (last != String.capitalize_ascii(last)) { super#expression(expr); } else { From 67d8e13311aa8f60ec2f5eeeb1e2abf5d2631754 Mon Sep 17 00:00:00 2001 From: Gabriel Bezerra Date: Mon, 14 Aug 2023 23:52:48 +0200 Subject: [PATCH 2/5] Recurse on the subexpressions --- src/Let_anything.re | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Let_anything.re b/src/Let_anything.re index 8b3fdfb..c175fcc 100644 --- a/src/Let_anything.re +++ b/src/Let_anything.re @@ -54,7 +54,7 @@ let parseLongident = txt => { }; class mapper = { - as _; + as self; inherit class Ast_traverse.map as super; pub! expression = expr => { @@ -91,7 +91,7 @@ class mapper = { ~loc, try_, [ - (Nolabel, super#expression(value)), + (Nolabel, self#expression(value)), (Nolabel, Ast_helper.Exp.function_(~loc=handlerLoc, handlers)), ], ); @@ -124,7 +124,7 @@ class mapper = { ~loc, let_, [ - (Nolabel, super#expression(expr)), + (Nolabel, self#expression(expr)), ( Nolabel, Ast_helper.Exp.fun_( @@ -132,7 +132,7 @@ class mapper = { Nolabel, None, pat, - super#expression(continuation), + self#expression(continuation), ), ), ], From e2c0c417d7be4d42f5f70be476e9e5a97a739ee5 Mon Sep 17 00:00:00 2001 From: Gabriel Bezerra Date: Tue, 15 Aug 2023 00:02:26 +0200 Subject: [PATCH 3/5] Use Ast_builder instead of Ast_helper --- src/Let_anything.re | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Let_anything.re b/src/Let_anything.re index c175fcc..4fd77ca 100644 --- a/src/Let_anything.re +++ b/src/Let_anything.re @@ -116,18 +116,18 @@ class mapper = { } else { let (pat, expr) = process_bindings(bindings, ident); let let_ = - Ast_helper.Exp.ident( + Ast_builder.Default.pexp_ident( ~loc, mkloc(Longident.Ldot(ident, "let_"), loc), ); - Ast_helper.Exp.apply( + Ast_builder.Default.pexp_apply( ~loc, let_, [ (Nolabel, self#expression(expr)), ( Nolabel, - Ast_helper.Exp.fun_( + Ast_builder.Default.pexp_fun( ~loc, Nolabel, None, From 24de5aadb2f12d2d573fb06a0ee2f81d1bef58e5 Mon Sep 17 00:00:00 2001 From: Gabriel Bezerra Date: Tue, 15 Aug 2023 00:03:25 +0200 Subject: [PATCH 4/5] fix ternary operator in copyPlatformBinaryInPlace.js --- copyPlatformBinaryInPlace.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/copyPlatformBinaryInPlace.js b/copyPlatformBinaryInPlace.js index 2ed086d..7628726 100644 --- a/copyPlatformBinaryInPlace.js +++ b/copyPlatformBinaryInPlace.js @@ -8,7 +8,7 @@ var platform = process.platform === "win32" ? "win" : process.platform; var rootDir = __dirname; var sourceExePath = path.join(rootDir, `bs-let-${platform}-${arch}.exe`); -var destExePath = path.join(rootDir, `ppx${platform == "win" ? : ".exe": ""}`); +var destExePath = path.join(rootDir, `ppx${platform === "win" ? ".exe": ""}`); copyBinary(sourceExePath, destExePath); From 12cab6da0559b44e402a73078197e73713f35889 Mon Sep 17 00:00:00 2001 From: Gabriel Bezerra Date: Tue, 15 Aug 2023 00:29:26 +0200 Subject: [PATCH 5/5] Make it work as ppx again --- bin/Bin.re | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/Bin.re b/bin/Bin.re index 69767a5..5191e32 100644 --- a/bin/Bin.re +++ b/bin/Bin.re @@ -1,3 +1,3 @@ open Ppxlib; -let _ = Driver.standalone(); +let _ = Driver.run_as_ppx_rewriter();