diff options
Diffstat (limited to 'subex/subexast.go')
-rw-r--r-- | subex/subexast.go | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/subex/subexast.go b/subex/subexast.go index a2c3675..2685925 100644 --- a/subex/subexast.go +++ b/subex/subexast.go @@ -489,6 +489,11 @@ func (ast SubexASTDestructure) compileWith(next SubexState, slotMap *SlotMap, in construct = &SubexConstructArrayValuesState { next: next, } + case MapStructure: + innerOutType = ValueType + construct = &SubexConstructMapState { + next: next, + } default: panic("Invalid ast structure") } @@ -523,6 +528,14 @@ func (ast SubexASTDestructure) compileWith(next SubexState, slotMap *SlotMap, in next: construct, }, } + case MapStructure: + innerInType = ValueType + destructFooter = &SubexDiscardTerminalState { + terminal: walk.MapEnd, + next: &SubexDecrementNestState { + next: construct, + }, + } default: panic("Invalid ast destructure") } @@ -550,6 +563,10 @@ func (ast SubexASTDestructure) compileWith(next SubexState, slotMap *SlotMap, in beginConstruct = &SubexCaptureBeginState { next: inner, } + case MapStructure: + beginConstruct = &SubexCaptureBeginState { + next: inner, + } default: panic("Invalid ast structure") } @@ -593,6 +610,18 @@ func (ast SubexASTDestructure) compileWith(next SubexState, slotMap *SlotMap, in }, }, } + case MapStructure: + return &SubexCaptureBeginState { + next: &SubexCopyState { + filter: anyMapFilter{}, + next: &SubexDiscardState { + next: &SubexIncrementNestState { + keys: true, + next: beginConstruct, + }, + }, + }, + } default: panic("Invalid destructure in ast") } |