From 58634f3410db1ff16f6e21d9d0e1fcfaa17b2453 Mon Sep 17 00:00:00 2001 From: Tavian Barnes Date: Fri, 29 Jan 2010 20:03:21 -0500 Subject: Fix lexing error handling. --- dimension/grammar.terminals | 3 ++- dimension/lexer.l | 5 +++-- 2 files changed, 5 insertions(+), 3 deletions(-) (limited to 'dimension') diff --git a/dimension/grammar.terminals b/dimension/grammar.terminals index 586715b..37d3c16 100644 --- a/dimension/grammar.terminals +++ b/dimension/grammar.terminals @@ -17,7 +17,8 @@ * along with this program. If not, see . * *************************************************************************/ -%token END 0 "end-of-file" +%token DMNSN_T_EOF 0 "end-of-file" +%token DMNSN_T_LEX_ERROR "error" /* Punctuation */ %token DMNSN_T_LBRACE "{" diff --git a/dimension/lexer.l b/dimension/lexer.l index 90c5a6b..e456e24 100644 --- a/dimension/lexer.l +++ b/dimension/lexer.l @@ -261,7 +261,7 @@ unsigned long wchar; dmnsn_diagnostic(filename, yylineno, yycolumn, "Unrecognized character '%c' (0x%X)", (int)*yytext, (unsigned int)*yytext); - return 1; + return DMNSN_T_LEX_ERROR; } %% @@ -281,9 +281,10 @@ dmnsn_tokenize(FILE *file, const char *filename) while ((token.type = dmnsn_yylex_impl(&item, &location, filename, scanner)) != 0) { - if (token.type == 1 || token.type == 2) { + if (token.type == DMNSN_T_LEX_ERROR) { dmnsn_delete_tokens(tokens); tokens = NULL; + break; } else { token.value = item.value; token.filename = location.first_filename; -- cgit v1.2.3