Stop compilation when an unexpected character is encountered.
This commit is contained in:
parent
bb0c5c2c78
commit
8c813602d4
|
@ -197,7 +197,7 @@ CHAR [a-zA-Z_]
|
||||||
}
|
}
|
||||||
|
|
||||||
<INITIAL,shift>. {
|
<INITIAL,shift>. {
|
||||||
return -1;
|
return token::ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
%%
|
%%
|
||||||
|
|
|
@ -51,7 +51,7 @@
|
||||||
static int yylex(Parser::semantic_type*, Parser::location_type*, Scanner&);
|
static int yylex(Parser::semantic_type*, Parser::location_type*, Scanner&);
|
||||||
}
|
}
|
||||||
|
|
||||||
%token MAIN
|
%token MAIN ERROR
|
||||||
%token RETURN
|
%token RETURN
|
||||||
%token ARTICLE TYPENAME STAR
|
%token ARTICLE TYPENAME STAR
|
||||||
%token VARDECL ASSIGN
|
%token VARDECL ASSIGN
|
||||||
|
@ -401,6 +401,7 @@ simple_expression:
|
||||||
void Parser::error(const location_type& loc, const std::string &message) {
|
void Parser::error(const location_type& loc, const std::string &message) {
|
||||||
std::cerr << "line " << loc.begin.line << ", col " << loc.begin.column;
|
std::cerr << "line " << loc.begin.line << ", col " << loc.begin.column;
|
||||||
std::cerr << ": " << message << std::endl;
|
std::cerr << ": " << message << std::endl;
|
||||||
|
std::exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
int yylex(Parser::semantic_type *lval, Parser::location_type *loc, Scanner &scanner) {
|
int yylex(Parser::semantic_type *lval, Parser::location_type *loc, Scanner &scanner) {
|
||||||
|
|
Reference in New Issue
Block a user