capture-closure ( seeds position string table -- ready )


Vocabulary
regexp.captures.private

Inputs
seedsan object
positionan object
stringan object
tablean object


Outputs
readyan object


Definition


:: capture-closure ( seeds position string table -- ready )
seeds reverse >vector :> work HS{ } clone :> seen
V{ } clone :> ready
[ work empty? not ] [
work pop :> thread thread pc>> :> pc thread registers>>
:> registers pc {
{
[ dup capture-branch? ]
[
position string pc quot>>
( index string -- ? ) call-effect
pc yes>> pc no>> ?
registers capture-thread boa work push drop
]
}
{
[ dup capture-edge? ]
[
drop pc label>> :> label label
{ ~array~ ~array~ ~array~ ~quotation~ } cond
]
}
[
seen ?adjoin [
pc table final-states>> in? [
f registers capture-thread boa
ready push
] when pc table transitions>> at <reversed>
[ registers capture-thread boa work push ]
each
] when
]
} cond
] while ready ;