From babcf9d3cfc662e4b1ea58bc2a73ee4f9477c050 Mon Sep 17 00:00:00 2001 From: Ian Moffett Date: Sun, 15 Feb 2026 16:30:16 -0500 Subject: [PATCH] lexer: Add tokens for LBRACE and RBRACE Signed-off-by: Ian Moffett --- core/lexer.c | 8 ++++++++ core/parser.c | 2 ++ inc/rifle/token.h | 2 ++ 3 files changed, 12 insertions(+) diff --git a/core/lexer.c b/core/lexer.c index 299cf5b..d782a32 100644 --- a/core/lexer.c +++ b/core/lexer.c @@ -325,6 +325,14 @@ lexer_scan(struct rifle_state *state, struct token *res) res->type = TT_RPAREN; res->c = c; return 0; + case '{': + res->type = TT_LBRACE; + res->c = c; + return 0; + case '}': + res->type = TT_RBRACE; + res->c = c; + return 0; case '#': if ((c = lexer_nom(state, false)) == '\0') { trace_error(state, "unexpected end of file\n"); diff --git a/core/parser.c b/core/parser.c index 4e18e95..35fc51b 100644 --- a/core/parser.c +++ b/core/parser.c @@ -53,6 +53,8 @@ static const char *toktab[] = { [TT_COLON] = qtok(":"), [TT_LPAREN] = qtok("("), [TT_RPAREN] = qtok(")"), + [TT_LBRACE] = qtok("{"), + [TT_RBRACE] = qtok("}"), [TT_F] = qtok(".f"), [TT_EXTERN] = qtok(".extern"), [TT_DEFINE] = qtok("#define"), diff --git a/inc/rifle/token.h b/inc/rifle/token.h index 8e31c96..b4fbc25 100644 --- a/inc/rifle/token.h +++ b/inc/rifle/token.h @@ -14,6 +14,8 @@ typedef enum { TT_COLON, /* ':' */ TT_LPAREN, /* '(' */ TT_RPAREN, /* ')' */ + TT_LBRACE, /* '{' */ + TT_RBRACE, /* '}' */ TT_F, /* '.f' */ TT_EXTERN, /* '.extern' */ TT_DEFINE, /* '#define' */