idk
This commit is contained in:
parent
e7ac672470
commit
406e71575f
6 changed files with 22 additions and 16 deletions
|
|
@ -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++
|
||||
|
|
|
|||
|
|
@ -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] = (<string>this.eat().value).split("e")
|
||||
return "" + (exp ? +num * 10 ** +exp : num)
|
||||
}
|
||||
|
||||
case TokenKind.VARIABLE:
|
||||
case TokenKind.NUMBER:
|
||||
case TokenKind.STRING:
|
||||
return <string>this.eat().value
|
||||
|
||||
|
|
|
|||
|
|
@ -96,6 +96,8 @@ export class UI<T extends Type, K extends Renderer | null = null> extends Class
|
|||
}
|
||||
this.bindings.push(binding)
|
||||
}
|
||||
|
||||
return this
|
||||
}
|
||||
|
||||
addChild<T extends Type, K extends Renderer | null>(child: UI<T, K>, properties?: Properties<T, K>, name?: string) {
|
||||
|
|
|
|||
|
|
@ -106,7 +106,7 @@ export function f(input: string): CompileBinding {
|
|||
* @returns {CompileBinding}
|
||||
*/
|
||||
export function b(input: string): CompileBinding {
|
||||
return `[ ${input} ]`
|
||||
return `[${input}]`
|
||||
}
|
||||
|
||||
// Quick Elements
|
||||
|
|
|
|||
|
|
@ -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"
|
||||
|
|
|
|||
Reference in a new issue