[flang] Get clean parse-unparse-reparse-unparse on f90_correct too.

Original-commit: flang-compiler/f18@901a9e462c
Reviewed-on: https://github.com/flang-compiler/f18/pull/25
Tree-same-pre-rewrite: false
This commit is contained in:
peter klausler 2018-03-15 10:59:46 -07:00
parent ed5a6c9faf
commit 42b72c46d1
4 changed files with 18 additions and 14 deletions

View file

@ -114,7 +114,8 @@ R722 length-selector -> ( [LEN =] type-param-value ) | * char-length [,]
R723 char-length -> ( type-param-value ) | digit-string
R724 char-literal-constant ->
[kind-param _] ' [rep-char]... ' | [kind-param _] " [rep-char]... "
R725 logical-literal-constant -> .TRUE. | .FALSE. @ | .T. | .F.
R725 logical-literal-constant ->
.TRUE. [_ kind-param] | .FALSE. [_ kind-param] @ | .T. | .F.
R726 derived-type-def ->
derived-type-stmt [type-param-def-stmt]... [private-or-sequence]...
[component-part] [type-bound-procedure-part] end-type-stmt

View file

@ -862,13 +862,15 @@ constexpr auto rawHollerithLiteral = deprecated(HollerithLiteral{});
TYPE_CONTEXT_PARSER("Hollerith"_en_US,
construct<HollerithLiteralConstant>{}(rawHollerithLiteral))
// R725 logical-literal-constant -> .TRUE. | .FALSE.
// R725 logical-literal-constant ->
// .TRUE. [_ kind-param] | .FALSE. [_ kind-param]
// Also accept .T. and .F. as extensions.
TYPE_PARSER(".TRUE." >> construct<LogicalLiteralConstant>{}(pure(true)) ||
".FALSE." >> construct<LogicalLiteralConstant>{}(pure(false)) ||
// PGI/Cray extensions
extension(".T."_tok >> construct<LogicalLiteralConstant>{}(pure(true))) ||
extension(".F."_tok >> construct<LogicalLiteralConstant>{}(pure(false))))
TYPE_PARSER(construct<LogicalLiteralConstant>{}(
(".TRUE."_tok || extension(".T."_tok)) >> pure(true),
maybe(underscore >> kindParam)) ||
construct<LogicalLiteralConstant>{}(
(".FALSE."_tok || extension(".F."_tok)) >> pure(false),
maybe(underscore >> kindParam)))
// R726 derived-type-def ->
// derived-type-stmt [type-param-def-stmt]...

View file

@ -754,8 +754,12 @@ struct HollerithLiteralConstant {
std::string GetString() const { return v; }
};
// R725 logical-literal-constant -> .TRUE. | .FALSE.
WRAPPER_CLASS(LogicalLiteralConstant, bool);
// R725 logical-literal-constant ->
// .TRUE. [_ kind-param] | .FALSE. [_ kind-param]
struct LogicalLiteralConstant {
TUPLE_CLASS_BOILERPLATE(LogicalLiteralConstant);
std::tuple<bool, std::optional<KindParam>> t;
};
// R764 boz-literal-constant -> binary-constant | octal-constant | hex-constant
// R765 binary-constant -> B ' digit [digit]... ' | B " digit [digit]... "

View file

@ -202,7 +202,8 @@ public:
return true;
}
bool Pre(const LogicalLiteralConstant &x) { // R725
Put(x.v ? ".TRUE." : ".FALSE.");
Put(std::get<bool>(x.t) ? ".TRUE." : ".FALSE.");
Walk("_", std::get<std::optional<KindParam>>(x.t));
return false;
}
bool Pre(const DerivedTypeStmt &x) { // R727
@ -857,10 +858,6 @@ public:
Word("%LOC("), Walk(x.v), Put(')');
return false;
}
bool Pre(const Expr::DefinedUnary &x) {
Put('.'), Walk(x.t, ". ");
return false;
}
bool Pre(const Expr::Power &x) {
Walk(x.t, "**");
return false;