From 9fa945ad9301dc099563353dd4e81007bdf40741 Mon Sep 17 00:00:00 2001 From: Calvin Rose Date: Fri, 29 Apr 2022 19:21:10 -0500 Subject: [PATCH] Don't include captures of last match from `to` combinator. --- src/core/peg.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/core/peg.c b/src/core/peg.c index cd321726..d8ab0265 100644 --- a/src/core/peg.c +++ b/src/core/peg.c @@ -289,7 +289,10 @@ tail: while (text <= s->text_end) { CapState cs2 = cap_save(s); next_text = peg_rule(s, rule_a, text); - if (next_text) break; + if (next_text) { + if (rule[0] == RULE_TO) cap_load(s, cs2); + break; + } cap_load(s, cs2); text++; }