Parser 2.0 (Major Delezer) #52

Merged
defunkt merged 35 commits from parser2 into main 2025-12-08 16:35:34 +00:00
2 changed files with 5 additions and 5 deletions
Showing only changes of commit 65119b720a - Show all commits

View File

@ -60,7 +60,7 @@ export class Parser {
if (stmt) node.add(stmt)
if (this.pos === prevPos && !this.isEOF())
Review

Needs backticks instead of "

Needs backticks instead of `"`
throw "parser didn't advance - you need to call next()\n\n ${this.input}\n"
throw `parser didn't advance - you need to call next()\n\n ${this.input}\n`
}
return node
@ -517,7 +517,7 @@ export class Parser {
if (this.is($T.Keyword, 'finally'))
finalNode = this.finally()
let end = this.keyword('end')
const end = this.keyword('end')
let last = block.at(-1)
if (finalNode) last = finalNode.children.at(-1)!
@ -687,7 +687,7 @@ export class Parser {
const ifWord = this.keyword('if')
const elseIfTest = this.testExpr()
const elseIfBlock = this.block()
const elseIfNode = new SyntaxNode('ElseIfExpr', ifBlock.at(-1)!.from, elseIfBlock.at(-1)!.to)
const elseIfNode = new SyntaxNode('ElseIfExpr', elseWord.from, elseIfBlock.at(-1)!.to)
elseIfNode.push(elseWord, ifWord, elseIfTest)
elseIfNode.push(...elseIfBlock)
node.push(elseIfNode)
@ -696,7 +696,7 @@ export class Parser {
if (this.is($T.Keyword, 'else') && this.nextIs($T.Colon)) {
const elseWord = this.keyword('else')
const elseBlock = this.block()
const elseNode = new SyntaxNode('ElseExpr', ifBlock.at(-1)!.from, elseBlock.at(-1)!.to)
const elseNode = new SyntaxNode('ElseExpr', elseWord.from, elseBlock.at(-1)!.to)
elseNode.push(elseWord)
elseNode.push(...elseBlock)
node.push(elseNode)

View File

@ -244,7 +244,7 @@ const findIdentifierEnd = (input: string, pos: number, maxPos: number): number =
let end = pos
while (end < maxPos) {
const char = input[end]
const char = input[end]!
// Stop at non-identifier characters
if (!/[a-z0-9\-?]/.test(char)) {