diff options
-rw-r--r-- | dimension/grammar.terminals | 3 | ||||
-rw-r--r-- | dimension/lexer.l | 5 |
2 files changed, 5 insertions, 3 deletions
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 <http://www.gnu.org/licenses/>. * *************************************************************************/ -%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; |