Exemplo n.º 1
0
        private AstItem ReadNewPointer(TokenIterator tokens)
        {
            tokens.PopExpected(TokenKind.New);

            var token = tokens.Current();

            if (token.Kind == TokenKind.SquareBracketOpen)
            {
                return(AstItem.NewHeapArray(ReadArray(tokens)));
            }
            else
            {
                var subType = ReadDataType(tokens);

                var dataType = DataType.Pointer(subType);

                var amountExpression = AstItem.Immediate("1");
                var current          = tokens.Current();
                if (current != null && current.Kind == TokenKind.RoundBracketOpen)
                {
                    tokens.Pop();
                    amountExpression = ReadExpression(tokens, TokenKind.RoundBracketClose);
                    tokens.PopExpected(TokenKind.RoundBracketClose);
                }

                return(AstItem.NewRawPointer(dataType, amountExpression));
            }
        }