Skip to content

Commit

Permalink
Add InvalidNumberError (#15)
Browse files Browse the repository at this point in the history
  • Loading branch information
JJtan2002 authored Mar 12, 2024
1 parent 0b7801a commit 17c51ee
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/errors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,19 @@ export namespace TokenizerErrors {
this.name = "NonFourIndentError";
}
}

export class InvalidNumberError extends BaseTokenizerError {
constructor(line: number, col: number, source: string, start: number, current: number) {
let msg = getFullLine(source, start) + "\n";
let hint = `^ Invalid Number input.`;
const diff = (current - start);
// +1 because we want the arrow to point after the string (where we expect the closing ")
hint = hint.padStart(hint.length + diff - MAGIC_OFFSET + 1, "~");
hint = hint.padStart(hint.length + col - diff, " ");
super(msg + hint, line, col);
this.name = "InvalidNumberError";
}
}

export class InconsistentIndentError extends BaseTokenizerError {
constructor(line: number, col: number, source: string, start: number) {
Expand Down

0 comments on commit 17c51ee

Please sign in to comment.