From 3ee65e6568e4e71fbe97d6ac9df283264f141f46 Mon Sep 17 00:00:00 2001 From: Xie Yuheng Date: Sat, 6 Jan 2024 14:29:56 +0800 Subject: [PATCH] up --- src/lexer/Lexer.ts | 3 +-- src/lexer/Lexing.ts | 3 +-- src/match/match.ts | 9 +++------ src/parser/Parser.ts | 5 ++--- src/parser/Parsing.ts | 2 +- src/parser/parser.test.ts | 12 +++++++++--- src/pattern-exp/evaluate.ts | 4 ++-- src/pattern/Pattern.ts | 2 +- src/pattern/formatPattern.ts | 3 +-- src/pattern/matchPattern.ts | 4 ++-- src/pattern/unfoldFormatCons.ts | 3 +-- src/sexp/formatSexp.ts | 3 +-- src/sexp/unfoldFormatCons.ts | 3 +-- src/span/Span.ts | 3 +-- 14 files changed, 27 insertions(+), 32 deletions(-) diff --git a/src/lexer/Lexer.ts b/src/lexer/Lexer.ts index a1209a5..8fc3280 100644 --- a/src/lexer/Lexer.ts +++ b/src/lexer/Lexer.ts @@ -1,5 +1,4 @@ -import type { ParserOptions } from "../parser/index.js" -import { ParserConfig } from "../parser/index.js" +import { ParserConfig, type ParserOptions } from "../parser/index.js" import { Token } from "../token/index.js" import { Lexing } from "./Lexing.js" diff --git a/src/lexer/Lexing.ts b/src/lexer/Lexing.ts index 445fa92..e1f5b4a 100644 --- a/src/lexer/Lexing.ts +++ b/src/lexer/Lexing.ts @@ -2,8 +2,7 @@ import { InternalError, ParsingError } from "../errors/index.js" import { Lexer } from "../lexer/index.js" import { Position } from "../position/index.js" import { Span } from "../span/index.js" -import type { TokenKind } from "../token/index.js" -import { Token } from "../token/index.js" +import { Token, type TokenKind } from "../token/index.js" export class Lexing implements Iterator { position = Position.init() diff --git a/src/match/match.ts b/src/match/match.ts index 5bf6b1f..d632174 100644 --- a/src/match/match.ts +++ b/src/match/match.ts @@ -1,10 +1,7 @@ import { ParsingError } from "../errors/index.js" -import type { PatternExp } from "../pattern-exp/index.js" -import { evaluate } from "../pattern-exp/index.js" -import type { Pattern } from "../pattern/index.js" -import { formatPattern, matchPattern } from "../pattern/index.js" -import type { Sexp } from "../sexp/index.js" -import { formatSexp } from "../sexp/index.js" +import { evaluate, type PatternExp } from "../pattern-exp/index.js" +import { formatPattern, matchPattern, type Pattern } from "../pattern/index.js" +import { formatSexp, type Sexp } from "../sexp/index.js" import { Span } from "../span/index.js" export function matchSymbol(sexp: Sexp): string { diff --git a/src/parser/Parser.ts b/src/parser/Parser.ts index 3f2af54..3756048 100644 --- a/src/parser/Parser.ts +++ b/src/parser/Parser.ts @@ -1,8 +1,7 @@ import { ParsingError } from "../errors/index.js" import { Lexer } from "../lexer/index.js" -import type { ParserOptions } from "../parser/index.js" -import { ParserConfig } from "../parser/index.js" -import type { Sexp } from "../sexp/index.js" +import { ParserConfig, type ParserOptions } from "../parser/index.js" +import { type Sexp } from "../sexp/index.js" import { Token } from "../token/index.js" import { Parsing } from "./Parsing.js" diff --git a/src/parser/Parsing.ts b/src/parser/Parsing.ts index adbc2d1..38577ee 100644 --- a/src/parser/Parsing.ts +++ b/src/parser/Parsing.ts @@ -1,8 +1,8 @@ import { InternalError, ParsingError } from "../errors/index.js" import { Parser } from "../parser/index.js" import { Position } from "../position/index.js" -import type { Sexp } from "../sexp/index.js" import * as Sexps from "../sexp/index.js" +import { type Sexp } from "../sexp/index.js" import { Span } from "../span/index.js" import { Token } from "../token/index.js" diff --git a/src/parser/parser.test.ts b/src/parser/parser.test.ts index 1af3668..5590e3d 100644 --- a/src/parser/parser.test.ts +++ b/src/parser/parser.test.ts @@ -1,10 +1,16 @@ import { expect, test } from "vitest" import { ParsingError } from "../errors/index.js" import { Parser } from "../parser/index.js" -import type { PatternExp } from "../pattern-exp/index.js" -import { cons, evaluate, list, str, v } from "../pattern-exp/index.js" +import { + cons, + evaluate, + list, + str, + v, + type PatternExp, +} from "../pattern-exp/index.js" import { matchPatternOrFail } from "../pattern/index.js" -import type { Sexp } from "../sexp/index.js" +import { type Sexp } from "../sexp/index.js" const parser = new Parser({ quotes: [ diff --git a/src/pattern-exp/evaluate.ts b/src/pattern-exp/evaluate.ts index dfff5e8..c92f4a6 100644 --- a/src/pattern-exp/evaluate.ts +++ b/src/pattern-exp/evaluate.ts @@ -1,7 +1,7 @@ import { InternalError } from "../errors/index.js" -import type { PatternExp } from "../pattern-exp/index.js" -import type { Pattern } from "../pattern/index.js" +import { type PatternExp } from "../pattern-exp/index.js" import * as Patterns from "../pattern/index.js" +import { type Pattern } from "../pattern/index.js" export function evaluate(exp: PatternExp): Pattern { if (typeof exp === "number") { diff --git a/src/pattern/Pattern.ts b/src/pattern/Pattern.ts index e7434ae..8d2cf92 100644 --- a/src/pattern/Pattern.ts +++ b/src/pattern/Pattern.ts @@ -1,5 +1,5 @@ import { ParsingError } from "../errors/index.js" -import type { Sexp } from "../sexp/index.js" +import { type Sexp } from "../sexp/index.js" import { equal } from "../utils/equal.js" export type Pattern = Var | Cons | Null | Num | Str | Sym diff --git a/src/pattern/formatPattern.ts b/src/pattern/formatPattern.ts index b6872db..96d5f21 100644 --- a/src/pattern/formatPattern.ts +++ b/src/pattern/formatPattern.ts @@ -1,5 +1,4 @@ -import type { Pattern } from "../pattern/index.js" -import { unfoldFormatCons } from "../pattern/index.js" +import { unfoldFormatCons, type Pattern } from "../pattern/index.js" export function formatPattern(pattern: Pattern): string { switch (pattern.kind) { diff --git a/src/pattern/matchPattern.ts b/src/pattern/matchPattern.ts index 636013d..8d3c9d5 100644 --- a/src/pattern/matchPattern.ts +++ b/src/pattern/matchPattern.ts @@ -1,6 +1,6 @@ import { ParsingError } from "../errors/index.js" -import type { Pattern } from "../pattern/index.js" -import type { Sexp } from "../sexp/index.js" +import { type Pattern } from "../pattern/index.js" +import { type Sexp } from "../sexp/index.js" import { equal } from "../utils/equal.js" export function matchPatternOrFail( diff --git a/src/pattern/unfoldFormatCons.ts b/src/pattern/unfoldFormatCons.ts index 075dd51..394b881 100644 --- a/src/pattern/unfoldFormatCons.ts +++ b/src/pattern/unfoldFormatCons.ts @@ -1,5 +1,4 @@ -import type { Pattern } from "../pattern/index.js" -import { formatPattern } from "../pattern/index.js" +import { formatPattern, type Pattern } from "../pattern/index.js" export function unfoldFormatCons(pattern: Pattern): { heads: Array diff --git a/src/sexp/formatSexp.ts b/src/sexp/formatSexp.ts index 3f91ce3..cea0448 100644 --- a/src/sexp/formatSexp.ts +++ b/src/sexp/formatSexp.ts @@ -1,5 +1,4 @@ -import type { Sexp } from "../sexp/index.js" -import { unfoldFormatCons } from "../sexp/index.js" +import { unfoldFormatCons, type Sexp } from "../sexp/index.js" export function formatSexp(sexp: Sexp): string { switch (sexp.kind) { diff --git a/src/sexp/unfoldFormatCons.ts b/src/sexp/unfoldFormatCons.ts index ec052fa..7bc4707 100644 --- a/src/sexp/unfoldFormatCons.ts +++ b/src/sexp/unfoldFormatCons.ts @@ -1,5 +1,4 @@ -import type { Sexp } from "../sexp/index.js" -import { formatSexp } from "../sexp/index.js" +import { formatSexp, type Sexp } from "../sexp/index.js" export function unfoldFormatCons(sexp: Sexp): { heads: Array diff --git a/src/span/Span.ts b/src/span/Span.ts index e9a13cd..a48d365 100644 --- a/src/span/Span.ts +++ b/src/span/Span.ts @@ -1,6 +1,5 @@ import { Position } from "../position/index.js" -import type { ColorMode } from "../utils/color.js" -import { color } from "../utils/color.js" +import { color, type ColorMode } from "../utils/color.js" import { intervalOverlap } from "../utils/interval.js" import { isBrowser } from "../utils/isBrowser.js"