<- 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.go13
1 files changed, 13 insertions, 0 deletions
diff --git a/subex/parse.go b/subex/parse.go
index 98821fd..1e17bb3 100644
--- a/subex/parse.go
+++ b/subex/parse.go
@@ -35,6 +35,7 @@ const (
StringStructure
ArrayStructure
ArrayValuesStructure
+ MapStructure
)
func (s Structure) String() string {
switch s {
@@ -46,6 +47,8 @@ func (s Structure) String() string {
return "@"
case ArrayValuesStructure:
return ":"
+ case MapStructure:
+ return "#"
default:
panic("Invalid structure")
}
@@ -329,6 +332,9 @@ func parseDestructure(l RuneReader, destructure Structure, inType Type) (lhs Sub
case ArrayValuesStructure:
innerInType = ValueType
expectedInType = ValueType
+ case MapStructure:
+ innerInType = ValueType
+ expectedInType = ValueType
default:
panic("Invalid structure")
}
@@ -356,6 +362,9 @@ func parseDestructure(l RuneReader, destructure Structure, inType Type) (lhs Sub
case ':':
structure = ArrayValuesStructure
expectedInnerOutType = ValueType
+ case '#':
+ structure = MapStructure
+ expectedInnerOutType = ValueType
default:
panic("Missing matching destructure")
}
@@ -371,6 +380,8 @@ func parseDestructure(l RuneReader, destructure Structure, inType Type) (lhs Sub
outType = ValueType
case ArrayValuesStructure:
outType = ValueType
+ case MapStructure:
+ outType = ValueType
}
lhs = SubexASTDestructure {
@@ -400,6 +411,8 @@ func parseSubex(l RuneReader, minPower int, inType Type) (lhs SubexAST, outType
lhs, outType = parseDestructure(l, ArrayStructure, inType)
case ':':
lhs, outType = parseDestructure(l, ArrayValuesStructure, inType)
+ case '#':
+ lhs, outType = parseDestructure(l, MapStructure, inType)
// TODO
// case '[':
// rangeParts := parseRangeSubex(l)