FsmFragment IExprVisitor <FsmFragment> .VisitAlternative(AlternativesExpr alternativesExpr) { var from = _fsm.CreateState(); var to = _fsm.CreateState(); foreach (var elem in alternativesExpr.Items) { var fragment = elem.Apply(this); _fsm.CreateTransition(from, fragment.From, FsmTransitionCondition.EmptyCondition); _fsm.CreateTransition(fragment.To, to, FsmTransitionCondition.EmptyCondition); } return(new FsmFragment(from, to)); }
ParsingState IExprVisitor <ParsingState> .VisitAlternative(AlternativesExpr alternativesExpr) { int startPos = _currState.Pos; ParsingState nextState; if (_currState.InvocationCount < alternativesExpr.Items.Count && _currState.LastMatchSuccessed != true) { nextState = _currState.EnterChild(alternativesExpr.Items[_currState.InvocationCount]); } else { nextState = _currState.ExitChild(_currState.LastMatchSuccessed.Value, _currState.Pos - startPos); } return(nextState); }