Parser 2.0 (Major Delezer) #52

Merged
defunkt merged 35 commits from parser2 into main 2025-12-08 16:35:34 +00:00
4 changed files with 11 additions and 11 deletions
Showing only changes of commit 3eac0a27a5 - Show all commits

View File

@ -23,15 +23,15 @@ describe('multi line function blocks', () => {
test('work with no args', () => {
expect(`
trap = do x: x end
trap:
true
trap:
true
end`).toEvaluateTo(true)
})
test('work with one arg', () => {
expect(`
trap = do x y: [ x (y) ] end
trap EXIT:
trap EXIT:
true
end`).toEvaluateTo(['EXIT', true])
})
@ -39,7 +39,7 @@ end`).toEvaluateTo(['EXIT', true])
test('work with named args', () => {
expect(`
attach = do signal fn: [ signal (fn) ] end
attach signal='exit':
attach signal='exit':
true
end`).toEvaluateTo(['exit', true])
})
@ -48,8 +48,8 @@ end`).toEvaluateTo(['exit', true])
test('work with dot-get', () => {
expect(`
signals = [trap=do x y: [x (y)] end]
signals.trap 'EXIT':
true
signals.trap 'EXIT':
true
end`).toEvaluateTo(['EXIT', true])
})
})

View File

@ -63,7 +63,7 @@ describe('calling functions', () => {
Identifier tail
NamedArg
NamedArgPrefix lines=
`)
})
})
@ -73,7 +73,7 @@ describe('Do', () => {
expect('do: 1 end').toMatchTree(`
FunctionDef
Do do
Params
Params
colon :
Number 1
keyword end`)

View File

@ -76,12 +76,12 @@ end
expect(`
do:
2
end
`).toMatchTree(`
FunctionDef
Do do
Params
Params
colon :
Number 2
keyword end

View File

@ -12,7 +12,7 @@ const nodeToString = (node: SyntaxNode, input: string, depth = 0): string => {
} else {
// Only strip quotes from whole String nodes (legacy DoubleQuote), not StringFragment/EscapeSeq/CurlyString
const cleanText = nodeName === 'String' ? text.slice(1, -1) : text
return `${indent}${nodeName} ${cleanText}`
return cleanText ? `${indent}${nodeName} ${cleanText}` : `${indent}${nodeName}`
}
}