2013-08-10 01:00:05 +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 <memory>
|
2013-08-16 01:54:01 +00:00
|
|
|
#include "environment.h"
|
|
|
|
#include "operator_info.h"
|
2013-08-10 01:00:05 +00:00
|
|
|
|
|
|
|
namespace lean {
|
|
|
|
/**
|
|
|
|
\brief Object for managing the environment, parser, pretty printer,
|
|
|
|
elaborator, etc.
|
|
|
|
*/
|
|
|
|
class frontend {
|
|
|
|
struct imp;
|
|
|
|
std::shared_ptr<imp> m_imp;
|
|
|
|
explicit frontend(imp * new_ptr);
|
|
|
|
explicit frontend(std::shared_ptr<imp> const & ptr);
|
|
|
|
public:
|
|
|
|
frontend();
|
|
|
|
~frontend();
|
|
|
|
|
2013-08-20 00:25:15 +00:00
|
|
|
/**
|
|
|
|
@name Parent/Child frontend management.
|
|
|
|
*/
|
|
|
|
/*@{*/
|
2013-08-10 01:00:05 +00:00
|
|
|
/**
|
|
|
|
\brief Create a child environment. This frontend object will
|
|
|
|
only allow "read-only" operations until all children frontend
|
|
|
|
objects are deleted.
|
|
|
|
*/
|
|
|
|
frontend mk_child() const;
|
|
|
|
|
|
|
|
/** \brief Return true iff this fronted has children frontend. */
|
|
|
|
bool has_children() const;
|
|
|
|
|
|
|
|
/** \brief Return true iff this frontend has a parent frontend. */
|
|
|
|
bool has_parent() const;
|
|
|
|
|
|
|
|
/** \brief Return parent frontend */
|
|
|
|
frontend parent() const;
|
2013-08-20 00:25:15 +00:00
|
|
|
/*@}*/
|
2013-08-10 01:00:05 +00:00
|
|
|
|
2013-08-20 00:25:15 +00:00
|
|
|
/**
|
|
|
|
@name Environment API
|
|
|
|
*/
|
|
|
|
/*@{*/
|
2013-08-10 01:00:05 +00:00
|
|
|
/** \brief Coercion frontend -> environment. */
|
2013-08-17 03:39:24 +00:00
|
|
|
environment const & get_environment() const;
|
|
|
|
operator environment const &() const { return get_environment(); }
|
2013-08-10 01:00:05 +00:00
|
|
|
|
|
|
|
level add_uvar(name const & n, level const & l);
|
|
|
|
level add_uvar(name const & n);
|
|
|
|
level get_uvar(name const & n) const;
|
2013-08-17 17:55:42 +00:00
|
|
|
void add_definition(name const & n, expr const & t, expr const & v, bool opaque = false);
|
|
|
|
void add_theorem(name const & n, expr const & t, expr const & v);
|
|
|
|
void add_definition(name const & n, expr const & v, bool opaque = false);
|
|
|
|
void add_axiom(name const & n, expr const & t);
|
|
|
|
void add_var(name const & n, expr const & t);
|
|
|
|
object const & get_object(name const & n) const;
|
|
|
|
object const & find_object(name const & n) const;
|
|
|
|
bool has_object(name const & n) const;
|
2013-08-18 01:13:55 +00:00
|
|
|
typedef environment::object_iterator object_iterator;
|
|
|
|
object_iterator begin_objects() const;
|
|
|
|
object_iterator end_objects() const;
|
|
|
|
object_iterator begin_local_objects() const;
|
|
|
|
object_iterator end_local_objects() const;
|
2013-08-20 00:25:15 +00:00
|
|
|
/*@}*/
|
2013-08-10 01:00:05 +00:00
|
|
|
|
2013-08-16 01:54:01 +00:00
|
|
|
/**
|
2013-08-20 00:25:15 +00:00
|
|
|
@name Notation for parsing and pretty printing.
|
|
|
|
*/
|
|
|
|
/*@{*/
|
|
|
|
void add_infix(name const & opn, unsigned precedence, expr const & d);
|
|
|
|
void add_infixl(name const & opn, unsigned precedence, expr const & d);
|
|
|
|
void add_infixr(name const & opn, unsigned precedence, expr const & d);
|
|
|
|
void add_prefix(name const & opn, unsigned precedence, expr const & d);
|
|
|
|
void add_postfix(name const & opn, unsigned precedence, expr const & d);
|
|
|
|
void add_mixfixl(unsigned sz, name const * opns, unsigned precedence, expr const & d);
|
|
|
|
void add_mixfixr(unsigned sz, name const * opns, unsigned precedence, expr const & d);
|
|
|
|
void add_mixfixc(unsigned sz, name const * opns, unsigned precedence, expr const & d);
|
|
|
|
/**
|
|
|
|
\brief Return the operator (if one exists) associated with the
|
|
|
|
given expression.
|
2013-08-16 01:54:01 +00:00
|
|
|
|
2013-08-20 00:25:15 +00:00
|
|
|
\remark If an operator is not associated with \c e, then
|
2013-08-17 17:55:42 +00:00
|
|
|
return the null operator.
|
2013-08-20 00:25:15 +00:00
|
|
|
|
|
|
|
\remark This is used for pretty printing.
|
2013-08-16 01:54:01 +00:00
|
|
|
*/
|
2013-08-20 00:25:15 +00:00
|
|
|
operator_info find_op_for(expr const & e) const;
|
|
|
|
/**
|
|
|
|
\brief Return the operator (if one exists) that can appear at
|
|
|
|
the beginning of a language construct.
|
2013-08-18 01:13:55 +00:00
|
|
|
|
2013-08-20 00:25:15 +00:00
|
|
|
\remark If there isn't a nud operator starting with \c n, then
|
|
|
|
return the null operator.
|
|
|
|
|
|
|
|
\remark This is used for parsing.
|
|
|
|
*/
|
2013-08-18 01:13:55 +00:00
|
|
|
operator_info find_nud(name const & n) const;
|
2013-08-20 00:25:15 +00:00
|
|
|
/**
|
|
|
|
\brief Return the operator (if one exists) that can appear
|
|
|
|
inside of a language construct.
|
2013-08-18 01:13:55 +00:00
|
|
|
|
2013-08-20 00:25:15 +00:00
|
|
|
\remark If there isn't a led operator starting with \c n, then
|
|
|
|
return the null operator.
|
|
|
|
|
|
|
|
\remark This is used for parsing.
|
|
|
|
*/
|
2013-08-18 01:13:55 +00:00
|
|
|
operator_info find_led(name const & n) const;
|
2013-08-20 00:25:15 +00:00
|
|
|
/*@}*/
|
2013-08-10 01:00:05 +00:00
|
|
|
};
|
|
|
|
}
|