From 0abc66ad91b8bcc25aeb7f3d086fcc52529ec8e8 Mon Sep 17 00:00:00 2001 From: Vincent Ambo Date: Thu, 13 Oct 2022 15:23:45 +0300 Subject: feat(tvix/eval): add an AST pretty-printing module This implements serde::Serialize for the rnix AST through a wrapper type, and exposes a function for serialising the AST into a (pretty-printed JSON) string representation. This can be used to debug issues with the AST, and to display an AST reprsentation in tools like tvixbolt. Serialize is implemented manually because we don't own any of the structs and the way to traverse them is not easily derived automatically, and this is quite verbose. We might be able to condense it a little bit, but at the same time it's also fairly straightforward. Change-Id: I922df43cfc25636f3c8baee7944c75ade516055c Reviewed-on: https://cl.tvl.fyi/c/depot/+/6943 Autosubmit: tazjin Tested-by: BuildkiteCI Reviewed-by: Adam Joseph Reviewed-by: tazjin --- corp/tvixbolt/Cargo.lock | 1 + 1 file changed, 1 insertion(+) (limited to 'corp/tvixbolt') diff --git a/corp/tvixbolt/Cargo.lock b/corp/tvixbolt/Cargo.lock index a50ca39bf29e..3359f6b36335 100644 --- a/corp/tvixbolt/Cargo.lock +++ b/corp/tvixbolt/Cargo.lock @@ -615,6 +615,7 @@ dependencies = [ "regex", "rnix", "rowan", + "serde", "serde_json", "smol_str", "tabwriter", -- cgit 1.4.1