Skip to content
This repository was archived by the owner on May 2, 2024. It is now read-only.

ppxlib make it work again #33

Open
wants to merge 5 commits into
base: anmonteiro/ppxlib
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion bin/Bin.re
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
open Ppxlib;

let _ = Driver.standalone();
let _ = Driver.run_as_ppx_rewriter();
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using standalone here allows for more options at runtime, but requires a wrapper around the ppx that passes --as-ppx argument before the arguments that the compiler used.

2 changes: 1 addition & 1 deletion copyPlatformBinaryInPlace.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
24 changes: 9 additions & 15 deletions src/Let_anything.re
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -60,7 +54,7 @@ let parseLongident = txt => {
};

class mapper = {
as _;
as self;
inherit class Ast_traverse.map as super;

pub! expression = expr => {
Expand All @@ -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 {
Expand All @@ -97,7 +91,7 @@ class mapper = {
~loc,
try_,
[
(Nolabel, super#expression(value)),
(Nolabel, self#expression(value)),
(Nolabel, Ast_helper.Exp.function_(~loc=handlerLoc, handlers)),
],
);
Expand All @@ -116,29 +110,29 @@ 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 {
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, super#expression(expr)),
(Nolabel, self#expression(expr)),
(
Nolabel,
Ast_helper.Exp.fun_(
Ast_builder.Default.pexp_fun(
~loc,
Nolabel,
None,
pat,
super#expression(continuation),
self#expression(continuation),
),
),
],
Expand Down