Skip to content

Commit

Permalink
add tab support and single slash support
Browse files Browse the repository at this point in the history
  • Loading branch information
TheCrystalKeeper authored Jun 21, 2024
1 parent dcd1f4d commit 8cfd813
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/lexer/lex.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ int skip_to_token(Lexer *l) {
char prev;
if ((cur = fgetc(l->fp)) != EOF) {
prev = cur;
if (!(cur == ' ' || cur == '/')) {
if (!(cur == ' ' || cur == '\t' || cur == '/')) {
fseek(file, -1, SEEK_CUR);
return 0; // token begins immediately
}
Expand All @@ -46,8 +46,12 @@ int skip_to_token(Lexer *l) {
in_block = 2; // block
else if ((in_block == 1 && cur == '\n') || (in_block == 2 && cur == '/' && prev == '*'))
in_block = 0; // out of comment
else if (prev == '/' && !(cur == '*' || cur == '/')) {
fseek(file, -2, SEEK_CUR);
return 0; // token was a slash without a * or / following it.
}

if (!(cur == ' ' || cur == '/') && in_block == 0) {
if (!(cur == ' ' || cur == '\t' || cur == '/') && in_block == 0) {
fseek(file, -1, SEEK_CUR);
return 0; // token is next
}
Expand Down

0 comments on commit 8cfd813

Please sign in to comment.