diff --git a/.madgerc b/.madgerc new file mode 100644 index 00000000..b407c6b4 --- /dev/null +++ b/.madgerc @@ -0,0 +1,7 @@ +{ + "detectiveOptions": { + "ts": { + "skipTypeImports": true + } + } +} diff --git a/packages/parjs-vitest-error/.gitignore b/packages/parjs-vitest-error/.gitignore new file mode 100644 index 00000000..4e03a400 --- /dev/null +++ b/packages/parjs-vitest-error/.gitignore @@ -0,0 +1,25 @@ +# Logs +logs +*.log +npm-debug.log* +yarn-debug.log* +yarn-error.log* +pnpm-debug.log* +lerna-debug.log* + +node_modules +dist +dist-ssr +*.local + +# Editor directories and files +.vscode/* +!.vscode/extensions.json +.idea +.DS_Store +*.suo +*.ntvs* +*.njsproj +*.sln +*.sw? +.yarn diff --git a/packages/parjs-vitest-error/.nvmrc b/packages/parjs-vitest-error/.nvmrc new file mode 100644 index 00000000..43bff1f8 --- /dev/null +++ b/packages/parjs-vitest-error/.nvmrc @@ -0,0 +1 @@ +20.9.0 \ No newline at end of file diff --git a/packages/parjs-vitest-error/.yarnrc.yml b/packages/parjs-vitest-error/.yarnrc.yml new file mode 100644 index 00000000..3186f3f0 --- /dev/null +++ b/packages/parjs-vitest-error/.yarnrc.yml @@ -0,0 +1 @@ +nodeLinker: node-modules diff --git a/packages/parjs-vitest-error/README.md b/packages/parjs-vitest-error/README.md new file mode 100644 index 00000000..e9cef8ed --- /dev/null +++ b/packages/parjs-vitest-error/README.md @@ -0,0 +1,6 @@ +To recreate: + +- `yarn` in the repo root directory to install packages +- `yarn test` to see test hang forever + +The line causing the problem is line 13 in parse.test.ts. Comment it out and restart vitest to see the test pass. diff --git a/packages/parjs-vitest-error/package.json b/packages/parjs-vitest-error/package.json new file mode 100644 index 00000000..d61a6041 --- /dev/null +++ b/packages/parjs-vitest-error/package.json @@ -0,0 +1,20 @@ +{ + "name": "perror", + "version": "0.0.0", + "private": true, + "type": "module", + "scripts": { + "build": "tsc && vite build", + "dev": "vite", + "preview": "vite preview", + "test": "vitest" + }, + "devDependencies": { + "typescript": "5.5.4", + "vite": "5.4.0", + "vitest": "2.0.5" + }, + "peerDependencies": { + "parjs": "*" + } +} diff --git a/packages/parjs-vitest-error/src/parse-hangs.test.ts b/packages/parjs-vitest-error/src/parse-hangs.test.ts new file mode 100644 index 00000000..9936e7e9 --- /dev/null +++ b/packages/parjs-vitest-error/src/parse-hangs.test.ts @@ -0,0 +1,17 @@ +import { expect, test } from "vitest"; + +import { float, whitespace } from "parjs"; +import { between } from "parjs/combinators"; + +test("adds 1 + 2 to equal 3", () => { + // this line causes the infinite loop or whatever. + // comment out this line, abort vitest, then re-run vitest to watch the test pass + const parser = float().pipe(between(whitespace())); + const parseResult = parser.parse("1"); + expect(parseResult).toMatchInlineSnapshot(` + ParjsSuccess { + "kind": "OK", + "value": 1, + } + `); +}); diff --git a/packages/parjs-vitest-error/tsconfig.json b/packages/parjs-vitest-error/tsconfig.json new file mode 100644 index 00000000..75abdef2 --- /dev/null +++ b/packages/parjs-vitest-error/tsconfig.json @@ -0,0 +1,23 @@ +{ + "compilerOptions": { + "target": "ES2020", + "useDefineForClassFields": true, + "module": "ESNext", + "lib": ["ES2020", "DOM", "DOM.Iterable"], + "skipLibCheck": true, + + /* Bundler mode */ + "moduleResolution": "bundler", + "allowImportingTsExtensions": true, + "resolveJsonModule": true, + "isolatedModules": true, + "noEmit": true, + + /* Linting */ + "strict": true, + "noUnusedLocals": true, + "noUnusedParameters": true, + "noFallthroughCasesInSwitch": true + }, + "include": ["src"] +} diff --git a/packages/parjs/examples/src/ini.ts b/packages/parjs/examples/src/ini.ts index bf0fbec8..7ce56296 100644 --- a/packages/parjs/examples/src/ini.ts +++ b/packages/parjs/examples/src/ini.ts @@ -9,7 +9,7 @@ import { or, qthen, stringify, - then, + thenceforth, thenq } from "parjs/combinators"; @@ -88,7 +88,7 @@ export const value = anyCharOf(valueCharacters).pipe(many1(), stringify()).expec export const definitionLine = token(identifier) .pipe( thenq(token(string("="))), - then(value, comment.pipe(maybe())), + thenceforth(value, comment.pipe(maybe())), thenq(newline().pipe(or(eof()))), map(([name, val]) => new Property(name.toLowerCase(), val)) ) @@ -113,7 +113,7 @@ export const sectionHeader = token( export const section = sectionHeader .pipe( thenq(newline()), - then(definitionList), + thenceforth(definitionList), map(([name, properties]) => new NamedSection(name, properties)) ) .expects("section"); @@ -126,7 +126,7 @@ export const globalSection = definitionList export const iniFile = globalSection .pipe( - then(section.pipe(many())), + thenceforth(section.pipe(many())), map(([global, sections]) => new IniFile(global, sections)) ) .expects("ini file"); diff --git a/packages/parjs/examples/src/json.ts b/packages/parjs/examples/src/json.ts index a3153764..ded0e425 100644 --- a/packages/parjs/examples/src/json.ts +++ b/packages/parjs/examples/src/json.ts @@ -17,7 +17,7 @@ import { or, qthen, stringify, - then, + thenceforth, thenq } from "parjs/combinators"; @@ -105,7 +105,7 @@ const pArray = pJsonValue.pipe( // Plus, whitespace around the property const pObjectProperty = pStr.pipe( thenq(string(":").pipe(between(whitespace()))), - then(pJsonValue), + thenceforth(pJsonValue), between(whitespace()), map(([name, value]) => { return new JsonObjectProperty(name, value); diff --git a/packages/parjs/examples/src/math.ts b/packages/parjs/examples/src/math.ts index 9b0bbafd..f35950a6 100644 --- a/packages/parjs/examples/src/math.ts +++ b/packages/parjs/examples/src/math.ts @@ -14,7 +14,7 @@ import type { Parjser } from "parjs"; import { float, string } from "parjs"; import type { DelayedParjser } from "parjs/combinators"; -import { between, later, many, map, or, then, thenq } from "parjs/combinators"; +import { between, later, many, map, or, thenceforth, thenq } from "parjs/combinators"; export interface Expression { calculate(): number; @@ -98,7 +98,7 @@ export const value: Parjser = t(numberLiteral) export const unary: Parjser = t(string("-")) .pipe( - then(value), + thenceforth(value), map(([op, val]) => new UnaryOperation(op, val)), or(value) ) @@ -108,7 +108,7 @@ export function product() { const operator = t(string("*").pipe(or(string("/"), string("%")))); return unary .pipe( - then(operator.pipe(then(unary), many())), + thenceforth(operator.pipe(thenceforth(unary), many())), map(expressions => { const [first, rest] = expressions; return rest.reduce((lhs, [op, rhs]) => new BinaryOperation(lhs, op, rhs), first); @@ -121,7 +121,7 @@ export function sum() { const operator = t(string("+").pipe(or(string("-")))); return product() .pipe( - then(operator.pipe(then(product()), many())), + thenceforth(operator.pipe(thenceforth(product()), many())), map(expressions => { const [first, rest] = expressions; return rest.reduce((lhs, [op, rhs]) => new BinaryOperation(lhs, op, rhs), first); diff --git a/packages/parjs/spec/unit/combinators/expects.spec.ts b/packages/parjs/spec/unit/combinators/expects.spec.ts index 1a770ea1..5a281c0e 100644 --- a/packages/parjs/spec/unit/combinators/expects.spec.ts +++ b/packages/parjs/spec/unit/combinators/expects.spec.ts @@ -1,5 +1,5 @@ import { fail, nope } from "@lib"; -import { reason, then } from "@lib/combinators"; +import { reason, thenceforth } from "@lib/combinators"; describe("expects combinator", () => { const base = nope("deez nuts"); @@ -13,7 +13,7 @@ describe("expects combinator", () => { }); it("modifies expecting", () => { const parser = base.pipe( - then(fail("deez nuts")), + thenceforth(fail("deez nuts")), reason(x => `${x.reason}! gottem!`) ); expect(parser.parse("abc")).toMatchObject({ diff --git a/packages/parjs/spec/unit/combinators/manySepBy.spec.ts b/packages/parjs/spec/unit/combinators/manySepBy.spec.ts index 6dbaddf3..2ac53fb3 100644 --- a/packages/parjs/spec/unit/combinators/manySepBy.spec.ts +++ b/packages/parjs/spec/unit/combinators/manySepBy.spec.ts @@ -1,5 +1,5 @@ import { ResultKind, fail, result, string } from "@lib"; -import { manySepBy, stringify, then, thenq } from "@lib/combinators"; +import { manySepBy, stringify, thenceforth, thenq } from "@lib/combinators"; import { getArrayWithSeparators } from "@lib/internal/combinators/many-sep-by"; const prs = string("ab"); @@ -38,7 +38,7 @@ describe("manySepBy combinator", () => { }); it("many that fails hard on 2nd iteration", () => { - const manyParser = string("a").pipe(then("b"), stringify(), manySepBy(", ")); + const manyParser = string("a").pipe(thenceforth("b"), stringify(), manySepBy(", ")); expect(manyParser.parse("ab, ac")).toBeFailure("Hard"); }); diff --git a/packages/parjs/spec/unit/combinators/maybe.spec.ts b/packages/parjs/spec/unit/combinators/maybe.spec.ts index 8ef01938..0a05e3dc 100644 --- a/packages/parjs/spec/unit/combinators/maybe.spec.ts +++ b/packages/parjs/spec/unit/combinators/maybe.spec.ts @@ -1,6 +1,6 @@ import type { Parjser } from "@lib"; import { fail, ResultKind, string } from "@lib"; -import { maybe, qthen, stringify, then } from "@lib/combinators"; +import { maybe, qthen, stringify, thenceforth } from "@lib/combinators"; describe("maybe combinator", () => { it("works", () => { @@ -22,9 +22,9 @@ describe("maybe combinator", () => { }); describe("maybe combinator again", () => { - const parser = string("a").pipe(then("b"), stringify(), maybe("c")); + const parser = string("a").pipe(thenceforth("b"), stringify(), maybe("c")); - const p2: Parjser<[0 | "a", "b"]> = string("a").pipe(maybe(0), then(string("b"))); + const p2: Parjser<[0 | "a", "b"]> = string("a").pipe(maybe(0), thenceforth(string("b"))); it("succeeds to parse", () => { expect(parser.parse("ab")).toBeSuccessful("ab"); }); diff --git a/packages/parjs/spec/unit/combinators/must.spec.ts b/packages/parjs/spec/unit/combinators/must.spec.ts index fd6dc5bc..397f3447 100644 --- a/packages/parjs/spec/unit/combinators/must.spec.ts +++ b/packages/parjs/spec/unit/combinators/must.spec.ts @@ -1,5 +1,5 @@ import { ResultKind, eof, string, stringLen } from "@lib"; -import { must, mustCapture, or, stringify, then } from "@lib/combinators"; +import { must, mustCapture, or, stringify, thenceforth } from "@lib/combinators"; describe("must combinators", () => { describe("must combinator", () => { @@ -24,7 +24,7 @@ describe("must combinators", () => { describe("mustCapture combinator", () => { const parser = string("a").pipe( - then("b"), + thenceforth("b"), stringify(), or(eof("")), mustCapture({ diff --git a/packages/parjs/spec/unit/combinators/not.spec.ts b/packages/parjs/spec/unit/combinators/not.spec.ts index cb6d7159..2ec7cca2 100644 --- a/packages/parjs/spec/unit/combinators/not.spec.ts +++ b/packages/parjs/spec/unit/combinators/not.spec.ts @@ -1,13 +1,13 @@ import { fail, rest, ResultKind, string } from "@lib"; -import { not, stringify, then } from "@lib/combinators"; +import { not, stringify, thenceforth } from "@lib/combinators"; describe("not combinator", () => { - const parser = string("a").pipe(then("b"), stringify(), not()); + const parser = string("a").pipe(thenceforth("b"), stringify(), not()); it("succeeds on empty input/soft fail", () => { expect(parser.parse("")).toBeSuccessful(undefined); }); it("succeeds on hard fail if we take care of the rest", () => { - const parser2 = parser.pipe(then(rest())); + const parser2 = parser.pipe(thenceforth(rest())); expect(parser2.parse("a")).toBeSuccessful(); }); it("soft fails on passing input", () => { diff --git a/packages/parjs/spec/unit/combinators/recover.spec.ts b/packages/parjs/spec/unit/combinators/recover.spec.ts index bb374df2..a21d3e51 100644 --- a/packages/parjs/spec/unit/combinators/recover.spec.ts +++ b/packages/parjs/spec/unit/combinators/recover.spec.ts @@ -1,9 +1,9 @@ import { fail, ResultKind, string } from "@lib"; -import { recover, stringify, then } from "@lib/combinators"; +import { recover, stringify, thenceforth } from "@lib/combinators"; describe("recover combinator", () => { const parser = string("a").pipe( - then("b"), + thenceforth("b"), stringify(), recover(() => ({ kind: "Soft" })) ); diff --git a/packages/parjs/spec/unit/combinators/recovery.spec.ts b/packages/parjs/spec/unit/combinators/recovery.spec.ts index 5af99e4f..6a89511d 100644 --- a/packages/parjs/spec/unit/combinators/recovery.spec.ts +++ b/packages/parjs/spec/unit/combinators/recovery.spec.ts @@ -9,7 +9,7 @@ import { reason, recover, stringify, - then + thenceforth } from "@lib/combinators"; describe("maybe combinator", () => { @@ -80,9 +80,9 @@ describe("or combinator", () => { }); describe("or val combinator", () => { - const parser = string("a").pipe(then("b"), stringify(), maybe("c")); + const parser = string("a").pipe(thenceforth("b"), stringify(), maybe("c")); - const p2: Parjser<[0 | "a", "b"]> = string("a").pipe(maybe(0), then(string("b"))); + const p2: Parjser<[0 | "a", "b"]> = string("a").pipe(maybe(0), thenceforth(string("b"))); it("succeeds to parse", () => { expect(parser.parse("ab")).toBeSuccessful("ab"); }); @@ -102,12 +102,12 @@ describe("or val combinator", () => { }); describe("not combinator", () => { - const parser = string("a").pipe(then("b"), stringify(), not()); + const parser = string("a").pipe(thenceforth("b"), stringify(), not()); it("succeeds on empty input/soft fail", () => { expect(parser.parse("")).toBeSuccessful(undefined); }); it("succeeds on hard fail if we take care of the rest", () => { - const parser2 = parser.pipe(then(rest())); + const parser2 = parser.pipe(thenceforth(rest())); expect(parser2.parse("a")).toBeSuccessful(); }); it("soft fails on passing input", () => { @@ -127,7 +127,7 @@ describe("not combinator", () => { describe("soft combinator", () => { const parser = string("a").pipe( - then("b"), + thenceforth("b"), stringify(), recover(() => ({ kind: "Soft" })) ); @@ -161,7 +161,7 @@ describe("expects combinator", () => { }); it("modifies expecting", () => { const parser = base.pipe( - then(fail("deez nuts")), + thenceforth(fail("deez nuts")), reason(x => `${x.reason}! gottem!`) ); expect(parser.parse("abc")).toMatchObject({ diff --git a/packages/parjs/spec/unit/combinators/sequential.spec.ts b/packages/parjs/spec/unit/combinators/sequential.spec.ts index 9cea24ba..911bc5cd 100644 --- a/packages/parjs/spec/unit/combinators/sequential.spec.ts +++ b/packages/parjs/spec/unit/combinators/sequential.spec.ts @@ -11,8 +11,8 @@ import { mapConst, qthen, stringify, - then, thenPick, + thenceforth, thenq } from "@lib/combinators"; import { many1 } from "@lib/internal/combinators"; @@ -43,7 +43,7 @@ describe("sequential combinators", () => { describe("then", () => { describe("1 arg", () => { - const parser = prs.pipe(then(prs2)); + const parser = prs.pipe(thenceforth(prs2)); it("succeeds", () => { expect(parser.parse(goodInput)).toBeSuccessful(["ab", "cd"]); }); @@ -58,13 +58,13 @@ describe("sequential combinators", () => { }); it("fails hard on first hard fail", () => { - const parser2 = fail().pipe(then("hi")); + const parser2 = fail().pipe(thenceforth("hi")); expect(parser2.parse("hi")).toBeFailure("Hard"); }); it("fails fatally on 2nd fatal fail", () => { const parser2 = string("hi").pipe( - then( + thenceforth( fail({ kind: "Fatal" }) @@ -74,13 +74,13 @@ describe("sequential combinators", () => { }); it("chain zero-matching parsers", () => { - const parser2 = string("hi").pipe(then(rest(), rest())); + const parser2 = string("hi").pipe(thenceforth(rest(), rest())); expect(parser2.parse("hi")).toBeSuccessful(["hi", "", ""]); }); }); describe("1 arg, then zero consume", () => { - const parser = prs.pipe(then(prs2), thenq(eof())); + const parser = prs.pipe(thenceforth(prs2), thenq(eof())); it("succeeds", () => { expect(parser.parse(goodInput)).toBeSuccessful(["ab", "cd"]); }); @@ -94,7 +94,7 @@ describe("sequential combinators", () => { const p3 = string("c").pipe(mapConst([] as string[])); const p = string("a").pipe( - then(p2, p3), + thenceforth(p2, p3), each(x => { Math.log(x[1]); x[0].toUpperCase(); @@ -112,7 +112,7 @@ describe("sequential combinators", () => { const p4 = string("d").pipe(mapConst(true)); const p = string("a").pipe( - then(p2, p3, p4), + thenceforth(p2, p3, p4), each(x => { Math.log(x[1]); x[0].toUpperCase(); @@ -242,7 +242,7 @@ describe("sequential combinators", () => { }); it("many that fails hard on 2nd iteration", () => { - const manyParser = string("a").pipe(then("b"), stringify(), manySepBy(", ")); + const manyParser = string("a").pipe(thenceforth("b"), stringify(), manySepBy(", ")); expect(manyParser.parse("ab, ac")).toBeFailure("Hard"); }); diff --git a/packages/parjs/spec/unit/combinators/special.spec.ts b/packages/parjs/spec/unit/combinators/special.spec.ts index 50ae5098..cfb83964 100644 --- a/packages/parjs/spec/unit/combinators/special.spec.ts +++ b/packages/parjs/spec/unit/combinators/special.spec.ts @@ -1,9 +1,9 @@ import { eof, string } from "@lib"; -import { backtrack, each, map, replaceState, then } from "@lib/combinators"; +import { backtrack, each, map, replaceState, thenceforth } from "@lib/combinators"; describe("special combinators", () => { describe("backtrack", () => { - const parser = string("hi").pipe(then(eof()), backtrack()); + const parser = string("hi").pipe(thenceforth(eof()), backtrack()); it("fails soft if inner fails soft", () => { expect(parser.parse("x")).toBeFailure("Soft"); @@ -15,7 +15,7 @@ describe("special combinators", () => { it("succeeds if inner succeeds, non-zero match", () => { const parseHi = string("hi"); - const redundantParser = parseHi.pipe(backtrack(), then("his")); + const redundantParser = parseHi.pipe(backtrack(), thenceforth("his")); expect(redundantParser.parse("his")).toBeSuccessful(["hi", "his"]); }); }); diff --git a/packages/parjs/spec/unit/combinators/then.spec.ts b/packages/parjs/spec/unit/combinators/then.spec.ts index 7605fb19..84023ec5 100644 --- a/packages/parjs/spec/unit/combinators/then.spec.ts +++ b/packages/parjs/spec/unit/combinators/then.spec.ts @@ -1,11 +1,11 @@ import { ResultKind, eof, fail, rest, string } from "@lib"; -import { each, mapConst, then, thenq } from "@lib/combinators"; +import { each, mapConst, thenceforth, thenq } from "@lib/combinators"; const excessInput = "abcde"; describe("then", () => { describe("1 arg", () => { - const parser = string("ab").pipe(then(string("cd"))); + const parser = string("ab").pipe(thenceforth(string("cd"))); it("succeeds", () => { expect(parser.parse("abcd")).toBeSuccessful(["ab", "cd"]); }); @@ -20,13 +20,13 @@ describe("then", () => { }); it("fails hard on first hard fail", () => { - const parser2 = fail().pipe(then("hi")); + const parser2 = fail().pipe(thenceforth("hi")); expect(parser2.parse("hi")).toBeFailure("Hard"); }); it("fails fatally on 2nd fatal fail", () => { const parser2 = string("hi").pipe( - then( + thenceforth( fail({ kind: "Fatal" }) @@ -36,13 +36,13 @@ describe("then", () => { }); it("chain zero-matching parsers", () => { - const parser2 = string("hi").pipe(then(rest(), rest())); + const parser2 = string("hi").pipe(thenceforth(rest(), rest())); expect(parser2.parse("hi")).toBeSuccessful(["hi", "", ""]); }); }); describe("1 arg, then zero consume", () => { - const parser = string("ab").pipe(then(string("cd")), thenq(eof())); + const parser = string("ab").pipe(thenceforth(string("cd")), thenq(eof())); it("succeeds", () => { expect(parser.parse("abcd")).toBeSuccessful(["ab", "cd"]); }); @@ -56,7 +56,7 @@ describe("then", () => { const p3 = string("c").pipe(mapConst([] as string[])); const p = string("a").pipe( - then(p2, p3), + thenceforth(p2, p3), each(x => { Math.log(x[1]); x[0].toUpperCase(); @@ -74,7 +74,7 @@ describe("then", () => { const p4 = string("d").pipe(mapConst(true)); const p = string("a").pipe( - then(p2, p3, p4), + thenceforth(p2, p3, p4), each(x => { Math.log(x[1]); x[0].toUpperCase(); diff --git a/packages/parjs/spec/unit/standalone/eof.spec.ts b/packages/parjs/spec/unit/standalone/eof.spec.ts index 7856a2ad..a202db22 100644 --- a/packages/parjs/spec/unit/standalone/eof.spec.ts +++ b/packages/parjs/spec/unit/standalone/eof.spec.ts @@ -1,5 +1,5 @@ import { ResultKind, eof } from "@lib"; -import { then } from "@lib/combinators"; +import { thenceforth } from "@lib/combinators"; describe("eof", () => { const parser = eof(); @@ -12,7 +12,7 @@ describe("eof", () => { expect(parser.parse(failInput)).toBeFailure(ResultKind.SoftFail); }); it("chain multiple EOF succeeds", () => { - const parser2 = parser.pipe(then(eof())); + const parser2 = parser.pipe(thenceforth(eof())); expect(parser2.parse("")).toBeSuccessful(undefined); }); }); diff --git a/packages/parjs/spec/unit/standalone/string.spec.ts b/packages/parjs/spec/unit/standalone/string.spec.ts index 357752c8..9810a624 100644 --- a/packages/parjs/spec/unit/standalone/string.spec.ts +++ b/packages/parjs/spec/unit/standalone/string.spec.ts @@ -20,7 +20,7 @@ import { upper, whitespace } from "@lib"; -import { many, then } from "@lib/combinators"; +import { many, thenceforth } from "@lib/combinators"; const uState = {}; @@ -301,7 +301,7 @@ describe("basic string parsers", () => { expect(parser.parse("abc")).toBeSuccessful(["abc"]); }); it("succeds using implicit", () => { - expect(string("abc").pipe(then(/abc/)).parse("abcabc")).toBeSuccessful([ + expect(string("abc").pipe(thenceforth(/abc/)).parse("abcabc")).toBeSuccessful([ "abc", ["abc"] ]); @@ -311,13 +311,16 @@ describe("basic string parsers", () => { }); it("match starts in the proper location", () => { const p = string("abc"); - expect(p.pipe(then(parser)).parse("abcabc")).toBeSuccessful(["abc", ["abc"]]); + expect(p.pipe(thenceforth(parser)).parse("abcabc")).toBeSuccessful([ + "abc", + ["abc"] + ]); }); it("match ends in the proper location", () => { const p1 = string("abc"); const p2 = regexp(/.{3}/); const p3 = string("eeee"); - const r = p1.pipe(then(p2, p3)); + const r = p1.pipe(thenceforth(p2, p3)); expect(r.parse("abcabceeee")).toBeSuccessful(["abc", ["abc"], "eeee"]); }); }); @@ -327,7 +330,7 @@ describe("basic string parsers", () => { it("succeeds on input", () => { expect(parser.parse("abc")).toBeSuccessful(["abc", "ab", "c"]); }); - const parser2 = parser.pipe(then("de")); + const parser2 = parser.pipe(thenceforth("de")); it("chains correctly", () => { expect(parser2.parse("abcde")).toBeSuccessful(); }); diff --git a/packages/parjs/spec/unit/trace.spec.ts b/packages/parjs/spec/unit/trace.spec.ts index 4e1fefb8..4d616dcd 100644 --- a/packages/parjs/spec/unit/trace.spec.ts +++ b/packages/parjs/spec/unit/trace.spec.ts @@ -1,6 +1,6 @@ import type { ParjsFailure } from "@lib"; import { string, whitespace } from "@lib"; -import { exactly, manySepBy, then } from "@lib/combinators"; +import { exactly, manySepBy, thenceforth } from "@lib/combinators"; import { visualizeTrace } from "@lib/internal/trace-visualizer"; describe("trace", () => { @@ -35,7 +35,7 @@ describe("trace", () => { describe("line breaks \\n", () => { const input = "\n".repeat(11) + "a".repeat(4); - const parser = whitespace().pipe(then(string("a").pipe(exactly(5)))); + const parser = whitespace().pipe(thenceforth(string("a").pipe(exactly(5)))); const res = parser.parse(input) as ParjsFailure; const { trace } = res; it("correct position", () => { @@ -53,7 +53,7 @@ describe("trace", () => { describe("line breaks mixed", () => { const input = "\r\n".repeat(3) + "\r".repeat(3) + "\n".repeat(3) + "a".repeat(4); - const parser = whitespace().pipe(then(string("a").pipe(exactly(5)))); + const parser = whitespace().pipe(thenceforth(string("a").pipe(exactly(5)))); const res = parser.parse(input) as ParjsFailure; const { trace } = res; diff --git a/packages/parjs/src/combinators.ts b/packages/parjs/src/combinators.ts index 31c1fa20..6ab43907 100644 --- a/packages/parjs/src/combinators.ts +++ b/packages/parjs/src/combinators.ts @@ -23,8 +23,8 @@ export { recover, replaceState, stringify, - then, thenPick, + thenceforth, thenq } from "./internal/combinators"; export type { diff --git a/packages/parjs/src/index.ts b/packages/parjs/src/index.ts index 949cce15..2171f5a6 100644 --- a/packages/parjs/src/index.ts +++ b/packages/parjs/src/index.ts @@ -52,4 +52,4 @@ export { upper, whitespace } from "./internal/index"; -export type { ConvertibleScalar, ImplicitParjser } from "./internal/wrap-implicit"; +export type { ConvertibleScalar, ImplicitParjser } from "./internal/parser"; diff --git a/packages/parjs/src/internal/ParjsFailure.ts b/packages/parjs/src/internal/ParjsFailure.ts new file mode 100644 index 00000000..abf9358b --- /dev/null +++ b/packages/parjs/src/internal/ParjsFailure.ts @@ -0,0 +1,29 @@ +import { ParjsParsingFailure } from "../errors"; +import type { FailureInfo, Trace } from "./result"; +import { visualizeTrace } from "./trace-visualizer"; + +/** A failure result from a Parjs parser. */ + +export class ParjsFailure implements FailureInfo { + constructor(public trace: Trace) {} + + get value(): never { + throw new ParjsParsingFailure(this); + } + + get kind() { + return this.trace.kind; + } + + get reason() { + return this.trace.reason; + } + + toString() { + return visualizeTrace(this.trace); + } + /** Whether this result is an OK. */ + get isOk() { + return false; + } +} diff --git a/packages/parjs/src/internal/combinators/between.ts b/packages/parjs/src/internal/combinators/between.ts index 644082de..ef792de4 100644 --- a/packages/parjs/src/internal/combinators/between.ts +++ b/packages/parjs/src/internal/combinators/between.ts @@ -1,5 +1,5 @@ import type { ImplicitParjser, ParjsCombinator } from "../../index"; -import { wrapImplicit } from "../wrap-implicit"; +import { wrapImplicit } from "../parser"; import { defineCombinator } from "./combinator"; import { qthen, thenq } from "./then"; diff --git a/packages/parjs/src/internal/combinators/combinator.ts b/packages/parjs/src/internal/combinators/combinator.ts index d265cfd4..54ccac3a 100644 --- a/packages/parjs/src/internal/combinators/combinator.ts +++ b/packages/parjs/src/internal/combinators/combinator.ts @@ -1,6 +1,7 @@ -import type { ImplicitParjser, ParjsCombinator, Parjser } from "../../index"; import type { CombinatorInput } from "../combinated"; -import { wrapImplicit } from "../wrap-implicit"; +import type { ParjsCombinator, Parjser } from "../parjser"; +import type { ImplicitParjser } from "../parser"; +import { wrapImplicit } from "../parser"; /** * Represents the given function as a Parjs combinator. diff --git a/packages/parjs/src/internal/combinators/each.ts b/packages/parjs/src/internal/combinators/each.ts index 541d6e18..a1aab382 100644 --- a/packages/parjs/src/internal/combinators/each.ts +++ b/packages/parjs/src/internal/combinators/each.ts @@ -4,7 +4,7 @@ import type { ParjsCombinator, ParjsProjection } from "../parjser"; import type { CombinatorInput } from "../combinated"; import { Combinated } from "../combinated"; -import { wrapImplicit } from "../wrap-implicit"; +import { wrapImplicit } from "../parser"; class Each extends Combinated { type = "each"; diff --git a/packages/parjs/src/internal/combinators/exactly.ts b/packages/parjs/src/internal/combinators/exactly.ts index 6b64d452..4123f426 100644 --- a/packages/parjs/src/internal/combinators/exactly.ts +++ b/packages/parjs/src/internal/combinators/exactly.ts @@ -1,9 +1,9 @@ import type { ImplicitParjser } from "../../index"; import type { CombinatorInput } from "../combinated"; import { Combinated } from "../combinated"; +import { wrapImplicit } from "../parser"; import { ResultKind } from "../result"; import type { ParsingState } from "../state"; -import { wrapImplicit } from "../wrap-implicit"; class Exactly extends Combinated { type = "exactly"; diff --git a/packages/parjs/src/internal/combinators/index.ts b/packages/parjs/src/internal/combinators/index.ts index 891265b4..5568ae35 100644 --- a/packages/parjs/src/internal/combinators/index.ts +++ b/packages/parjs/src/internal/combinators/index.ts @@ -25,5 +25,5 @@ export type { ParserFailureState, RecoveryFunction } from "./recover"; export { replaceState } from "./replace-state"; export type { UserStateOrProjection } from "./replace-state"; export { stringify } from "./stringify"; -export { qthen, then, thenq } from "./then"; +export { qthen, thenceforth, thenq } from "./then"; export { thenPick } from "./then-pick"; diff --git a/packages/parjs/src/internal/combinators/many-sep-by.ts b/packages/parjs/src/internal/combinators/many-sep-by.ts index 31caad8a..ac7560ab 100644 --- a/packages/parjs/src/internal/combinators/many-sep-by.ts +++ b/packages/parjs/src/internal/combinators/many-sep-by.ts @@ -2,10 +2,9 @@ import type { ImplicitParjser, ParjsCombinator } from "../../index"; import type { CombinatorInput } from "../combinated"; import { Combinated } from "../combinated"; import { Issues } from "../issues"; -import type { ParjserBase } from "../parser"; +import { wrapImplicit, type ParjserBase } from "../parser"; import { ResultKind } from "../result"; import type { ParsingState } from "../state"; -import { wrapImplicit } from "../wrap-implicit"; export type ArrayWithSeparators = Normal[] & { separators: Separator[]; diff --git a/packages/parjs/src/internal/combinators/many-till.ts b/packages/parjs/src/internal/combinators/many-till.ts index 519b0f0e..09c21112 100644 --- a/packages/parjs/src/internal/combinators/many-till.ts +++ b/packages/parjs/src/internal/combinators/many-till.ts @@ -1,10 +1,11 @@ -import type { ImplicitParjser, ParjsCombinator } from "../../index"; +import type { ParjsCombinator } from "../../index"; import type { CombinatorInput } from "../combinated"; import { Combinated } from "../combinated"; import { Issues } from "../issues"; +import type { ImplicitParjser } from "../parser"; +import { wrapImplicit } from "../parser"; import { ResultKind } from "../result"; import type { ParsingState, UserState } from "../state"; -import { wrapImplicit } from "../wrap-implicit"; import { pipe } from "./combinator"; import { qthen } from "./then"; diff --git a/packages/parjs/src/internal/combinators/many.ts b/packages/parjs/src/internal/combinators/many.ts index 89b93392..f2b58d56 100644 --- a/packages/parjs/src/internal/combinators/many.ts +++ b/packages/parjs/src/internal/combinators/many.ts @@ -5,7 +5,7 @@ import type { ParsingState } from "../state"; import type { CombinatorInput } from "../combinated"; import { Combinated } from "../combinated"; -import { wrapImplicit } from "../wrap-implicit"; +import { wrapImplicit } from "../parser"; class Many extends Combinated { type = "many"; diff --git a/packages/parjs/src/internal/combinators/many1.ts b/packages/parjs/src/internal/combinators/many1.ts index 9aa75e8b..81c7f668 100644 --- a/packages/parjs/src/internal/combinators/many1.ts +++ b/packages/parjs/src/internal/combinators/many1.ts @@ -4,7 +4,7 @@ import type { ParjsCombinator } from "../parjser"; import type { ParjserBase } from "../parser"; import { ResultKind } from "../result"; import type { ParsingState } from "../state"; -import { wrapImplicit } from "../wrap-implicit"; +import { wrapImplicit } from "../parser"; class Many1 extends Combinated { type = "many1"; diff --git a/packages/parjs/src/internal/combinators/map.ts b/packages/parjs/src/internal/combinators/map.ts index 6c92ecbb..b792ed41 100644 --- a/packages/parjs/src/internal/combinators/map.ts +++ b/packages/parjs/src/internal/combinators/map.ts @@ -2,7 +2,7 @@ import { Combinated } from "../combinated"; import type { ParjsCombinator, ParjsProjection } from "../parjser"; import type { ParjserBase } from "../parser"; import type { ParsingState } from "../state"; -import { wrapImplicit } from "../wrap-implicit"; +import { wrapImplicit } from "../parser"; class Map extends Combinated { type = "map"; diff --git a/packages/parjs/src/internal/combinators/maybe.ts b/packages/parjs/src/internal/combinators/maybe.ts index ee081385..9924f113 100644 --- a/packages/parjs/src/internal/combinators/maybe.ts +++ b/packages/parjs/src/internal/combinators/maybe.ts @@ -3,7 +3,7 @@ import { Combinated } from "../combinated"; import type { ParjsCombinator } from "../parjser"; import { ResultKind } from "../result"; import type { ParsingState } from "../state"; -import { wrapImplicit } from "../wrap-implicit"; +import { wrapImplicit } from "../parser"; class MaybeCombinator extends Combinated { type = "maybe"; diff --git a/packages/parjs/src/internal/combinators/must-capture.ts b/packages/parjs/src/internal/combinators/must-capture.ts index 73f6737b..6b84087d 100644 --- a/packages/parjs/src/internal/combinators/must-capture.ts +++ b/packages/parjs/src/internal/combinators/must-capture.ts @@ -6,7 +6,7 @@ import type { ParjserBase } from "../parser"; import { defaults } from "../../utils"; import { Combinated } from "../combinated"; -import { wrapImplicit } from "../wrap-implicit"; +import { wrapImplicit } from "../parser"; const defaultFailure: FailureInfo = { reason: "succeeded without capturing input", diff --git a/packages/parjs/src/internal/combinators/must.ts b/packages/parjs/src/internal/combinators/must.ts index 1ff17da1..3a5fe3a8 100644 --- a/packages/parjs/src/internal/combinators/must.ts +++ b/packages/parjs/src/internal/combinators/must.ts @@ -3,7 +3,7 @@ import type { CombinatorInput } from "../combinated"; import { Combinated } from "../combinated"; import type { ParjsValidator } from "../parjser"; import type { ParsingState } from "../state"; -import { wrapImplicit } from "../wrap-implicit"; +import { wrapImplicit } from "../parser"; class Must extends Combinated { type = "must"; diff --git a/packages/parjs/src/internal/combinators/not.ts b/packages/parjs/src/internal/combinators/not.ts index 385a144f..0a544dc5 100644 --- a/packages/parjs/src/internal/combinators/not.ts +++ b/packages/parjs/src/internal/combinators/not.ts @@ -2,7 +2,7 @@ import type { ParjsCombinator } from "../../"; import { Combinated } from "../combinated"; import { ResultKind } from "../result"; import type { ParsingState } from "../state"; -import { wrapImplicit } from "../wrap-implicit"; +import { wrapImplicit } from "../parser"; class Not extends Combinated { type = "not"; diff --git a/packages/parjs/src/internal/combinators/or.ts b/packages/parjs/src/internal/combinators/or.ts index b153c5c1..89a13497 100644 --- a/packages/parjs/src/internal/combinators/or.ts +++ b/packages/parjs/src/internal/combinators/or.ts @@ -1,10 +1,10 @@ import type { CombinatorInput } from "../combinated"; import { Combinated } from "../combinated"; import type { ParjsCombinator } from "../parjser"; +import type { ImplicitParjser } from "../parser"; +import { wrapImplicit } from "../parser"; import { ResultKind } from "../result"; import type { ParsingState } from "../state"; -import type { ImplicitParjser } from "../wrap-implicit"; -import { wrapImplicit } from "../wrap-implicit"; import type { getParsedType } from "../util-types"; diff --git a/packages/parjs/src/internal/combinators/reason.ts b/packages/parjs/src/internal/combinators/reason.ts index 44fd9dcd..9d3cc9e4 100644 --- a/packages/parjs/src/internal/combinators/reason.ts +++ b/packages/parjs/src/internal/combinators/reason.ts @@ -1,10 +1,10 @@ import type { CombinatorInput } from "../combinated"; import { Combinated } from "../combinated"; import type { ParjsCombinator } from "../parjser"; +import type { ImplicitParjser } from "../parser"; +import { wrapImplicit } from "../parser"; import type { FailureInfo } from "../result"; import type { ParsingState } from "../state"; -import type { ImplicitParjser } from "../wrap-implicit"; -import { wrapImplicit } from "../wrap-implicit"; class Expects extends Combinated { type = "expects"; diff --git a/packages/parjs/src/internal/combinators/recover.ts b/packages/parjs/src/internal/combinators/recover.ts index 95c3da44..bcd23b8f 100644 --- a/packages/parjs/src/internal/combinators/recover.ts +++ b/packages/parjs/src/internal/combinators/recover.ts @@ -1,9 +1,9 @@ import type { ParjsCombinator } from "../../"; import type { CombinatorInput } from "../combinated"; import { Combinated } from "../combinated"; +import { wrapImplicit } from "../parser"; import type { FailureInfo, ResultKindFail, SuccessInfo } from "../result"; import type { ParsingState, UserState } from "../state"; -import { wrapImplicit } from "../wrap-implicit"; /** Information about the failure. */ export interface ParserFailureState { diff --git a/packages/parjs/src/internal/combinators/replace-state.ts b/packages/parjs/src/internal/combinators/replace-state.ts index e1051ad8..eaeef8ed 100644 --- a/packages/parjs/src/internal/combinators/replace-state.ts +++ b/packages/parjs/src/internal/combinators/replace-state.ts @@ -2,9 +2,8 @@ import type { ParjsCombinator, UserState } from "../../index"; import { defaults } from "../../utils"; import { Combinated } from "../combinated"; import type { ParjserBase } from "../parser"; -import { ParserUserState } from "../parser"; +import { ParserUserState, wrapImplicit } from "../parser"; import type { ParsingState } from "../state"; -import { wrapImplicit } from "../wrap-implicit"; /** A user state object or a projection to the external user state. */ export type UserStateOrProjection = UserState | ((externalState: UserState) => UserState); diff --git a/packages/parjs/src/internal/combinators/stringify.ts b/packages/parjs/src/internal/combinators/stringify.ts index 5f09cf58..a27230f6 100644 --- a/packages/parjs/src/internal/combinators/stringify.ts +++ b/packages/parjs/src/internal/combinators/stringify.ts @@ -1,8 +1,8 @@ import { Combinated } from "../combinated"; import { recJoin } from "../functions"; import type { ParjsCombinator } from "../parjser"; +import { wrapImplicit } from "../parser"; import type { ParsingState } from "../state"; -import { wrapImplicit } from "../wrap-implicit"; class Str extends Combinated { type = "stringify"; diff --git a/packages/parjs/src/internal/combinators/then-pick.ts b/packages/parjs/src/internal/combinators/then-pick.ts index fa9a321b..4ad744be 100644 --- a/packages/parjs/src/internal/combinators/then-pick.ts +++ b/packages/parjs/src/internal/combinators/then-pick.ts @@ -1,9 +1,8 @@ import type { CombinatorInput } from "../combinated"; import { Combinated } from "../combinated"; import type { ParjsCombinator, ParjsProjection } from "../parjser"; +import { wrapImplicit, type ImplicitParjser } from "../parser"; import type { ParsingState } from "../state"; -import type { ImplicitParjser } from "../wrap-implicit"; -import { wrapImplicit } from "../wrap-implicit"; class ThenPick extends Combinated { type = "then-pick"; diff --git a/packages/parjs/src/internal/combinators/then.ts b/packages/parjs/src/internal/combinators/then.ts index 7707575f..182bb15b 100644 --- a/packages/parjs/src/internal/combinators/then.ts +++ b/packages/parjs/src/internal/combinators/then.ts @@ -4,10 +4,10 @@ import type { ParsingState } from "../state"; import type { CombinatorInput } from "../combinated"; import { Combinated } from "../combinated"; -import { wrapImplicit } from "../wrap-implicit"; import { composeCombinator } from "./combinator"; import { map } from "./map"; +import { wrapImplicit } from "../parser"; import type { getParsedType } from "../util-types"; /** @@ -17,7 +17,7 @@ import type { getParsedType } from "../util-types"; */ export function qthen(next: ImplicitParjser): ParjsCombinator { return composeCombinator( - then(next), + thenceforth(next), map(arr => arr[1]) ); } @@ -29,7 +29,7 @@ export function qthen(next: ImplicitParjser): ParjsCombinator */ export function thenq(next: ImplicitParjser): ParjsCombinator { return composeCombinator( - then(next), + thenceforth(next), map(arr => arr[0]) ); } @@ -80,7 +80,7 @@ class Then[]> extends Combinated< } } -export function then[]>( +export function thenceforth[]>( ...parsers: Parsers ): ParjsCombinator }]> { const resolvedParsers = parsers.map(wrapImplicit) as { diff --git a/packages/parjs/src/internal/index.ts b/packages/parjs/src/internal/index.ts index b5c925f0..79bd1a4b 100644 --- a/packages/parjs/src/internal/index.ts +++ b/packages/parjs/src/internal/index.ts @@ -1,9 +1,10 @@ export { ParjserBase, ParserUserState } from "./parser"; export type { ParsingState, UserState } from "./state"; +export { ParjsFailure } from "./ParjsFailure"; export { composeCombinator, defineCombinator } from "./combinators"; export type { ParjsCombinator, ParjsProjection, ParjsValidator, Parjser } from "./parjser"; -export { regexp, string } from "./parser"; +export { regexp, string, wrapImplicit } from "./parser"; export { anyChar, anyCharOf, @@ -38,7 +39,6 @@ export { whitespace } from "./parsers"; export type { FloatOptions, IntOptions } from "./parsers"; -export { ParjsFailure, ParjsSuccess, ResultKind } from "./result"; +export { ParjsSuccess, ResultKind } from "./result"; export type { ErrorLocation, FailureInfo, ParjsResult, SuccessInfo, Trace } from "./result"; export { BasicParsingState, FAIL_RESULT, UNINITIALIZED_RESULT } from "./state"; -export { wrapImplicit } from "./wrap-implicit"; diff --git a/packages/parjs/src/internal/parjser.ts b/packages/parjs/src/internal/parjser.ts index cb0d9080..abd2d6ac 100644 --- a/packages/parjs/src/internal/parjser.ts +++ b/packages/parjs/src/internal/parjser.ts @@ -1,7 +1,6 @@ -import type { ParjserDebugFunction } from "./parser"; +import type { ImplicitParjser, ParjserDebugFunction } from "./parser"; import type { FailureInfo, ParjsResult } from "./result"; import type { ParsingState, UserState } from "./state"; -import type { ImplicitParjser } from "./wrap-implicit"; /** A combinator or operator that takes a source parser that returns a new parser based on it. */ export interface ParjsCombinator { @@ -30,7 +29,7 @@ export interface Parjser { readonly expecting: string; /** - * Exposes the display name of the parser. Userful when debugging. + * Exposes the display name of the parser. Useful when debugging. * * @group informational */ diff --git a/packages/parjs/src/internal/parser.ts b/packages/parjs/src/internal/parser.ts index 890a69e2..7bae7660 100644 --- a/packages/parjs/src/internal/parser.ts +++ b/packages/parjs/src/internal/parser.ts @@ -1,11 +1,12 @@ import { ParserDefinitionError } from "../errors"; import { clone, defaults } from "../utils"; +import { ParjsFailure } from "./ParjsFailure"; +import type { CombinatorInput } from "./combinated"; import type { ParjsCombinator, Parjser } from "./parjser"; import type { ErrorLocation, ParjsResult, Trace } from "./result"; -import { ParjsFailure, ParjsSuccess, ResultKind } from "./result"; +import { ParjsSuccess, ResultKind } from "./result"; import type { ParsingState, UserState } from "./state"; import { BasicParsingState, FAIL_RESULT, UNINITIALIZED_RESULT } from "./state"; -import { wrapImplicit } from "./wrap-implicit"; function getErrorLocation(ps: ParsingState) { const endln = /\r\n|\n|\r/g; @@ -141,7 +142,7 @@ export abstract class ParjserBase implements Parjser { } /** - * The internal operation performed by the PARSER. This will be overriden by derived classes. + * The internal operation performed by the PARSER. This will be overridden by derived classes. * * @param ps */ @@ -276,3 +277,45 @@ class ParseString extends ParjserBase { ps.kind = ResultKind.Ok; } } + +/** A {@link Parjser} or a literal value convertible to a {@link Parjser}. */ +/** + * @private Should Not be used from user code. Used to implement implicit parser literals. + * @type {symbol} + */ +export const convertibleSymbol: unique symbol = Symbol("ParjsConvertibleLiteral"); + +/** + * A literal type which is implicitly convertible to a parser. This normally includes the `string` + * and `RegExp` types. + */ +export interface ConvertibleScalar { + [convertibleSymbol](): Parjser; +} + +declare global { + interface String { + [convertibleSymbol](): Parjser; + } + + interface RegExp { + [convertibleSymbol](): Parjser; + } +} + +/** + * Either a Parjser or a scalar value convertible to one. + * + * @module parjs + */ +export type ImplicitParjser = Parjser | ConvertibleScalar; + +export function wrapImplicit(scalarOrParjser: ImplicitParjser): CombinatorInput { + if (typeof scalarOrParjser === "string") { + return string(scalarOrParjser) as unknown as CombinatorInput; + } else if (scalarOrParjser instanceof RegExp) { + return regexp(scalarOrParjser) as CombinatorInput; + } else { + return scalarOrParjser as CombinatorInput; + } +} diff --git a/packages/parjs/src/internal/result.ts b/packages/parjs/src/internal/result.ts index 7517cc1a..c0c79cac 100644 --- a/packages/parjs/src/internal/result.ts +++ b/packages/parjs/src/internal/result.ts @@ -1,6 +1,5 @@ -import { ParjsParsingFailure } from "../errors"; +import { ParjsFailure } from "./ParjsFailure"; import type { Parjser } from "./parjser"; -import { visualizeTrace } from "./trace-visualizer"; /** Indicates a success reply and contains the value and other information. */ export class ParjsSuccess implements SuccessInfo { @@ -46,31 +45,6 @@ export interface Trace extends FailureInfo { input: string; } -/** A failure result from a Parjs parser. */ -export class ParjsFailure implements FailureInfo { - constructor(public trace: Trace) {} - - get value(): never { - throw new ParjsParsingFailure(this); - } - - get kind() { - return this.trace.kind; - } - - get reason() { - return this.trace.reason; - } - - toString() { - return visualizeTrace(this.trace); - } - /** Whether this result is an OK. */ - get isOk() { - return false; - } -} - export function isParjsSuccess(x: unknown): x is ParjsSuccess { return x instanceof ParjsSuccess; } diff --git a/packages/parjs/src/internal/state.ts b/packages/parjs/src/internal/state.ts index 401b61e7..3b367d99 100644 --- a/packages/parjs/src/internal/state.ts +++ b/packages/parjs/src/internal/state.ts @@ -100,7 +100,7 @@ export class BasicParsingState implements ParsingState { } } -/** A unique object value indicating the reuslt of a failed parser. */ +/** A unique object value indicating the result of a failed parser. */ export const FAIL_RESULT = Object.create(null); /** * A unique object value indicating that a parser did not initialize the ParsingState's value diff --git a/packages/parjs/src/internal/util-types.ts b/packages/parjs/src/internal/util-types.ts index afdbbced..9c66de98 100644 --- a/packages/parjs/src/internal/util-types.ts +++ b/packages/parjs/src/internal/util-types.ts @@ -1,5 +1,5 @@ import type { Parjser } from "./parjser"; -import type { ImplicitParjser } from "./wrap-implicit"; +import type { ImplicitParjser } from "./parser"; export type union = Args extends [ infer A, diff --git a/packages/parjs/src/internal/wrap-implicit.ts b/packages/parjs/src/internal/wrap-implicit.ts deleted file mode 100644 index 0195b92c..00000000 --- a/packages/parjs/src/internal/wrap-implicit.ts +++ /dev/null @@ -1,46 +0,0 @@ -import type { Parjser } from "./parjser"; - -import type { CombinatorInput } from "./combinated"; -import { regexp, string } from "./parser"; - -/** A {@link Parjser} or a literal value convertible to a {@link Parjser}. */ -/** - * @private Should Not be used from user code. Used to implement implicit parser literals. - * @type {symbol} - */ -export const convertibleSymbol: unique symbol = Symbol("ParjsConvertibleLiteral"); - -/** - * A literal type which is implicitly convertible to a parser. This normally includes the `string` - * and `RegExp` types. - */ -export interface ConvertibleScalar { - [convertibleSymbol](): Parjser; -} - -declare global { - interface String { - [convertibleSymbol](): Parjser; - } - - interface RegExp { - [convertibleSymbol](): Parjser; - } -} - -/** - * Either a Parjser or a scalar value convertible to one. - * - * @module parjs - */ -export type ImplicitParjser = Parjser | ConvertibleScalar; - -export function wrapImplicit(scalarOrParjser: ImplicitParjser): CombinatorInput { - if (typeof scalarOrParjser === "string") { - return string(scalarOrParjser) as unknown as CombinatorInput; - } else if (scalarOrParjser instanceof RegExp) { - return regexp(scalarOrParjser) as CombinatorInput; - } else { - return scalarOrParjser as CombinatorInput; - } -} diff --git a/packages/parjs/tsconfig.tsbuildinfo b/packages/parjs/tsconfig.tsbuildinfo new file mode 100644 index 00000000..ed593788 --- /dev/null +++ b/packages/parjs/tsconfig.tsbuildinfo @@ -0,0 +1 @@ +{"program":{"fileNames":[],"fileInfos":[],"root":[],"options":{"composite":true},"referencedMap":[],"exportedModulesMap":[]},"version":"5.4.5"} \ No newline at end of file diff --git a/yarn.lock b/yarn.lock index 18af192d..05374986 100644 --- a/yarn.lock +++ b/yarn.lock @@ -22,6 +22,16 @@ __metadata: languageName: node linkType: hard +"@ampproject/remapping@npm:^2.3.0": + version: 2.3.0 + resolution: "@ampproject/remapping@npm:2.3.0" + dependencies: + "@jridgewell/gen-mapping": "npm:^0.3.5" + "@jridgewell/trace-mapping": "npm:^0.3.24" + checksum: 10c0/81d63cca5443e0f0c72ae18b544cc28c7c0ec2cea46e7cb888bb0e0f411a1191d0d6b7af798d54e30777d8d1488b2ec0732aac2be342d3d7d3ffd271c6f489ed + languageName: node + linkType: hard + "@babel/code-frame@npm:^7.0.0, @babel/code-frame@npm:^7.12.13, @babel/code-frame@npm:^7.23.5": version: 7.23.5 resolution: "@babel/code-frame@npm:7.23.5" @@ -668,6 +678,167 @@ __metadata: languageName: node linkType: hard +"@esbuild/aix-ppc64@npm:0.21.5": + version: 0.21.5 + resolution: "@esbuild/aix-ppc64@npm:0.21.5" + conditions: os=aix & cpu=ppc64 + languageName: node + linkType: hard + +"@esbuild/android-arm64@npm:0.21.5": + version: 0.21.5 + resolution: "@esbuild/android-arm64@npm:0.21.5" + conditions: os=android & cpu=arm64 + languageName: node + linkType: hard + +"@esbuild/android-arm@npm:0.21.5": + version: 0.21.5 + resolution: "@esbuild/android-arm@npm:0.21.5" + conditions: os=android & cpu=arm + languageName: node + linkType: hard + +"@esbuild/android-x64@npm:0.21.5": + version: 0.21.5 + resolution: "@esbuild/android-x64@npm:0.21.5" + conditions: os=android & cpu=x64 + languageName: node + linkType: hard + +"@esbuild/darwin-arm64@npm:0.21.5": + version: 0.21.5 + resolution: "@esbuild/darwin-arm64@npm:0.21.5" + conditions: os=darwin & cpu=arm64 + languageName: node + linkType: hard + +"@esbuild/darwin-x64@npm:0.21.5": + version: 0.21.5 + resolution: "@esbuild/darwin-x64@npm:0.21.5" + conditions: os=darwin & cpu=x64 + languageName: node + linkType: hard + +"@esbuild/freebsd-arm64@npm:0.21.5": + version: 0.21.5 + resolution: "@esbuild/freebsd-arm64@npm:0.21.5" + conditions: os=freebsd & cpu=arm64 + languageName: node + linkType: hard + +"@esbuild/freebsd-x64@npm:0.21.5": + version: 0.21.5 + resolution: "@esbuild/freebsd-x64@npm:0.21.5" + conditions: os=freebsd & cpu=x64 + languageName: node + linkType: hard + +"@esbuild/linux-arm64@npm:0.21.5": + version: 0.21.5 + resolution: "@esbuild/linux-arm64@npm:0.21.5" + conditions: os=linux & cpu=arm64 + languageName: node + linkType: hard + +"@esbuild/linux-arm@npm:0.21.5": + version: 0.21.5 + resolution: "@esbuild/linux-arm@npm:0.21.5" + conditions: os=linux & cpu=arm + languageName: node + linkType: hard + +"@esbuild/linux-ia32@npm:0.21.5": + version: 0.21.5 + resolution: "@esbuild/linux-ia32@npm:0.21.5" + conditions: os=linux & cpu=ia32 + languageName: node + linkType: hard + +"@esbuild/linux-loong64@npm:0.21.5": + version: 0.21.5 + resolution: "@esbuild/linux-loong64@npm:0.21.5" + conditions: os=linux & cpu=loong64 + languageName: node + linkType: hard + +"@esbuild/linux-mips64el@npm:0.21.5": + version: 0.21.5 + resolution: "@esbuild/linux-mips64el@npm:0.21.5" + conditions: os=linux & cpu=mips64el + languageName: node + linkType: hard + +"@esbuild/linux-ppc64@npm:0.21.5": + version: 0.21.5 + resolution: "@esbuild/linux-ppc64@npm:0.21.5" + conditions: os=linux & cpu=ppc64 + languageName: node + linkType: hard + +"@esbuild/linux-riscv64@npm:0.21.5": + version: 0.21.5 + resolution: "@esbuild/linux-riscv64@npm:0.21.5" + conditions: os=linux & cpu=riscv64 + languageName: node + linkType: hard + +"@esbuild/linux-s390x@npm:0.21.5": + version: 0.21.5 + resolution: "@esbuild/linux-s390x@npm:0.21.5" + conditions: os=linux & cpu=s390x + languageName: node + linkType: hard + +"@esbuild/linux-x64@npm:0.21.5": + version: 0.21.5 + resolution: "@esbuild/linux-x64@npm:0.21.5" + conditions: os=linux & cpu=x64 + languageName: node + linkType: hard + +"@esbuild/netbsd-x64@npm:0.21.5": + version: 0.21.5 + resolution: "@esbuild/netbsd-x64@npm:0.21.5" + conditions: os=netbsd & cpu=x64 + languageName: node + linkType: hard + +"@esbuild/openbsd-x64@npm:0.21.5": + version: 0.21.5 + resolution: "@esbuild/openbsd-x64@npm:0.21.5" + conditions: os=openbsd & cpu=x64 + languageName: node + linkType: hard + +"@esbuild/sunos-x64@npm:0.21.5": + version: 0.21.5 + resolution: "@esbuild/sunos-x64@npm:0.21.5" + conditions: os=sunos & cpu=x64 + languageName: node + linkType: hard + +"@esbuild/win32-arm64@npm:0.21.5": + version: 0.21.5 + resolution: "@esbuild/win32-arm64@npm:0.21.5" + conditions: os=win32 & cpu=arm64 + languageName: node + linkType: hard + +"@esbuild/win32-ia32@npm:0.21.5": + version: 0.21.5 + resolution: "@esbuild/win32-ia32@npm:0.21.5" + conditions: os=win32 & cpu=ia32 + languageName: node + linkType: hard + +"@esbuild/win32-x64@npm:0.21.5": + version: 0.21.5 + resolution: "@esbuild/win32-x64@npm:0.21.5" + conditions: os=win32 & cpu=x64 + languageName: node + linkType: hard + "@eslint-community/eslint-utils@npm:^4.2.0, @eslint-community/eslint-utils@npm:^4.4.0": version: 4.4.0 resolution: "@eslint-community/eslint-utils@npm:4.4.0" @@ -1071,6 +1242,13 @@ __metadata: languageName: node linkType: hard +"@jridgewell/sourcemap-codec@npm:^1.5.0": + version: 1.5.0 + resolution: "@jridgewell/sourcemap-codec@npm:1.5.0" + checksum: 10c0/2eb864f276eb1096c3c11da3e9bb518f6d9fc0023c78344cdc037abadc725172c70314bdb360f2d4b7bffec7f5d657ce006816bc5d4ecb35e61b66132db00c18 + languageName: node + linkType: hard + "@jridgewell/trace-mapping@npm:0.3.9": version: 0.3.9 resolution: "@jridgewell/trace-mapping@npm:0.3.9" @@ -1164,6 +1342,118 @@ __metadata: languageName: node linkType: hard +"@rollup/rollup-android-arm-eabi@npm:4.19.1": + version: 4.19.1 + resolution: "@rollup/rollup-android-arm-eabi@npm:4.19.1" + conditions: os=android & cpu=arm + languageName: node + linkType: hard + +"@rollup/rollup-android-arm64@npm:4.19.1": + version: 4.19.1 + resolution: "@rollup/rollup-android-arm64@npm:4.19.1" + conditions: os=android & cpu=arm64 + languageName: node + linkType: hard + +"@rollup/rollup-darwin-arm64@npm:4.19.1": + version: 4.19.1 + resolution: "@rollup/rollup-darwin-arm64@npm:4.19.1" + conditions: os=darwin & cpu=arm64 + languageName: node + linkType: hard + +"@rollup/rollup-darwin-x64@npm:4.19.1": + version: 4.19.1 + resolution: "@rollup/rollup-darwin-x64@npm:4.19.1" + conditions: os=darwin & cpu=x64 + languageName: node + linkType: hard + +"@rollup/rollup-linux-arm-gnueabihf@npm:4.19.1": + version: 4.19.1 + resolution: "@rollup/rollup-linux-arm-gnueabihf@npm:4.19.1" + conditions: os=linux & cpu=arm & libc=glibc + languageName: node + linkType: hard + +"@rollup/rollup-linux-arm-musleabihf@npm:4.19.1": + version: 4.19.1 + resolution: "@rollup/rollup-linux-arm-musleabihf@npm:4.19.1" + conditions: os=linux & cpu=arm & libc=musl + languageName: node + linkType: hard + +"@rollup/rollup-linux-arm64-gnu@npm:4.19.1": + version: 4.19.1 + resolution: "@rollup/rollup-linux-arm64-gnu@npm:4.19.1" + conditions: os=linux & cpu=arm64 & libc=glibc + languageName: node + linkType: hard + +"@rollup/rollup-linux-arm64-musl@npm:4.19.1": + version: 4.19.1 + resolution: "@rollup/rollup-linux-arm64-musl@npm:4.19.1" + conditions: os=linux & cpu=arm64 & libc=musl + languageName: node + linkType: hard + +"@rollup/rollup-linux-powerpc64le-gnu@npm:4.19.1": + version: 4.19.1 + resolution: "@rollup/rollup-linux-powerpc64le-gnu@npm:4.19.1" + conditions: os=linux & cpu=ppc64 & libc=glibc + languageName: node + linkType: hard + +"@rollup/rollup-linux-riscv64-gnu@npm:4.19.1": + version: 4.19.1 + resolution: "@rollup/rollup-linux-riscv64-gnu@npm:4.19.1" + conditions: os=linux & cpu=riscv64 & libc=glibc + languageName: node + linkType: hard + +"@rollup/rollup-linux-s390x-gnu@npm:4.19.1": + version: 4.19.1 + resolution: "@rollup/rollup-linux-s390x-gnu@npm:4.19.1" + conditions: os=linux & cpu=s390x & libc=glibc + languageName: node + linkType: hard + +"@rollup/rollup-linux-x64-gnu@npm:4.19.1": + version: 4.19.1 + resolution: "@rollup/rollup-linux-x64-gnu@npm:4.19.1" + conditions: os=linux & cpu=x64 & libc=glibc + languageName: node + linkType: hard + +"@rollup/rollup-linux-x64-musl@npm:4.19.1": + version: 4.19.1 + resolution: "@rollup/rollup-linux-x64-musl@npm:4.19.1" + conditions: os=linux & cpu=x64 & libc=musl + languageName: node + linkType: hard + +"@rollup/rollup-win32-arm64-msvc@npm:4.19.1": + version: 4.19.1 + resolution: "@rollup/rollup-win32-arm64-msvc@npm:4.19.1" + conditions: os=win32 & cpu=arm64 + languageName: node + linkType: hard + +"@rollup/rollup-win32-ia32-msvc@npm:4.19.1": + version: 4.19.1 + resolution: "@rollup/rollup-win32-ia32-msvc@npm:4.19.1" + conditions: os=win32 & cpu=ia32 + languageName: node + linkType: hard + +"@rollup/rollup-win32-x64-msvc@npm:4.19.1": + version: 4.19.1 + resolution: "@rollup/rollup-win32-x64-msvc@npm:4.19.1" + conditions: os=win32 & cpu=x64 + languageName: node + linkType: hard + "@sinclair/typebox@npm:^0.27.8": version: 0.27.8 resolution: "@sinclair/typebox@npm:0.27.8" @@ -1425,6 +1715,13 @@ __metadata: languageName: node linkType: hard +"@types/estree@npm:1.0.5, @types/estree@npm:^1.0.0": + version: 1.0.5 + resolution: "@types/estree@npm:1.0.5" + checksum: 10c0/b3b0e334288ddb407c7b3357ca67dbee75ee22db242ca7c56fe27db4e1a31989cb8af48a84dd401deb787fe10cc6b2ab1ee82dc4783be87ededbe3d53c79c70d + languageName: node + linkType: hard + "@types/graceful-fs@npm:^4.1.3": version: 4.1.9 resolution: "@types/graceful-fs@npm:4.1.9" @@ -1846,6 +2143,69 @@ __metadata: languageName: node linkType: hard +"@vitest/expect@npm:2.0.5": + version: 2.0.5 + resolution: "@vitest/expect@npm:2.0.5" + dependencies: + "@vitest/spy": "npm:2.0.5" + "@vitest/utils": "npm:2.0.5" + chai: "npm:^5.1.1" + tinyrainbow: "npm:^1.2.0" + checksum: 10c0/08cb1b0f106d16a5b60db733e3d436fa5eefc68571488eb570dfe4f599f214ab52e4342273b03dbe12331cc6c0cdc325ac6c94f651ad254cd62f3aa0e3d185aa + languageName: node + linkType: hard + +"@vitest/pretty-format@npm:2.0.5, @vitest/pretty-format@npm:^2.0.5": + version: 2.0.5 + resolution: "@vitest/pretty-format@npm:2.0.5" + dependencies: + tinyrainbow: "npm:^1.2.0" + checksum: 10c0/236c0798c5170a0b5ad5d4bd06118533738e820b4dd30079d8fbcb15baee949d41c60f42a9f769906c4a5ce366d7ef11279546070646c0efc03128c220c31f37 + languageName: node + linkType: hard + +"@vitest/runner@npm:2.0.5": + version: 2.0.5 + resolution: "@vitest/runner@npm:2.0.5" + dependencies: + "@vitest/utils": "npm:2.0.5" + pathe: "npm:^1.1.2" + checksum: 10c0/d0ed3302a7e015bf44b7c0df9d8f7da163659e082d86f9406944b5a31a61ab9ddc1de530e06176d1f4ef0bde994b44bff4c7dab62aacdc235c8fc04b98e4a72a + languageName: node + linkType: hard + +"@vitest/snapshot@npm:2.0.5": + version: 2.0.5 + resolution: "@vitest/snapshot@npm:2.0.5" + dependencies: + "@vitest/pretty-format": "npm:2.0.5" + magic-string: "npm:^0.30.10" + pathe: "npm:^1.1.2" + checksum: 10c0/7bf38474248f5ae0aac6afad511785d2b7a023ac5158803c2868fd172b5b9c1a569fb1dd64a09a49e43fd342cab71ea485ada89b7f08d37b1622a5a0ac00271d + languageName: node + linkType: hard + +"@vitest/spy@npm:2.0.5": + version: 2.0.5 + resolution: "@vitest/spy@npm:2.0.5" + dependencies: + tinyspy: "npm:^3.0.0" + checksum: 10c0/70634c21921eb271b54d2986c21d7ab6896a31c0f4f1d266940c9bafb8ac36237846d6736638cbf18b958bd98e5261b158a6944352742accfde50b7818ff655e + languageName: node + linkType: hard + +"@vitest/utils@npm:2.0.5": + version: 2.0.5 + resolution: "@vitest/utils@npm:2.0.5" + dependencies: + "@vitest/pretty-format": "npm:2.0.5" + estree-walker: "npm:^3.0.3" + loupe: "npm:^3.1.1" + tinyrainbow: "npm:^1.2.0" + checksum: 10c0/0d1de748298f07a50281e1ba058b05dcd58da3280c14e6f016265e950bd79adab6b97822de8f0ea82d3070f585654801a9b1bcf26db4372e51cf7746bf86d73b + languageName: node + linkType: hard + "abbrev@npm:^2.0.0": version: 2.0.0 resolution: "abbrev@npm:2.0.0" @@ -2113,6 +2473,13 @@ __metadata: languageName: node linkType: hard +"assertion-error@npm:^2.0.1": + version: 2.0.1 + resolution: "assertion-error@npm:2.0.1" + checksum: 10c0/bbbcb117ac6480138f8c93cf7f535614282dea9dc828f540cdece85e3c665e8f78958b96afac52f29ff883c72638e6a87d469ecc9fe5bc902df03ed24a55dba8 + languageName: node + linkType: hard + "ast-module-types@npm:^2.7.1": version: 2.7.1 resolution: "ast-module-types@npm:2.7.1" @@ -2429,6 +2796,13 @@ __metadata: languageName: node linkType: hard +"cac@npm:^6.7.14": + version: 6.7.14 + resolution: "cac@npm:6.7.14" + checksum: 10c0/4ee06aaa7bab8981f0d54e5f5f9d4adcd64058e9697563ce336d8a3878ed018ee18ebe5359b2430eceae87e0758e62ea2019c3f52ae6e211b1bd2e133856cd10 + languageName: node + linkType: hard + "cacache@npm:^18.0.0": version: 18.0.2 resolution: "cacache@npm:18.0.2" @@ -2516,6 +2890,19 @@ __metadata: languageName: node linkType: hard +"chai@npm:^5.1.1": + version: 5.1.1 + resolution: "chai@npm:5.1.1" + dependencies: + assertion-error: "npm:^2.0.1" + check-error: "npm:^2.1.1" + deep-eql: "npm:^5.0.1" + loupe: "npm:^3.1.0" + pathval: "npm:^2.0.0" + checksum: 10c0/e7f00e5881e3d5224f08fe63966ed6566bd9fdde175863c7c16dd5240416de9b34c4a0dd925f4fd64ad56256ca6507d32cf6131c49e1db65c62578eb31d4566c + languageName: node + linkType: hard + "chalk@npm:5.3.0": version: 5.3.0 resolution: "chalk@npm:5.3.0" @@ -2582,6 +2969,13 @@ __metadata: languageName: node linkType: hard +"check-error@npm:^2.1.1": + version: 2.1.1 + resolution: "check-error@npm:2.1.1" + checksum: 10c0/979f13eccab306cf1785fa10941a590b4e7ea9916ea2a4f8c87f0316fc3eab07eabefb6e587424ef0f88cbcd3805791f172ea739863ca3d7ce2afc54641c7f0e + languageName: node + linkType: hard + "chokidar@npm:^3.4.3": version: 3.6.0 resolution: "chokidar@npm:3.6.0" @@ -3012,6 +3406,18 @@ __metadata: languageName: node linkType: hard +"debug@npm:^4.3.5": + version: 4.3.6 + resolution: "debug@npm:4.3.6" + dependencies: + ms: "npm:2.1.2" + peerDependenciesMeta: + supports-color: + optional: true + checksum: 10c0/3293416bff072389c101697d4611c402a6bacd1900ac20c0492f61a9cdd6b3b29750fc7f5e299f8058469ef60ff8fb79b86395a30374fbd2490113c1c7112285 + languageName: node + linkType: hard + "decamelize@npm:^1.2.0": version: 1.2.0 resolution: "decamelize@npm:1.2.0" @@ -3049,6 +3455,13 @@ __metadata: languageName: node linkType: hard +"deep-eql@npm:^5.0.1": + version: 5.0.2 + resolution: "deep-eql@npm:5.0.2" + checksum: 10c0/7102cf3b7bb719c6b9c0db2e19bf0aa9318d141581befe8c7ce8ccd39af9eaa4346e5e05adef7f9bd7015da0f13a3a25dcfe306ef79dc8668aedbecb658dd247 + languageName: node + linkType: hard + "deep-extend@npm:^0.6.0": version: 0.6.0 resolution: "deep-extend@npm:0.6.0" @@ -3609,6 +4022,86 @@ __metadata: languageName: node linkType: hard +"esbuild@npm:^0.21.3": + version: 0.21.5 + resolution: "esbuild@npm:0.21.5" + dependencies: + "@esbuild/aix-ppc64": "npm:0.21.5" + "@esbuild/android-arm": "npm:0.21.5" + "@esbuild/android-arm64": "npm:0.21.5" + "@esbuild/android-x64": "npm:0.21.5" + "@esbuild/darwin-arm64": "npm:0.21.5" + "@esbuild/darwin-x64": "npm:0.21.5" + "@esbuild/freebsd-arm64": "npm:0.21.5" + "@esbuild/freebsd-x64": "npm:0.21.5" + "@esbuild/linux-arm": "npm:0.21.5" + "@esbuild/linux-arm64": "npm:0.21.5" + "@esbuild/linux-ia32": "npm:0.21.5" + "@esbuild/linux-loong64": "npm:0.21.5" + "@esbuild/linux-mips64el": "npm:0.21.5" + "@esbuild/linux-ppc64": "npm:0.21.5" + "@esbuild/linux-riscv64": "npm:0.21.5" + "@esbuild/linux-s390x": "npm:0.21.5" + "@esbuild/linux-x64": "npm:0.21.5" + "@esbuild/netbsd-x64": "npm:0.21.5" + "@esbuild/openbsd-x64": "npm:0.21.5" + "@esbuild/sunos-x64": "npm:0.21.5" + "@esbuild/win32-arm64": "npm:0.21.5" + "@esbuild/win32-ia32": "npm:0.21.5" + "@esbuild/win32-x64": "npm:0.21.5" + dependenciesMeta: + "@esbuild/aix-ppc64": + optional: true + "@esbuild/android-arm": + optional: true + "@esbuild/android-arm64": + optional: true + "@esbuild/android-x64": + optional: true + "@esbuild/darwin-arm64": + optional: true + "@esbuild/darwin-x64": + optional: true + "@esbuild/freebsd-arm64": + optional: true + "@esbuild/freebsd-x64": + optional: true + "@esbuild/linux-arm": + optional: true + "@esbuild/linux-arm64": + optional: true + "@esbuild/linux-ia32": + optional: true + "@esbuild/linux-loong64": + optional: true + "@esbuild/linux-mips64el": + optional: true + "@esbuild/linux-ppc64": + optional: true + "@esbuild/linux-riscv64": + optional: true + "@esbuild/linux-s390x": + optional: true + "@esbuild/linux-x64": + optional: true + "@esbuild/netbsd-x64": + optional: true + "@esbuild/openbsd-x64": + optional: true + "@esbuild/sunos-x64": + optional: true + "@esbuild/win32-arm64": + optional: true + "@esbuild/win32-ia32": + optional: true + "@esbuild/win32-x64": + optional: true + bin: + esbuild: bin/esbuild + checksum: 10c0/fa08508adf683c3f399e8a014a6382a6b65542213431e26206c0720e536b31c09b50798747c2a105a4bbba1d9767b8d3615a74c2f7bf1ddf6d836cd11eb672de + languageName: node + linkType: hard + "escalade@npm:^3.1.1": version: 3.1.2 resolution: "escalade@npm:3.1.2" @@ -3809,6 +4302,15 @@ __metadata: languageName: node linkType: hard +"estree-walker@npm:^3.0.3": + version: 3.0.3 + resolution: "estree-walker@npm:3.0.3" + dependencies: + "@types/estree": "npm:^1.0.0" + checksum: 10c0/c12e3c2b2642d2bcae7d5aa495c60fa2f299160946535763969a1c83fc74518ffa9c2cd3a8b69ac56aea547df6a8aac25f729a342992ef0bbac5f1c73e78995d + languageName: node + linkType: hard + "esutils@npm:^2.0.2, esutils@npm:^2.0.3": version: 2.0.3 resolution: "esutils@npm:2.0.3" @@ -3823,7 +4325,7 @@ __metadata: languageName: node linkType: hard -"execa@npm:8.0.1": +"execa@npm:8.0.1, execa@npm:^8.0.1": version: 8.0.1 resolution: "execa@npm:8.0.1" dependencies: @@ -4128,7 +4630,7 @@ __metadata: languageName: node linkType: hard -"fsevents@npm:^2.3.2, fsevents@npm:~2.3.2": +"fsevents@npm:^2.3.2, fsevents@npm:~2.3.2, fsevents@npm:~2.3.3": version: 2.3.3 resolution: "fsevents@npm:2.3.3" dependencies: @@ -4138,7 +4640,7 @@ __metadata: languageName: node linkType: hard -"fsevents@patch:fsevents@npm%3A^2.3.2#optional!builtin, fsevents@patch:fsevents@npm%3A~2.3.2#optional!builtin": +"fsevents@patch:fsevents@npm%3A^2.3.2#optional!builtin, fsevents@patch:fsevents@npm%3A~2.3.2#optional!builtin, fsevents@patch:fsevents@npm%3A~2.3.3#optional!builtin": version: 2.3.3 resolution: "fsevents@patch:fsevents@npm%3A2.3.3#optional!builtin::version=2.3.3&hash=df0bf1" dependencies: @@ -4214,6 +4716,13 @@ __metadata: languageName: node linkType: hard +"get-func-name@npm:^2.0.1": + version: 2.0.2 + resolution: "get-func-name@npm:2.0.2" + checksum: 10c0/89830fd07623fa73429a711b9daecdb304386d237c71268007f788f113505ef1d4cc2d0b9680e072c5082490aec9df5d7758bf5ac6f1c37062855e8e3dc0b9df + languageName: node + linkType: hard + "get-intrinsic@npm:^1.1.3, get-intrinsic@npm:^1.2.1, get-intrinsic@npm:^1.2.2, get-intrinsic@npm:^1.2.3, get-intrinsic@npm:^1.2.4": version: 1.2.4 resolution: "get-intrinsic@npm:1.2.4" @@ -6001,6 +6510,15 @@ __metadata: languageName: node linkType: hard +"loupe@npm:^3.1.0, loupe@npm:^3.1.1": + version: 3.1.1 + resolution: "loupe@npm:3.1.1" + dependencies: + get-func-name: "npm:^2.0.1" + checksum: 10c0/99f88badc47e894016df0c403de846fedfea61154aadabbf776c8428dd59e8d8378007135d385d737de32ae47980af07d22ba7bec5ef7beebd721de9baa0a0af + languageName: node + linkType: hard + "lowercase-keys@npm:^1.0.0, lowercase-keys@npm:^1.0.1": version: 1.0.1 resolution: "lowercase-keys@npm:1.0.1" @@ -6084,6 +6602,15 @@ __metadata: languageName: node linkType: hard +"magic-string@npm:^0.30.10": + version: 0.30.11 + resolution: "magic-string@npm:0.30.11" + dependencies: + "@jridgewell/sourcemap-codec": "npm:^1.5.0" + checksum: 10c0/b9eb370773d0bd90ca11a848753409d8e5309b1ad56d2a1aa49d6649da710a6d2fe7237ad1a643c5a5d3800de2b9946ed9690acdfc00e6cc1aeafff3ab1752c4 + languageName: node + linkType: hard + "make-dir@npm:^3.0.0, make-dir@npm:^3.0.2": version: 3.1.0 resolution: "make-dir@npm:3.1.0" @@ -7257,6 +7784,32 @@ __metadata: languageName: node linkType: hard +"pathe@npm:^1.1.2": + version: 1.1.2 + resolution: "pathe@npm:1.1.2" + checksum: 10c0/64ee0a4e587fb0f208d9777a6c56e4f9050039268faaaaecd50e959ef01bf847b7872785c36483fa5cdcdbdfdb31fef2ff222684d4fc21c330ab60395c681897 + languageName: node + linkType: hard + +"pathval@npm:^2.0.0": + version: 2.0.0 + resolution: "pathval@npm:2.0.0" + checksum: 10c0/602e4ee347fba8a599115af2ccd8179836a63c925c23e04bd056d0674a64b39e3a081b643cc7bc0b84390517df2d800a46fcc5598d42c155fe4977095c2f77c5 + languageName: node + linkType: hard + +"perror@workspace:packages/parjs-vitest-error": + version: 0.0.0-use.local + resolution: "perror@workspace:packages/parjs-vitest-error" + dependencies: + typescript: "npm:5.5.4" + vite: "npm:5.4.0" + vitest: "npm:2.0.5" + peerDependencies: + parjs: "*" + languageName: unknown + linkType: soft + "picocolors@npm:^1.0.0": version: 1.0.0 resolution: "picocolors@npm:1.0.0" @@ -7264,6 +7817,13 @@ __metadata: languageName: node linkType: hard +"picocolors@npm:^1.0.1": + version: 1.0.1 + resolution: "picocolors@npm:1.0.1" + checksum: 10c0/c63cdad2bf812ef0d66c8db29583802355d4ca67b9285d846f390cc15c2f6ccb94e8cb7eb6a6e97fc5990a6d3ad4ae42d86c84d3146e667c739a4234ed50d400 + languageName: node + linkType: hard + "picomatch@npm:^2.0.4, picomatch@npm:^2.2.1, picomatch@npm:^2.2.2, picomatch@npm:^2.2.3, picomatch@npm:^2.3.1": version: 2.3.1 resolution: "picomatch@npm:2.3.1" @@ -7380,6 +7940,17 @@ __metadata: languageName: node linkType: hard +"postcss@npm:^8.4.40": + version: 8.4.41 + resolution: "postcss@npm:8.4.41" + dependencies: + nanoid: "npm:^3.3.7" + picocolors: "npm:^1.0.1" + source-map-js: "npm:^1.2.0" + checksum: 10c0/c1828fc59e7ec1a3bf52b3a42f615dba53c67960ed82a81df6441b485fe43c20aba7f4e7c55425762fd99c594ecabbaaba8cf5b30fd79dfec5b52a9f63a2d690 + languageName: node + linkType: hard + "precinct@npm:^8.1.0": version: 8.3.1 resolution: "precinct@npm:8.3.1" @@ -7866,6 +8437,69 @@ __metadata: languageName: node linkType: hard +"rollup@npm:^4.13.0": + version: 4.19.1 + resolution: "rollup@npm:4.19.1" + dependencies: + "@rollup/rollup-android-arm-eabi": "npm:4.19.1" + "@rollup/rollup-android-arm64": "npm:4.19.1" + "@rollup/rollup-darwin-arm64": "npm:4.19.1" + "@rollup/rollup-darwin-x64": "npm:4.19.1" + "@rollup/rollup-linux-arm-gnueabihf": "npm:4.19.1" + "@rollup/rollup-linux-arm-musleabihf": "npm:4.19.1" + "@rollup/rollup-linux-arm64-gnu": "npm:4.19.1" + "@rollup/rollup-linux-arm64-musl": "npm:4.19.1" + "@rollup/rollup-linux-powerpc64le-gnu": "npm:4.19.1" + "@rollup/rollup-linux-riscv64-gnu": "npm:4.19.1" + "@rollup/rollup-linux-s390x-gnu": "npm:4.19.1" + "@rollup/rollup-linux-x64-gnu": "npm:4.19.1" + "@rollup/rollup-linux-x64-musl": "npm:4.19.1" + "@rollup/rollup-win32-arm64-msvc": "npm:4.19.1" + "@rollup/rollup-win32-ia32-msvc": "npm:4.19.1" + "@rollup/rollup-win32-x64-msvc": "npm:4.19.1" + "@types/estree": "npm:1.0.5" + fsevents: "npm:~2.3.2" + dependenciesMeta: + "@rollup/rollup-android-arm-eabi": + optional: true + "@rollup/rollup-android-arm64": + optional: true + "@rollup/rollup-darwin-arm64": + optional: true + "@rollup/rollup-darwin-x64": + optional: true + "@rollup/rollup-linux-arm-gnueabihf": + optional: true + "@rollup/rollup-linux-arm-musleabihf": + optional: true + "@rollup/rollup-linux-arm64-gnu": + optional: true + "@rollup/rollup-linux-arm64-musl": + optional: true + "@rollup/rollup-linux-powerpc64le-gnu": + optional: true + "@rollup/rollup-linux-riscv64-gnu": + optional: true + "@rollup/rollup-linux-s390x-gnu": + optional: true + "@rollup/rollup-linux-x64-gnu": + optional: true + "@rollup/rollup-linux-x64-musl": + optional: true + "@rollup/rollup-win32-arm64-msvc": + optional: true + "@rollup/rollup-win32-ia32-msvc": + optional: true + "@rollup/rollup-win32-x64-msvc": + optional: true + fsevents: + optional: true + bin: + rollup: dist/bin/rollup + checksum: 10c0/2e526c38b4bcb22a058cf95e40c8c105a86f27d582c677c47df9315a17b18e75c772edc0773ca4d12d58ceca254bb5d63d4172041f6fd9f01e1a613d8bba6d09 + languageName: node + linkType: hard + "root-workspace-0b6124@workspace:.": version: 0.0.0-use.local resolution: "root-workspace-0b6124@workspace:." @@ -8135,6 +8769,13 @@ __metadata: languageName: node linkType: hard +"siginfo@npm:^2.0.0": + version: 2.0.0 + resolution: "siginfo@npm:2.0.0" + checksum: 10c0/3def8f8e516fbb34cb6ae415b07ccc5d9c018d85b4b8611e3dc6f8be6d1899f693a4382913c9ed51a06babb5201639d76453ab297d1c54a456544acf5c892e34 + languageName: node + linkType: hard + "signal-exit@npm:^3.0.2, signal-exit@npm:^3.0.3, signal-exit@npm:^3.0.7": version: 3.0.7 resolution: "signal-exit@npm:3.0.7" @@ -8261,6 +8902,13 @@ __metadata: languageName: node linkType: hard +"source-map-js@npm:^1.2.0": + version: 1.2.0 + resolution: "source-map-js@npm:1.2.0" + checksum: 10c0/7e5f896ac10a3a50fe2898e5009c58ff0dc102dcb056ed27a354623a0ece8954d4b2649e1a1b2b52ef2e161d26f8859c7710350930751640e71e374fe2d321a4 + languageName: node + linkType: hard + "source-map-support@npm:0.5.13": version: 0.5.13 resolution: "source-map-support@npm:0.5.13" @@ -8361,6 +9009,20 @@ __metadata: languageName: node linkType: hard +"stackback@npm:0.0.2": + version: 0.0.2 + resolution: "stackback@npm:0.0.2" + checksum: 10c0/89a1416668f950236dd5ac9f9a6b2588e1b9b62b1b6ad8dff1bfc5d1a15dbf0aafc9b52d2226d00c28dffff212da464eaeebfc6b7578b9d180cef3e3782c5983 + languageName: node + linkType: hard + +"std-env@npm:^3.7.0": + version: 3.7.0 + resolution: "std-env@npm:3.7.0" + checksum: 10c0/60edf2d130a4feb7002974af3d5a5f3343558d1ccf8d9b9934d225c638606884db4a20d2fe6440a09605bca282af6b042ae8070a10490c0800d69e82e478f41e + languageName: node + linkType: hard + "stream-to-array@npm:^2.3.0": version: 2.3.0 resolution: "stream-to-array@npm:2.3.0" @@ -8666,6 +9328,34 @@ __metadata: languageName: node linkType: hard +"tinybench@npm:^2.8.0": + version: 2.9.0 + resolution: "tinybench@npm:2.9.0" + checksum: 10c0/c3500b0f60d2eb8db65250afe750b66d51623057ee88720b7f064894a6cb7eb93360ca824a60a31ab16dab30c7b1f06efe0795b352e37914a9d4bad86386a20c + languageName: node + linkType: hard + +"tinypool@npm:^1.0.0": + version: 1.0.0 + resolution: "tinypool@npm:1.0.0" + checksum: 10c0/71b20b9c54366393831c286a0772380c20f8cad9546d724c484edb47aea3228f274c58e98cf51d28c40869b39f5273209ef3ea94a9d2a23f8b292f4731cd3e4e + languageName: node + linkType: hard + +"tinyrainbow@npm:^1.2.0": + version: 1.2.0 + resolution: "tinyrainbow@npm:1.2.0" + checksum: 10c0/7f78a4b997e5ba0f5ecb75e7ed786f30bab9063716e7dff24dd84013fb338802e43d176cb21ed12480561f5649a82184cf31efb296601a29d38145b1cdb4c192 + languageName: node + linkType: hard + +"tinyspy@npm:^3.0.0": + version: 3.0.0 + resolution: "tinyspy@npm:3.0.0" + checksum: 10c0/eb0dec264aa5370efd3d29743825eb115ed7f1ef8a72a431e9a75d5c9e7d67e99d04b0d61d86b8cd70c79ec27863f241ad0317bc453f78762e0cbd76d2c332d0 + languageName: node + linkType: hard + "tmpl@npm:1.0.5": version: 1.0.5 resolution: "tmpl@npm:1.0.5" @@ -8978,6 +9668,16 @@ __metadata: languageName: node linkType: hard +"typescript@npm:5.5.4": + version: 5.5.4 + resolution: "typescript@npm:5.5.4" + bin: + tsc: bin/tsc + tsserver: bin/tsserver + checksum: 10c0/422be60f89e661eab29ac488c974b6cc0a660fb2228003b297c3d10c32c90f3bcffc1009b43876a082515a3c376b1eefcce823d6e78982e6878408b9a923199c + languageName: node + linkType: hard + "typescript@npm:^3.9.10, typescript@npm:^3.9.7": version: 3.9.10 resolution: "typescript@npm:3.9.10" @@ -9008,6 +9708,16 @@ __metadata: languageName: node linkType: hard +"typescript@patch:typescript@npm%3A5.5.4#optional!builtin": + version: 5.5.4 + resolution: "typescript@patch:typescript@npm%3A5.5.4#optional!builtin::version=5.5.4&hash=b45daf" + bin: + tsc: bin/tsc + tsserver: bin/tsserver + checksum: 10c0/10dd9881baba22763de859e8050d6cb6e2db854197495c6f1929b08d1eb2b2b00d0b5d9b0bcee8472f1c3f4a7ef6a5d7ebe0cfd703f853aa5ae465b8404bc1ba + languageName: node + linkType: hard + "typescript@patch:typescript@npm%3A^3.9.10#optional!builtin, typescript@patch:typescript@npm%3A^3.9.7#optional!builtin": version: 3.9.10 resolution: "typescript@patch:typescript@npm%3A3.9.10#optional!builtin::version=3.9.10&hash=3bd3d3" @@ -9198,6 +9908,113 @@ __metadata: languageName: node linkType: hard +"vite-node@npm:2.0.5": + version: 2.0.5 + resolution: "vite-node@npm:2.0.5" + dependencies: + cac: "npm:^6.7.14" + debug: "npm:^4.3.5" + pathe: "npm:^1.1.2" + tinyrainbow: "npm:^1.2.0" + vite: "npm:^5.0.0" + bin: + vite-node: vite-node.mjs + checksum: 10c0/affcc58ae8d45bce3e8bc3b5767acd57c24441634e2cd967cf97f4e5ed2bcead1714b60150cdf7ee153ebad47659c5cd419883207e1a95b69790331e3243749f + languageName: node + linkType: hard + +"vite@npm:5.4.0, vite@npm:^5.0.0": + version: 5.4.0 + resolution: "vite@npm:5.4.0" + dependencies: + esbuild: "npm:^0.21.3" + fsevents: "npm:~2.3.3" + postcss: "npm:^8.4.40" + rollup: "npm:^4.13.0" + peerDependencies: + "@types/node": ^18.0.0 || >=20.0.0 + less: "*" + lightningcss: ^1.21.0 + sass: "*" + sass-embedded: "*" + stylus: "*" + sugarss: "*" + terser: ^5.4.0 + dependenciesMeta: + fsevents: + optional: true + peerDependenciesMeta: + "@types/node": + optional: true + less: + optional: true + lightningcss: + optional: true + sass: + optional: true + sass-embedded: + optional: true + stylus: + optional: true + sugarss: + optional: true + terser: + optional: true + bin: + vite: bin/vite.js + checksum: 10c0/122de7795e1c3c08cd0acc7d77296f908398266b424492be7310400107f37a3cf4c9506f2b4b16619e57299ca2859b8ca187aac5e25f8e66d84f9204a1d72d18 + languageName: node + linkType: hard + +"vitest@npm:2.0.5": + version: 2.0.5 + resolution: "vitest@npm:2.0.5" + dependencies: + "@ampproject/remapping": "npm:^2.3.0" + "@vitest/expect": "npm:2.0.5" + "@vitest/pretty-format": "npm:^2.0.5" + "@vitest/runner": "npm:2.0.5" + "@vitest/snapshot": "npm:2.0.5" + "@vitest/spy": "npm:2.0.5" + "@vitest/utils": "npm:2.0.5" + chai: "npm:^5.1.1" + debug: "npm:^4.3.5" + execa: "npm:^8.0.1" + magic-string: "npm:^0.30.10" + pathe: "npm:^1.1.2" + std-env: "npm:^3.7.0" + tinybench: "npm:^2.8.0" + tinypool: "npm:^1.0.0" + tinyrainbow: "npm:^1.2.0" + vite: "npm:^5.0.0" + vite-node: "npm:2.0.5" + why-is-node-running: "npm:^2.3.0" + peerDependencies: + "@edge-runtime/vm": "*" + "@types/node": ^18.0.0 || >=20.0.0 + "@vitest/browser": 2.0.5 + "@vitest/ui": 2.0.5 + happy-dom: "*" + jsdom: "*" + peerDependenciesMeta: + "@edge-runtime/vm": + optional: true + "@types/node": + optional: true + "@vitest/browser": + optional: true + "@vitest/ui": + optional: true + happy-dom: + optional: true + jsdom: + optional: true + bin: + vitest: vitest.mjs + checksum: 10c0/b4e6cca00816bf967a8589111ded72faa12f92f94ccdd0dcd0698ffcfdfc52ec662753f66b387549c600ac699b993fd952efbd99dc57fcf4d1c69a2f1022b259 + languageName: node + linkType: hard + "vscode-oniguruma@npm:^1.7.0": version: 1.7.0 resolution: "vscode-oniguruma@npm:1.7.0" @@ -9310,6 +10127,18 @@ __metadata: languageName: node linkType: hard +"why-is-node-running@npm:^2.3.0": + version: 2.3.0 + resolution: "why-is-node-running@npm:2.3.0" + dependencies: + siginfo: "npm:^2.0.0" + stackback: "npm:0.0.2" + bin: + why-is-node-running: cli.js + checksum: 10c0/1cde0b01b827d2cf4cb11db962f3958b9175d5d9e7ac7361d1a7b0e2dc6069a263e69118bd974c4f6d0a890ef4eedfe34cf3d5167ec14203dbc9a18620537054 + languageName: node + linkType: hard + "widest-line@npm:^3.1.0": version: 3.1.0 resolution: "widest-line@npm:3.1.0"