diff options
author | Charlie Stanton <charlie@shtanton.xyz> | 2024-12-15 17:54:45 +0000 |
---|---|---|
committer | Charlie Stanton <charlie@shtanton.xyz> | 2024-12-15 17:54:45 +0000 |
commit | 62aa738be03845f96c40edde087ea39693b27e4e (patch) | |
tree | 81a86faa96db42d9da5e7014f53974468229d3e6 /subex/subexstate.go | |
parent | b434fe4e14f6dcc8d1d7433a29351b8e8ea77d37 (diff) | |
download | stred-go-62aa738be03845f96c40edde087ea39693b27e4e.tar |
Implement new number systemnumbers
Diffstat (limited to 'subex/subexstate.go')
-rw-r--r-- | subex/subexstate.go | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/subex/subexstate.go b/subex/subexstate.go index 8f27a10..3bcbdee 100644 --- a/subex/subexstate.go +++ b/subex/subexstate.go @@ -43,6 +43,9 @@ func (state SubexGroupState) epsilon(aux auxiliaryState) []SubexBranch { }, } } +func (state SubexGroupState) String() string { + return fmt.Sprintf("{%T %p, %T %p}", state.first, state.first, state.second, state.second) +} type SubexCopyState struct { next SubexState @@ -83,6 +86,24 @@ func (state SubexCopyRuneState) String() string { return fmt.Sprintf("SubexCopyRuneState[%v]", state.filter) } +type SubexCopyNumberState struct { + next SubexState + filter numberFilter +} +func (state SubexCopyNumberState) eat(aux auxiliaryState, edible walk.Edible) []SubexBranch { + number, isNumber := edible.(walk.NumberValue) + if !isNumber || !state.filter.numberFilter(float64(number)) { + return nil + } + return []SubexBranch {{ + state: state.next, + aux: aux.topAppend([]walk.Value {number}), + }} +} +func (state SubexCopyNumberState) accepting(aux auxiliaryState) []OutputStack { + return nil +} + // Just pushes to the OutputStack and hands over to the next state // Used to capture the output of the state being handed over to type SubexCaptureBeginState struct { |