From e2503def53445f74d37fcbc5d67b956bd795092f Mon Sep 17 00:00:00 2001 From: Ian Moffett Date: Wed, 1 Oct 2025 02:25:49 -0400 Subject: np: lex: Handle digits in the stream Signed-off-by: Ian Moffett --- src/sys/np/core/np_parse.c | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'src/sys/np/core/np_parse.c') diff --git a/src/sys/np/core/np_parse.c b/src/sys/np/core/np_parse.c index 165fed5..253b017 100644 --- a/src/sys/np/core/np_parse.c +++ b/src/sys/np/core/np_parse.c @@ -56,6 +56,9 @@ static const char *stoktab[] = { /* Types */ [TT_U8] = "", + /* Values */ + [TT_NUMBER] = "", + /* Keywords */ [TT_BEGIN] = "", [TT_PROC] = "", @@ -79,11 +82,17 @@ parse_work(struct np_work *work) return error; } + /* Don't overflow the table */ if (tok.token > NELEM(stoktab)) { pr_error("bad token %d\n", tok.token); return -1; } + + /* Log the token */ printf("tok.type: %s\n", stoktab[tok.token]); + if (tok.token == TT_NUMBER) { + printf("tok.val: %d\n", tok.val); + } } return 0; -- cgit v1.2.3