示例#1
0
        // (int)something
        private bool ParseDirectCastExpression(ref ASTNode retn)
        {
            if (tokenStream.Current != ExpressionTokenType.ParenOpen)
            {
                return(false);
            }

            ASTNode expression = null;

            int advance = tokenStream.FindMatchingIndex(ExpressionTokenType.ParenOpen, ExpressionTokenType.ParenClose);

            if (advance == -1)
            {
                Abort();
                return(false);
            }

            tokenStream.Save();

            ExpressionParser subParser  = CreateSubParser(advance);
            TypeLookup       typeLookup = new TypeLookup();
            bool             valid      = subParser.ParseTypePath(ref typeLookup);

            subParser.Release();

            if (!valid)
            {
                tokenStream.Restore();
                return(false);
            }

            if (!ParseExpression(ref expression))
            {
                typeLookup.Release();
                tokenStream.Restore();
                tokenStream.Restore();
                return(false);
            }

            retn = ASTNode.DirectCastNode(typeLookup, expression);
            return(true);
        }