[flang] Move dump-parse-tree.h from semantics into parser.
authorpeter klausler <pklausler@nvidia.com>
Thu, 14 Mar 2019 23:28:06 +0000 (16:28 -0700)
committerpeter klausler <pklausler@nvidia.com>
Thu, 14 Mar 2019 23:28:06 +0000 (16:28 -0700)
Original-commit: flang-compiler/f18@9075adfcdf5a300471c9bd5512674ec33a9ad90d
Reviewed-on: https://github.com/flang-compiler/f18/pull/330
Tree-same-pre-rewrite: false

flang/lib/parser/dump-parse-tree.h [moved from flang/lib/semantics/dump-parse-tree.h with 97% similarity]
flang/lib/semantics/expression.cc
flang/tools/f18/CMakeLists.txt
flang/tools/f18/f18-parse-demo.cc
flang/tools/f18/f18.cc

similarity index 97%
rename from flang/lib/semantics/dump-parse-tree.h
rename to flang/lib/parser/dump-parse-tree.h
index 51b73d4..76973e5 100644 (file)
 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 // See the License for the specific language governing permissions and
 // limitations under the License.
-#ifndef FORTRAN_SEMANTICS_DUMP_PARSE_TREE_H_
-#define FORTRAN_SEMANTICS_DUMP_PARSE_TREE_H_
+#ifndef FORTRAN_PARSER_DUMP_PARSE_TREE_H_
+#define FORTRAN_PARSER_DUMP_PARSE_TREE_H_
 
-#include "symbol.h"
+#include "format-specification.h"
+#include "parse-tree-visitor.h"
+#include "parse-tree.h"
 #include "../common/idioms.h"
 #include "../common/indirection.h"
-#include "../parser/format-specification.h"
-#include "../parser/parse-tree-visitor.h"
-#include "../parser/parse-tree.h"
 #include <ostream>
 #include <string>
 
-namespace Fortran::semantics {
+namespace Fortran::parser {
 
 using namespace std::string_literals;
 
@@ -733,23 +732,19 @@ public:
     }
   }
 
-  bool PutName(const std::string &name, const semantics::Symbol *symbol) {
+  bool PutName(const std::string &name) {
     IndentEmptyLine();
-    if (symbol != nullptr) {
-      out_ << "symbol = " << *symbol;
-    } else {
-      out_ << "Name = '" << name << '\'';
-    }
+    out_ << "Name = '" << name << '\'';
     ++indent_;
     EndLine();
     return true;
   }
 
-  bool Pre(const parser::Name &x) { return PutName(x.ToString(), x.symbol); }
+  bool Pre(const parser::Name &x) { return PutName(x.ToString()); }
 
   void Post(const parser::Name &) { --indent_; }
 
-  bool Pre(const std::string &x) { return PutName(x, nullptr); }
+  bool Pre(const std::string &x) { return PutName(x); }
 
   void Post(const std::string &x) { --indent_; }
 
@@ -874,4 +869,4 @@ template<typename T> void DumpTree(std::ostream &out, const T &x) {
   parser::Walk(x, dumper);
 }
 }
-#endif  // FORTRAN_SEMANTICS_DUMP_PARSE_TREE_H_
+#endif  // FORTRAN_PARSER_DUMP_PARSE_TREE_H_
index ac84ce0..83c2161 100644 (file)
@@ -31,7 +31,7 @@
 // TODO pmk remove when scaffolding is obsolete
 #undef PMKDEBUG  // #define PMKDEBUG 1
 #if PMKDEBUG
-#include "dump-parse-tree.h"
+#include "../parser/dump-parse-tree.h"
 #include <iostream>
 #endif
 
@@ -322,7 +322,7 @@ static void FixMisparsedSubstring(const parser::Designator &d) {
                     },
                     arrElement.base.u)}) {
               const Symbol &ultimate{symbol->GetUltimate()};
-              if (const semantics::DeclTypeSpec *type{ultimate.GetType()}) {
+              if (const semantics::DeclTypeSpec * type{ultimate.GetType()}) {
                 if (!ultimate.IsObjectArray() &&
                     type->category() == semantics::DeclTypeSpec::Character) {
                   // The ambiguous S(j:k) was parsed as an array section
@@ -1935,7 +1935,7 @@ void ExprChecker::Enter(const parser::Expr &expr) {
     } else {
 #if PMKDEBUG
       std::cout << "TODO: expression analysis failed for this expression: ";
-      DumpTree(std::cout, expr);
+      parser::DumpTree(std::cout, expr);
 #endif
     }
   }
index c04cb47..c962f70 100644 (file)
@@ -36,5 +36,4 @@ add_executable(f18-parse-demo
 
 target_link_libraries(f18-parse-demo
   FortranParser
-  FortranSemantics
 )
index 1ac7e83..9379c54 100644 (file)
@@ -29,6 +29,7 @@
 
 #include "../../lib/common/default-kinds.h"
 #include "../../lib/parser/characters.h"
+#include "../../lib/parser/dump-parse-tree.h"
 #include "../../lib/parser/features.h"
 #include "../../lib/parser/message.h"
 #include "../../lib/parser/parse-tree-visitor.h"
@@ -36,7 +37,6 @@
 #include "../../lib/parser/parsing.h"
 #include "../../lib/parser/provenance.h"
 #include "../../lib/parser/unparse.h"
-#include "../../lib/semantics/dump-parse-tree.h"
 #include <cerrno>
 #include <cstdio>
 #include <cstring>
@@ -208,7 +208,7 @@ std::string CompileFortran(
   }
   auto &parseTree{*parsing.parseTree()};
   if (driver.dumpParseTree) {
-    Fortran::semantics::DumpTree(std::cout, parseTree);
+    Fortran::parser::DumpTree(std::cout, parseTree);
     return {};
   }
   if (driver.dumpUnparse) {
index acc423f..5665a71 100644 (file)
@@ -20,6 +20,7 @@
 #endif
 #include "../../lib/common/default-kinds.h"
 #include "../../lib/parser/characters.h"
+#include "../../lib/parser/dump-parse-tree.h"
 #include "../../lib/parser/features.h"
 #include "../../lib/parser/message.h"
 #include "../../lib/parser/parse-tree-visitor.h"
@@ -27,7 +28,6 @@
 #include "../../lib/parser/parsing.h"
 #include "../../lib/parser/provenance.h"
 #include "../../lib/parser/unparse.h"
-#include "../../lib/semantics/dump-parse-tree.h"
 #include "../../lib/semantics/expression.h"
 #include "../../lib/semantics/semantics.h"
 #include "../../lib/semantics/unparse-with-symbols.h"
@@ -249,7 +249,7 @@ std::string CompileFortran(std::string path, Fortran::parser::Options options,
     return {};
   }
   if (driver.dumpParseTree) {
-    Fortran::semantics::DumpTree(std::cout, parseTree);
+    Fortran::parser::DumpTree(std::cout, parseTree);
   }
   if (driver.dumpUnparse) {
     Unparse(std::cout, parseTree, driver.encoding, true /*capitalize*/,