BalticAmadeus.FluentMdx.MdxParser.TryParseConstantValue C# (CSharp) Method

TryParseConstantValue() static private method

Performs constant value syntactical analysis over collection of Token objects using IStatedTwoWayEnumerator{T}.
static private TryParseConstantValue ( IStatedTwoWayEnumerator enumerator, MdxExpressionBase &expression ) : bool
enumerator IStatedTwoWayEnumerator Extended enumerator of collection of objects.
expression MdxExpressionBase Output parsed constant value if syntactic analysis was succeeded.
return bool
        internal static bool TryParseConstantValue(IStatedTwoWayEnumerator<Token> enumerator, out MdxExpressionBase expression)
        {
            enumerator.SavePosition();
            expression = null;

            var constantValue = Mdx.ConstantValue();

            if (!IsNextTokenValid(enumerator, TokenType.LogicalExpression) &&
                !IsNextTokenValid(enumerator, TokenType.DateExpression) &&
                !IsNextTokenValid(enumerator, TokenType.TitleExpression) &&
                !IsNextTokenValid(enumerator, TokenType.NumberExpression) &&
                !IsNextTokenValid(enumerator, TokenType.AnyExpression) &&
                !IsNextTokenValid(enumerator, TokenType.Ordering))
            {
                enumerator.RestoreLastSavedPosition();
                return false;
            }

            string constantVal = enumerator.Current.Value;
            if (IsNextTokenValid(enumerator, TokenType.AnyExpression))
                constantVal += enumerator.Current.Value;

            constantValue.WithValue(constantVal);

            expression = constantValue;

            enumerator.RemoveLastSavedState();
            return true;
        }