Exemplo n.º 1
0
        private static IEnumerable <SqlGrammarRuleSequence> GetCompatibleSequences(SqlGrammarRuleSequence sequence, StatementGrammarNode parentNode)
        {
            var inputItems = sequence.Items
                             .Cast <ISqlGrammarRuleSequenceItem>()
                             .TakeWhileInclusive(i => !i.IsRequired);

            var isInputSequence = inputItems.Any(i => String.Equals(i.Id, parentNode.ChildNodes[0].Id));

            return(isInputSequence
                                ? Enumerable.Repeat(sequence, 1)
                                : inputItems.Where(i => i.Type == NodeType.NonTerminal)
                   .SelectMany(i => NonTerminalRules[i.Id].Sequences)
                   .SelectMany(s => GetCompatibleSequences(s, parentNode)));
        }
Exemplo n.º 2
0
		private static IEnumerable<SqlGrammarRuleSequence> GetCompatibleSequences(SqlGrammarRuleSequence sequence, StatementGrammarNode parentNode)
		{
			var inputItems = sequence.Items
				.Cast<ISqlGrammarRuleSequenceItem>()
				.TakeWhileInclusive(i => !i.IsRequired);

			var isInputSequence = inputItems.Any(i => String.Equals(i.Id, parentNode.ChildNodes[0].Id));

			return isInputSequence
				? Enumerable.Repeat(sequence, 1)
				: inputItems.Where(i => i.Type == NodeType.NonTerminal)
					.SelectMany(i => NonTerminalRules[i.Id].Sequences)
					.SelectMany(s => GetCompatibleSequences(s, parentNode));
		}