-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathnode.go
More file actions
37 lines (29 loc) · 655 Bytes
/
node.go
File metadata and controls
37 lines (29 loc) · 655 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
package messageformat
import "bytes"
type (
Expression interface{}
node struct {
children []*nodeExpr
}
nodeExpr struct {
ctype string
expr Expression
}
)
func (x *node) add(ctype string, child Expression) {
x.children = append(x.children, &nodeExpr{ctype, child})
}
func (x *node) format(ptr_output *bytes.Buffer, data *map[string]interface{}, ptr_mf *MessageFormat, pound string) error {
for _, child := range x.children {
ctype := child.ctype
fn, err := ptr_mf.getFormatter(ctype)
if err != nil {
return err
}
err = fn(child.expr, ptr_output, data, ptr_mf, pound)
if err != nil {
return err
}
}
return nil
}