record bnode(value,left,right)

procedure btree(stree)
   local x
   stree ? if x := bnode(tab(upto('('))) then {
      move(1)
      x.left := btree(tab(bal(',')))
      move(1)
      x.right := btree(tab(bal(')')))
      }
      else x := bnode(tab(0))
   return x
end

procedure stree(btree)
   local s
   if /btree.left then return btree.value
   s := btree.value || "(" ||
      stree(btree.left) || "," || stree(btree.right) || ")"
   return s
end
