Json dumping functions for debugging #848
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 including1f
), since that's apparently required.