<- Back to shtanton's homepage
aboutsummaryrefslogtreecommitdiff
path: root/subex
diff options
context:
space:
mode:
authorCharlie Stanton <charlie@shtanton.xyz>2023-04-24 19:12:46 +0100
committerCharlie Stanton <charlie@shtanton.xyz>2023-04-24 19:12:46 +0100
commitc10bca852dfd2ed3ae8f776c12705675a8ab99bf (patch)
treed63b20b30eeb1e81a8cda2e8c5e381c0252fc13e /subex
parent1e092ec62cf591e57f0b0bfb80b4484dd90c9c8c (diff)
downloadstred-go-c10bca852dfd2ed3ae8f776c12705675a8ab99bf.tar
Adds a check to end subex execution early if no viable branches remain
Diffstat (limited to 'subex')
-rw-r--r--subex/main.go3
1 files changed, 3 insertions, 0 deletions
diff --git a/subex/main.go b/subex/main.go
index ae829d9..c1718a4 100644
--- a/subex/main.go
+++ b/subex/main.go
@@ -112,6 +112,9 @@ func RunTransducer(transducer SubexState, input []walk.Atom) (output []walk.Atom
newStates = append(newStates, state.eat(piece)...)
}
states = pruneStates(newStates)
+ if len(states) == 0 {
+ return nil, true
+ }
}
for _, state := range states {
acceptingStacks := state.accepting()