Post #2029199
2026-05-04 13:54 UTC
Replies (1)
-
@bal4e@tech.lgbt 2026-05-04 14:47
@jamey I think you're right, a macro match arm is pretty much limited to regular languages. I had considered mentioning regexes near the end, but omitted them because they can be ambiguous about ambiguity :p. But regular languages do explicitly allow for ambiguity, so that would work. I think the literature on regular languages could inform this design space further -- thanks for bringing that up! However, meta-variables like $:expr do not fit within regular languages. It seems there is another case of ambiguity there -- a match arm like $(0 +)* $e:expr, given 0 + 0 + 0 + 0 + 0 + 0 + 0, could still result in asymptotic (this time, at worst quadratic) blowup. You could guard for this by supporting packrat parsing for meta-variables too (perhaps only enabling it after certain iterations of the match arm, so that you don't waste time caching stuff in easy cases). I'll add a note to the blog post :)