private static IObject EvalBlockStatement(Ast.BlockStatement block, Environment env)
        {
            IObject result = null;

            foreach (var s in block.Statements)
            {
                result = Eval(s, env);

                if (result == null)
                {
                    continue;
                }
                var rt = result.getType();
                if (rt == Type.Return | rt == Type.Error)
                {
                    return(result);
                }
            }

            return(result);
        }
        private Ast.BlockStatement ParseBlockStatement()
        {
            var block = new Ast.BlockStatement
            {
                Token      = _curToken,
                Statements = new List <Ast.IStatement>()
            };

            NextToken();

            while (!CurTokenIs(TokenType.Rbrace) && !CurTokenIs(TokenType.Eof))
            {
                var statement = ParseStatement();
                if (statement != null)
                {
                    block.Statements.Add(statement);
                }
                NextToken();
            }

            return(block);
        }