From ec3f0a41258099b4aa04ce236d062ffe0580f27d Mon Sep 17 00:00:00 2001 From: Ian Moffett Date: Wed, 1 Oct 2025 16:32:58 -0400 Subject: np: lex: Add TT_NONE token for invalid types Signed-off-by: Ian Moffett --- src/sys/include/np/lex.h | 3 +++ src/sys/np/core/np_lex.c | 1 + src/sys/np/core/np_parse.c | 3 +++ 3 files changed, 7 insertions(+) (limited to 'src') diff --git a/src/sys/include/np/lex.h b/src/sys/include/np/lex.h index 9c6e69e..cbbc403 100644 --- a/src/sys/include/np/lex.h +++ b/src/sys/include/np/lex.h @@ -47,6 +47,9 @@ struct np_work; * possible */ typedef enum { + /* Reserved */ + TT_NONE, /* Always invalid */ + /* Symbols */ TT_LPAREN, /* '(' */ TT_RPAREN, /* ')' */ diff --git a/src/sys/np/core/np_lex.c b/src/sys/np/core/np_lex.c index 8eb5039..eb15a52 100644 --- a/src/sys/np/core/np_lex.c +++ b/src/sys/np/core/np_lex.c @@ -256,6 +256,7 @@ lex_nom(struct np_work *work, struct lex_token *res) } lex_st = &work->lex_st; + res->token = TT_NONE; /* Skip all whitespace */ while ((c = lex_pop(work)) != 0) { diff --git a/src/sys/np/core/np_parse.c b/src/sys/np/core/np_parse.c index b894edb..2b52cbe 100644 --- a/src/sys/np/core/np_parse.c +++ b/src/sys/np/core/np_parse.c @@ -40,6 +40,9 @@ /* Token to string conversion table */ static const char *stoktab[] = { + /* Reserved */ + [TT_NONE] = "", + /* Symbols */ [TT_LPAREN] = "", [TT_RPAREN] = "", -- cgit v1.2.3