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
|
|
|
|
*/
|
2014-01-02 21:14:21 +00:00
|
|
|
#include "library/io_state_stream.h"
|
2013-09-13 03:09:35 +00:00
|
|
|
#include "frontends/lean/parser.h"
|
|
|
|
#include "frontends/lean/pp.h"
|
2014-01-02 14:46:28 +00:00
|
|
|
#include "frontends/lean/parser_imp.h"
|
2013-08-25 17:34:19 +00:00
|
|
|
|
2013-08-18 01:13:55 +00:00
|
|
|
namespace lean {
|
2013-12-18 22:37:55 +00:00
|
|
|
parser::parser(environment const & env, io_state const & ios, std::istream & in, script_state * S, bool use_exceptions, bool interactive) {
|
2014-01-02 14:46:28 +00:00
|
|
|
parser_imp::show_prompt(interactive, ios);
|
|
|
|
m_ptr.reset(new parser_imp(env, ios, in, S, use_exceptions, interactive));
|
2013-12-18 22:37:55 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
parser::parser(environment const & env, std::istream & in, script_state * S, bool use_exceptions, bool interactive):
|
|
|
|
parser(env, io_state(), in, S, use_exceptions, interactive) {
|
|
|
|
m_ptr->m_io_state.set_formatter(mk_pp_formatter(m_ptr->m_env));
|
2013-08-18 01:35:50 +00:00
|
|
|
}
|
2013-08-25 17:34:19 +00:00
|
|
|
|
|
|
|
parser::~parser() {
|
|
|
|
}
|
|
|
|
|
|
|
|
bool parser::operator()() {
|
|
|
|
return m_ptr->parse_commands();
|
|
|
|
}
|
|
|
|
|
|
|
|
expr parser::parse_expr() {
|
|
|
|
return m_ptr->parse_expr_main();
|
|
|
|
}
|
|
|
|
|
2013-12-18 22:37:55 +00:00
|
|
|
io_state parser::get_io_state() const {
|
|
|
|
return m_ptr->m_io_state;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool parse_commands(environment const & env, io_state & ios, std::istream & in, script_state * S, bool use_exceptions, bool interactive) {
|
|
|
|
parser p(env, ios, in, S, use_exceptions, interactive);
|
|
|
|
bool r = p();
|
|
|
|
ios = p.get_io_state();
|
2013-11-15 23:55:15 +00:00
|
|
|
return r;
|
|
|
|
}
|
|
|
|
|
2013-12-18 22:37:55 +00:00
|
|
|
expr parse_expr(environment const & env, io_state & ios, std::istream & in, script_state * S, bool use_exceptions) {
|
|
|
|
parser p(env, ios, in, S, use_exceptions);
|
|
|
|
expr r = p.parse_expr();
|
|
|
|
ios = p.get_io_state();
|
2013-11-15 23:55:15 +00:00
|
|
|
return r;
|
|
|
|
}
|
2013-08-18 01:13:55 +00:00
|
|
|
}
|