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 13 additions and 1 deletions
Showing only changes of commit 2c2b277b29 - Show all commits

View File

@ -729,7 +729,7 @@ export class Parser {
// throw blah
throw(): SyntaxNode {
const keyword = this.keyword('throw')
const val = this.value()
const val = this.expression()
const node = new SyntaxNode('Throw', keyword.from, val.to)
return node.push(keyword, val)
}

View File

@ -139,6 +139,18 @@ describe('try/catch/finally/throw', () => {
`)
})
test('parses throw statement with BinOp', () => {
expect("throw 'error message:' + msg").toMatchTree(`
Throw
keyword throw
BinOp
String
StringFragment error message:
Plus +
Identifier msg
`)
})
test('parses throw statement with identifier', () => {
expect('throw error-object').toMatchTree(`
Throw