summaryrefslogtreecommitdiff
path: root/src/lexer.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/lexer.c')
-rw-r--r--src/lexer.c50
1 files changed, 22 insertions, 28 deletions
diff --git a/src/lexer.c b/src/lexer.c
index e1f0d80..bbf29fc 100644
--- a/src/lexer.c
+++ b/src/lexer.c
@@ -1,27 +1,27 @@
/*
-* Copyright (C) 2023 Johnny Richard
-*
-* This program is free software: you can redistribute it and/or modify
-* it under the terms of the GNU General Public License as published by
-* the Free Software Foundation, either version 3 of the License, or
-* (at your option) any later version.
-*
-* This program is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-* GNU General Public License for more details.
-*
-* You should have received a copy of the GNU General Public License
-* along with this program. If not, see <https://www.gnu.org/licenses/>.
-*/
+ * Copyright (C) 2023 Johnny Richard
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <https://www.gnu.org/licenses/>.
+ */
+#include "lexer.h"
#include <assert.h>
#include <ctype.h>
#include <errno.h>
#include <stdbool.h>
#include <stdio.h>
#include <string.h>
-#include "lexer.h"
void
lexer_init(lexer_t *lexer, char *filepath)
@@ -29,10 +29,10 @@ lexer_init(lexer_t *lexer, char *filepath)
assert(lexer && "lexer must be defined");
assert(filepath && "filepath must be defined");
lexer->filepath = filepath;
- lexer->srclen = 0;
- lexer->cur = 0;
- lexer->row = 0;
- lexer->bol = 0;
+ lexer->srclen = 0;
+ lexer->cur = 0;
+ lexer->row = 0;
+ lexer->bol = 0;
lexer_load_file_contents(lexer);
}
@@ -151,11 +151,8 @@ lexer_next_token(lexer_t *lexer, token_t *token)
return;
}
- if (lexer_current_char(lexer) == '+'
- || lexer_current_char(lexer) == '-'
- || lexer_current_char(lexer) == '*'
- || lexer_current_char(lexer) == '/'
- || lexer_current_char(lexer) == '=') {
+ if (lexer_current_char(lexer) == '+' || lexer_current_char(lexer) == '-' || lexer_current_char(lexer) == '*' ||
+ lexer_current_char(lexer) == '/' || lexer_current_char(lexer) == '=') {
lexer_define_literal_token_props(lexer, token, TOKEN_OP);
lexer_drop_char(lexer);
return;
@@ -197,7 +194,6 @@ lexer_load_file_contents(lexer_t *lexer)
fprintf(stderr, "could not read file '%s'\n", lexer->filepath);
exit(EXIT_FAILURE);
}
-
}
void
@@ -220,7 +216,6 @@ lexer_is_eof(lexer_t *lexer)
return lexer->cur >= lexer->srclen;
}
-
bool
lexer_is_not_eof(lexer_t *lexer)
{
@@ -263,4 +258,3 @@ token_kind_to_str(token_kind_t kind)
assert(false && "unreachable");
}
}
-