def syntaxError(self, recognizer, offendingSymbol, line, column, msg, e): #print("line %s:%s [%s] : %s" % (line, column, offendingSymbol, msg), file=sys.stderr) #t = e.offendingToken #print(" ::", t.text) # the RecognitionException is catched by DefaultErrorStrategy # I need to stop parsing when syntax error happend tok = e.offendingToken istr = tok.getTokenSource().inputStream #try: src = istr.fileName #except: src = istr.name #print("D: %s :" % istr.data) raise ParseCancellationException( "Syntax error in '%s' line %s:%s, near '%s'" % (src, line, column, tok.text))
def recover(self, recognizer: Parser, e: RecognitionException): context = recognizer._ctx while context is not None: context.exception = e context = context.parentCtx raise ParseCancellationException(e)
def syntaxError(self, recognizer, offending_symbol, line, column, msg, e): print(f"Error on line: {line} msg: {msg}") raise ParseCancellationException(f"line: {line} msg: {msg}")
def syntaxError(recognizer, offending_symbol, line, column, msg, e): print( f'Error on {line} line with: {msg}\n offending symbol: {offending_symbol}' ) raise ParseCancellationException(f"line: {line} msg: {msg}")
def syntaxError(self, recognizer, offendingSymbol, line, column, msg, e): logging.critical("SyntaxError: %s", msg) raise ParseCancellationException("Syntax Error lol")
def syntaxError(self, recognizer, offendingSymbol, line, column, msg, e): ex = ParseCancellationException(f'line {line}: {column} {msg}') ex.line = line ex.column = column raise ex
def syntaxError(self, recognizer, offendingSymbol, line, column, msg, e): ex = ParseCancellationException( f'In line {line}, column {column}: {msg}') ex.line = line ex.column = column self.errors.append(ex)
def syntaxError(self, recognizer, offendingSymbol, line, column, msg, e): raise ParseCancellationException(f"line {line}:{column} {msg}")
def reportContextSensitivity(self, recognizer, dfa, startIndex, stopIndex, prediction, configs): message: str = f"Context ERROR, {str(configs)}" raise PypefitterError(message) from ParseCancellationException(message)
def reportAttemptingFullContext(self, recognizer, dfa, startIndex, stopIndex, conflictingAlts, configs): message: str = f"Attempting full context ERROR, {str(configs)}" raise PypefitterError(message) from ParseCancellationException(message)
def reportAmbiguity(self, recognizer, dfa, startIndex, stopIndex, exact, ambigAlts, configs): message: str = f"Ambiguity ERROR, {str(configs)}" raise PypefitterError(message) from ParseCancellationException(message)
def syntaxError(self, recognizer, offendingSymbol, line, column, msg, e): message: str = f"{str(line)}:{str(column)}: syntax ERROR, {str(msg)}" raise PypefitterError(message) from ParseCancellationException(message)
def syntaxError(self, recognizer, offending_symbol, line, column, msg, e): raise ParseCancellationException("line " + str(line) + ":" + str(column) + " " + msg)