Last active
May 11, 2020 23:35
-
-
Save amazzalel-habib/c290da845fb21d492fcb5b877d92e08b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { ANTLRErrorListener, RecognitionException, Recognizer } from "antlr4ts"; | |
export interface ITodoLangError { | |
startLineNumber: number; | |
startColumn: number; | |
endLineNumber: number; | |
endColumn: number; | |
message: string; | |
code: string; | |
} | |
export default class TodoLangErrorListener implements ANTLRErrorListener<any>{ | |
private errors: ITodoLangError[] = [] | |
syntaxError(recognizer: Recognizer<any, any>, offendingSymbol: any, line: number, charPositionInLine: number, message: string, e: RecognitionException | undefined): void { | |
this.errors.push( | |
{ | |
startLineNumber:line, | |
endLineNumber: line, | |
startColumn: charPositionInLine, | |
endColumn: charPositionInLine+1,//Let's suppose the length of the error is only 1 char for simplicity | |
message, | |
code: "1" // This the error code you can customize them as you want | |
} | |
) | |
} | |
getErrors(): ITodoLangError[] { | |
return this.errors; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment