Esempio n. 1
0
 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))
Esempio n. 2
0
 def recover(self, recognizer: Parser, e: RecognitionException):
     context = recognizer._ctx
     while context is not None:
         context.exception = e
         context = context.parentCtx
     raise ParseCancellationException(e)
Esempio n. 3
0
 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}")
Esempio n. 5
0
 def syntaxError(self, recognizer, offendingSymbol, line, column, msg, e):
     logging.critical("SyntaxError: %s", msg)
     raise ParseCancellationException("Syntax Error lol")
Esempio n. 6
0
 def syntaxError(self, recognizer, offendingSymbol, line, column, msg, e):
     ex = ParseCancellationException(f'line {line}: {column} {msg}')
     ex.line = line
     ex.column = column
     raise ex
Esempio n. 7
0
 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)
Esempio n. 8
0
 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)
Esempio n. 10
0
 def reportAttemptingFullContext(self, recognizer, dfa, startIndex,
                                 stopIndex, conflictingAlts, configs):
     message: str = f"Attempting full context ERROR, {str(configs)}"
     raise PypefitterError(message) from ParseCancellationException(message)
Esempio n. 11
0
 def reportAmbiguity(self, recognizer, dfa, startIndex, stopIndex, exact,
                     ambigAlts, configs):
     message: str = f"Ambiguity ERROR, {str(configs)}"
     raise PypefitterError(message) from ParseCancellationException(message)
Esempio n. 12
0
 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)
Esempio n. 13
0
 def syntaxError(self, recognizer, offending_symbol, line, column,
                 msg, e):
     raise ParseCancellationException("line " + str(line) + ":" +
                                      str(column) + " " + msg)