2014-06-11 00:02:06 +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
|
|
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
#include <string>
|
|
|
|
#include <functional>
|
|
|
|
#include "kernel/environment.h"
|
2014-06-29 14:03:25 +00:00
|
|
|
#include "library/tactic/tactic.h"
|
2014-06-30 16:14:55 +00:00
|
|
|
#include "frontends/lean/parser_pos_provider.h"
|
2014-06-11 00:02:06 +00:00
|
|
|
|
|
|
|
namespace lean {
|
|
|
|
class parser;
|
|
|
|
typedef std::function<environment(parser&)> command_fn;
|
|
|
|
|
|
|
|
template<typename F>
|
|
|
|
struct cmd_info_tmpl {
|
|
|
|
name m_name;
|
|
|
|
std::string m_descr;
|
|
|
|
F m_fn;
|
|
|
|
public:
|
|
|
|
cmd_info_tmpl(name const & n, char const * d, F const & fn):
|
|
|
|
m_name(n), m_descr(d), m_fn(fn) {}
|
2014-06-11 18:26:17 +00:00
|
|
|
cmd_info_tmpl() {}
|
2014-06-11 00:02:06 +00:00
|
|
|
name const & get_name() const { return m_name; }
|
|
|
|
std::string const & get_descr() const { return m_descr; }
|
|
|
|
F const & get_fn() const { return m_fn; }
|
|
|
|
};
|
|
|
|
|
2014-07-02 03:43:53 +00:00
|
|
|
typedef cmd_info_tmpl<command_fn> cmd_info;
|
2014-09-28 17:23:11 +00:00
|
|
|
typedef name_map<cmd_info> cmd_table;
|
2014-06-11 18:52:58 +00:00
|
|
|
inline void add_cmd(cmd_table & t, cmd_info const & cmd) { t.insert(cmd.get_name(), cmd); }
|
2014-06-11 00:02:06 +00:00
|
|
|
}
|