Context: getting creative with target language syntax in a PL course.
I want to use match
ellipses to apply to multiple elements. syntax/parse
has a ~seq
feature that handles this. Here's what I would like to write, imagining that the ~seq
feature was present in match:
(match '{locals : x = 3 : y = {+ 4} : {+ x y}}
[(list 'locals ': (~seq vars '= var-exprs ':) ... expr)
(list vars var-exprs expr)])
In other words, I want the ellipsis to apply to vars, the equal sign, the var-exprs, and the trailing colon. Is there a way to do this that I'm missing?
(To be clear: it's very easy to do this by soaking up all the elements between the first and last, and just using a helper function. The question is just whether there's match magic that can make this fly.)