feat(frontends/lean/decl_attributes): add [attr1, attr2] syntax
This commit is contained in:
parent
cb6a6b642e
commit
a2659cdaa5
4 changed files with 17 additions and 5 deletions
|
|
@ -16,8 +16,10 @@ Author: Leonardo de Moura
|
|||
|
||||
namespace lean {
|
||||
void decl_attributes::parse(parser & p) {
|
||||
while (p.curr_is_token(get_lbracket_tk())) {
|
||||
p.next();
|
||||
if (!p.curr_is_token(get_lbracket_tk()))
|
||||
return;
|
||||
p.next();
|
||||
while (true) {
|
||||
auto pos = p.pos();
|
||||
auto name = p.check_id_next("invalid attribute declaration, identifier expected");
|
||||
if (name == "priority") {
|
||||
|
|
@ -50,7 +52,15 @@ void decl_attributes::parse(parser & p) {
|
|||
if (name == "parsing_only")
|
||||
m_parsing_only = true;
|
||||
}
|
||||
p.check_token_next(get_rbracket_tk(), "invalid attribute declaration, ']' expected");
|
||||
if (p.curr_is_token(get_comma_tk())) {
|
||||
p.next();
|
||||
} else {
|
||||
p.check_token_next(get_rbracket_tk(), "invalid attribute declaration, ']' expected");
|
||||
if (p.curr_is_token(get_lbracket_tk()))
|
||||
p.next();
|
||||
else
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -312,7 +312,7 @@ public:
|
|||
/** \brief Return true iff the current token is an identifier */
|
||||
bool curr_is_identifier() const { return curr() == scanner::token_kind::Identifier; }
|
||||
/** \brief Return true iff the current token is a numeral */
|
||||
bool curr_is_numeral() const { return curr() == scanner::token_kind::Numeral; }
|
||||
virtual bool curr_is_numeral() const final override { return curr() == scanner::token_kind::Numeral; }
|
||||
bool curr_is_decimal() const { return curr() == scanner::token_kind::Decimal; }
|
||||
/** \brief Return true iff the current token is a string */
|
||||
bool curr_is_string() const { return curr() == scanner::token_kind::String; }
|
||||
|
|
|
|||
|
|
@ -25,6 +25,8 @@ public:
|
|||
|
||||
/** \brief Return true iff the current token is a keyword (or command keyword) named \c tk */
|
||||
virtual bool curr_is_token(name const & tk) const = 0;
|
||||
/** \brief Return true iff the current token is a numeral */
|
||||
virtual bool curr_is_numeral() const = 0;
|
||||
/** \brief Read the next token if the current one is not End-of-file. */
|
||||
virtual void next() = 0;
|
||||
|
||||
|
|
|
|||
|
|
@ -145,7 +145,7 @@ environment basic_attribute::set(environment const & env, io_state const & ios,
|
|||
|
||||
void indices_attribute_data::parse(abstract_parser & p) {
|
||||
buffer<unsigned> vs;
|
||||
while (!p.curr_is_token("]")) {
|
||||
while (p.curr_is_numeral()) {
|
||||
auto pos = p.pos();
|
||||
unsigned v = p.parse_small_nat();
|
||||
if (v == 0)
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue