From 1574ec62498ed1ae51d4bf9500d89e63422ce567 Mon Sep 17 00:00:00 2001 From: omicron Date: Wed, 16 Apr 2025 12:13:02 +0200 Subject: [PATCH] Fix parse_consecutive behavior when the token stream runs out --- src/parser/combinators.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/parser/combinators.c b/src/parser/combinators.c index 1c6cba7..7f6637d 100644 --- a/src/parser/combinators.c +++ b/src/parser/combinators.c @@ -1,4 +1,5 @@ #include "combinators.h" +#include "util.h" // Parse a list of the given parser delimited by the given token id. Does not // store the delimiters in the parent node @@ -122,5 +123,12 @@ parse_result_t parse_consecutive(tokenlist_entry_t *current, node_id_t id, } current = result.next; } + + // token stream ended before we matched all parsers + if (parser != nullptr) { + ast_node_free(all); + return parse_no_match(); + } + return parse_success(all, current); }