Matcher for a repeated pattern.
class repeat matcher[readonly value element type, covariant any value result type, any value intermediate type]
extends repeat pattern[element type]
implements matcher[element type, result type]
procedure[result type, readonly list[intermediate type]] list converter
Parse the list and produce a result. Assumes this pattern matches the list.
implement result type parse(readonly list[element type] the list)
var nonnegative index : 0
while index < the listsize
match : the patternmatch prefix(the listskip(index))
if match is null
utilitiespanic("Can't parse list in repeat_matcher")
assert match > 0
matched : (the pattern !> matcher[element type, intermediate type]) • parse(the listslice(index, index + match))
intermediate listappend(matched)
index += match
return list converter(intermediate list)