From 17bdb2d7cb026b7db262a6e79d79a60e12bcf23b Mon Sep 17 00:00:00 2001 From: Sam Vervaeck Date: Wed, 12 Apr 2023 19:38:45 +0200 Subject: [PATCH] Fix some bugs in textual input/ouput --- src/cst.ts | 5 ++--- src/diagnostics.ts | 4 ++-- src/scanner.ts | 3 +-- 3 files changed, 5 insertions(+), 7 deletions(-) diff --git a/src/cst.ts b/src/cst.ts index 76b1db596..a141d7289 100644 --- a/src/cst.ts +++ b/src/cst.ts @@ -39,9 +39,8 @@ export class TextPosition { } else { this.column++; } - this.offset += text.length; } - + this.offset += text.length; } } @@ -617,7 +616,7 @@ export class StringLiteral extends TokenBase { } else if (code <= 127) { out += '\\x' + code.toString(16).padStart(2, '0'); } else { - out += '\\u' + code.toString(17).padStart(4, '0'); + out += '\\u' + code.toString(16).padStart(4, '0'); } } out += '"'; diff --git a/src/diagnostics.ts b/src/diagnostics.ts index 6575fc20f..d7f7ae8ac 100644 --- a/src/diagnostics.ts +++ b/src/diagnostics.ts @@ -331,14 +331,14 @@ export class ConsoleDiagnostics implements Diagnostics { if (leftNode !== null) { this.writer.indent(); this.writer.write(ANSI_FG_YELLOW + ANSI_BOLD + `info: ` + ANSI_RESET); - this.writer.write(`type ` + ANSI_FG_GREEN + describeType(diagnostic.left) + ANSI_RESET + ` was inferred from diagnostic expression:\n\n`); + this.writer.write(`type ` + ANSI_FG_GREEN + describeType(diagnostic.left) + ANSI_RESET + ` was inferred from this expression:\n\n`); this.writer.write(printNode(leftNode) + '\n'); this.writer.dedent(); } if (rightNode !== null) { this.writer.indent(); this.writer.write(ANSI_FG_YELLOW + ANSI_BOLD + `info: ` + ANSI_RESET); - this.writer.write(`type ` + ANSI_FG_GREEN + describeType(diagnostic.right) + ANSI_RESET + ` was inferred from diagnostic expression:\n\n`); + this.writer.write(`type ` + ANSI_FG_GREEN + describeType(diagnostic.right) + ANSI_RESET + ` was inferred from this expression:\n\n`); this.writer.write(printNode(rightNode) + '\n'); this.writer.dedent(); } diff --git a/src/scanner.ts b/src/scanner.ts index 227905f06..301952984 100644 --- a/src/scanner.ts +++ b/src/scanner.ts @@ -46,7 +46,7 @@ import { InstanceKeyword, Backslash, } from "./cst" -import { Diagnostics, UnexpectedCharDiagnostic } from "./diagnostics" +import { Diagnostics } from "./diagnostics" import { Stream, BufferedStream, assert } from "./util"; const EOF = '\uFFFF' @@ -182,7 +182,6 @@ export class Scanner extends BufferedStream { case '"': { - const startPos = this.getCurrentPosition(); let contents = ''; let escaping = false; for (;;) {