2018-02-15 00:07:59 +01:00
|
|
|
#include "../parser/idioms.h"
|
2018-02-07 01:46:29 +01:00
|
|
|
#include "attr.h"
|
2018-02-15 00:07:59 +01:00
|
|
|
#include <stddef.h>
|
2018-02-07 01:46:29 +01:00
|
|
|
|
|
|
|
namespace Fortran {
|
2018-02-08 00:54:07 +01:00
|
|
|
namespace semantics {
|
2018-02-07 01:46:29 +01:00
|
|
|
|
2018-02-15 17:27:19 +01:00
|
|
|
void Attrs::CheckValid(const Attrs &allowed) const {
|
|
|
|
if (!allowed.HasAll(*this)) {
|
2018-02-15 00:07:59 +01:00
|
|
|
parser::die("invalid attribute");
|
2018-02-07 01:46:29 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-02-15 00:07:59 +01:00
|
|
|
std::ostream &operator<<(std::ostream &o, Attr attr) {
|
2018-03-23 22:31:14 +01:00
|
|
|
return o << EnumToString(attr);
|
2018-02-15 00:07:59 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
std::ostream &operator<<(std::ostream &o, const Attrs &attrs) {
|
2018-04-06 01:49:48 +02:00
|
|
|
const char *comma{""};
|
|
|
|
std::size_t n{attrs.count()}, seen{0};
|
|
|
|
for (std::size_t j{0}; seen < n; ++j) {
|
|
|
|
Attr attr{static_cast<Attr>(j)};
|
|
|
|
if (attrs.test(attr)) {
|
|
|
|
o << comma << attr;
|
|
|
|
comma = ", ";
|
|
|
|
++seen;
|
2018-02-07 01:46:29 +01:00
|
|
|
}
|
|
|
|
}
|
2018-02-15 00:07:59 +01:00
|
|
|
return o;
|
2018-02-07 01:46:29 +01:00
|
|
|
}
|
2018-02-08 00:54:07 +01:00
|
|
|
} // namespace semantics
|
2018-02-07 01:46:29 +01:00
|
|
|
} // namespace Fortran
|