public void run() {

        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));

        while (true) {
            String line;
            try {
                System.out.print("> ");
                line = reader.readLine();
            } catch (IOException e) {
                break;
            }

            if (line.equalsIgnoreCase("quit"))
                break;
            else if (line.isEmpty())
                continue;

            Symbol sym;
            try {
                sym = MiniSqlParser.parse(new ByteArrayInputStream(line.getBytes()));
            } catch (Exception e) {
                System.err.println("Couldn't parse input.");
                continue;
            }

            List<Statement> statements = (List<Statement>)sym.value;
            for (Statement statement : statements) {
                Result result;
                try {
                    result = statement.execute(database);
                } catch (DatabaseException e) {
                    System.err.println(String.format("An error occurred: %s", e.getMessage()));
                    break;
                }

                System.out.println(formatResult(result));
            }

            database.save();
        }
    }