From 406e71575fcaa86bb7c151258946d0cd4548a844 Mon Sep 17 00:00:00 2001 From: Asaki Yuki Date: Sun, 25 Jan 2026 02:50:36 +0700 Subject: [PATCH] idk --- src/compilers/bindings/Lexer.ts | 12 ++++++++++++ src/compilers/bindings/Parser.ts | 8 ++++++-- src/components/UI.ts | 2 ++ src/components/Utils.ts | 2 +- src/index.ts | 2 -- test/app.ts | 12 +----------- 6 files changed, 22 insertions(+), 16 deletions(-) diff --git a/src/compilers/bindings/Lexer.ts b/src/compilers/bindings/Lexer.ts index 6865b97..bfb5ca9 100644 --- a/src/compilers/bindings/Lexer.ts +++ b/src/compilers/bindings/Lexer.ts @@ -188,6 +188,18 @@ export function Lexer(input: string, start: number = 0, end?: number) { if (Checker.isNumberChar(token)) { while (Checker.isNumberChar(input[index + 1])) index++ + if (input[index + 1] === "e") { + index++ + if (input[index + 1] === "-") index++ + if (!Checker.isNumberChar(input[index + 1])) { + console.error( + `\x1b[31merror: ${input + "\n" + " ".repeat(index + 7) + "^"}\nInvalid character.\x1b[0m`, + ) + throw new Error() + } + while (Checker.isNumberChar(input[index + 1])) index++ + } + tokens.push(makeToken(input, TokenKind.NUMBER, start, index - start + 1)) } else if (Checker.isWordChar(token)) { while (Checker.isWordChar(input[index + 1])) index++ diff --git a/src/compilers/bindings/Parser.ts b/src/compilers/bindings/Parser.ts index 0a169e0..370decd 100644 --- a/src/compilers/bindings/Parser.ts +++ b/src/compilers/bindings/Parser.ts @@ -125,7 +125,7 @@ export class Parser { const operator = this.eat() const right = this.parsePrimaryExpression() - if (current.value === "%") left = `(${left} - ${left} / ${right} * ${right})` + if (current.value === "%") left = `(${left} - (${left} / ${right} * ${right}))` else left = `(${left} ${operator.value} ${right})` } @@ -147,8 +147,12 @@ export class Parser { return `(${value})` } + case TokenKind.NUMBER: { + const [num, exp] = (this.eat().value).split("e") + return "" + (exp ? +num * 10 ** +exp : num) + } + case TokenKind.VARIABLE: - case TokenKind.NUMBER: case TokenKind.STRING: return this.eat().value diff --git a/src/components/UI.ts b/src/components/UI.ts index 156a59f..f071fc5 100644 --- a/src/components/UI.ts +++ b/src/components/UI.ts @@ -96,6 +96,8 @@ export class UI extends Class } this.bindings.push(binding) } + + return this } addChild(child: UI, properties?: Properties, name?: string) { diff --git a/src/components/Utils.ts b/src/components/Utils.ts index e92ff7d..2e31995 100644 --- a/src/components/Utils.ts +++ b/src/components/Utils.ts @@ -106,7 +106,7 @@ export function f(input: string): CompileBinding { * @returns {CompileBinding} */ export function b(input: string): CompileBinding { - return `[ ${input} ]` + return `[${input}]` } // Quick Elements diff --git a/src/index.ts b/src/index.ts index 9fb78aa..6fbd040 100644 --- a/src/index.ts +++ b/src/index.ts @@ -9,5 +9,3 @@ export * from "./types/enums/index.js" export * as Properties from "./types/properties/index.js" export { ItemAuxID } from "./types/enums/Items.js" - -export * from "./compilers/bindings/index.js" diff --git a/test/app.ts b/test/app.ts index de3c19c..930365e 100644 --- a/test/app.ts +++ b/test/app.ts @@ -1,11 +1 @@ -import { Panel } from ".." - -const now = performance.now() -for (let index = 0; index < 1e4; index++) { - Panel().addBindings({ - source_property_name: `[ f'#{f'#{f'#{f'#{f'#{f'#{f'#{f'#{f'#{f'#{f'#{f'#{f'#{f'#{f'#{f'#{f'#{f'#{f'#{f'#{abs(-(#a + #b)) + 'abc'}'}'}'}'}'}'}'}'}'}'}'}'}'}'}'}'}'}'}'}#{f'#{f'#{f'#{f'#{f'#{f'#{f'#{f'#{f'#{f'#{f'#{f'#{f'#{f'#{f'#{f'#{f'#{f'#{f'#{abs(-(#a + #b))}'}'}'}'}'}'}'}'}'}'}'}'}'}'}'}'}'}'}'}#{f'#{f'#{f'#{f'#{f'#{f'#{f'#{f'#{f'#{f'#{f'#{f'#{f'#{f'#{f'#{f'#{f'#{f'#{f'#{abs(-(#a + #b))}'}'}'}'}'}'}'}'}'}'}'}'}'}'}'}'}'}'}'}#{f'#{f'#{f'#{f'#{f'#{f'#{f'#{f'#{f'#{f'#{f'#{f'#{f'#{f'#{f'#{f'#{f'#{f'#{f'#{abs(-(#a + #b))}'}'}'}'}'}'}'}'}'}'}'}'}'}'}'}'}'}'}'}#{f'#{f'#{f'#{f'#{f'#{f'#{f'#{f'#{f'#{f'#{f'#{f'#{f'#{f'#{f'#{f'#{f'#{f'#{f'#{abs(-(#a + #b))}'}'}'}'}'}'}'}'}'}'}'}'}'}'}'}'}'}'}'}' ]`, - target_property_name: "#test", - }) -} -const end = performance.now() -console.log(end - now) +import { Modify, Panel, StackPanel, Toggle, GetItemByAuxID, ItemAuxID } from ".."