/*
	restoreState

	evalRules
		if want tok, use if there else return
*/
restoreState

evalRules
if want tok, use if there else return
/ * restoreState evalRules if want tok use if there else return * /
func restoreRuleState(current *capture, evRule rule) (bool, *eval, *rulestate, int) {
	depth := 0
	ruleEv := &evRule.ev
	ruleState := &current.Rs
	for {
		for ruleState.Child != nil {
			child := ruleEv.getEval(ruleState.get())
			ruleEv = child
			ruleState = ruleState.Child
			depth++
		}
		ruleEval := ruleEv.getEval(ruleState.get())
		if ruleEval != nil {
			ruleState = ruleState.push()
			ruleEv = ruleEval
			depth++
			continue
		}
		if ruleState.get() >= len(ruleEv.items) {
			if depth > 0 {
				parentState := ruleState.pop()
				parentState.inc()
				ruleEv = &evRule.ev
				ruleState = &current.Rs
				depth--
				continue
			}
			current.Rs.set(0)
			return true, nil, nil, 0
		}
		break
	}
	return false, ruleEv, ruleState, depth
}
func restoreRuleState ( current * capture , evRule rule ) ( bool , * eval , * rulestate , int ) { depth := 0 ruleEv := & evRule . ev ruleState := & current . Rs for { for ruleState . Child != nil { child := ruleEv . getEval ( ruleState . get ( ) ) ruleEv = child ruleState = ruleState . Child depth ++ } ruleEval := ruleEv . getEval ( ruleState . get ( ) ) if ruleEval != nil { ruleState = ruleState . push ( ) ruleEv = ruleEval depth ++ continue } if ruleState . get ( ) >= len ( ruleEv . items ) { if depth > 0 { parentState := ruleState . pop ( ) parentState . inc ( ) ruleEv = & evRule . ev ruleState = & current . Rs depth -- continue } current . Rs . set ( 0 ) return true , nil , nil , 0 } break } return false , ruleEv , ruleState , depth }
restoreState
restoreState
// walk existing child states // walk new child states // if we've advanced past the number of rule items // we've advanced all the way to the top