예제 #1
0
    public override bool Equals(object obj, bool includeChildren)
    {
        if (!base.Equals(obj, includeChildren))
        {
            return(false);
        }

        LeftHandUnaryToken other = (LeftHandUnaryToken)obj;

        if (Lhs != null)
        {
            if (!Lhs.Equals(other.Lhs))
            {
                return(false);
            }
        }
        else if (other.Lhs != null)
        {
            return(false);
        }

        return(true);
    }
예제 #2
0
    protected TokenImpl ApplyPrecedence(ExpressionCompiler compiler, BinaryToken lhs, LeftHandUnaryToken newToken)
    {
        // If the left-hand side is a binary token, and the new token has a higher precedence,
        // then take the right-hand side from the old left-hand side and use that as the left
        // hand side on the new token. The new token then becomes the right-hand side of the left
        // hand side.
        int lhsPrecedence = compiler.GetPrecedence(lhs.GetType());
        int newPrecedence = compiler.GetPrecedence(newToken.GetType());

        if (newPrecedence < lhsPrecedence)
        {
            newToken.Lhs = lhs.Rhs;
            lhs.Rhs      = newToken;

            return(lhs);
        }
        else
        {
            return(newToken);
        }
    }