port lexer to cpp

This commit is contained in:
Asaki Yuki 2026-01-18 20:46:18 +07:00
parent cacc641378
commit b3b21f3101
13 changed files with 276 additions and 32 deletions

View file

@ -1,8 +1,8 @@
import { Expression, GenBinding, Token, TokenKind, TSToken, TSTokenKind } from "./types.js"
import { BindingType } from "../../types/enums/BindingType.js"
import { BindingItem } from "../../types/properties/value.js"
import { FuntionMap } from "./Funtion.js"
import { Lexer } from "./Lexer.js"
import { Expression, GenBinding, Token, TokenKind, TSToken, TSTokenKind } from "./types.js"
export class Parser {
position: number = 0
@ -240,14 +240,14 @@ export class Parser {
this.eat()
return this.funtionCall(<string>callerToken.value, ...args)
} else if (left.kind === TokenKind.OPERATOR) {
} else if (left?.kind === TokenKind.OPERATOR) {
this.warn(
`Implicit string literal '${callerToken.value}'. Use quoted string ('${callerToken.value}') for clarity!`,
callerToken,
)
return <string>callerToken.value
} else {
this.expect(TokenKind.OPERATOR, "Unexpected token!")
this.expect(TokenKind.WORD, "Unexpected token!")
return <string>callerToken.value
}
}