<- Back to shtanton's homepage
summaryrefslogtreecommitdiff
path: root/main/subexstate.go
diff options
context:
space:
mode:
authorCharlie Stanton <charlie@shtanton.xyz>2022-12-24 10:04:42 +0000
committerCharlie Stanton <charlie@shtanton.xyz>2022-12-24 10:04:42 +0000
commitb2d1d965dee8cc2c1e063067d53a3c8e28a46d6c (patch)
tree1319884f055b2c64cf1787936c1b4b580d40dcff /main/subexstate.go
parentce2db2bc333ed938ec93d5ad0838f8cb720c4865 (diff)
downloadsubex-main.tar
Adds the character range mapping syntaxHEADmain
Ranges of characters can be mapped with [] For example, capitalisation of a letter: [a-z=A-Z] Caesar cipher shift of 1: [a-zA-Z=b-zaB-ZA]
Diffstat (limited to 'main/subexstate.go')
-rw-r--r--main/subexstate.go20
1 files changed, 20 insertions, 0 deletions
diff --git a/main/subexstate.go b/main/subexstate.go
index 00b9e75..880be38 100644
--- a/main/subexstate.go
+++ b/main/subexstate.go
@@ -123,3 +123,23 @@ func (state SubexCopyAnyState) eat(store Store, char rune) []SubexBranch {
func (state SubexCopyAnyState) accepting(store Store) []string {
return nil
}
+
+type SubexRangeState struct {
+ parts map[rune]rune
+ next SubexState
+}
+func (state SubexRangeState) eat(store Store, char rune) []SubexBranch {
+ out, exists := state.parts[char]
+ if !exists {
+ return nil
+ } else {
+ return []SubexBranch{{
+ state: state.next,
+ output: string(out),
+ store: store,
+ }}
+ }
+}
+func (state SubexRangeState) accepting(store Store) []string {
+ return nil
+}