internal override void AddArc(Arc start, Arc end) { start = ParseElementCollection.TrimStart(start, _backend); end = ParseElementCollection.TrimEnd(end, _backend); State start2 = end.Start; State end2 = start.End; if ((start.IsEpsilonTransition & start.IsPropertylessTransition) && end2 != null && end2.InArcs.IsEmpty) { start.End = null; _backend.MoveOutputTransitionsAndDeleteState(end2, _startState); } else { start.Start = _startState; } if ((end.IsEpsilonTransition & end.IsPropertylessTransition) && start2 != null && start2.OutArcs.IsEmpty) { end.Start = null; _backend.MoveInputTransitionsAndDeleteState(start2, _endState); } else { end.End = _endState; } }
void IElement.PostParse(IElement parentElement) { if (_startArc.End.OutArcs.IsEmpty) { XmlParser.ThrowSrgsException(SRID.EmptyOneOf); } _startArc = ParseElementCollection.TrimStart(_startArc, _backend); _endArc = ParseElementCollection.TrimEnd(_endArc, _backend); PostParse((ParseElementCollection)parentElement); }
void IElement.PostParse(IElement parentElement) { if (_maxRepeat != _minRepeat && _startArc != null && _startArc == _endArc && _endArc.IsEpsilonTransition && !_endArc.IsPropertylessTransition) { XmlParser.ThrowSrgsException(SRID.InvalidTagInAnEmptyItem); } if (_startArc == null || _maxRepeat == 0) { if (_maxRepeat == 0 && _startArc != null && _startArc.End != null) { State end = _startArc.End; _startArc.End = null; _backend.DeleteSubGraph(end); } _startArc = (_endArc = _backend.EpsilonTransition(_repeatProbability)); } else if (_minRepeat != 1 || _maxRepeat != 1) { _startArc = InsertState(_startArc, _repeatProbability, Position.Before); State end2 = _startArc.End; if (_maxRepeat == int.MaxValue && _minRepeat == 1) { _endArc = InsertState(_endArc, 1f, Position.After); AddEpsilonTransition(_endArc.Start, end2, 1f - _repeatProbability); } else { State srcFromState = end2; for (uint num = 1u; num < _maxRepeat && num < 255; num++) { State state = _backend.CreateNewState(_endArc.Start.Rule); State state2 = _backend.CloneSubGraph(srcFromState, _endArc.Start, state); _endArc.End = state; _endArc = state2.OutArcs.First; if (_maxRepeat == int.MaxValue) { if (num == _minRepeat - 1) { _endArc = InsertState(_endArc, 1f, Position.After); AddEpsilonTransition(_endArc.Start, state, 1f - _repeatProbability); break; } } else if (num <= _maxRepeat - _minRepeat) { AddEpsilonTransition(end2, state, 1f - _repeatProbability); } srcFromState = state; } } if (_minRepeat == 0 && (_startArc != _endArc || !_startArc.IsEpsilonTransition)) { if (!_endArc.IsEpsilonTransition || _endArc.SemanticTagCount > 0) { _endArc = InsertState(_endArc, 1f, Position.After); } AddEpsilonTransition(end2, _endArc.Start, 1f - _repeatProbability); } _startArc = ParseElementCollection.TrimStart(_startArc, _backend); } PostParse((ParseElementCollection)parentElement); }