Skip to main content

pretty_print

Function pretty_print 

Source
pub fn pretty_print(expr: &Expr) -> String
Expand description

Pretty print an expression to a string.

The output uses Haskell-style surface syntax with minimal parentheses.

ยงExamples

use std::sync::Arc;
use panproto_expr::{Expr, Literal, BuiltinOp};
use panproto_expr_parser::pretty_print;

let e = Expr::Builtin(BuiltinOp::Add, vec![
    Expr::Var(Arc::from("x")),
    Expr::Lit(Literal::Int(1)),
]);
assert_eq!(pretty_print(&e), "x + 1");