Give head, index, bound and draw one meaning each, name familyRoot, and type the token kinds
This commit is contained in:
@@ -11,12 +11,12 @@ import (
|
||||
// its sibling names, and a render one per group for its reference paths.
|
||||
type hold struct {
|
||||
variant map[string]node
|
||||
value map[string]draw
|
||||
value map[string]readValue
|
||||
pins pinSet
|
||||
}
|
||||
|
||||
// draw is what one read drew: its text, and whether it landed on a null.
|
||||
type draw struct {
|
||||
// readValue is what one read drew: its text, and whether it landed on a null.
|
||||
type readValue struct {
|
||||
text string
|
||||
null bool
|
||||
}
|
||||
@@ -26,7 +26,7 @@ type draw struct {
|
||||
// kept, so {place.postal-code} and {place.locality} read one row, either read twice
|
||||
// gives one value, and a shown operand is the operand computed. Every other name is
|
||||
// drawn afresh, so {word} {word} still draws twice.
|
||||
func readField(s *session, t *template, held *hold, sc renderScope, a arm) draw {
|
||||
func readField(s *session, t *template, held *hold, sc renderScope, a arm) readValue {
|
||||
if s.trace != nil {
|
||||
traceRead(s.trace, t, sc, a)
|
||||
}
|
||||
@@ -34,7 +34,7 @@ func readField(s *session, t *template, held *hold, sc renderScope, a arm) draw
|
||||
if len(a.tail) > 0 {
|
||||
panic(fmt.Sprintf("fejkdata: %q reads a path into %q, which the expansion does not hold", a.spelling, a.key))
|
||||
}
|
||||
return draw{text: render(s, t.head(a.key), sc)}
|
||||
return readValue{text: render(s, t.head(a.key), sc)}
|
||||
}
|
||||
d := readHold(held, sc, a)
|
||||
if r, done := d.value[a.path]; done {
|
||||
@@ -45,7 +45,7 @@ func readField(s *session, t *template, held *hold, sc renderScope, a arm) draw
|
||||
}
|
||||
r := renderLeaf(s, drawPath(t.head(a.key), a.tail, a.key, &pathDraw{s: s, pins: &d.pins, held: d, a: &a}), sc)
|
||||
if d.value == nil {
|
||||
d.value = map[string]draw{}
|
||||
d.value = map[string]readValue{}
|
||||
}
|
||||
d.value[a.path] = r
|
||||
return r
|
||||
@@ -81,20 +81,20 @@ func readHold(held *hold, sc renderScope, a arm) *hold {
|
||||
|
||||
// renderLeaf draws and renders what a read lands on: null on a null item, or on a column of one
|
||||
// reference alone whose read drew null.
|
||||
func renderLeaf(s *session, n node, sc renderScope) draw {
|
||||
func renderLeaf(s *session, n node, sc renderScope) readValue {
|
||||
n = resolveChoice(s, n)
|
||||
switch leaf := n.(type) {
|
||||
case *nullItem:
|
||||
return draw{null: true}
|
||||
return readValue{null: true}
|
||||
case *template:
|
||||
if leaf.readsColumn != nil {
|
||||
return readField(s, leaf, nil, sc.in(leaf), leaf.readsColumn.a)
|
||||
}
|
||||
}
|
||||
return draw{text: render(s, n, sc)}
|
||||
return readValue{text: render(s, n, sc)}
|
||||
}
|
||||
|
||||
// resolveChoice resolves a choice to one variant, so a bound head is a concrete node the
|
||||
// resolveChoice resolves a choice to one variant, so a held head is a concrete node the
|
||||
// rest of the expansion shares. Nested choices unwrap too: a draw is one value, not
|
||||
// another set to pick from.
|
||||
func resolveChoice(s *session, n node) node {
|
||||
|
||||
Reference in New Issue
Block a user