Address #1674 - Add cms combinator to peg.

It behaves like `cmt`, but flattens the result and can collect
multiple captures if an indexed data structure is returned.
This commit is contained in:
Calvin Rose
2025-11-30 14:19:51 -06:00
parent 238d6c2e13
commit f79e4d6249
4 changed files with 38 additions and 7 deletions
+10 -1
View File
@@ -835,5 +835,14 @@
(test "issue 1554 case 8" '(between 2 3 (? (> '1))) "abc" @["a" "a" "a"])
(test "issue 1554 case 9" '(between 0 0 (> (? '1))) "abc" @[])
(end-suite)
# Capture Match Flatten
(test "capture match splice 1"
~(cms (* 1 '1 1) ,|[$ $ $])
"abc"
@["b" "b" "b"])
(test "capture match no splice 1"
~(cmt (* 1 '1 1) ,|[$ $ $])
"abc"
@[["b" "b" "b"]])
(end-suite)