Expose SourceLocation in ParseError object

This commit is contained in:
Rene Saarsoo 2020-12-25 15:31:08 +02:00
parent 97f6beb1a8
commit c6aa02bb06
1 changed files with 4 additions and 2 deletions

View File

@ -1,7 +1,9 @@
import { SourceLocation } from "./tokenizer";
export class ParseError extends Error {
constructor(msg: string, { row, col }: SourceLocation) {
super(`${msg} at line ${row + 1} char ${col + 1}`);
public loc: SourceLocation;
constructor(msg: string, loc: SourceLocation) {
super(`${msg} at line ${loc.row + 1} char ${loc.col + 1}`);
this.loc = loc;
}
}