def render

bolt@1.27.0.0 · src/syntax/bind.bend:322

import bolt@1.27.0.0/src/syntax/bind.bend as Bind
import Base
import bolt@1.27.0.0/src/syntax/lex.bend as Lex
import bolt@1.27.0.0/src/syntax/tree.bend as Tree

322# the text of a chain up to its first comma
323def render(nn: Tree.Node) -> String:
324  match nn:
325    case Tree.NCons{Tree.Leaf{Lex.Tok{Lex.TComma{}, t, l, c}}, rest}:
326      ""
327    case Tree.NCons{Tree.Leaf{Lex.Tok{k, t, l, c}}, rest}:
328      spaced(t) ++ render(rest)
329    case Tree.NCons{Tree.Group{Lex.Tok{k, t, l, c}, kids, close}, rest}:
330      t ++ render_all(kids) ++ render_close(close) ++ render(rest)
331    case other:
332      ""

Uses (8)

Used by (1)