fix: compiling but not working -- need debug

This commit is contained in:
Matteo Flebus 2026-01-15 20:42:28 +01:00
parent 1eecb1bd42
commit 04529f858c
4 changed files with 11 additions and 3 deletions

View file

@ -12,6 +12,7 @@
static char *end_last_token;
static ssize_t remaining_chars;
static bool at_beginning = true;
/* @brief: saves state for the next call the the lexer.
*
@ -20,6 +21,7 @@ static void save_state(char *stream, ssize_t i)
{
remaining_chars -= i;
end_last_token = stream + i;
at_beginning = false;
return;
}
@ -43,6 +45,7 @@ static void set_token_spechar(struct token *tok, char *begin, ssize_t size)
if (begin[0] == EOF)
{
tok->type = TOKEN_EOF;
remaining_chars = 0;
}
else if (begin[0] == ';')
{
@ -100,6 +103,7 @@ static void set_token_word(struct token *tok, char *begin, ssize_t size)
{
if (tok->type == TOKEN_NULL)
{
tok->type = TOKEN_WORD;
tok->data = calloc(size + 1, sizeof(char));
if (tok->data == NULL)
return;
@ -133,9 +137,10 @@ char *stream_init(void)
{
char *stream;
if (remaining_chars == 0)
if (at_beginning)
{
remaining_chars = stream_read(&stream);
// at_beginning = true;
}
else
{