public int CompareTo(Operator other) { if (other == null) { return(-1); } if (other.ParenthesesCount < ParenthesesCount) { return(-1); } if (other.ParenthesesCount > ParenthesesCount) { return(1); } int precedenceCompare = Precedence.CompareTo(other.Precedence); if (precedenceCompare == 0) { return(-1); } return(precedenceCompare); }
/// <summary> /// A value that indicates if this operator's precedence is greater than, equal or less than /// the other operator's precedence /// </summary> /// <param name="other">The other operator</param> /// <returns> /// Positive if the precedence of this operator is greater. /// 0 if they have the same precedence. /// Negative if the precedence of this operator is lower. /// </returns> public int ComparePrecedence(OperatorTokenType other) { return(Precedence.CompareTo(other.Precedence)); }
/// <summary> /// Compares this operator to another /// </summary> /// <param name="other"></param> /// <returns></returns> public int CompareTo(BinaryOperator other) { return(Precedence.CompareTo(other.Precedence)); }