From d22b9aedb9ade938673d493fd47bba304a10d0b8 Mon Sep 17 00:00:00 2001 From: Abdulaziz Ghuloum Date: Mon, 25 Nov 2024 15:11:35 +0300 Subject: [PATCH] removed union_type and object_type and replaced them with binary_expression and object --- src/AST.ts | 4 ---- src/ASTVis.tsx | 2 +- src/expander.ts | 2 +- src/parser-loader.ts | 6 ++++++ 4 files changed, 8 insertions(+), 6 deletions(-) diff --git a/src/AST.ts b/src/AST.ts index 78b7e02..41d46c6 100644 --- a/src/AST.ts +++ b/src/AST.ts @@ -49,12 +49,10 @@ export type list_tag = | "predefined_type" | "literal_type" | "tuple_type" - | "object_type" | "pair" | "object" | "array_pattern" | "object_pattern" - | "union_type" | "slice" | "ERROR"; @@ -83,12 +81,10 @@ export const list_tags: { [k in list_tag]: list_tag } = { predefined_type: "predefined_type", literal_type: "literal_type", tuple_type: "tuple_type", - object_type: "object_type", pair: "pair", object: "object", object_pattern: "object_pattern", array_pattern: "array_pattern", - union_type: "union_type", ERROR: "ERROR", }; diff --git a/src/ASTVis.tsx b/src/ASTVis.tsx index 2413d1c..3fd2af3 100644 --- a/src/ASTVis.tsx +++ b/src/ASTVis.tsx @@ -14,7 +14,7 @@ const colormap: { [k in AST.atom_tag]: string } = { number: "magenta", type_identifier: "orange", jsx_text: "teal", - string_fragment: "cyan", + string: "cyan", regex_pattern: "magenta", other: "grey", ERROR: "red", diff --git a/src/expander.ts b/src/expander.ts index 6f8037e..adf4d39 100644 --- a/src/expander.ts +++ b/src/expander.ts @@ -454,7 +454,7 @@ function find_form(loc: Loc): ffrv { const { tag } = loc.t; const action = list_handlers_table[tag]; if (action === undefined) { - throw new Error(`no stop_table entry for ${tag}`); + debug(loc, `no stop_table entry for ${tag}`); } switch (action) { case "descend": diff --git a/src/parser-loader.ts b/src/parser-loader.ts index 0f2ba2f..bccbd67 100644 --- a/src/parser-loader.ts +++ b/src/parser-loader.ts @@ -75,6 +75,12 @@ function absurdly(node: Parser.SyntaxNode): AST { return { type: "list", tag: "required_parameter", content: array_to_ll(ls) }; } } + case "union_type": { + return { type: "list", tag: "binary_expression", content: array_to_ll(ls) }; + } + case "object_type": { + return { type: "list", tag: "object", content: array_to_ll(ls) }; + } case "arrow_function": { if (ls.length === 3) { const fmls = ls[0];