mirror of
https://github.com/Noratrieb/riverdelta.git
synced 2026-01-15 00:45:04 +01:00
Change let
This commit is contained in:
parent
40543b501c
commit
7c2faaecb8
9 changed files with 200 additions and 100 deletions
11
src/error.ts
11
src/error.ts
|
|
@ -52,8 +52,13 @@ function renderError(input: string, e: CompilerError) {
|
|||
console.error(`${lineIdx} | ${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(startRelLine)}^`
|
||||
`${" ".repeat(String(lineIdx).length)} ${" ".repeat(
|
||||
startRelLine
|
||||
)}${"^".repeat(spanLength)}`
|
||||
);
|
||||
}
|
||||
|
||||
|
|
@ -81,3 +86,7 @@ export function lines(input: string): Span[] {
|
|||
export function todo(msg: string): never {
|
||||
throw new CompilerError(`TODO: ${msg}`, { start: 0, end: 0 });
|
||||
}
|
||||
|
||||
function min(a: number, b: number): number {
|
||||
return a < b ? a : b;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue