use test_lang::Snapshot;
#[derive(Debug)]
#[allow(dead_code)]
enum Expr {
Int(i64),
Binary {
op: char,
lhs: Box<Expr>,
rhs: Box<Expr>,
},
}
fn parse_example() -> Expr {
Expr::Binary {
op: '+',
lhs: Box::new(Expr::Int(1)),
rhs: Box::new(Expr::Binary {
op: '*',
lhs: Box::new(Expr::Int(2)),
rhs: Box::new(Expr::Int(3)),
}),
}
}
fn main() {
let tree = parse_example();
let snapshot = Snapshot::debug(&tree);
println!("captured syntax tree:\n{snapshot}\n");
match snapshot.check(snapshot.as_str()) {
Ok(()) => println!("tree snapshot is stable"),
Err(mismatch) => {
println!("{mismatch}");
std::process::exit(1);
}
}
}