public ClauseGroup GetClauseGroup(string block) { var span = block.AsSpan(); var result = new ClauseGroup(); var currentGroup = result; var startIndex = 0; while (startIndex < span.Length) { var word = GetWord(span, false, ref startIndex, out var state, out var keyword); if (word == "(") { var group = new ClauseGroup() { Parent = currentGroup }; currentGroup.ClauseQueue.Enqueue(group); currentGroup = group; continue; } else if (word == ")") { currentGroup = currentGroup.Parent; } var group1 = new ClauseGroup() { Parent = currentGroup }; currentGroup.ClauseQueue.Enqueue(group1); group1.IsCondition = true; var currentCondition = group1.Condition = new Condition(); currentCondition.Left = word; if (state == ReadPhraseState.Operator) { currentCondition.Operator = TryParseOperator(keyword); currentCondition.IsSingle = false; var rightWord = GetWord(span, true, ref startIndex, out var state1, out var keyword1); currentCondition.Right = rightWord; if (!string.IsNullOrEmpty(keyword1)) { currentGroup.RelationQueue.Enqueue(TryParseRelation(keyword1)); } } else { currentCondition.IsSingle = true; if (!string.IsNullOrEmpty(keyword)) { currentGroup.RelationQueue.Enqueue(TryParseRelation(keyword)); } } } return(result); }
public ClauseGroup GetClauseGroup() { var i = 0; var clauseGroup = new ClauseGroup(); while (i < _block.Length) { var j = i; while (j < _block.Length) { if (_block[j] == '&') { clauseGroup.Collection.Add(_block[i..(j)]);