From daf076bb6026005c118dac321b7fe752e530faf8 Mon Sep 17 00:00:00 2001 From: "Sven M. Hallberg" <pesco@khjk.org> Date: Sun, 24 Nov 2019 22:18:19 +0100 Subject: [PATCH] pprint a null AST as "(null)" and TT_NONE as "none" --- src/pprint.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/pprint.c b/src/pprint.c index 52f42eb6..c178eb72 100644 --- a/src/pprint.c +++ b/src/pprint.c @@ -31,9 +31,13 @@ typedef struct pp_state { } pp_state_t; void h_pprint(FILE* stream, const HParsedToken* tok, int indent, int delta) { + if (tok == NULL) { + fprintf(stream, "%*s(null)\n", indent, ""); + return; + } switch (tok->token_type) { case TT_NONE: - fprintf(stream, "%*snull\n", indent, ""); + fprintf(stream, "%*snone\n", indent, ""); break; case TT_BYTES: if (tok->bytes.len == 0) @@ -54,7 +58,6 @@ void h_pprint(FILE* stream, const HParsedToken* tok, int indent, int delta) { fprintf(stream, "%*ss -%#" PRIx64 "\n", indent, "", -tok->sint); else fprintf(stream, "%*ss %#" PRIx64 "\n", indent, "", tok->sint); - break; case TT_UINT: fprintf(stream, "%*su %#" PRIx64 "\n", indent, "", tok->uint); -- GitLab