diff --git a/src/frontends/lean/decl_attributes.cpp b/src/frontends/lean/decl_attributes.cpp index 65b15b49bf..b70a333dd7 100644 --- a/src/frontends/lean/decl_attributes.cpp +++ b/src/frontends/lean/decl_attributes.cpp @@ -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; + } } } diff --git a/src/frontends/lean/parser.h b/src/frontends/lean/parser.h index 9bbd72d64c..ab6638bd50 100644 --- a/src/frontends/lean/parser.h +++ b/src/frontends/lean/parser.h @@ -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; } diff --git a/src/library/abstract_parser.h b/src/library/abstract_parser.h index 95a6ee3278..7e50ba48cf 100644 --- a/src/library/abstract_parser.h +++ b/src/library/abstract_parser.h @@ -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; diff --git a/src/library/attribute_manager.cpp b/src/library/attribute_manager.cpp index 7a0379a808..5e56a271ef 100644 --- a/src/library/attribute_manager.cpp +++ b/src/library/attribute_manager.cpp @@ -145,7 +145,7 @@ environment basic_attribute::set(environment const & env, io_state const & ios, void indices_attribute_data::parse(abstract_parser & p) { buffer vs; - while (!p.curr_is_token("]")) { + while (p.curr_is_numeral()) { auto pos = p.pos(); unsigned v = p.parse_small_nat(); if (v == 0)