internal static bool ParseUnitary(Parser.ParseContext context) { char c = context.Expression[context.TokenPosition]; int offset = 0; string subStr; OperatorType operationType = OperatorType.None; TokenType lastTokenType = context.LastTokenType; switch (c) { case '-': if (lastTokenType == TokenType.OpenBracket || lastTokenType == TokenType.OpenParenthesis || lastTokenType == TokenType.UnitaryOperator || lastTokenType == TokenType.Start || lastTokenType == TokenType.BinaryOperator) { offset = 1; operationType = OperatorType.Negative; break; } return(false); case '!': subStr = context.Expression.Substring(context.TokenPosition, Math.Min(2, context.Expression.Length - context.TokenPosition)); if (!subStr.Equals("!=")) { offset = 1; operationType = OperatorType.Not; break; } return(false); case 'n': subStr = context.Expression.Substring(context.TokenPosition, Math.Min(4, context.Expression.Length - context.TokenPosition)); if (subStr.Equals("not ") || subStr.Equals("not(")) { operationType = OperatorType.Not; offset = 3; break; } return(false); default: return(false); } ValidateTokenOrder(context, TokenType.UnitaryOperator); ElementOperator element = new ElementUnitaryOperator(operationType); ProcessOperator(context, element); context.TokenPosition += offset; return(true); }
internal static bool Parse(Parser.ParseContext context) { if (ElementBinaryOperator.ParseBinary(context)) { return(true); } else if (ElementUnitaryOperator.ParseUnitary(context)) { return(true); } else if (ElementDot.ParseDot(context)) { return(true); } else if (ElementFunction.ParseFunction(context)) { return(true); } return(false); }