diff options
Diffstat (limited to 'src/lexer.h')
-rw-r--r-- | src/lexer.h | 18 |
1 files changed, 13 insertions, 5 deletions
diff --git a/src/lexer.h b/src/lexer.h index efd03df..e2862bb 100644 --- a/src/lexer.h +++ b/src/lexer.h @@ -4,6 +4,8 @@ #include <stddef.h> #include <stdint.h> +#include "types.h" + enum { LEXIDENT, @@ -12,12 +14,14 @@ enum { LEXEQ = '=', LEXLANGL = '<', LEXLBRACE = '{', + LEXLBRKT = '[', LEXLPAR = '(', LEXMINUS = '-', LEXPIPE = '|', LEXPLUS = '+', LEXRANGL = '>', LEXRBRACE = '}', + LEXRBRKT = ']', LEXRPAR = ')', LEXSEMI = ';', LEXSLASH = '/', @@ -33,12 +37,16 @@ enum { typedef uint8_t lexeme_kind; -struct lexeme { - lexeme_kind kind; - const char *p; - size_t len; +#define LEXEMES_SOA_BLKSZ (sizeof(lexeme_kind) + sizeof(struct strview)) + +struct lexemes_soa { + lexeme_kind *kinds; + struct strview *strs; + size_t len, cap; }; -struct lexeme *lexstring(const unsigned char *, size_t, size_t *); +#define lexemes_free(x) free(x.kinds) + +struct lexemes_soa lexstring(const uchar *, size_t); #endif /* !ORYX_LEXER_H */ |