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>
|
2013-12-20 03:08:10 +00:00
|
|
|
#include "util/lua.h"
|
2013-12-18 22:37:55 +00:00
|
|
|
#include "kernel/environment.h"
|
2013-12-30 19:20:23 +00:00
|
|
|
#include "kernel/io_state.h"
|
2013-08-18 01:13:55 +00:00
|
|
|
|
|
|
|
namespace lean {
|
2013-11-27 22:57:33 +00:00
|
|
|
class script_state;
|
2014-01-02 14:46:28 +00:00
|
|
|
class parser_imp;
|
2013-08-25 17:34:19 +00:00
|
|
|
/** \brief Functional object for parsing commands and expressions */
|
|
|
|
class parser {
|
2013-12-26 20:58:47 +00:00
|
|
|
private:
|
2014-01-14 00:54:21 +00:00
|
|
|
std::shared_ptr<parser_imp> m_ptr;
|
2013-08-25 17:34:19 +00:00
|
|
|
public:
|
2014-01-09 19:01:27 +00:00
|
|
|
parser(environment const & env, io_state const & st, std::istream & in, char const * strm_name, 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();
|
2013-12-18 22:37:55 +00:00
|
|
|
|
|
|
|
io_state get_io_state() const;
|
2013-08-25 17:34:19 +00:00
|
|
|
};
|
|
|
|
|
2014-01-09 19:01:27 +00:00
|
|
|
bool parse_commands(environment const & env, io_state & st, std::istream & in, char const * strm_name, script_state * S = nullptr, bool use_exceptions = true, bool interactive = false);
|
|
|
|
bool parse_commands(environment const & env, io_state & st, char const * fname, script_state * S = nullptr, bool use_exceptions = true, bool interactive = false);
|
|
|
|
expr parse_expr(environment const & env, io_state & st, std::istream & in, char const * strm_name, script_state * S = nullptr, bool use_exceptions = true);
|
2013-12-20 03:08:10 +00:00
|
|
|
void open_macros(lua_State * L);
|
2013-08-18 01:13:55 +00:00
|
|
|
}
|