2015-06-12 20:38:57 +00:00
|
|
|
/*
|
|
|
|
Copyright (c) 2015 Microsoft Corporation. All rights reserved.
|
|
|
|
Released under Apache 2.0 license as described in the file LICENSE.
|
|
|
|
|
|
|
|
Author: Leonardo de Moura
|
|
|
|
*/
|
|
|
|
#pragma once
|
2015-12-18 06:50:01 +00:00
|
|
|
#include <string>
|
2015-06-12 20:38:57 +00:00
|
|
|
#include "kernel/environment.h"
|
|
|
|
#include "library/io_state.h"
|
|
|
|
namespace lean {
|
|
|
|
class parser;
|
|
|
|
class decl_attributes {
|
2015-12-18 06:19:55 +00:00
|
|
|
public:
|
|
|
|
struct entry {
|
|
|
|
std::string m_attr;
|
|
|
|
list<unsigned> m_params;
|
|
|
|
entry() {}
|
|
|
|
entry(char const * attr):m_attr(attr) {}
|
|
|
|
entry(char const * attr, unsigned p):m_attr(attr), m_params(to_list(p)) {}
|
|
|
|
entry(char const * attr, list<unsigned> const & ps):m_attr(attr), m_params(ps) {}
|
|
|
|
bool operator==(entry const & e) const { return m_attr == e.m_attr && m_params == e.m_params; }
|
|
|
|
bool operator!=(entry const & e) const { return !operator==(e); }
|
|
|
|
};
|
|
|
|
private:
|
2015-06-12 20:38:57 +00:00
|
|
|
bool m_is_abbrev; // if true only abbreviation attributes are allowed
|
|
|
|
bool m_persistent;
|
2015-12-18 06:19:55 +00:00
|
|
|
bool m_parsing_only;
|
|
|
|
list<entry> m_entries;
|
|
|
|
optional<unsigned> m_prio;
|
2015-06-12 20:38:57 +00:00
|
|
|
public:
|
2015-06-18 00:23:20 +00:00
|
|
|
decl_attributes(bool is_abbrev = false, bool persistent = true);
|
2015-06-12 20:38:57 +00:00
|
|
|
void parse(parser & p);
|
2015-12-05 18:28:01 +00:00
|
|
|
environment apply(environment env, io_state const & ios, name const & d, name const & ns) const;
|
2015-12-18 06:19:55 +00:00
|
|
|
bool is_parsing_only() const { return m_parsing_only; }
|
2015-06-13 00:32:18 +00:00
|
|
|
void write(serializer & s) const;
|
|
|
|
void read(deserializer & d);
|
2015-12-14 02:22:51 +00:00
|
|
|
friend bool operator==(decl_attributes const & d1, decl_attributes const & d2);
|
2015-06-12 20:38:57 +00:00
|
|
|
};
|
2015-12-14 02:22:51 +00:00
|
|
|
bool operator==(decl_attributes const & d1, decl_attributes const & d2);
|
2015-06-12 20:38:57 +00:00
|
|
|
}
|