コード例 #1
0
        /// <summary>
        /// Determines whether [is compute operator] [the specified input].
        /// </summary>
        /// <param name="input">The input.</param>
        /// <param name="computeOperator">The compute operator.</param>
        /// <returns><c>true</c> if [is compute operator] [the specified input]; otherwise, <c>false</c>.</returns>
        private bool IsComputeOperator(string input, out ComputeOperator computeOperator)
        {
            var result = BooleanSearchCore.ToComputeOperator(input);

            if (result.HasValue)
            {
                computeOperator = result.Value;
                return(true);
            }

            computeOperator = default(ComputeOperator);
            return(false);
        }
コード例 #2
0
        /// <summary>
        /// Expects the compute operator.
        /// </summary>
        /// <param name="input">The input.</param>
        /// <param name="position">The position.</param>
        /// <returns>System.Nullable&lt;ComputeOperator&gt;.</returns>
        /// <exception cref="Beyova.Diagnostic.InvalidExpressiontException"></exception>
        private ComputeOperator?ExpectComputeOperator(string input, ref int position)
        {
            string operatorString = null;

            TrimStartSpaces(input, ref position);
            var  startPosition = position;
            bool isSymbol      = position < input.Length && computeOperatorSymbolChars.HasItem(input[position]);

            while (position < input.Length)
            {
                if (isSymbol)
                {
                    if (computeOperatorSymbolChars.HasItem(input[position]))
                    {
                        position++;
                    }
                    else
                    {
                        break;
                    }
                }
                else
                {
                    if (!relationshipOperatorInterruptChars.HasItem(input[position]))
                    {
                        position++;
                    }
                    else
                    {
                        break;
                    }
                }
            }

            operatorString = input.Substring(startPosition, position - startPosition);

            return(BooleanSearchCore.ToComputeOperator(operatorString));
        }