From 86285533c637d673dc14d4e34530ce8864831600 Mon Sep 17 00:00:00 2001 From: WormHeamer Date: Sat, 2 Aug 2025 02:40:04 -0400 Subject: whole bunch of graph stuff, fixing up, basic arithmetic peepholes... --- lex.h | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) (limited to 'lex.h') diff --git a/lex.h b/lex.h index daf71cc..9c38208 100644 --- a/lex.h +++ b/lex.h @@ -22,6 +22,10 @@ X(EQUALS, "=")\ X(COLON, ":")\ X(COMMA, ",")\ + X(NOT, "~")\ + X(AND, "&")\ + X(OR, "|")\ + X(XOR, "^")\ X(LIT_STR, "string literal")\ X(LIT_CHAR, "character literal")\ X(LIT_NUM, "numeric literal") @@ -37,7 +41,12 @@ X(TOK_SLASH, '/')\ X(TOK_EQUALS, '=')\ X(TOK_COLON, ':')\ - X(TOK_COMMA, ',') + X(TOK_COMMA, ',')\ + X(TOK_NOT, '~')\ + X(TOK_AND, '&')\ + X(TOK_OR, '|')\ + X(TOK_XOR, '^') + typedef enum { #define X(n, s) TOK_##n, @@ -60,9 +69,14 @@ typedef enum { #undef X } TokMask; +typedef struct { + int ofs, n; +} LexSpan; + typedef struct { Token tok; Str ident; + LexSpan pos; Str filename, buf; Arena arena; int ofs; @@ -79,8 +93,9 @@ void lex_expected(Lexer *l, TokMask t); void lex_expected_not(Lexer *l, TokMask t); void lex_expect(Lexer *l, TokMask t); /* next -> expected */ void lex_expect_not(Lexer *l, TokMask t); /* next -> expected_not */ +void lex_error_at(Lexer *l, LexSpan pos, LexErr e, Str msg); void lex_error(Lexer *l, LexErr e, Str msg); -void lex_pos(Lexer *l, int *line, int *col); +void lex_pos(Lexer *l, int ofs, int *line, int *col); void lex_next(Lexer *l); #endif -- cgit v1.2.3