diff options
author | Ian Moffett <ian@osmora.org> | 2025-10-01 19:49:00 -0400 |
---|---|---|
committer | Ian Moffett <ian@osmora.org> | 2025-10-01 19:49:00 -0400 |
commit | f927e045e37129cf1a57ad85c15a0b04093f3177 (patch) | |
tree | 6365e5282b525345e954b1c8042299bd01d7272d | |
parent | 61ba4c15aaf1ccb985f32ce9af39ecd0b146fdfa (diff) |
np: lex: Add LEX_EOF define
Signed-off-by: Ian Moffett <ian@osmora.org>
-rw-r--r-- | src/sys/include/np/lex.h | 3 | ||||
-rw-r--r-- | src/sys/np/core/np_lex.c | 2 | ||||
-rw-r--r-- | src/sys/np/core/np_parse.c | 3 |
3 files changed, 7 insertions, 1 deletions
diff --git a/src/sys/include/np/lex.h b/src/sys/include/np/lex.h index 0edf262..ebd6f32 100644 --- a/src/sys/include/np/lex.h +++ b/src/sys/include/np/lex.h @@ -32,6 +32,9 @@ #include <sys/types.h> +/* End-of-file */ +#define LEX_EOF (-2) + struct np_work; /* Keywords */ diff --git a/src/sys/np/core/np_lex.c b/src/sys/np/core/np_lex.c index b2fad3a..7d72db8 100644 --- a/src/sys/np/core/np_lex.c +++ b/src/sys/np/core/np_lex.c @@ -323,7 +323,7 @@ lex_nom(struct np_work *work, struct lex_token *res) /* Match the token type */ switch (c) { case '\0': - return -2; /* EOF */ + return LEX_EOF; case '(': res->token = TT_LPAREN; break; diff --git a/src/sys/np/core/np_parse.c b/src/sys/np/core/np_parse.c index aba7198..4973ac0 100644 --- a/src/sys/np/core/np_parse.c +++ b/src/sys/np/core/np_parse.c @@ -272,6 +272,9 @@ parse_work(struct np_work *work) while (error == 0) { error = lex_nom(work, &tok); + if (error == LEX_EOF) { + break; + } if (error < 0) { return error; } |