miking-lang / miking

Miking - the meta viking: a meta-language system for creating embedded languages
Other
51 stars 31 forks source link

Json dumping functions for debugging #848

Closed elegios closed 3 months ago

elegios commented 6 months ago

I found during development of the reptypes stuff that it was convenient to dump lots of data as json, then explore with, e.g., jless or jq, so I figured it'd be useful to have similar tools available for mexpr in general (and it was in fact useful to debug some lambda-lifting issues). This PR thus adds a basic module that just dumps everything in the AST. There's no place in the compiler (or any of the dependent projects) that uses this right now, but it's now a straightforward tool to reach for when you need to explore a large AST and the other tools we have don't really scale.

It also uses the idea of #826 when printing chains of bindings (I did not have time to do the full refactor unfortunately, but updating this library once that is done should be trivial).

Finally, I also changed json.mc so that it escapes all values with codepoints < 32 (i.e., up to and including 1f), since that's apparently required.