better syn tree display
This commit is contained in:
@@ -10,7 +10,7 @@ mod parse;
|
|||||||
mod symbols;
|
mod symbols;
|
||||||
|
|
||||||
fn write_expr(expr: &Expr, writer: &mut impl Write, prefix: &str, is_last: bool) -> io::Result<()> {
|
fn write_expr(expr: &Expr, writer: &mut impl Write, prefix: &str, is_last: bool) -> io::Result<()> {
|
||||||
let branch = if is_last { "+--" } else { "|--" };
|
let branch = if is_last { "└──" } else { "├──" };
|
||||||
|
|
||||||
match expr {
|
match expr {
|
||||||
Expr::Int { value, .. } => writeln!(writer, "{}{}<{}>", prefix, branch, value),
|
Expr::Int { value, .. } => writeln!(writer, "{}{}<{}>", prefix, branch, value),
|
||||||
@@ -22,7 +22,7 @@ fn write_expr(expr: &Expr, writer: &mut impl Write, prefix: &str, is_last: bool)
|
|||||||
let new_prefix = if is_last {
|
let new_prefix = if is_last {
|
||||||
format!("{} ", prefix)
|
format!("{} ", prefix)
|
||||||
} else {
|
} else {
|
||||||
format!("{}| ", prefix)
|
format!("{}│ ", prefix)
|
||||||
};
|
};
|
||||||
|
|
||||||
write_expr(lhs, writer, &new_prefix, false)?;
|
write_expr(lhs, writer, &new_prefix, false)?;
|
||||||
|
|||||||
Reference in New Issue
Block a user