Cleaner error message for lexer errors

This commit is contained in:
Robin Jadoul 2017-01-31 16:59:38 +01:00
parent 87fbee24a3
commit 47039e67ab
1 changed files with 5 additions and 1 deletions

View File

@ -22,6 +22,7 @@
*/ */
#include "Parsodus/parser.h" #include "Parsodus/parser.h"
#include "g3log/g3log.hpp"
#include <deque> #include <deque>
namespace pds { namespace pds {
@ -121,7 +122,10 @@ Parser::Token Parser::lex() {
} catch(ParsodusLexer::NoMoreTokens) { } catch(ParsodusLexer::NoMoreTokens) {
return Token{ parsodusParser_Symbol::T_EOF, nullptr }; return Token{ parsodusParser_Symbol::T_EOF, nullptr };
} } catch (ParsodusLexer::NoMatch) {
LOG(WARNING) << "Unrecognized character: " << m_lex.peek() << std::endl;
throw SyntaxError("Unrecognized character");
}
} }
std::unique_ptr<Config> Parser::reduce_0(std::deque<Token> subparts) { std::unique_ptr<Config> Parser::reduce_0(std::deque<Token> subparts) {