From 3b2977779b457a7fb018fb4dfca7f7b908142d0d Mon Sep 17 00:00:00 2001 From: Samual Norman Date: Mon, 30 Dec 2024 17:11:20 +0000 Subject: [PATCH] Revert "do basic check for valid subscript syntax" This reverts commit 24be49c6c1a42ab0019c84e66383558ea7fdce4b. --- src/processScript/preprocess.ts | 22 ---------------------- 1 file changed, 22 deletions(-) diff --git a/src/processScript/preprocess.ts b/src/processScript/preprocess.ts index 1b0baef..ccdfcdc 100644 --- a/src/processScript/preprocess.ts +++ b/src/processScript/preprocess.ts @@ -7,7 +7,6 @@ import t from "@babel/types" import type { LaxPartial } from "@samual/lib" import { assert } from "@samual/lib/assert" import { spliceString } from "@samual/lib/spliceString" -import { tokenizer as tokenise, tokTypes as TokenTypes } from "acorn" import { resolve as resolveModule } from "import-meta-resolve" // eslint-disable-next-line @typescript-eslint/consistent-type-imports @@ -15,8 +14,6 @@ const { default: traverse } = babelTraverse as any as typeof import("@babel/trav // eslint-disable-next-line @typescript-eslint/consistent-type-imports const { default: generate } = babelGenerator as any as typeof import("@babel/generator") -const SUBSCRIPT_PREFIXES = [ `s`, `fs`, `4s`, `hs`, `3s`, `ms`, `2s`, `ls`, `1s`, `ns`, `0s` ] - export type PreprocessOptions = LaxPartial<{ /** 11 a-z 0-9 characters */ uniqueId: string }> /** @param code source code for preprocessing @@ -25,25 +22,6 @@ export async function preprocess(code: string, { uniqueId = `00000000000` }: Pre : Promise<{ code: string }> { assert(/^\w{11}$/.test(uniqueId), HERE) - const tokensIterable = tokenise(code, { ecmaVersion: `latest` }) - - for (const token of tokensIterable) { - assert(`value` in token, HERE) - - if (token.type != TokenTypes.privateId) - continue - - assert(typeof token.value == `string`, HERE) - - if (!SUBSCRIPT_PREFIXES.includes(token.value)) - continue - - const nextToken = tokensIterable.getToken() - - if (nextToken.type != TokenTypes._in && nextToken.type != TokenTypes.dot) - throw SyntaxError(`Subscripts must be in the form of #fs.foo.bar`) - } - const sourceCode = code let lengthBefore -- knotmirror 0.0.1