mirror of
https://github.com/Noratrieb/riverdelta.git
synced 2026-01-15 00:45:04 +01:00
write prInt
This commit is contained in:
parent
d9868e3111
commit
7f65dc0277
8 changed files with 155 additions and 40 deletions
|
|
@ -47,16 +47,17 @@ function renderError(input: string, e: CompilerError) {
|
|||
throw Error(`Span out of bounds: ${e.span.start}..${e.span.end}`);
|
||||
}
|
||||
const lineIdx = lineSpans.indexOf(line);
|
||||
const lineNo = lineIdx + 1;
|
||||
console.error(`error: ${e.message}`);
|
||||
|
||||
console.error(`${lineIdx} | ${spanToSnippet(input, line)}`);
|
||||
console.error(`${lineNo} | ${spanToSnippet(input, line)}`);
|
||||
const startRelLine =
|
||||
e.span.start === Number.MAX_SAFE_INTEGER ? 0 : e.span.start - line.start;
|
||||
|
||||
const spanLength = min(e.span.end, line.end) - e.span.start;
|
||||
|
||||
console.error(
|
||||
`${" ".repeat(String(lineIdx).length)} ${" ".repeat(
|
||||
`${" ".repeat(String(lineNo).length)} ${" ".repeat(
|
||||
startRelLine
|
||||
)}${"^".repeat(spanLength)}`
|
||||
);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue