From 5d66c96a190a396a1535c89bed4e33c2a005fe8d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yaroslav=20de=20la=20Pe=C3=B1a=20Smirnov?= Date: Thu, 24 Mar 2022 01:04:02 +0300 Subject: Initial commit Basically it works, just needs some polishing and maybe a couple of features that I could actually use. Also probably better docs. Not sure if it will be of use to anybody besides me. --- include/lexer.h | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 include/lexer.h (limited to 'include/lexer.h') diff --git a/include/lexer.h b/include/lexer.h new file mode 100644 index 0000000..8491c5a --- /dev/null +++ b/include/lexer.h @@ -0,0 +1,33 @@ +#ifndef ROSCHA_LEXER_H +#define ROSCHA_LEXER_H + +#include "slice.h" +#include "token.h" + +#include +#include + +/* The lexer */ +struct lexer { + /* Source input */ + const char *input; + /* Length of input */ + size_t len; + /* The current slice of the input string that will be tokenized */ + struct slice word; + /* The current character belongs to content and should not be tokenized */ + bool in_content; + size_t line; + size_t column; +}; + +/* Allocate a new lexer with input as the source */ +struct lexer *lexer_new(const char *input); + +/* Get the next token from the lexer */ +struct token lexer_next_token(struct lexer *); + +/* Free all memory related to the lexer */ +void lexer_destroy(struct lexer *); + +#endif -- cgit v1.2.3