<- Back to shtanton's homepage
aboutsummaryrefslogtreecommitdiff
path: root/subex/subexstate.go
diff options
context:
space:
mode:
Diffstat (limited to 'subex/subexstate.go')
-rw-r--r--subex/subexstate.go67
1 files changed, 40 insertions, 27 deletions
diff --git a/subex/subexstate.go b/subex/subexstate.go
index 4f5dc19..1e1e94e 100644
--- a/subex/subexstate.go
+++ b/subex/subexstate.go
@@ -133,6 +133,19 @@ func (state SubexStoreEndState) epsilon(aux auxiliaryState) []SubexBranch {
}}
}
+type SubexStoreRunesEndState struct {
+ slot int
+ next SubexState
+}
+func (state SubexStoreRunesEndState) epsilon(aux auxiliaryState) []SubexBranch {
+ toStore, aux := aux.popOutputRunes()
+ aux.store = aux.store.withRunes(state.slot, toStore)
+ return []SubexBranch {{
+ state: state.next,
+ aux: aux,
+ }}
+}
+
/*
// A part of an output literal, either an Atom or a slot from which to load
type OutputContent interface {
@@ -211,48 +224,48 @@ func (state SubexOutputState) accepting(aux auxiliaryState) []OutputStack {
}
*/
-type OutputValue interface {
- build(store Store) []walk.Value
-}
-
-type OutputValueLoad struct {
- slot int
+type SubexOutputValueLiteralState struct {
+ literal walk.Scalar
+ next SubexState
}
-func (ov OutputValueLoad) build(store Store) []walk.Value {
- return store.values[ov.slot]
+func (state SubexOutputValueLiteralState) epsilon(aux auxiliaryState) []SubexBranch {
+ return []SubexBranch {{
+ state: state.next,
+ aux: aux.topAppend([]walk.Value {state.literal}),
+ }}
}
-type OutputValueLiteral struct {
- scalar walk.Scalar
+type SubexOutputValueLoadState struct {
+ slot int
+ next SubexState
}
-func (ov OutputValueLiteral) build(store Store) []walk.Value {
- return []walk.Value{ov.scalar}
+func (state SubexOutputValueLoadState) epsilon(aux auxiliaryState) []SubexBranch {
+ return []SubexBranch {{
+ state: state.next,
+ aux: aux.topAppend(aux.store.values[state.slot]),
+ }}
}
-type SubexOutputValuesState struct {
- content []OutputValue
+type SubexOutputRuneLiteralState struct {
+ literal rune
next SubexState
}
-func (state SubexOutputValuesState) epsilon(aux auxiliaryState) []SubexBranch {
- var content []walk.Value
- for _, el := range state.content {
- content = append(content, el.build(aux.store)...)
- }
+func (state SubexOutputRuneLiteralState) epsilon(aux auxiliaryState) []SubexBranch {
return []SubexBranch {{
state: state.next,
- aux: aux.topAppend(content),
+ aux: aux.topAppendRune([]rune {state.literal}),
}}
}
-type OutputRune interface {
-}
-
-type OutputRuneLoad struct {
+type SubexOutputRuneLoadState struct {
slot int
+ next SubexState
}
-
-type OutputRuneLiteral struct {
- r rune
+func (state SubexOutputRuneLoadState) epsilon(aux auxiliaryState) []SubexBranch {
+ return []SubexBranch {{
+ state: state.next,
+ aux: aux.topAppendRune(aux.store.runes[state.slot]),
+ }}
}
// A final state, transitions to nothing but is accepting