diff options
| author | 0x221e | 2026-06-17 00:07:58 +0200 |
|---|---|---|
| committer | 0x221e | 2026-06-17 01:12:23 +0300 |
| commit | 8a77b4096d9f61b6b6eaefb4c8c8abe7f4793b73 (patch) | |
| tree | 2a51d4bc47e9add8c4175b6906ca8b1e5921c133 /include/lex.h | |
| parent | 9224992817c3faf7d6274681fb5bacc5ad761504 (diff) | |
lex: pretty error messages and lex_number() checks
Error messages are now pretty (not rlly), and lex_number() now checks
improper use of number and binary literals. osal.h now also requires
platforms to implement a printv() wrapper.
Diffstat (limited to 'include/lex.h')
| -rw-r--r-- | include/lex.h | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/include/lex.h b/include/lex.h index 634be5f..bdfd32f 100644 --- a/include/lex.h +++ b/include/lex.h @@ -33,10 +33,15 @@ const char* lex_get_token_name(int id); +#define LEX_NUMBER_ERR 0 +#define LEX_HEX_ERR 1 +#define LEX_BINARY_ERR 2 + + struct token { int type; // size_t line; -// size_t pos; +// size_t linepos; size_t length; char *lexeme; }; @@ -45,12 +50,16 @@ struct lex { size_t pos; size_t size; char* buffer; + const char* filepath; size_t line; + size_t linepos; }; char lex_advance(struct lex *l, size_t o); char lex_seek(struct lex *l, size_t o); +void lex_error(struct lex *l, int err_code, const char *s, ...); + struct token lex_number(struct lex *l); struct token lex_directive(struct lex *l); struct token lex_link_unit(struct lex *l); |
