Skip to content

Commit

Permalink
removed wrong special handling of slice in curlies
Browse files Browse the repository at this point in the history
  • Loading branch information
azizghuloum committed Nov 25, 2024
1 parent 79caa5f commit ca5eb5d
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 28 deletions.
30 changes: 2 additions & 28 deletions src/expander.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,7 @@ import {
extend_context_lexical,
CorePatterns,
} from "./STX";
import {
change,
change_splicing,
go_down,
go_next,
go_right,
go_up,
mkzipper,
stx_list_content,
wrap_loc,
} from "./zipper";
import { change, go_down, go_next, go_right, go_up, mkzipper, wrap_loc } from "./zipper";
import { apply_syntax_rules, core_handlers } from "./syntax-core-patterns";
import { debug, DONE, inspect, in_isolation, Step, syntax_error } from "./step";

Expand Down Expand Up @@ -176,13 +166,6 @@ function expand_program(step: {
});
}

const empty_statement: STX = {
type: "list",
tag: "empty_statement",
wrap: undefined,
content: null,
};

function preexpand_body(step: {
loc: Loc;
rib: Rib;
Expand Down Expand Up @@ -226,16 +209,6 @@ function preexpand_body_curly(step: {
step.loc,
(loc, k) => preexpand_forms({ ...step, loc, k: (gs) => k(gs.loc, gs) }),
(loc, { rib, context, counter, unit }) => {
if (loc.t.tag === "slice") {
const subforms = stx_list_content(loc.t);
const new_loc = change_splicing(
loc,
subforms === null ? [empty_statement, null] : subforms,
);
return inspect(new_loc, "spliced", () => {
preexpand_body_curly({ loc: new_loc, rib, unit: step.unit, context, counter, k: step.k });
});
}
return go_right(
loc,
(loc) => preexpand_body_curly({ loc, rib, counter, context, unit, k: step.k }),
Expand Down Expand Up @@ -275,6 +248,7 @@ const atom_handlers_table: { [tag in atom_tag]: "next" | "stop" } = {
const list_handlers_table: { [tag in list_tag]: "descend" | "stop" } = {
lexical_declaration: "stop",
variable_declarator: "stop",
export_statement: "stop",
slice: "descend",
arrow_function: "stop",
statement_block: "stop",
Expand Down
5 changes: 5 additions & 0 deletions tests/arrow-function-5.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
const foo = (x) => {
using_syntax_rules([t,t,x]).rewrite(splice(() => {
t
}));
}
5 changes: 5 additions & 0 deletions tests/arrow-function-5.ts.expanded
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
const foo_3 = (x_5) => {
x_5;
};
================================
DONE

0 comments on commit ca5eb5d

Please sign in to comment.