#include <string>
namespace Fortran {
+namespace semantics {
std::ostream &operator<<(std::ostream &o, Attr attr) {
switch (attr) {
std::ostream &operator<<(std::ostream &o, const Attrs &attrs) {
int n = 0;
for (auto attr : attrs) {
- if (n++) { o << ", "; }
+ if (n++) {
+ o << ", ";
+ }
o << attr;
}
return o;
}
}
+} // namespace semantics
} // namespace Fortran
#ifndef FORTRAN_ATTR_H_
#define FORTRAN_ATTR_H_
-#include "lib/parser/idioms.h"
+#include "../parser/idioms.h"
#include <iostream>
#include <set>
#include <string>
namespace Fortran {
+namespace semantics {
// All available attributes.
enum class Attr {
// Report internal error if attrs is not a subset of allowed.
void checkAttrs(std::string className, Attrs attrs, Attrs allowed);
+} // namespace semantics
} // namespace Fortran
#endif
#include <iostream>
namespace Fortran {
+namespace semantics {
// Check that values specified for param defs are valid: they must match the
// names of the params and any def that doesn't have a default value must have a
Name name = def.name();
validNames.insert(name);
if (!def.defaultValue() && values.find(name) == values.end()) {
- parser::die("no value or default value for %s parameter '%s'", kindOrLen.c_str(),
- name.c_str());
+ parser::die("no value or default value for %s parameter '%s'",
+ kindOrLen.c_str(), name.c_str());
}
}
for (auto pair : values) {
o << '(';
int n = 0;
for (auto param : x.lenParams_) {
- if (n++) { o << ", "; }
+ if (n++) {
+ o << ", ";
+ }
o << param.name();
}
for (auto param : x.kindParams_) {
- if (n++) { o << ", "; }
+ if (n++) {
+ o << ", ";
+ }
o << param.name();
}
o << ')';
for (auto param : x.kindParams_) {
o << " " << param.type() << ", KIND :: " << param.name() << "\n";
}
- if (x.private_) { o << " PRIVATE\n"; }
- if (x.sequence_) { o << " SEQUENCE\n"; }
+ if (x.private_) {
+ o << " PRIVATE\n";
+ }
+ if (x.sequence_) {
+ o << " SEQUENCE\n";
+ }
// components
return o << "END TYPE\n";
}
o << '(';
int n = 0;
for (auto pair : x.kindParamValues_) {
- if (n++) { o << ", "; }
+ if (n++) {
+ o << ", ";
+ }
o << pair.first << '=' << pair.second;
}
for (auto pair : x.lenParamValues_) {
- if (n++) { o << ", "; }
+ if (n++) {
+ o << ", ";
+ }
o << pair.first << '=' << pair.second;
}
o << ')';
CHECK(x.ub_.isAssumed());
o << "..";
} else {
- if (!x.lb_.isDeferred()) { o << x.lb_; }
+ if (!x.lb_.isDeferred()) {
+ o << x.lb_;
+ }
o << ':';
- if (!x.ub_.isDeferred()) { o << x.ub_; }
+ if (!x.ub_.isDeferred()) {
+ o << x.ub_;
+ }
}
return o;
}
+} // namespace semantics
} // namespace Fortran
-using namespace Fortran;
+using namespace Fortran::semantics;
void testTypeSpec() {
LogicalTypeSpec l1 = LogicalTypeSpec::make();
#ifndef FORTRAN_TYPE_H_
#define FORTRAN_TYPE_H_
+#include "../parser/idioms.h"
#include "attr.h"
-#include "lib/parser/idioms.h"
#include <algorithm>
#include <list>
#include <map>
*/
namespace Fortran {
+namespace semantics {
using Name = std::string;
virtual std::ostream &output(std::ostream &o) const {
return o << this->value_;
}
+
private:
static std::unordered_map<int, IntConst> cache;
IntConst(int value) : value_{value} {}
const Bound ub_;
};
+} // namespace semantics
} // namespace Fortran
#endif