2013-08-18 01:13:55 +00:00
|
|
|
/*
|
|
|
|
Copyright (c) 2013 Microsoft Corporation. All rights reserved.
|
|
|
|
Released under Apache 2.0 license as described in the file LICENSE.
|
|
|
|
|
|
|
|
Author: Leonardo de Moura
|
|
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
#include <iostream>
|
|
|
|
|
|
|
|
namespace lean {
|
2013-11-27 22:57:33 +00:00
|
|
|
class script_state;
|
2013-11-15 23:55:15 +00:00
|
|
|
class frontend;
|
2013-11-21 23:51:29 +00:00
|
|
|
class io_state;
|
2013-11-15 23:55:15 +00:00
|
|
|
class environment;
|
2013-08-25 17:34:19 +00:00
|
|
|
/** \brief Functional object for parsing commands and expressions */
|
|
|
|
class parser {
|
|
|
|
class imp;
|
|
|
|
std::unique_ptr<imp> m_ptr;
|
|
|
|
public:
|
2013-11-27 22:57:33 +00:00
|
|
|
parser(frontend & fe, std::istream & in, script_state * S, bool use_exceptions = true, bool interactive = false);
|
2013-08-25 17:34:19 +00:00
|
|
|
~parser();
|
|
|
|
|
|
|
|
/** \brief Parse a sequence of commands */
|
|
|
|
bool operator()();
|
|
|
|
|
|
|
|
/** \brief Parse a single expression */
|
|
|
|
expr parse_expr();
|
|
|
|
};
|
|
|
|
|
|
|
|
/** \brief Implements the Read Eval Print loop */
|
|
|
|
class shell {
|
2013-11-27 22:57:33 +00:00
|
|
|
frontend & m_frontend;
|
|
|
|
script_state * m_script_state;
|
2013-08-25 17:34:19 +00:00
|
|
|
public:
|
2013-11-27 22:57:33 +00:00
|
|
|
shell(frontend & fe, script_state * S);
|
2013-08-25 17:34:19 +00:00
|
|
|
~shell();
|
|
|
|
|
|
|
|
bool operator()();
|
|
|
|
};
|
|
|
|
|
2013-11-27 22:57:33 +00:00
|
|
|
bool parse_commands(frontend & fe, std::istream & in, script_state * S = nullptr, bool use_exceptions = true, bool interactive = false);
|
|
|
|
bool parse_commands(environment const & env, io_state & st, std::istream & in, script_state * S = nullptr, bool use_exceptions = true, bool interactive = false);
|
|
|
|
expr parse_expr(frontend & fe, std::istream & in, script_state * S = nullptr, bool use_exceptions = true);
|
|
|
|
expr parse_expr(environment const & env, io_state & st, std::istream & in, script_state * S = nullptr, bool use_exceptions = true);
|
2013-08-18 01:13:55 +00:00
|
|
|
}
|