Example #1
0
        /// <summary>
        /// Creates a matching for the specified kind of binary operation.
        /// </summary>
        /// <param name="kind">kind of binary operation to match</param>
        /// <param name="peer">right child matching</param>
        public Matching MBinOp(BinOp.Kind kind, Matching peer)
        {
            BinOp cmp = new BinOp()
            {
                Operation = kind
            };
            Matching newm = new Matching();

            newm._func = e => e.NodeEquals(cmp) &&
                         this.Match(e.Children.ElementAt(0)) &&
                         peer.Match(e.Children.ElementAt(1));
            newm._gen = () => newm._expr == null ?
                        new BinOp()
            {
                Operation = kind, Operand1 = _gen(), Operand2 = peer._gen()
            } : newm._expr;
            return(newm);
        }
 /// <summary>
 /// Creates a matching for the specified kind of binary operation.
 /// </summary>
 /// <param name="kind">kind of binary operation to match</param>
 /// <param name="peer">right child matching</param>
 public Matching MBinOp(BinOp.Kind kind, Matching peer)
 {
     BinOp cmp = new BinOp() { Operation = kind };
     Matching newm = new Matching();
     newm._func = e => e.NodeEquals(cmp) && 
             this.Match(e.Children.ElementAt(0)) && 
             peer.Match(e.Children.ElementAt(1));
     newm._gen = () => newm._expr == null ? 
         new BinOp() { Operation = kind, Operand1 = _gen(), Operand2 = peer._gen() } : newm._expr;
     return newm;
 }