From 8c813602d4c603a0a966597f3eaad01099f1b31d Mon Sep 17 00:00:00 2001 From: Stefano Sanfilippo Date: Sat, 29 Nov 2014 22:31:25 +0100 Subject: [PATCH] Stop compilation when an unexpected character is encountered. --- Monicelli.lpp | 2 +- Monicelli.ypp | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/Monicelli.lpp b/Monicelli.lpp index 7d725a1..1e189c8 100644 --- a/Monicelli.lpp +++ b/Monicelli.lpp @@ -197,7 +197,7 @@ CHAR [a-zA-Z_] } . { - return -1; + return token::ERROR; } %% diff --git a/Monicelli.ypp b/Monicelli.ypp index 4fa0e33..d8e6bf3 100644 --- a/Monicelli.ypp +++ b/Monicelli.ypp @@ -51,7 +51,7 @@ static int yylex(Parser::semantic_type*, Parser::location_type*, Scanner&); } -%token MAIN +%token MAIN ERROR %token RETURN %token ARTICLE TYPENAME STAR %token VARDECL ASSIGN @@ -401,6 +401,7 @@ simple_expression: void Parser::error(const location_type& loc, const std::string &message) { std::cerr << "line " << loc.begin.line << ", col " << loc.begin.column; std::cerr << ": " << message << std::endl; + std::exit(1); } int yylex(Parser::semantic_type *lval, Parser::location_type *loc, Scanner &scanner) {