Split the picks and the name fences out of name.go, state the repeat refusal and the naming rule where they hold, and draw a memo's variants one way
This commit is contained in:
@@ -323,7 +323,7 @@ func (t *table) compileRowFormat(format string) error {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if err := checkTableToks(toks, nil); err != nil {
|
||||
if err := refuseTableBinding(toks); err != nil {
|
||||
return err
|
||||
}
|
||||
for _, tok := range toks {
|
||||
@@ -345,25 +345,21 @@ func (t *table) compileRowFormat(format string) error {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if err := checkTableToks(nil, unbound); err != nil {
|
||||
return err
|
||||
if len(unbound) > 0 {
|
||||
return unbound[0].err
|
||||
}
|
||||
t.formatTemplate = &template{format: format, tokens: toks, fields: fields, repeat: 1, isRecord: true, site: tableSite{t, formatRow}}
|
||||
t.rowNode = &tableRow{t}
|
||||
return nil
|
||||
}
|
||||
|
||||
// checkTableToks refuses a table's format or cell binding a name, or reading a head no column
|
||||
// holds: a table holds no names.
|
||||
func checkTableToks(toks []formatToken, unbound []unboundRead) error {
|
||||
// refuseTableBinding refuses a table's format or cell binding a name.
|
||||
func refuseTableBinding(toks []formatToken) error {
|
||||
for _, tok := range toks {
|
||||
if tok.kind == nameBind {
|
||||
return fmt.Errorf("token {%s}: a table binds no name; bind it in a template reading the table", tok.body)
|
||||
}
|
||||
}
|
||||
if len(unbound) > 0 {
|
||||
return unbound[0].err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user