From 64feef1b9ea72adf7ba32998e9dca7d507607498 Mon Sep 17 00:00:00 2001 From: Preston Pan Date: Mon, 2 Jan 2023 22:31:49 -0800 Subject: a lot of stuff. --- src/include/lexer.h | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 src/include/lexer.h (limited to 'src/include/lexer.h') diff --git a/src/include/lexer.h b/src/include/lexer.h new file mode 100644 index 0000000..36c5db8 --- /dev/null +++ b/src/include/lexer.h @@ -0,0 +1,39 @@ +#ifndef LEXER_H +#define LEXER_H + +#include "./token.h" + +#include + +typedef struct { + char *source; + int i; + char c; + + int row; + int col; + bool finished; +} lexer_t; + +void lexer_reset(lexer_t *lexer, char *source); + +lexer_t *init_lexer(char *source); + +void lexer_move(lexer_t *lexer); + +void lexer_skip_whitespace(lexer_t *lexer); + +void lexer_skip_comment(lexer_t *lexer); + +token_t *lexer_collect_bool(lexer_t *lexer); + +token_t *lexer_collect_id(lexer_t *lexer); + +token_t *lexer_collect_num(lexer_t *lexer); + +token_t *lexer_collect_string(lexer_t *lexer); + +token_t *lexer_collect_next(lexer_t *lexer); + +void lexer_error(lexer_t *lexer); +#endif -- cgit