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-15 20:13:03 +00:00
|
|
|
class script_evaluator;
|
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-15 20:13:03 +00:00
|
|
|
parser(frontend & fe, std::istream & in, script_evaluator * 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-07 18:00:12 +00:00
|
|
|
frontend & m_frontend;
|
2013-11-15 20:13:03 +00:00
|
|
|
script_evaluator * m_script_evaluator;
|
2013-08-25 17:34:19 +00:00
|
|
|
public:
|
2013-11-15 20:13:03 +00:00
|
|
|
shell(frontend & fe, script_evaluator * S);
|
2013-08-25 17:34:19 +00:00
|
|
|
~shell();
|
|
|
|
|
|
|
|
bool operator()();
|
|
|
|
};
|
|
|
|
|
2013-11-15 23:55:15 +00:00
|
|
|
bool parse_commands(frontend & fe, std::istream & in, script_evaluator * S = nullptr, bool use_exceptions = true, bool interactive = false);
|
2013-11-21 23:51:29 +00:00
|
|
|
bool parse_commands(environment const & env, io_state & st, std::istream & in, script_evaluator * S = nullptr, bool use_exceptions = true, bool interactive = false);
|
2013-11-15 23:55:15 +00:00
|
|
|
expr parse_expr(frontend & fe, std::istream & in, script_evaluator * S = nullptr, bool use_exceptions = true);
|
2013-11-21 23:51:29 +00:00
|
|
|
expr parse_expr(environment const & env, io_state & st, std::istream & in, script_evaluator * S = nullptr, bool use_exceptions = true);
|
2013-08-18 01:13:55 +00:00
|
|
|
}
|