Example #1
0
            static void Walk(IndentedTextWriter writer, BoundQuery node)
            {
                switch (node)
                {
                case BoundKevValueQuery kevValue:
                    writer.WriteLine($"{(kevValue.IsNegated ? "-" : "")}{kevValue.Key}:{kevValue.Value}");
                    break;

                case BoundTextQuery text:
                    writer.WriteLine($"{(text.IsNegated ? "-" : "")}{text.Text}");
                    break;

                case BoundNegatedQuery negated:
                    writer.WriteLine("NOT");
                    writer.Indent++;
                    Walk(writer, negated.Query);
                    writer.Indent--;
                    break;

                case BoundAndQuery and:
                    writer.WriteLine("AND");
                    writer.Indent++;
                    Walk(writer, and.Left);
                    Walk(writer, and.Right);
                    writer.Indent--;
                    break;

                case BoundOrQuery or:
                    writer.WriteLine("OR");
                    writer.Indent++;
                    Walk(writer, or.Left);
                    Walk(writer, or.Right);
                    writer.Indent--;
                    break;

                default:
                    throw new Exception($"Unexpected node {node.GetType()}");
                }
            }
Example #2
0
        private static BoundQuery Negate(BoundQuery node)
        {
            switch (node)
            {
            case BoundKevValueQuery kevValue:
                return(NegateKevValueExpression(kevValue));

            case BoundTextQuery text:
                return(NegateTextExpression(text));

            case BoundNegatedQuery negated:
                return(NegateNegatedExpression(negated));

            case BoundAndQuery and:
                return(NegateAndExpression(and));

            case BoundOrQuery or:
                return(NegateOrExpression(or));

            default:
                throw new Exception($"Unexpected node {node.GetType()}");
            }
        }