import { ANTLRErrorListener, Recognizer, RecognitionException, Token } from "antlr4ts"; export interface SyntaxIssue { line: number; column: number; message: string; offendingSymbol?: string; ruleStack?: string[]; } export class CertusErrorListener implements ANTLRErrorListener { public errors: SyntaxIssue[] = []; syntaxError( recognizer: Recognizer, offendingSymbol: any, line: number, charPositionInLine: number, msg: string, e: RecognitionException | undefined ): void { const ruleStack = (recognizer as any).ruleInvocationStack?.slice()?.reverse(); this.errors.push({ line, column: charPositionInLine, message: msg, offendingSymbol: offendingSymbol?.text, ruleStack, }); } }