<- Back to shtanton's homepage
aboutsummaryrefslogtreecommitdiff
path: root/walk
diff options
context:
space:
mode:
Diffstat (limited to 'walk')
-rw-r--r--walk/walk.go32
1 files changed, 32 insertions, 0 deletions
diff --git a/walk/walk.go b/walk/walk.go
index 1df7a6e..30bfb29 100644
--- a/walk/walk.go
+++ b/walk/walk.go
@@ -19,19 +19,47 @@ const (
func (value TerminalValue) Pieces(out chan<- Datum) {
out<-value
}
+func (value TerminalValue) String() string {
+ switch value {
+ case ArrayBegin:
+ return "["
+ case ArrayEnd:
+ return "]"
+ case MapBegin:
+ return "{"
+ case MapEnd:
+ return "}"
+ default:
+ panic("Unknown TerminalValue")
+ }
+}
type ValueNull struct {}
func (value ValueNull) Pieces(out chan<- Datum) {
out<-value
}
+func (value ValueNull) String() string {
+ return "null"
+}
type ValueBool bool
func (value ValueBool) Pieces(out chan<- Datum) {
out<-value
}
+func (value ValueBool) String() string {
+ if value {
+ return "true"
+ } else {
+ return "false"
+ }
+}
type ValueNumber float64
func (value ValueNumber) Pieces(out chan<- Datum) {
out<-value
}
+func (value ValueNumber) String() string {
+ v := float64(value)
+ return fmt.Sprintf("%f", v)
+}
type StartString struct {}
type EndString struct {}
@@ -43,11 +71,15 @@ func (value ValueString) Pieces(out chan<- Datum) {
}
out<-EndString{}
}
+func (value ValueString) String() string {
+ return fmt.Sprintf("\"%s\"", string(value))
+}
type Datum interface {}
type WalkValue interface {
Pieces(out chan<- Datum)
+ String() string
}
type WalkItem struct {