<- Back to shtanton's homepage
aboutsummaryrefslogtreecommitdiff
path: root/subex/parse.go
diff options
context:
space:
mode:
Diffstat (limited to 'subex/parse.go')
-rw-r--r--subex/parse.go21
1 files changed, 18 insertions, 3 deletions
diff --git a/subex/parse.go b/subex/parse.go
index f1565f5..98821fd 100644
--- a/subex/parse.go
+++ b/subex/parse.go
@@ -34,13 +34,18 @@ const (
NoneStructure Structure = iota
StringStructure
ArrayStructure
+ ArrayValuesStructure
)
-func (s Structure) innerType() Type {
+func (s Structure) String() string {
switch s {
+ case NoneStructure:
+ return "-"
case StringStructure:
- return RuneType
+ return "~"
case ArrayStructure:
- return ValueType
+ return "@"
+ case ArrayValuesStructure:
+ return ":"
default:
panic("Invalid structure")
}
@@ -321,6 +326,9 @@ func parseDestructure(l RuneReader, destructure Structure, inType Type) (lhs Sub
case ArrayStructure:
innerInType = ValueType
expectedInType = ValueType
+ case ArrayValuesStructure:
+ innerInType = ValueType
+ expectedInType = ValueType
default:
panic("Invalid structure")
}
@@ -345,6 +353,9 @@ func parseDestructure(l RuneReader, destructure Structure, inType Type) (lhs Sub
case '@':
structure = ArrayStructure
expectedInnerOutType = ValueType
+ case ':':
+ structure = ArrayValuesStructure
+ expectedInnerOutType = ValueType
default:
panic("Missing matching destructure")
}
@@ -358,6 +369,8 @@ func parseDestructure(l RuneReader, destructure Structure, inType Type) (lhs Sub
outType = ValueType
case ArrayStructure:
outType = ValueType
+ case ArrayValuesStructure:
+ outType = ValueType
}
lhs = SubexASTDestructure {
@@ -385,6 +398,8 @@ func parseSubex(l RuneReader, minPower int, inType Type) (lhs SubexAST, outType
lhs, outType = parseDestructure(l, StringStructure, inType)
case '@':
lhs, outType = parseDestructure(l, ArrayStructure, inType)
+ case ':':
+ lhs, outType = parseDestructure(l, ArrayValuesStructure, inType)
// TODO
// case '[':
// rangeParts := parseRangeSubex(l)