diff options
author | Tavian Barnes <tavianator@gmail.com> | 2010-01-29 20:03:21 -0500 |
---|---|---|
committer | Tavian Barnes <tavianator@gmail.com> | 2010-01-29 20:03:21 -0500 |
commit | 58634f3410db1ff16f6e21d9d0e1fcfaa17b2453 (patch) | |
tree | 890d1398659c873a459e6d639cf4b949f550f50f /dimension | |
parent | 557dfdbb9b770f755feae04afe9aaef60d63ada3 (diff) | |
download | dimension-58634f3410db1ff16f6e21d9d0e1fcfaa17b2453.tar.xz |
Fix lexing error handling.
Diffstat (limited to 'dimension')
-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; |