Fixing bugs. escaping things when pretty printing. adding reflect host function. getting further with tree view
This commit is contained in:
parent
f27b946790
commit
fec18486d8
5 changed files with 165 additions and 73 deletions
|
|
@ -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}`;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue