diff --git a/contributors.txt b/contributors.txt index 2bbc5edf6..45662376f 100644 --- a/contributors.txt +++ b/contributors.txt @@ -138,4 +138,5 @@ YYYY/MM/DD, github id, Full name, email 2017/02/14, xied75, Dong Xie, xied75@gmail.com 2017/02/20, Thomasb81, Thomas Burg, thomasb81@gmail.com 2017/02/26, jvasileff, John Vasileff, john@vasileff.com -2017/03/08, harry-tallbelt, Igor Vysokopoyasny, harry.tallbelt@gmail.com +2017/03/03, chund, Christian Hund, christian.hund@gmail.com +2017/03/08, harry-tallbelt, Igor Vysokopoyasny, harry.tallbelt@gmail.com \ No newline at end of file diff --git a/runtime/Cpp/runtime/src/InputMismatchException.cpp b/runtime/Cpp/runtime/src/InputMismatchException.cpp index 0caa77a3c..1d5d1c1fb 100755 --- a/runtime/Cpp/runtime/src/InputMismatchException.cpp +++ b/runtime/Cpp/runtime/src/InputMismatchException.cpp @@ -10,6 +10,6 @@ using namespace antlr4; InputMismatchException::InputMismatchException(Parser *recognizer) - : RecognitionException(recognizer, recognizer->getInputStream(), recognizer->getContext(), + : RecognitionException("Input mismatch", recognizer, recognizer->getInputStream(), recognizer->getContext(), recognizer->getCurrentToken()) { } diff --git a/runtime/Cpp/runtime/src/RecognitionException.cpp b/runtime/Cpp/runtime/src/RecognitionException.cpp index b51308feb..2dfe027b3 100755 --- a/runtime/Cpp/runtime/src/RecognitionException.cpp +++ b/runtime/Cpp/runtime/src/RecognitionException.cpp @@ -10,6 +10,7 @@ #include "misc/IntervalSet.h" #include "RecognitionException.h" +#include "Token.h" using namespace antlr4; @@ -20,7 +21,8 @@ RecognitionException::RecognitionException(Recognizer *recognizer, IntStream *in RecognitionException::RecognitionException(const std::string &message, Recognizer *recognizer, IntStream *input, ParserRuleContext *ctx, Token *offendingToken) - : RuntimeException(message), _recognizer(recognizer), _input(input), _ctx(ctx), _offendingToken(offendingToken) { + : RuntimeException(message + (offendingToken ? " near token " + offendingToken->getText() + " in line " + std::to_string(offendingToken->getLine()) : "")) + , _recognizer(recognizer), _input(input), _ctx(ctx), _offendingToken(offendingToken) { InitializeInstanceFields(); if (recognizer != nullptr) { _offendingState = recognizer->getState();