Skip to content

Commit d8970f7

Browse files
committed
Add a custom lexer error
1 parent 4662edf commit d8970f7

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

lexer.c

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#include "lexer.h"
2+
#include "error.h"
23

34
#include <assert.h>
45
#include <ctype.h>
@@ -133,10 +134,8 @@ void next_token(struct Lexer* const lexer) {
133134
break;
134135
}
135136

136-
assert(0 && "A token that does not exist was being parsed.");
137-
138-
// Something went wrong
139-
break;
137+
print_parser_error(lexer->fptr, lexer->file_name, "Lexer Error", "Cannot decypher this token.");
138+
exit(5);
140139
}
141140

142141
lexer->curr_token = lexer->next_token;

0 commit comments

Comments
 (0)