def show
bolt@1.27.0.0 · src/syntax/tree.bend:445
import bolt@1.27.0.0/src/syntax/tree.bend as Tree
import Base
import bolt@1.27.0.0/src/syntax/lex.bend as Lex
445
446
447
448def show(nn: Node) -> String:
449 match nn:
450 case Leaf{Lex.Tok{k, t, l, c}}:
451 t
452 case Group{Lex.Tok{k, t, l, c}, kids, close}:
453 t ++ show(kids) ++ show_close(close)
454 case Stmt{kind, kids, body}:
455 +b = show(body)
456 "[" ++ show(kids) ++ Bool.pick(String, String.is_empty(b), "", " {" ++ b ++ "}") ++ "]"
457 case NNil{}:
458 ""
459 case NCons{h, t}:
460 +rest = show(t)
461 show(h) ++ Bool.pick(String, String.is_empty(rest), "", " " ++ rest)