Fixing bugs. escaping things when pretty printing. adding reflect host function. getting further with tree view

This commit is contained in:
Dustin Swan 2026-02-14 22:08:58 -07:00
parent f27b946790
commit fec18486d8
No known key found for this signature in database
GPG key ID: 30D46587E2100467
5 changed files with 165 additions and 73 deletions

View file

@ -180,7 +180,12 @@ export function prettyPrint(ast: AST, indent = 0): string {
case 'literal': {
const val = ast.value;
if (val.kind === 'string') {
return `"${val.value}"`;
const escaped = val.value
.replace(/\\/g, '\\\\')
.replace(/"/g, '\\"')
.replace(/\n/g, '\\n')
.replace(/\t/g, '\\t');
return `"${escaped}"`;
}
return `${val.value}`;
}