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 <tazjin@tvl.su> Tested-by: BuildkiteCI Reviewed-by: Adam Joseph <adam@westernsemico.com> Reviewed-by: tazjin <tazjin@tvl.su>
This commit is contained in:
parent
d9c497520c
commit
0abc66ad91
6 changed files with 503 additions and 2 deletions
|
@ -5,6 +5,7 @@ mod errors;
|
|||
mod eval;
|
||||
pub mod observer;
|
||||
mod opcode;
|
||||
mod pretty_ast;
|
||||
mod source;
|
||||
mod spans;
|
||||
mod upvalues;
|
||||
|
@ -25,6 +26,7 @@ pub use crate::builtins::global_builtins;
|
|||
pub use crate::compiler::compile;
|
||||
pub use crate::errors::EvalResult;
|
||||
pub use crate::eval::{interpret, Options};
|
||||
pub use crate::pretty_ast::pretty_print_expr;
|
||||
pub use crate::source::SourceCode;
|
||||
pub use crate::value::Value;
|
||||
pub use crate::vm::run_lambda;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue