Get rid of the stub file
This commit is contained in:
parent
b2e96b9a22
commit
309fa373f4
2 changed files with 6 additions and 61 deletions
|
|
@ -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<Info, Error> = {
|
|
||||||
expressions: Expr<Info, Error>[],
|
|
||||||
error?: Error,
|
|
||||||
} & Info
|
|
||||||
|
|
||||||
export type Expr<Info, Error> =
|
|
||||||
| Literal<Info, Error>
|
|
||||||
| List<Info, Error>
|
|
||||||
| { 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<Info, Error> =
|
|
||||||
{ tag: "list", open: DelimiterToken, items: ListItem<Info, Error>[], close?: DelimiterToken, error?: Error } & Info
|
|
||||||
|
|
||||||
export type ListItem<Info, Error> =
|
|
||||||
| Expr<Info, Error>
|
|
||||||
| { tag: "error-list-separator", error: Error } & Info
|
|
||||||
|
|
||||||
export type Literal<Info, Error> =
|
|
||||||
// === 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];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -7,6 +7,9 @@ export type ConcreteSyntaxResult =
|
||||||
| { tag: "valid", value: ValidConcreteSyntax }
|
| { tag: "valid", value: ValidConcreteSyntax }
|
||||||
| { tag: "invalid", value: PartialConcreteSyntax }
|
| { 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<ConcreteInfo, never>
|
export type ValidConcreteSyntax = Program<ConcreteInfo, never>
|
||||||
export type PartialConcreteSyntax = Program<ConcreteInfo, ConcreteError>
|
export type PartialConcreteSyntax = Program<ConcreteInfo, ConcreteError>
|
||||||
|
|
||||||
|
|
@ -56,7 +59,7 @@ export type Program<Info, Error> = {
|
||||||
export type Expr<Info, Error> =
|
export type Expr<Info, Error> =
|
||||||
| Literal<Info, Error>
|
| Literal<Info, Error>
|
||||||
| List<Info, Error>
|
| List<Info, Error>
|
||||||
| { 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<Info, Error> =
|
export type List<Info, Error> =
|
||||||
{ tag: "list", open: DelimiterToken, items: ListItem<Info, Error>[], close?: DelimiterToken, error?: Error } & Info
|
{ tag: "list", open: DelimiterToken, items: ListItem<Info, Error>[], close?: DelimiterToken, error?: Error } & Info
|
||||||
|
|
@ -66,8 +69,10 @@ export type ListItem<Info, Error> =
|
||||||
| { tag: "error-list-separator", error: Error } & Info
|
| { tag: "error-list-separator", error: Error } & Info
|
||||||
|
|
||||||
export type Literal<Info, Error> =
|
export type Literal<Info, Error> =
|
||||||
|
// === number ===
|
||||||
| { tag: "number", value: number } & Info
|
| { tag: "number", value: number } & Info
|
||||||
| { tag: "error-number", error: Error } & Info
|
| { tag: "error-number", error: Error } & Info
|
||||||
|
// === identifier ===
|
||||||
| { tag: "identifier", value: Identifier } & Info
|
| { tag: "identifier", value: Identifier } & Info
|
||||||
| { tag: "error-identifier", error: Error } & Info
|
| { tag: "error-identifier", error: Error } & Info
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue