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 --- tvix/eval/Cargo.lock | 1 + 1 file changed, 1 insertion(+) (limited to 'tvix/eval/Cargo.lock') diff --git a/tvix/eval/Cargo.lock b/tvix/eval/Cargo.lock index 5e9aaa0867..e4ab0214af 100644 --- a/tvix/eval/Cargo.lock +++ b/tvix/eval/Cargo.lock @@ -1223,6 +1223,7 @@ dependencies = [ "rnix", "rowan", "rustyline", + "serde", "serde_json", "smol_str", "tabwriter", -- cgit 1.4.1