From 309fa373f46616a1344ac23453deabd5f52dd6a2 Mon Sep 17 00:00:00 2001 From: Yura Dupyn <2153100+omedusyo@users.noreply.github.com> Date: Sat, 25 Apr 2026 15:25:49 +0200 Subject: [PATCH] Get rid of the stub file --- src/new_syntax.ts | 60 ----------------------------------------------- src/syntax.ts | 7 +++++- 2 files changed, 6 insertions(+), 61 deletions(-) delete mode 100644 src/new_syntax.ts diff --git a/src/new_syntax.ts b/src/new_syntax.ts deleted file mode 100644 index 77a2851..0000000 --- a/src/new_syntax.ts +++ /dev/null @@ -1,60 +0,0 @@ -import type { CodePointSpan } from 'source-region'; -import type { ParseError } from './parse_errors'; - -export type ConcreteSyntaxResult = -| { tag: "valid", value: ValidConcreteSyntax } -| { tag: "invalid", value: PartialConcreteSyntax } - -// The main constraints are -// - `ValidConcreteSyntax` should be a subtype of `PartialConcreteSyntax` -// - if `PartialConcreteSyntax` doesn't contain any sort of error nodes, we should be able to coerce it to `ValidConcreteSyntax` without rebuilding the whole tree -export type ValidConcreteSyntax = Program<{ span: CodePointSpan }, never> -export type PartialConcreteSyntax = Program<{ span: CodePointSpan }, ConcreteError > - -export type ConcreteError = ConcreteErrorNode[] // Can't be empty array. -export type ConcreteErrorNode = { - span: CodePointSpan, - error: ParseError, - panickedOver?: CodePointSpan, -} - -export type DelimiterToken = - | { tag: "open-paren"; span: CodePointSpan } - | { tag: "close-paren"; span: CodePointSpan } - | { tag: "open-bracket"; span: CodePointSpan } - | { tag: "close-bracket"; span: CodePointSpan }; - -export type Program = { - expressions: Expr[], - error?: Error, -} & Info - -export type Expr = -| Literal -| List -| { tag: "error-expression", error: Error } & Info // This is for errors that don't really correspond to any sort of node. Unknown errors. - -export type List = - { tag: "list", open: DelimiterToken, items: ListItem[], close?: DelimiterToken, error?: Error } & Info - -export type ListItem = -| Expr -| { tag: "error-list-separator", error: Error } & Info - -export type Literal = -// === number === -| { tag: "number", value: number } & Info -| { tag: "error-number", error: Error } & Info -// === identifier === -| { tag: "identifier", value: Identifier } & Info -| { tag: "error-identifier", error: Error } & Info - -export type Identifier = string - - - -export namespace ConcreteError { - export function single(node: ConcreteErrorNode): ConcreteError { - return [node]; - } -} diff --git a/src/syntax.ts b/src/syntax.ts index bbf5f22..03806e3 100644 --- a/src/syntax.ts +++ b/src/syntax.ts @@ -7,6 +7,9 @@ export type ConcreteSyntaxResult = | { tag: "valid", value: ValidConcreteSyntax } | { tag: "invalid", value: PartialConcreteSyntax } +// The main constraints are +// - `ValidConcreteSyntax` should be a subtype of `PartialConcreteSyntax` +// - if `PartialConcreteSyntax` doesn't contain any sort of error nodes, we should be able to coerce it to `ValidConcreteSyntax` without rebuilding the whole tree export type ValidConcreteSyntax = Program export type PartialConcreteSyntax = Program @@ -56,7 +59,7 @@ export type Program = { export type Expr = | Literal | List -| { tag: "error-expression", error: Error } & Info +| { tag: "error-expression", error: Error } & Info // This is for errors that don't really correspond to any sort of node. Unknown errors. export type List = { tag: "list", open: DelimiterToken, items: ListItem[], close?: DelimiterToken, error?: Error } & Info @@ -66,8 +69,10 @@ export type ListItem = | { tag: "error-list-separator", error: Error } & Info export type Literal = +// === number === | { tag: "number", value: number } & Info | { tag: "error-number", error: Error } & Info +// === identifier === | { tag: "identifier", value: Identifier } & Info | { tag: "error-identifier", error: Error } & Info