Split drawCheck.reads's condition into readsOnEdge and walksInto, and drop the done item
This commit is contained in:
+14
-1
@@ -119,7 +119,7 @@ func (c *drawCheck) reads(n node, stopAtGroup bool) bool {
|
|||||||
}
|
}
|
||||||
r := false
|
r := false
|
||||||
for _, e := range renderEdges(n) {
|
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
|
r = true
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
@@ -131,6 +131,19 @@ func (c *drawCheck) reads(n node, stopAtGroup bool) bool {
|
|||||||
return r
|
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 {
|
func repeats(n node) bool {
|
||||||
t, isTemplate := n.(*template)
|
t, isTemplate := n.(*template)
|
||||||
return isTemplate && t.repeat > 1
|
return isTemplate && t.repeat > 1
|
||||||
|
|||||||
@@ -19,7 +19,6 @@ Self-sufficiency 5.6), every seat capped by Locality or Self-sufficiency.
|
|||||||
|
|
||||||
This round, in order:
|
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`
|
- 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
|
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
|
`ftoken` and a builtin in `formatToken` and `op`; `tokens` is a template's parsed format
|
||||||
|
|||||||
Reference in New Issue
Block a user