Parse a format once into tokens, and have the fences read its ops

This commit is contained in:
2026-09-24 23:26:39 +02:00
committed by Lillem4n
parent aa972bbd95
commit 467cb6fb18
9 changed files with 186 additions and 208 deletions
+8 -16
View File
@@ -127,31 +127,23 @@ func renderEdges(n node) []renderEdge {
return es
case *template:
var es []renderEdge
add := func(name, operand string) {
a := splitArm(name, n.refs)
add := func(a arm, operand string) {
c := n.head(a.key)
if c == nil {
return
}
for _, leaf := range pathLeaves(c, a.tail) {
es = append(es, renderEdge{leaf, name, operand})
es = append(es, renderEdge{leaf, a.name, operand})
}
}
_ = eachToken(n.format, func(t ftoken) error {
if t.kind != 'b' {
return nil
for _, o := range n.ops {
for _, a := range o.operands {
add(a, o.fn)
}
if fn, _, isFunc := funcCall(t.body); isFunc {
for _, operand := range tokenOperands(t.body) {
add(operand, fn)
}
return nil
for _, a := range o.arms {
add(a, "")
}
for _, name := range splitOutside(t.body, '|') {
add(name, "")
}
return nil
})
}
return es
case *table:
return []renderEdge{{to: n.format, label: "format"}}