Skip to content

Commit

Permalink
fix: Fix lexer bug on file ending with a directive
Browse files Browse the repository at this point in the history
  • Loading branch information
keyvank committed Nov 29, 2024
1 parent acba071 commit 2575b92
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions lexer.c
Original file line number Diff line number Diff line change
Expand Up @@ -183,17 +183,18 @@ typed_token *next_op(char **inp_ptr, int is_newline)
}
continue;
}
if (*inp == '\n' || *inp == '\0')
{
line[sz] = '\0';
*inp_ptr = inp;
typed_token *dir_tkns = tokenize(line);
return new_tkn(TKN_DIRECTIVE, dir_tkns, directive_tkn_debug);
}

if (*inp == '\n')
break;

line[sz] = *inp;
sz++;
inp++;
}
line[sz] = '\0';
*inp_ptr = inp;
typed_token *dir_tkns = tokenize(line);
return new_tkn(TKN_DIRECTIVE, dir_tkns, directive_tkn_debug);
}
if (*inp == '?')
{
Expand Down

0 comments on commit 2575b92

Please sign in to comment.