From ab0a10115db14add699a305351ea8822a997c72c Mon Sep 17 00:00:00 2001 From: Lilleman auf Larv Date: Fri, 25 Sep 2026 09:01:49 +0200 Subject: [PATCH] Split drawCheck.reads's condition into readsOnEdge and walksInto, and drop the done item --- drawfence.go | 15 ++++++++++++++- todo.md | 1 - 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/drawfence.go b/drawfence.go index ec40eda..400b925 100644 --- a/drawfence.go +++ b/drawfence.go @@ -119,7 +119,7 @@ func (c *drawCheck) reads(n node, stopAtGroup bool) bool { } r := false for _, e := range renderEdges(n) { - if a, isRef := refRead(n, e.label); (isRef && (len(a.tail) > 0 || readsTable(n, a))) || (!repeats(e.to) && !(stopAtGroup && grouped(e.to)) && c.reads(e.to, stopAtGroup)) { + if readsOnEdge(n, e.label) || (walksInto(e.to, stopAtGroup) && c.reads(e.to, stopAtGroup)) { r = true break } @@ -131,6 +131,19 @@ func (c *drawCheck) reads(n node, stopAtGroup bool) bool { return r } +// readsOnEdge reports whether an edge of n is itself a reference path: a reference with a tail, or +// one naming a table. +func readsOnEdge(n node, label string) bool { + a, isRef := refRead(n, label) + return isRef && (len(a.tail) > 0 || readsTable(n, a)) +} + +// walksInto reports whether reads walks on into to, which it does short of a repeat, and of a draw +// group when stopAtGroup. +func walksInto(to node, stopAtGroup bool) bool { + return !repeats(to) && !(stopAtGroup && grouped(to)) +} + func repeats(n node) bool { t, isTemplate := n.(*template) return isTemplate && t.repeat > 1 diff --git a/todo.md b/todo.md index ce749a6..7b9aa8c 100644 --- a/todo.md +++ b/todo.md @@ -19,7 +19,6 @@ Self-sufficiency 5.6), every seat capped by Locality or Self-sufficiency. This round, in order: -- Split `drawCheck.reads`'s six-term condition into named predicates. - Rename what names two things: `template.go` holds the token grammar while `template` is `node.go`'s type and `Template` `inline.go`'s; `kind` `'b'` is a brace body in `ftoken` and a builtin in `formatToken` and `op`; `tokens` is a template's parsed format