Skip to content

Commit

Permalink
Use new error capabilities
Browse files Browse the repository at this point in the history
  • Loading branch information
adamhutchings committed Jun 19, 2024
1 parent 7bcbef5 commit 889ad89
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/lexer/lex.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

#include <string.h> // memcpy

#include <util/out.h> // error reporting

int lex(Lexer *l, Token *t) {
// If there are any tokens waiting in the putback buffer, read from there
// instead.
Expand All @@ -17,7 +19,10 @@ int lex(Lexer *l, Token *t) {
int unlex(Lexer *l, Token *t) {
// First, make sure we can actually fit it in the buffer.
if (l->unlexed_count >= TOKEN_PUTBACKS) {
// TODO: error reporting
PRINT_ERROR(
"internal: tried to unlex more than %d tokens at a time",
TOKEN_PUTBACKS
);
return -1; // Error return code
}
memcpy(&l->unlexed[l->unlexed_count], t, sizeof(Token));
Expand Down

0 comments on commit 889ad89

Please sign in to comment.