Skip to content

Commit

Permalink
fixed printing of slice and added extra newlines
Browse files Browse the repository at this point in the history
  • Loading branch information
azizghuloum committed Nov 25, 2024
1 parent ca5eb5d commit 0e0e612
Show file tree
Hide file tree
Showing 10 changed files with 26 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/pprint.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,8 @@ function loc_to_ns(loc: Loc): ns {
return ["(", ls, ")"];
case "program":
case "statement_block":
return ls.map((x) => [x, "\n"]);
case "slice":
return ls.map((x) => [x, "\n\n"]);
}
return ls;
}
Expand Down Expand Up @@ -104,6 +105,6 @@ export async function pprint(loc: Loc) {
});
return pretty;
} catch (err) {
return src;
return `/* !!not pretty!! */\n${src}`;
}
}
2 changes: 2 additions & 0 deletions tests/arrow-function-1.ts.expanded
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
const f_3 = (x_9) => x_9;

const g_5 = (x_9) => f_3(x_9);

const h_7 = (x_9) => x_9((x_12) => f_3(x_12));
================================
DONE
3 changes: 3 additions & 0 deletions tests/splice-1.ts.expanded
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
const t_3 = 13;

const x_5 = 17;

const y_7 = x_5 + t_3;

const q_9 = t_3 + x_5;
================================
DONE
6 changes: 6 additions & 0 deletions tests/splice-2.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
const foo = (x) => {
using_syntax_rules([t,t,x]).rewrite(splice(() => {
t;
t;
}));
}
7 changes: 7 additions & 0 deletions tests/splice-2.ts.expanded
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
const foo_3 = (x_5) => {
x_5;

x_5;
};
================================
DONE
1 change: 1 addition & 0 deletions tests/test-1.ts.expanded
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
const x_3 = 12;

x_3;
================================
DONE
1 change: 1 addition & 0 deletions tests/test-2.ts.expanded
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
const x_3 = 12;

x_3 + x_3;
================================
DONE
1 change: 1 addition & 0 deletions tests/using-syntax-rules-2.ts.expanded
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
x_8 + x_8;

const x_8 = 12;
================================
DONE
1 change: 1 addition & 0 deletions tests/using-syntax-rules-3.ts.expanded
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
(foo_8) => x_6 + x_6;

const x_6 = 12;
================================
DONE
1 change: 1 addition & 0 deletions tests/using-syntax-rules-4.ts.expanded
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
x_7 + ((foo_9, foo_11) => foo_11 + foo_9);

const x_7 = 12;
================================
DONE

0 comments on commit 0e0e612

Please sign in to comment.