From 4f62fe8f9fde8caf9ecd34ac4318c89ceb745673 Mon Sep 17 00:00:00 2001 From: Ian Moffett Date: Tue, 30 Sep 2025 21:17:56 -0400 Subject: np: lex: Add pr_error() macro for error logs Signed-off-by: Ian Moffett --- src/sys/np/core/np_lex.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'src/sys/np/core') diff --git a/src/sys/np/core/np_lex.c b/src/sys/np/core/np_lex.c index 5a96443..ca1d065 100644 --- a/src/sys/np/core/np_lex.c +++ b/src/sys/np/core/np_lex.c @@ -35,6 +35,7 @@ #include #define pr_trace(fmt, ...) printf("pirho.lex: " fmt, ##__VA_ARGS__) +#define pr_error(fmt, ...) printf("pirho.lex: error: " fmt, ##__VA_ARGS__) /* Max identifier length */ #define MAX_ID_LEN 32 @@ -118,7 +119,7 @@ lex_matchstr(struct np_work *work, char c, struct lex_token *res) /* Grab the identifier */ do { if (id_idx >= sizeof(id) - 1) { - pr_trace("error: identifier too long!\n"); + pr_error("identifier too long!\n"); return -1; } if (!is_alpha(c) && !is_num(c)) { @@ -132,7 +133,7 @@ lex_matchstr(struct np_work *work, char c, struct lex_token *res) /* Match the tokens */ error = lex_cmptok(id, res); if (error < 0) { - pr_trace("error: invalid indentifier '%s'\n", id); + pr_error("invalid indentifier '%s'\n", id); } return error; } @@ -173,7 +174,7 @@ lex_nom(struct np_work *work, struct lex_token *res) default: /* Stuff like '1var_name' is invalid */ if (!is_alpha(c)) { - pr_trace("error: unexpected token '%c'\n", c); + pr_error("unexpected token '%c'\n", c); return -1; } @@ -182,7 +183,7 @@ lex_nom(struct np_work *work, struct lex_token *res) break; } - pr_trace("error: got bad token '%c'\n", c); + pr_error("got bad token '%c'\n", c); error = -1; break; } -- cgit v1.2.3