2014-06-10 17:39:22 +00:00
|
|
|
/*
|
|
|
|
Copyright (c) 2014 Microsoft Corporation. All rights reserved.
|
|
|
|
Released under Apache 2.0 license as described in the file LICENSE.
|
|
|
|
|
|
|
|
Author: Leonardo de Moura
|
|
|
|
*/
|
|
|
|
#include "frontends/lean/parser_config.h"
|
2014-06-12 03:56:10 +00:00
|
|
|
#include "frontends/lean/builtin_exprs.h"
|
2014-06-11 18:44:16 +00:00
|
|
|
#include "frontends/lean/builtin_cmds.h"
|
|
|
|
#include "frontends/lean/builtin_tactic_cmds.h"
|
2014-06-10 17:39:22 +00:00
|
|
|
|
|
|
|
namespace lean {
|
2014-06-11 00:02:06 +00:00
|
|
|
parser_config::parser_config() {
|
|
|
|
m_tokens = mk_default_token_table();
|
2014-06-12 03:56:10 +00:00
|
|
|
m_nud = get_builtin_nud_table();
|
|
|
|
m_led = get_builtin_led_table();
|
2014-06-11 00:02:06 +00:00
|
|
|
m_cmds = get_builtin_cmds();
|
|
|
|
m_tactic_cmds = get_builtin_tactic_cmds();
|
|
|
|
}
|
|
|
|
|
2014-06-10 17:39:22 +00:00
|
|
|
struct parser_ext : public environment_extension {
|
|
|
|
// Configuration for a Pratt's parser
|
2014-06-11 00:02:06 +00:00
|
|
|
parser_config m_cfg;
|
2014-06-10 17:39:22 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
struct parser_ext_reg {
|
|
|
|
unsigned m_ext_id;
|
|
|
|
parser_ext_reg() { m_ext_id = environment::register_extension(std::make_shared<parser_ext>()); }
|
|
|
|
};
|
|
|
|
static parser_ext_reg g_ext;
|
|
|
|
static parser_ext const & get_extension(environment const & env) {
|
|
|
|
return static_cast<parser_ext const &>(env.get_extension(g_ext.m_ext_id));
|
|
|
|
}
|
|
|
|
static environment update(environment const & env, parser_ext const & ext) {
|
|
|
|
return env.update(g_ext.m_ext_id, std::make_shared<parser_ext>(ext));
|
|
|
|
}
|
2014-06-11 00:02:06 +00:00
|
|
|
parser_config const & get_parser_config(environment const & env) {
|
|
|
|
return get_extension(env).m_cfg;
|
2014-06-10 17:39:22 +00:00
|
|
|
}
|
2014-06-11 00:02:06 +00:00
|
|
|
environment update_parser_config(environment const & env, parser_config const & c) {
|
2014-06-10 17:39:22 +00:00
|
|
|
parser_ext ext = get_extension(env);
|
2014-06-11 00:02:06 +00:00
|
|
|
ext.m_cfg = c;
|
2014-06-10 17:39:22 +00:00
|
|
|
return update(env, ext);
|
|
|
|
}
|
|
|
|
}
|