This commit is contained in:
Asaki Yuki 2026-01-25 02:50:36 +07:00
parent e7ac672470
commit 406e71575f
6 changed files with 22 additions and 16 deletions

View file

@ -188,6 +188,18 @@ export function Lexer(input: string, start: number = 0, end?: number) {
if (Checker.isNumberChar(token)) { if (Checker.isNumberChar(token)) {
while (Checker.isNumberChar(input[index + 1])) index++ 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)) tokens.push(makeToken(input, TokenKind.NUMBER, start, index - start + 1))
} else if (Checker.isWordChar(token)) { } else if (Checker.isWordChar(token)) {
while (Checker.isWordChar(input[index + 1])) index++ while (Checker.isWordChar(input[index + 1])) index++

View file

@ -125,7 +125,7 @@ export class Parser {
const operator = this.eat() const operator = this.eat()
const right = this.parsePrimaryExpression() 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})` else left = `(${left} ${operator.value} ${right})`
} }
@ -147,8 +147,12 @@ export class Parser {
return `(${value})` return `(${value})`
} }
case TokenKind.NUMBER: {
const [num, exp] = (<string>this.eat().value).split("e")
return "" + (exp ? +num * 10 ** +exp : num)
}
case TokenKind.VARIABLE: case TokenKind.VARIABLE:
case TokenKind.NUMBER:
case TokenKind.STRING: case TokenKind.STRING:
return <string>this.eat().value return <string>this.eat().value

View file

@ -96,6 +96,8 @@ export class UI<T extends Type, K extends Renderer | null = null> extends Class
} }
this.bindings.push(binding) this.bindings.push(binding)
} }
return this
} }
addChild<T extends Type, K extends Renderer | null>(child: UI<T, K>, properties?: Properties<T, K>, name?: string) { addChild<T extends Type, K extends Renderer | null>(child: UI<T, K>, properties?: Properties<T, K>, name?: string) {

View file

@ -9,5 +9,3 @@ export * from "./types/enums/index.js"
export * as Properties from "./types/properties/index.js" export * as Properties from "./types/properties/index.js"
export { ItemAuxID } from "./types/enums/Items.js" export { ItemAuxID } from "./types/enums/Items.js"
export * from "./compilers/bindings/index.js"

View file

@ -1,11 +1 @@
import { Panel } from ".." import { Modify, Panel, StackPanel, Toggle, GetItemByAuxID, ItemAuxID } 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)