One tricky part is backtracking: ... semantic actions must be prepared for the possibility that their results will be discarded. ... A straightforward [solution] is to limit your semantic actions to building ...an AST node, and [ensuring] the nodes get cleaned up if they’re not needed. In many cases, it would be nicer to be able to, say, emit bytecode into a buffer, but I’m not sure what the interface to that would look like.

Hmmm. I'd thought you were already in the (abstract) process of building a quasiquoter with alternative, potentially unused, expansions: so I think you know what an interface might look like, you just don't know if it's more trouble than it's worth to bootstrap...

-Dave

(emitting HTML or bytecode into a buffer is the monoidal string case; building an AST is the monadic (monoidal endofunctor) case)
cf http://okmij.org/ftp/tagless-final/course/index.html
(semantic actions are popular because they're normally an effective deforestation of the text -unfold-> AST -fold-> effects hylomorphism; if you hooked up a pattern matcher in front of the semantic actions it might be possible to come up with a tree-awk to decouple the actions from the parsing, at the risk of reinventing xslt)

--
To unsubscribe: http://lists.canonical.org/mailman/listinfo/kragen-discuss

Reply via email to