Letting me save things to _ or _myVar to throw it away. fixing printing newlines in strings
This commit is contained in:
parent
d36f694d80
commit
586d55df85
3 changed files with 24 additions and 5 deletions
|
|
@ -243,7 +243,7 @@ export function prettyPrint(ast: AST, indent = 0): string {
|
|||
const escaped = val.value
|
||||
.replace(/\\/g, '\\\\')
|
||||
.replace(/"/g, '\\"')
|
||||
.replace(/\n/g, '\\n')
|
||||
// .replace(/\n/g, '\\n')
|
||||
.replace(/\t/g, '\\t');
|
||||
return `"${escaped}"`;
|
||||
}
|
||||
|
|
@ -347,13 +347,14 @@ export function prettyPrint(ast: AST, indent = 0): string {
|
|||
return `...${prettyPrint(ast.spread, indent)}`;
|
||||
|
||||
case 'definition':
|
||||
const displayName = /^_\d+$/.test(ast.name) ? '_' : ast.name;
|
||||
const ann = ast.annotation
|
||||
? ` : ${ast.annotation.constraints.length > 0
|
||||
? ast.annotation.constraints.map(c => `${c.className} ${c.typeVar}`).join(', ') + ' :: '
|
||||
: ''}${prettyPrintType(ast.annotation.type)}`
|
||||
: '';
|
||||
if (!ast.body) return `${ast.name}${ann};`;
|
||||
return `${ast.name}${ann} = ${prettyPrint(ast.body, indent)};`;
|
||||
if (!ast.body) return `${displayName}${ann};`;
|
||||
return `${displayName}${ann} = ${prettyPrint(ast.body, indent)};`;
|
||||
|
||||
default:
|
||||
return `Unknown AST kind: ${i}${(ast as any).kind}`
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue