<- Back to shtanton's homepage
aboutsummaryrefslogtreecommitdiff
path: root/walk
diff options
context:
space:
mode:
authorCharlie Stanton <charlie@shtanton.xyz>2024-03-29 09:49:26 +0000
committerCharlie Stanton <charlie@shtanton.xyz>2024-03-29 09:49:26 +0000
commit080a24e894f125d4f1741cfdcba7cb722304d209 (patch)
tree78c12af110a8a239b6a3b1f828e4f193fcb8cd32 /walk
parent510a8c95ce112617c33f8dfb865e752db0716cb1 (diff)
downloadstred-go-080a24e894f125d4f1741cfdcba7cb722304d209.tar
Completely remove the path space
The new design uses deeply nested values in the value space instead.
Diffstat (limited to 'walk')
-rw-r--r--walk/read.go4
-rw-r--r--walk/walk.go49
2 files changed, 45 insertions, 8 deletions
diff --git a/walk/read.go b/walk/read.go
index f25109c..5aedafb 100644
--- a/walk/read.go
+++ b/walk/read.go
@@ -6,6 +6,6 @@ type StredReader interface {
}
type StredWriter interface {
- Write(WalkItem) error
+ Write(Value) error
AssertDone()
-} \ No newline at end of file
+}
diff --git a/walk/walk.go b/walk/walk.go
index fc9e9de..3fba62f 100644
--- a/walk/walk.go
+++ b/walk/walk.go
@@ -7,7 +7,41 @@ import (
type PathSegment interface {}
+type OutputList interface {
+ outputList()
+}
+
+type OutputValueList []Value
+func (_ OutputValueList) outputList() {}
+
+type OutputRuneList []rune
+func (_ OutputRuneList) outputList() {}
+
+// Can be passed to .eat on a state
+type Edible interface {
+ edible()
+}
+
+type RuneEdible rune
+func (_ RuneEdible) edible() {}
+
+type Terminal int
+const (
+ ArrayEnd Terminal = iota
+ MapEnd
+ StringEnd
+)
+func (_ Terminal) edible() {}
+
+// Simple value
+// Has a literal
+type Scalar interface {
+ Value
+ scalar()
+}
+
type Value interface {
+ Edible
value()
Debug() string
}
@@ -17,6 +51,8 @@ func (_ NullValue) value() {}
func (_ NullValue) Debug() string {
return "null"
}
+func (_ NullValue) edible() {}
+func (_ NullValue) scalar() {}
type BoolValue bool
func (_ BoolValue) value() {}
@@ -26,24 +62,23 @@ func (b BoolValue) Debug() string {
}
return "false"
}
+func (_ BoolValue) edible() {}
+func (_ BoolValue) scalar() {}
type NumberValue float64
func (_ NumberValue) value() {}
func (n NumberValue) Debug() string {
return fmt.Sprintf("%v", float64(n))
}
-
-type RuneValue rune
-func (_ RuneValue) value() {}
-func (r RuneValue) Debug() string {
- return string(r)
-}
+func (_ NumberValue) edible() {}
+func (_ NumberValue) scalar() {}
type StringValue string
func (_ StringValue) value() {}
func (s StringValue) Debug() string {
return fmt.Sprintf("%q", string(s))
}
+func (_ StringValue) edible() {}
type ArrayElement struct {
Index int
@@ -66,6 +101,7 @@ func (array ArrayValue) Debug() string {
builder.WriteRune(']')
return builder.String()
}
+func (_ ArrayValue) edible() {}
type MapElement struct {
Key string
@@ -88,6 +124,7 @@ func (m MapValue) Debug() string {
builder.WriteRune('}')
return builder.String()
}
+func (_ MapValue) edible() {}
type WalkItem struct {
Value Value