Browse Source

Merge topic 'fortran-parser-updates'

ecca8fd9 cmFortranParser: Port to bison 3
eebe732b cmFortranParser: Factor out of cmDependsFortran
fd194458 cmDependsFortran: Simplify storage of preprocessor definitions
295480b9 cmDependsFortran: Move FindIncludeFile method into parser class
98b9645b Rename Fortran parser infrastructure to drop "Depends" prefix
096dd3c9 cmDependsFortranLexer: Remove trailing blank line
Brad King 10 years ago
parent
commit
24dd88d156

+ 6 - 4
Source/CMakeLists.txt

@@ -88,7 +88,7 @@ option(CMAKE_REGENERATE_YACCLEX
   "Regenerate YACC and LEXX files" OFF)
 mark_as_advanced(CMAKE_REGENERATE_YACCLEX)
 if(CMAKE_REGENERATE_YACCLEX)
-  set(parsersLexers cmDependsFortran cmCommandArgument cmExpr)
+  set(parsersLexers cmFortran cmCommandArgument cmExpr)
   find_program(YACC_EXECUTABLE
     NAMES yacc bison
     PATHS /usr/bin
@@ -193,9 +193,6 @@ set(SRCS
   cmDependsC.h
   cmDependsFortran.cxx
   cmDependsFortran.h
-  cmDependsFortranLexer.cxx
-  cmDependsFortranParser.cxx
-  cmDependsFortranParser.h
   cmDependsJava.cxx
   cmDependsJava.h
   cmDependsJavaLexer.cxx
@@ -243,6 +240,11 @@ set(SRCS
   cmFileLockResult.h
   cmFileTimeComparison.cxx
   cmFileTimeComparison.h
+  cmFortranLexer.cxx
+  cmFortranLexer.h
+  cmFortranParser.cxx
+  cmFortranParser.h
+  cmFortranParserImpl.cxx
   cmGeneratedFileStream.cxx
   cmGeneratorExpressionContext.cxx
   cmGeneratorExpressionContext.h

+ 23 - 489
Source/cmDependsFortran.cxx

@@ -16,83 +16,14 @@
 #include "cmMakefile.h"
 #include "cmGeneratedFileStream.h"
 
-#include "cmDependsFortranParser.h" /* Interface to parser object.  */
+#include "cmFortranParser.h" /* Interface to parser object.  */
 #include <cmsys/FStream.hxx>
 #include <assert.h>
-#include <stack>
 
 // TODO: Test compiler for the case of the mod file.  Some always
 // use lower case and some always use upper case.  I do not know if any
 // use the case from the source code.
 
-//----------------------------------------------------------------------------
-// Information about a single source file.
-class cmDependsFortranSourceInfo
-{
-public:
-  // The name of the source file.
-  std::string Source;
-
-  // Set of provided and required modules.
-  std::set<std::string> Provides;
-  std::set<std::string> Requires;
-
-  // Set of files included in the translation unit.
-  std::set<std::string> Includes;
-};
-
-//----------------------------------------------------------------------------
-// Parser methods not included in generated interface.
-
-// Get the current buffer processed by the lexer.
-YY_BUFFER_STATE cmDependsFortranLexer_GetCurrentBuffer(yyscan_t yyscanner);
-
-// The parser entry point.
-int cmDependsFortran_yyparse(yyscan_t);
-
-//----------------------------------------------------------------------------
-// Define parser object internal structure.
-struct cmDependsFortranFile
-{
-  cmDependsFortranFile(FILE* file, YY_BUFFER_STATE buffer,
-                       const std::string& dir):
-    File(file), Buffer(buffer), Directory(dir) {}
-  FILE* File;
-  YY_BUFFER_STATE Buffer;
-  std::string Directory;
-};
-
-struct cmDependsFortranParser_s
-{
-  cmDependsFortranParser_s(cmDependsFortran* self,
-                           std::set<std::string>& ppDefines,
-                           cmDependsFortranSourceInfo& info);
-  ~cmDependsFortranParser_s();
-
-  // Pointer back to the main class.
-  cmDependsFortran* Self;
-
-  // Lexical scanner instance.
-  yyscan_t Scanner;
-
-  // Stack of open files in the translation unit.
-  std::stack<cmDependsFortranFile> FileStack;
-
-  // Buffer for string literals.
-  std::string TokenString;
-
-  // Flag for whether lexer is reading from inside an interface.
-  bool InInterface;
-
-  int OldStartcond;
-  std::set<std::string> PPDefinitions;
-  size_t InPPFalseBranch;
-  std::stack<bool> SkipToEnd;
-
-  // Information about the parsed source.
-  cmDependsFortranSourceInfo& Info;
-};
-
 //----------------------------------------------------------------------------
 class cmDependsFortranInternals
 {
@@ -105,18 +36,18 @@ public:
   TargetRequiresMap TargetRequires;
 
   // Information about each object file.
-  typedef std::map<std::string, cmDependsFortranSourceInfo> ObjectInfoMap;
+  typedef std::map<std::string, cmFortranSourceInfo> ObjectInfoMap;
   ObjectInfoMap ObjectInfo;
 
-  cmDependsFortranSourceInfo& CreateObjectInfo(const char* obj,
+  cmFortranSourceInfo& CreateObjectInfo(const char* obj,
                                                const char* src)
     {
-    std::map<std::string, cmDependsFortranSourceInfo>::iterator i =
+    std::map<std::string, cmFortranSourceInfo>::iterator i =
       this->ObjectInfo.find(obj);
     if(i == this->ObjectInfo.end())
       {
-      std::map<std::string, cmDependsFortranSourceInfo>::value_type
-        entry(obj, cmDependsFortranSourceInfo());
+      std::map<std::string, cmFortranSourceInfo>::value_type
+        entry(obj, cmFortranSourceInfo());
       i = this->ObjectInfo.insert(entry).first;
       i->second.Source = src;
       }
@@ -126,7 +57,7 @@ public:
 
 //----------------------------------------------------------------------------
 cmDependsFortran::cmDependsFortran():
-  PPDefinitions(0), Internal(0)
+  Internal(0)
 {
 }
 
@@ -159,7 +90,7 @@ cmDependsFortran
       {
       def = it->substr(0, assignment);
       }
-    this->PPDefinitions.push_back(def);
+    this->PPDefinitions.insert(def);
     }
 }
 
@@ -192,22 +123,18 @@ bool cmDependsFortran::WriteDependencies(
     {
     const std::string& src = *it;
     // Get the information object for this source.
-    cmDependsFortranSourceInfo& info =
+    cmFortranSourceInfo& info =
       this->Internal->CreateObjectInfo(obj.c_str(), src.c_str());
 
-    // Make a copy of the macros defined via ADD_DEFINITIONS
-    std::set<std::string> ppDefines(this->PPDefinitions.begin(),
-                                    this->PPDefinitions.end());
-
-    // Create the parser object. The constructor takes ppMacro and info per
-    // reference, so we may look into the resulting objects later.
-    cmDependsFortranParser parser(this, ppDefines, info);
+    // Create the parser object. The constructor takes info by reference,
+    // so we may look into the resulting objects later.
+    cmFortranParser parser(this->IncludePath, this->PPDefinitions, info);
 
     // Push on the starting file.
-    cmDependsFortranParser_FilePush(&parser, src.c_str());
+    cmFortranParser_FilePush(&parser, src.c_str());
 
     // Parse the translation unit.
-    if(cmDependsFortran_yyparse(parser.Scanner) != 0)
+    if(cmFortran_yyparse(parser.Scanner) != 0)
       {
       // Failed to parse the file.  Report failure to write dependencies.
       okay = false;
@@ -318,7 +245,7 @@ void cmDependsFortran::LocateModules()
   for(ObjectInfoMap::const_iterator infoI = objInfo.begin();
       infoI != objInfo.end(); ++infoI)
     {
-    cmDependsFortranSourceInfo const& info = infoI->second;
+    cmFortranSourceInfo const& info = infoI->second;
     // Include this module in the set provided by this target.
     this->Internal->TargetProvides.insert(info.Provides.begin(),
                                           info.Provides.end());
@@ -428,7 +355,7 @@ void cmDependsFortran::ConsiderModule(const char* name,
 bool
 cmDependsFortran
 ::WriteDependenciesReal(const char *obj,
-                        cmDependsFortranSourceInfo const& info,
+                        cmFortranSourceInfo const& info,
                         const char* mod_dir, const char* stamp_dir,
                         std::ostream& makeDepends,
                         std::ostream& internalDepends)
@@ -701,7 +628,7 @@ bool cmDependsFortran::CopyModule(const std::vector<std::string>& args)
 // is later used for longer sequences it should be re-written using an
 // efficient string search algorithm such as Boyer-Moore.
 static
-bool cmDependsFortranStreamContainsSequence(std::istream& ifs,
+bool cmFortranStreamContainsSequence(std::istream& ifs,
                                             const char* seq, int len)
 {
   assert(len > 0);
@@ -734,7 +661,7 @@ bool cmDependsFortranStreamContainsSequence(std::istream& ifs,
 
 //----------------------------------------------------------------------------
 // Helper function to compare the remaining content in two streams.
-static bool cmDependsFortranStreamsDiffer(std::istream& ifs1,
+static bool cmFortranStreamsDiffer(std::istream& ifs1,
                                           std::istream& ifs2)
 {
   // Compare the remaining content.
@@ -837,7 +764,7 @@ bool cmDependsFortran::ModulesDiffer(const char* modFile,
       const char seq[1] = {'\n'};
       const int seqlen = 1;
 
-      if(!cmDependsFortranStreamContainsSequence(finModFile, seq, seqlen))
+      if(!cmFortranStreamContainsSequence(finModFile, seq, seqlen))
         {
         // The module is of unexpected format.  Assume it is different.
         std::cerr << compilerId << " fortran module " << modFile
@@ -845,7 +772,7 @@ bool cmDependsFortran::ModulesDiffer(const char* modFile,
         return true;
         }
 
-      if(!cmDependsFortranStreamContainsSequence(finStampFile, seq, seqlen))
+      if(!cmFortranStreamContainsSequence(finStampFile, seq, seqlen))
         {
         // The stamp must differ if the sequence is not contained.
         return true;
@@ -857,7 +784,7 @@ bool cmDependsFortran::ModulesDiffer(const char* modFile,
     const char seq[2] = {'\n', '\0'};
     const int seqlen = 2;
 
-    if(!cmDependsFortranStreamContainsSequence(finModFile, seq, seqlen))
+    if(!cmFortranStreamContainsSequence(finModFile, seq, seqlen))
       {
       // The module is of unexpected format.  Assume it is different.
       std::cerr << compilerId << " fortran module " << modFile
@@ -865,7 +792,7 @@ bool cmDependsFortran::ModulesDiffer(const char* modFile,
       return true;
       }
 
-    if(!cmDependsFortranStreamContainsSequence(finStampFile, seq, seqlen))
+    if(!cmFortranStreamContainsSequence(finStampFile, seq, seqlen))
       {
       // The stamp must differ if the sequence is not contained.
       return true;
@@ -875,7 +802,7 @@ bool cmDependsFortran::ModulesDiffer(const char* modFile,
   // Compare the remaining content.  If no compiler id matched above,
   // including the case none was given, this will compare the whole
   // content.
-  if(!cmDependsFortranStreamsDiffer(finModFile, finStampFile))
+  if(!cmFortranStreamsDiffer(finModFile, finStampFile))
     {
     return false;
     }
@@ -883,396 +810,3 @@ bool cmDependsFortran::ModulesDiffer(const char* modFile,
    // The modules are different.
    return true;
 }
-
-//----------------------------------------------------------------------------
-bool cmDependsFortran::FindIncludeFile(const char* dir,
-                                       const char* includeName,
-                                       std::string& fileName)
-{
-  // If the file is a full path, include it directly.
-  if(cmSystemTools::FileIsFullPath(includeName))
-    {
-    fileName = includeName;
-    return cmSystemTools::FileExists(fileName.c_str(), true);
-    }
-  else
-    {
-    // Check for the file in the directory containing the including
-    // file.
-    std::string fullName = dir;
-    fullName += "/";
-    fullName += includeName;
-    if(cmSystemTools::FileExists(fullName.c_str(), true))
-      {
-      fileName = fullName;
-      return true;
-      }
-
-    // Search the include path for the file.
-    for(std::vector<std::string>::const_iterator i =
-          this->IncludePath.begin(); i != this->IncludePath.end(); ++i)
-      {
-      fullName = *i;
-      fullName += "/";
-      fullName += includeName;
-      if(cmSystemTools::FileExists(fullName.c_str(), true))
-        {
-        fileName = fullName;
-        return true;
-        }
-      }
-    }
-  return false;
-}
-
-//----------------------------------------------------------------------------
-cmDependsFortranParser_s
-::cmDependsFortranParser_s(cmDependsFortran* self,
-                           std::set<std::string>& ppDefines,
-                           cmDependsFortranSourceInfo& info):
-  Self(self), PPDefinitions(ppDefines), Info(info)
-{
-  this->InInterface = 0;
-  this->InPPFalseBranch = 0;
-
-  // Initialize the lexical scanner.
-  cmDependsFortran_yylex_init(&this->Scanner);
-  cmDependsFortran_yyset_extra(this, this->Scanner);
-
-  // Create a dummy buffer that is never read but is the fallback
-  // buffer when the last file is popped off the stack.
-  YY_BUFFER_STATE buffer =
-    cmDependsFortran_yy_create_buffer(0, 4, this->Scanner);
-  cmDependsFortran_yy_switch_to_buffer(buffer, this->Scanner);
-}
-
-//----------------------------------------------------------------------------
-cmDependsFortranParser_s::~cmDependsFortranParser_s()
-{
-  cmDependsFortran_yylex_destroy(this->Scanner);
-}
-
-//----------------------------------------------------------------------------
-bool cmDependsFortranParser_FilePush(cmDependsFortranParser* parser,
-                                    const char* fname)
-{
-  // Open the new file and push it onto the stack.  Save the old
-  // buffer with it on the stack.
-  if(FILE* file = cmsys::SystemTools::Fopen(fname, "rb"))
-    {
-    YY_BUFFER_STATE current =
-      cmDependsFortranLexer_GetCurrentBuffer(parser->Scanner);
-    std::string dir = cmSystemTools::GetParentDirectory(fname);
-    cmDependsFortranFile f(file, current, dir);
-    YY_BUFFER_STATE buffer =
-      cmDependsFortran_yy_create_buffer(0, 16384, parser->Scanner);
-    cmDependsFortran_yy_switch_to_buffer(buffer, parser->Scanner);
-    parser->FileStack.push(f);
-    return 1;
-    }
-  else
-    {
-    return 0;
-    }
-}
-
-//----------------------------------------------------------------------------
-bool cmDependsFortranParser_FilePop(cmDependsFortranParser* parser)
-{
-  // Pop one file off the stack and close it.  Switch the lexer back
-  // to the next one on the stack.
-  if(parser->FileStack.empty())
-    {
-    return 0;
-    }
-  else
-    {
-    cmDependsFortranFile f = parser->FileStack.top(); parser->FileStack.pop();
-    fclose(f.File);
-    YY_BUFFER_STATE current =
-      cmDependsFortranLexer_GetCurrentBuffer(parser->Scanner);
-    cmDependsFortran_yy_delete_buffer(current, parser->Scanner);
-    cmDependsFortran_yy_switch_to_buffer(f.Buffer, parser->Scanner);
-    return 1;
-    }
-}
-
-//----------------------------------------------------------------------------
-int cmDependsFortranParser_Input(cmDependsFortranParser* parser,
-                                 char* buffer, size_t bufferSize)
-{
-  // Read from the file on top of the stack.  If the stack is empty,
-  // the end of the translation unit has been reached.
-  if(!parser->FileStack.empty())
-    {
-    FILE* file = parser->FileStack.top().File;
-    return (int)fread(buffer, 1, bufferSize, file);
-    }
-  return 0;
-}
-
-//----------------------------------------------------------------------------
-void cmDependsFortranParser_StringStart(cmDependsFortranParser* parser)
-{
-  parser->TokenString = "";
-}
-
-//----------------------------------------------------------------------------
-const char* cmDependsFortranParser_StringEnd(cmDependsFortranParser* parser)
-{
-  return parser->TokenString.c_str();
-}
-
-//----------------------------------------------------------------------------
-void cmDependsFortranParser_StringAppend(cmDependsFortranParser* parser,
-                                         char c)
-{
-  parser->TokenString += c;
-}
-
-//----------------------------------------------------------------------------
-void cmDependsFortranParser_SetInInterface(cmDependsFortranParser* parser,
-                                           bool in)
-{
-  if(parser->InPPFalseBranch)
-    {
-    return;
-    }
-
-  parser->InInterface = in;
-}
-
-//----------------------------------------------------------------------------
-bool cmDependsFortranParser_GetInInterface(cmDependsFortranParser* parser)
-{
-  return parser->InInterface;
-}
-
-//----------------------------------------------------------------------------
-void cmDependsFortranParser_SetOldStartcond(cmDependsFortranParser* parser,
-                                            int arg)
-{
-  parser->OldStartcond = arg;
-}
-
-//----------------------------------------------------------------------------
-int cmDependsFortranParser_GetOldStartcond(cmDependsFortranParser* parser)
-{
-  return parser->OldStartcond;
-}
-
-//----------------------------------------------------------------------------
-void cmDependsFortranParser_Error(cmDependsFortranParser*, const char*)
-{
-  // If there is a parser error just ignore it.  The source will not
-  // compile and the user will edit it.  Then dependencies will have
-  // to be regenerated anyway.
-}
-
-//----------------------------------------------------------------------------
-void cmDependsFortranParser_RuleUse(cmDependsFortranParser* parser,
-                                    const char* name)
-{
-  if(!parser->InPPFalseBranch)
-    {
-    parser->Info.Requires.insert(cmSystemTools::LowerCase(name) );
-    }
-}
-
-//----------------------------------------------------------------------------
-void cmDependsFortranParser_RuleInclude(cmDependsFortranParser* parser,
-                                        const char* name)
-{
-  if(parser->InPPFalseBranch)
-    {
-    return;
-    }
-
-  // If processing an include statement there must be an open file.
-  assert(!parser->FileStack.empty());
-
-  // Get the directory containing the source in which the include
-  // statement appears.  This is always the first search location for
-  // Fortran include files.
-  std::string dir = parser->FileStack.top().Directory;
-
-  // Find the included file.  If it cannot be found just ignore the
-  // problem because either the source will not compile or the user
-  // does not care about depending on this included source.
-  std::string fullName;
-  if(parser->Self->FindIncludeFile(dir.c_str(), name, fullName))
-    {
-    // Found the included file.  Save it in the set of included files.
-    parser->Info.Includes.insert(fullName);
-
-    // Parse it immediately to translate the source inline.
-    cmDependsFortranParser_FilePush(parser, fullName.c_str());
-    }
-}
-
-//----------------------------------------------------------------------------
-void cmDependsFortranParser_RuleModule(cmDependsFortranParser* parser,
-                                       const char* name)
-{
-  if(!parser->InPPFalseBranch && !parser->InInterface)
-    {
-    parser->Info.Provides.insert(cmSystemTools::LowerCase(name));
-    }
-}
-
-//----------------------------------------------------------------------------
-void cmDependsFortranParser_RuleDefine(cmDependsFortranParser* parser,
-                                       const char* macro)
-{
-  if(!parser->InPPFalseBranch)
-    {
-    parser->PPDefinitions.insert(macro);
-    }
-}
-
-//----------------------------------------------------------------------------
-void cmDependsFortranParser_RuleUndef(cmDependsFortranParser* parser,
-                                      const char* macro)
-{
-  if(!parser->InPPFalseBranch)
-    {
-    std::set<std::string>::iterator match;
-    match = parser->PPDefinitions.find(macro);
-    if(match != parser->PPDefinitions.end())
-      {
-      parser->PPDefinitions.erase(match);
-      }
-    }
-}
-
-//----------------------------------------------------------------------------
-void cmDependsFortranParser_RuleIfdef(cmDependsFortranParser* parser,
-                                      const char* macro)
-{
-  // A new PP branch has been opened
-  parser->SkipToEnd.push(false);
-
-  if (parser->InPPFalseBranch)
-    {
-    parser->InPPFalseBranch++;
-    }
-  else if(parser->PPDefinitions.find(macro) == parser->PPDefinitions.end())
-    {
-    parser->InPPFalseBranch=1;
-    }
-  else
-    {
-    parser->SkipToEnd.top() = true;
-    }
-}
-
-//----------------------------------------------------------------------------
-void cmDependsFortranParser_RuleIfndef(cmDependsFortranParser* parser,
-  const char* macro)
-{
-  // A new PP branch has been opened
-  parser->SkipToEnd.push(false);
-
-  if (parser->InPPFalseBranch)
-    {
-    parser->InPPFalseBranch++;
-    }
-  else if(parser->PPDefinitions.find(macro) != parser->PPDefinitions.end())
-    {
-    parser->InPPFalseBranch = 1;
-    }
-  else
-    {
-    // ignore other branches
-    parser->SkipToEnd.top() = true;
-    }
-}
-
-//----------------------------------------------------------------------------
-void cmDependsFortranParser_RuleIf(cmDependsFortranParser* parser)
-{
-  /* Note: The current parser is _not_ able to get statements like
-   *   #if 0
-   *   #if 1
-   *   #if MYSMBOL
-   *   #if defined(MYSYMBOL)
-   *   #if defined(MYSYMBOL) && ...
-   * right.  The same for #elif.  Thus in
-   *   #if SYMBOL_1
-   *     ..
-   *   #elif SYMBOL_2
-   *     ...
-   *     ...
-   *   #elif SYMBOL_N
-   *     ..
-   *   #else
-   *     ..
-   *   #endif
-   * _all_ N+1 branches are considered.  If you got something like this
-   *   #if defined(MYSYMBOL)
-   *   #if !defined(MYSYMBOL)
-   * use
-   *   #ifdef MYSYMBOL
-   *   #ifndef MYSYMBOL
-   * instead.
-   */
-
-  // A new PP branch has been opened
-  // Never skip!  See note above.
-  parser->SkipToEnd.push(false);
-}
-
-//----------------------------------------------------------------------------
-void cmDependsFortranParser_RuleElif(cmDependsFortranParser* parser)
-{
-  /* Note: There are parser limitations.  See the note at
-   * cmDependsFortranParser_RuleIf(..)
-   */
-
-  // Always taken unless an #ifdef or #ifndef-branch has been taken
-  // already.  If the second condition isn't meet already
-  // (parser->InPPFalseBranch == 0) correct it.
-  if(!parser->SkipToEnd.empty() &&
-     parser->SkipToEnd.top() && !parser->InPPFalseBranch)
-    {
-    parser->InPPFalseBranch = 1;
-    }
-}
-
-//----------------------------------------------------------------------------
-void cmDependsFortranParser_RuleElse(cmDependsFortranParser* parser)
-{
-  // if the parent branch is false do nothing!
-  if(parser->InPPFalseBranch > 1)
-    {
-    return;
-    }
-
-  // parser->InPPFalseBranch is either 0 or 1.  We change it depending on
-  // parser->SkipToEnd.top()
-  if(!parser->SkipToEnd.empty() &&
-     parser->SkipToEnd.top())
-    {
-    parser->InPPFalseBranch = 1;
-    }
-  else
-    {
-    parser->InPPFalseBranch = 0;
-    }
-}
-
-//----------------------------------------------------------------------------
-void cmDependsFortranParser_RuleEndif(cmDependsFortranParser* parser)
-{
-  if(!parser->SkipToEnd.empty())
-    {
-    parser->SkipToEnd.pop();
-    }
-
-  // #endif doesn't know if there was a "#else" in before, so it
-  // always decreases InPPFalseBranch
-  if(parser->InPPFalseBranch)
-    {
-    parser->InPPFalseBranch--;
-    }
-}

+ 5 - 11
Source/cmDependsFortran.h

@@ -9,13 +9,13 @@
   implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
   See the License for more information.
 ============================================================================*/
-#ifndef cmDependsFortran_h
-#define cmDependsFortran_h
+#ifndef cmFortran_h
+#define cmFortran_h
 
 #include "cmDepends.h"
 
 class cmDependsFortranInternals;
-class cmDependsFortranSourceInfo;
+class cmFortranSourceInfo;
 
 /** \class cmDependsFortran
  * \brief Dependency scanner for Fortran object files.
@@ -46,12 +46,6 @@ public:
   static bool  ModulesDiffer(const char* modFile, const char* stampFile,
                              const char* compilerId);
 
-  /** Method to find an included file in the include path.  Fortran
-      always searches the directory containing the including source
-      first.  */
-  bool FindIncludeFile(const char* dir, const char* includeName,
-                       std::string& fileName);
-
 protected:
   // Finalize the dependency information for the target.
   virtual bool Finalize(std::ostream& makeDepends,
@@ -71,7 +65,7 @@ protected:
 
   // Actually write the depenencies to the streams.
   bool WriteDependenciesReal(const char *obj,
-                             cmDependsFortranSourceInfo const& info,
+                             cmFortranSourceInfo const& info,
                              const char* mod_dir, const char* stamp_dir,
                              std::ostream& makeDepends,
                              std::ostream& internalDepends);
@@ -79,7 +73,7 @@ protected:
   // The source file from which to start scanning.
   std::string SourceFile;
 
-  std::vector<std::string> PPDefinitions;
+  std::set<std::string> PPDefinitions;
 
   // Internal implementation details.
   cmDependsFortranInternals* Internal;

+ 0 - 96
Source/cmDependsFortranParser.h

@@ -1,96 +0,0 @@
-/*============================================================================
-  CMake - Cross Platform Makefile Generator
-  Copyright 2000-2009 Kitware, Inc., Insight Software Consortium
-
-  Distributed under the OSI-approved BSD License (the "License");
-  see accompanying file Copyright.txt for details.
-
-  This software is distributed WITHOUT ANY WARRANTY; without even the
-  implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
-  See the License for more information.
-============================================================================*/
-#ifndef cmDependsFortranParser_h
-#define cmDependsFortranParser_h
-
-#include <stddef.h> /* size_t */
-
-/* Forward declare parser object type.  */
-typedef struct cmDependsFortranParser_s cmDependsFortranParser;
-
-/* Functions to enter/exit #include'd files in order.  */
-bool cmDependsFortranParser_FilePush(cmDependsFortranParser* parser,
-                                    const char* fname);
-bool cmDependsFortranParser_FilePop(cmDependsFortranParser* parser);
-
-/* Callbacks for lexer.  */
-int cmDependsFortranParser_Input(cmDependsFortranParser* parser,
-                                 char* buffer, size_t bufferSize);
-
-
-void cmDependsFortranParser_StringStart(cmDependsFortranParser* parser);
-const char* cmDependsFortranParser_StringEnd(cmDependsFortranParser* parser);
-void cmDependsFortranParser_StringAppend(cmDependsFortranParser* parser,
-                                         char c);
-
-void cmDependsFortranParser_SetInInterface(cmDependsFortranParser* parser,
-                                           bool is_in);
-bool cmDependsFortranParser_GetInInterface(cmDependsFortranParser* parser);
-
-
-void cmDependsFortranParser_SetInPPFalseBranch(cmDependsFortranParser* parser,
-                                               bool is_in);
-bool cmDependsFortranParser_GetInPPFalseBranch(cmDependsFortranParser* parser);
-
-
-void cmDependsFortranParser_SetOldStartcond(cmDependsFortranParser* parser,
-                                            int arg);
-int cmDependsFortranParser_GetOldStartcond(cmDependsFortranParser* parser);
-
-/* Callbacks for parser.  */
-void cmDependsFortranParser_Error(cmDependsFortranParser* parser,
-                                  const char* message);
-void cmDependsFortranParser_RuleUse(cmDependsFortranParser* parser,
-                                    const char* name);
-void cmDependsFortranParser_RuleInclude(cmDependsFortranParser* parser,
-                                        const char* name);
-void cmDependsFortranParser_RuleModule(cmDependsFortranParser* parser,
-                                       const char* name);
-void cmDependsFortranParser_RuleDefine(cmDependsFortranParser* parser,
-                                       const char* name);
-void cmDependsFortranParser_RuleUndef(cmDependsFortranParser* parser,
-                                      const char* name);
-void cmDependsFortranParser_RuleIfdef(cmDependsFortranParser* parser,
-                                      const char* name);
-void cmDependsFortranParser_RuleIfndef(cmDependsFortranParser* parser,
-                                       const char* name);
-void cmDependsFortranParser_RuleIf(cmDependsFortranParser* parser);
-void cmDependsFortranParser_RuleElif(cmDependsFortranParser* parser);
-void cmDependsFortranParser_RuleElse(cmDependsFortranParser* parser);
-void cmDependsFortranParser_RuleEndif(cmDependsFortranParser* parser);
-
-/* Define the parser stack element type.  */
-typedef union cmDependsFortran_yystype_u cmDependsFortran_yystype;
-union cmDependsFortran_yystype_u
-{
-  char* string;
-};
-
-/* Setup the proper yylex interface.  */
-#define YY_EXTRA_TYPE cmDependsFortranParser*
-#define YY_DECL \
-int cmDependsFortran_yylex(YYSTYPE* yylvalp, yyscan_t yyscanner)
-#define YYSTYPE cmDependsFortran_yystype
-#define YYSTYPE_IS_DECLARED 1
-#if !defined(cmDependsFortranLexer_cxx)
-# include "cmDependsFortranLexer.h"
-#endif
-#if !defined(cmDependsFortranLexer_cxx)
-#if !defined(cmDependsFortranParser_cxx)
-# undef YY_EXTRA_TYPE
-# undef YY_DECL
-# undef YYSTYPE
-# undef YYSTYPE_IS_DECLARED
-#endif
-#endif
-
-#endif

File diff suppressed because it is too large
+ 185 - 185
Source/cmFortranLexer.cxx


+ 38 - 38
Source/cmDependsFortranLexer.h → Source/cmFortranLexer.h

@@ -9,9 +9,9 @@
   implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
   See the License for more information.
 ============================================================================*/
-#ifndef cmDependsFortran_yyHEADER_H
-#define cmDependsFortran_yyHEADER_H 1
-#define cmDependsFortran_yyIN_HEADER 1
+#ifndef cmFortran_yyHEADER_H
+#define cmFortran_yyHEADER_H 1
+#define cmFortran_yyIN_HEADER 1
 
 #define  YY_INT_ALIGNED short int
 
@@ -211,25 +211,25 @@ struct yy_buffer_state
         };
 #endif /* !YY_STRUCT_YY_BUFFER_STATE */
 
-void cmDependsFortran_yyrestart (FILE *input_file ,yyscan_t yyscanner );
-void cmDependsFortran_yy_switch_to_buffer (YY_BUFFER_STATE new_buffer ,yyscan_t yyscanner );
-YY_BUFFER_STATE cmDependsFortran_yy_create_buffer (FILE *file,int size ,yyscan_t yyscanner );
-void cmDependsFortran_yy_delete_buffer (YY_BUFFER_STATE b ,yyscan_t yyscanner );
-void cmDependsFortran_yy_flush_buffer (YY_BUFFER_STATE b ,yyscan_t yyscanner );
-void cmDependsFortran_yypush_buffer_state (YY_BUFFER_STATE new_buffer ,yyscan_t yyscanner );
-void cmDependsFortran_yypop_buffer_state (yyscan_t yyscanner );
+void cmFortran_yyrestart (FILE *input_file ,yyscan_t yyscanner );
+void cmFortran_yy_switch_to_buffer (YY_BUFFER_STATE new_buffer ,yyscan_t yyscanner );
+YY_BUFFER_STATE cmFortran_yy_create_buffer (FILE *file,int size ,yyscan_t yyscanner );
+void cmFortran_yy_delete_buffer (YY_BUFFER_STATE b ,yyscan_t yyscanner );
+void cmFortran_yy_flush_buffer (YY_BUFFER_STATE b ,yyscan_t yyscanner );
+void cmFortran_yypush_buffer_state (YY_BUFFER_STATE new_buffer ,yyscan_t yyscanner );
+void cmFortran_yypop_buffer_state (yyscan_t yyscanner );
 
-YY_BUFFER_STATE cmDependsFortran_yy_scan_buffer (char *base,yy_size_t size ,yyscan_t yyscanner );
-YY_BUFFER_STATE cmDependsFortran_yy_scan_string (yyconst char *yy_str ,yyscan_t yyscanner );
-YY_BUFFER_STATE cmDependsFortran_yy_scan_bytes (yyconst char *bytes,int len ,yyscan_t yyscanner );
+YY_BUFFER_STATE cmFortran_yy_scan_buffer (char *base,yy_size_t size ,yyscan_t yyscanner );
+YY_BUFFER_STATE cmFortran_yy_scan_string (yyconst char *yy_str ,yyscan_t yyscanner );
+YY_BUFFER_STATE cmFortran_yy_scan_bytes (yyconst char *bytes,int len ,yyscan_t yyscanner );
 
-void *cmDependsFortran_yyalloc (yy_size_t ,yyscan_t yyscanner );
-void *cmDependsFortran_yyrealloc (void *,yy_size_t ,yyscan_t yyscanner );
-void cmDependsFortran_yyfree (void * ,yyscan_t yyscanner );
+void *cmFortran_yyalloc (yy_size_t ,yyscan_t yyscanner );
+void *cmFortran_yyrealloc (void *,yy_size_t ,yyscan_t yyscanner );
+void cmFortran_yyfree (void * ,yyscan_t yyscanner );
 
 /* Begin user sect3 */
 
-#define cmDependsFortran_yywrap(n) 1
+#define cmFortran_yywrap(n) 1
 #define YY_SKIP_YYWRAP
 
 #define yytext_ptr yytext_r
@@ -247,38 +247,38 @@ void cmDependsFortran_yyfree (void * ,yyscan_t yyscanner );
 #define YY_EXTRA_TYPE void *
 #endif
 
-int cmDependsFortran_yylex_init (yyscan_t* scanner);
+int cmFortran_yylex_init (yyscan_t* scanner);
 
-int cmDependsFortran_yylex_init_extra (YY_EXTRA_TYPE user_defined,yyscan_t* scanner);
+int cmFortran_yylex_init_extra (YY_EXTRA_TYPE user_defined,yyscan_t* scanner);
 
 /* Accessor methods to globals.
    These are made visible to non-reentrant scanners for convenience. */
 
-int cmDependsFortran_yylex_destroy (yyscan_t yyscanner );
+int cmFortran_yylex_destroy (yyscan_t yyscanner );
 
-int cmDependsFortran_yyget_debug (yyscan_t yyscanner );
+int cmFortran_yyget_debug (yyscan_t yyscanner );
 
-void cmDependsFortran_yyset_debug (int debug_flag ,yyscan_t yyscanner );
+void cmFortran_yyset_debug (int debug_flag ,yyscan_t yyscanner );
 
-YY_EXTRA_TYPE cmDependsFortran_yyget_extra (yyscan_t yyscanner );
+YY_EXTRA_TYPE cmFortran_yyget_extra (yyscan_t yyscanner );
 
-void cmDependsFortran_yyset_extra (YY_EXTRA_TYPE user_defined ,yyscan_t yyscanner );
+void cmFortran_yyset_extra (YY_EXTRA_TYPE user_defined ,yyscan_t yyscanner );
 
-FILE *cmDependsFortran_yyget_in (yyscan_t yyscanner );
+FILE *cmFortran_yyget_in (yyscan_t yyscanner );
 
-void cmDependsFortran_yyset_in  (FILE * in_str ,yyscan_t yyscanner );
+void cmFortran_yyset_in  (FILE * in_str ,yyscan_t yyscanner );
 
-FILE *cmDependsFortran_yyget_out (yyscan_t yyscanner );
+FILE *cmFortran_yyget_out (yyscan_t yyscanner );
 
-void cmDependsFortran_yyset_out  (FILE * out_str ,yyscan_t yyscanner );
+void cmFortran_yyset_out  (FILE * out_str ,yyscan_t yyscanner );
 
-int cmDependsFortran_yyget_leng (yyscan_t yyscanner );
+int cmFortran_yyget_leng (yyscan_t yyscanner );
 
-char *cmDependsFortran_yyget_text (yyscan_t yyscanner );
+char *cmFortran_yyget_text (yyscan_t yyscanner );
 
-int cmDependsFortran_yyget_lineno (yyscan_t yyscanner );
+int cmFortran_yyget_lineno (yyscan_t yyscanner );
 
-void cmDependsFortran_yyset_lineno (int line_number ,yyscan_t yyscanner );
+void cmFortran_yyset_lineno (int line_number ,yyscan_t yyscanner );
 
 /* Macros after this point can all be overridden by user definitions in
  * section 1.
@@ -286,9 +286,9 @@ void cmDependsFortran_yyset_lineno (int line_number ,yyscan_t yyscanner );
 
 #ifndef YY_SKIP_YYWRAP
 #ifdef __cplusplus
-extern "C" int cmDependsFortran_yywrap (yyscan_t yyscanner );
+extern "C" int cmFortran_yywrap (yyscan_t yyscanner );
 #else
-extern int cmDependsFortran_yywrap (yyscan_t yyscanner );
+extern int cmFortran_yywrap (yyscan_t yyscanner );
 #endif
 #endif
 
@@ -325,9 +325,9 @@ static int yy_flex_strlen (yyconst char * ,yyscan_t yyscanner);
 #ifndef YY_DECL
 #define YY_DECL_IS_OURS 1
 
-extern int cmDependsFortran_yylex (yyscan_t yyscanner);
+extern int cmFortran_yylex (yyscan_t yyscanner);
 
-#define YY_DECL int cmDependsFortran_yylex (yyscan_t yyscanner)
+#define YY_DECL int cmFortran_yylex (yyscan_t yyscanner)
 #endif /* !YY_DECL */
 
 /* yy_get_previous_state - get the state just before the EOB char was reached */
@@ -344,5 +344,5 @@ extern int cmDependsFortran_yylex (yyscan_t yyscanner);
 #undef YY_DECL
 #endif
 
-#undef cmDependsFortran_yyIN_HEADER
-#endif /* cmDependsFortran_yyHEADER_H */
+#undef cmFortran_yyIN_HEADER
+#endif /* cmFortran_yyHEADER_H */

+ 19 - 19
Source/cmDependsFortranLexer.in.l → Source/cmFortranLexer.in.l

@@ -26,18 +26,18 @@ This file must be translated to C and modified to build everywhere.
 
 Run flex like this:
 
-  flex -i --prefix=cmDependsFortran_yy --header-file=cmDependsFortranLexer.h -ocmDependsFortranLexer.cxx cmDependsFortranLexer.in.l
+  flex -i --prefix=cmFortran_yy --header-file=cmFortranLexer.h -ocmFortranLexer.cxx cmFortranLexer.in.l
 
-Modify cmDependsFortranLexer.cxx:
+Modify cmFortranLexer.cxx:
   - remove TABs
   - remove use of the 'register' storage class specifier
   - remove "yyscanner" argument from these methods:
-      yy_fatal_error, cmDependsFortran_yyalloc, cmDependsFortran_yyrealloc, cmDependsFortran_yyfree
-  - remove "yyscanner = NULL" from end of cmDependsFortran_yylex_destroy
+      yy_fatal_error, cmFortran_yyalloc, cmFortran_yyrealloc, cmFortran_yyfree
+  - remove "yyscanner = NULL" from end of cmFortran_yylex_destroy
   - remove all YY_BREAK lines occurring right after return statements
   - change while ( 1 ) to for(;;)
 
-Modify cmDependsFortranLexer.h:
+Modify cmFortranLexer.h:
   - remove TABs
   - remove the yy_init_globals function
   - remove the block that includes unistd.h
@@ -47,16 +47,16 @@ Modify cmDependsFortranLexer.h:
 
 #include "cmStandardLexer.h"
 
-#define cmDependsFortranLexer_cxx
-#include "cmDependsFortranParser.h" /* Interface to parser object.  */
+#define cmFortranLexer_cxx
+#include "cmFortranParser.h" /* Interface to parser object.  */
 
 /* Replace the lexer input function.  */
 #undef YY_INPUT
 #define YY_INPUT(buf, result, max_size) \
-  { result = cmDependsFortranParser_Input(yyextra, buf, max_size); }
+  { result = cmFortranParser_Input(yyextra, buf, max_size); }
 
 /* Include the set of tokens from the parser.  */
-#include "cmDependsFortranParserTokens.h"
+#include "cmFortranParserTokens.h"
 
 /*--------------------------------------------------------------------------*/
 %}
@@ -72,21 +72,21 @@ Modify cmDependsFortranLexer.h:
 %%
 
 \"              {
-  cmDependsFortranParser_StringStart(yyextra);
-  cmDependsFortranParser_SetOldStartcond(yyextra, YY_START);
+  cmFortranParser_StringStart(yyextra);
+  cmFortranParser_SetOldStartcond(yyextra, YY_START);
   BEGIN(str_dq);
 }
 
 '               {
-  cmDependsFortranParser_StringStart(yyextra);
-  cmDependsFortranParser_SetOldStartcond(yyextra, YY_START);
+  cmFortranParser_StringStart(yyextra);
+  cmFortranParser_SetOldStartcond(yyextra, YY_START);
   BEGIN(str_sq);
 }
 
 <str_dq>\" |
 <str_sq>'  {
-  BEGIN(cmDependsFortranParser_GetOldStartcond(yyextra) );
-  yylvalp->string = strdup(cmDependsFortranParser_StringEnd(yyextra));
+  BEGIN(cmFortranParser_GetOldStartcond(yyextra) );
+  yylvalp->string = strdup(cmFortranParser_StringEnd(yyextra));
   return STRING;
 }
 
@@ -94,7 +94,7 @@ Modify cmDependsFortranLexer.h:
 <str_dq,str_sq>&[ \t]*\n[ \t]*&  /* Ignore (continued strings, free fmt) */
 
 <fixed_fmt,str_dq,str_sq>\n[ ]{5}[^ \t\n] {
-  if (cmDependsFortranParser_GetOldStartcond(yyextra) == fixed_fmt)
+  if (cmFortranParser_GetOldStartcond(yyextra) == fixed_fmt)
     ; /* Ignore (cont. strings, fixed fmt) */
   else
     {
@@ -110,7 +110,7 @@ Modify cmDependsFortranLexer.h:
 }
 
 <str_sq,str_dq>. {
-  cmDependsFortranParser_StringAppend(yyextra, yytext[0]);
+  cmFortranParser_StringAppend(yyextra, yytext[0]);
 }
 
 !.*\n                   { return EOSTMT; } /* Treat comments like */
@@ -173,7 +173,7 @@ $[ \t]*endif    { return F90PPR_ENDIF; }
 . { return *yytext; }
 
 <<EOF>> {
-  if(!cmDependsFortranParser_FilePop(yyextra) )
+  if(!cmFortranParser_FilePop(yyextra) )
     {
     return YY_NULL;
     }
@@ -182,7 +182,7 @@ $[ \t]*endif    { return F90PPR_ENDIF; }
 %%
 
 /*--------------------------------------------------------------------------*/
-YY_BUFFER_STATE cmDependsFortranLexer_GetCurrentBuffer(yyscan_t yyscanner)
+YY_BUFFER_STATE cmFortranLexer_GetCurrentBuffer(yyscan_t yyscanner)
 {
   /* Hack into the internal flex-generated scanner to get the buffer.  */
   struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;

File diff suppressed because it is too large
+ 260 - 379
Source/cmFortranParser.cxx


+ 175 - 0
Source/cmFortranParser.h

@@ -0,0 +1,175 @@
+/*============================================================================
+  CMake - Cross Platform Makefile Generator
+  Copyright 2000-2009 Kitware, Inc., Insight Software Consortium
+
+  Distributed under the OSI-approved BSD License (the "License");
+  see accompanying file Copyright.txt for details.
+
+  This software is distributed WITHOUT ANY WARRANTY; without even the
+  implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+  See the License for more information.
+============================================================================*/
+#ifndef cmFortranParser_h
+#define cmFortranParser_h
+
+#if !defined(cmFortranLexer_cxx) && !defined(cmFortranParser_cxx)
+# include "cmStandardIncludes.h"
+#endif
+
+#include <stddef.h> /* size_t */
+
+/* Forward declare parser object type.  */
+typedef struct cmFortranParser_s cmFortranParser;
+
+/* Functions to enter/exit #include'd files in order.  */
+bool cmFortranParser_FilePush(cmFortranParser* parser,
+                                    const char* fname);
+bool cmFortranParser_FilePop(cmFortranParser* parser);
+
+/* Callbacks for lexer.  */
+int cmFortranParser_Input(cmFortranParser* parser,
+                                 char* buffer, size_t bufferSize);
+
+
+void cmFortranParser_StringStart(cmFortranParser* parser);
+const char* cmFortranParser_StringEnd(cmFortranParser* parser);
+void cmFortranParser_StringAppend(cmFortranParser* parser,
+                                         char c);
+
+void cmFortranParser_SetInInterface(cmFortranParser* parser,
+                                           bool is_in);
+bool cmFortranParser_GetInInterface(cmFortranParser* parser);
+
+
+void cmFortranParser_SetInPPFalseBranch(cmFortranParser* parser,
+                                               bool is_in);
+bool cmFortranParser_GetInPPFalseBranch(cmFortranParser* parser);
+
+
+void cmFortranParser_SetOldStartcond(cmFortranParser* parser,
+                                            int arg);
+int cmFortranParser_GetOldStartcond(cmFortranParser* parser);
+
+/* Callbacks for parser.  */
+void cmFortranParser_Error(cmFortranParser* parser,
+                                  const char* message);
+void cmFortranParser_RuleUse(cmFortranParser* parser,
+                                    const char* name);
+void cmFortranParser_RuleInclude(cmFortranParser* parser,
+                                        const char* name);
+void cmFortranParser_RuleModule(cmFortranParser* parser,
+                                       const char* name);
+void cmFortranParser_RuleDefine(cmFortranParser* parser,
+                                       const char* name);
+void cmFortranParser_RuleUndef(cmFortranParser* parser,
+                                      const char* name);
+void cmFortranParser_RuleIfdef(cmFortranParser* parser,
+                                      const char* name);
+void cmFortranParser_RuleIfndef(cmFortranParser* parser,
+                                       const char* name);
+void cmFortranParser_RuleIf(cmFortranParser* parser);
+void cmFortranParser_RuleElif(cmFortranParser* parser);
+void cmFortranParser_RuleElse(cmFortranParser* parser);
+void cmFortranParser_RuleEndif(cmFortranParser* parser);
+
+/* Define the parser stack element type.  */
+typedef union cmFortran_yystype_u cmFortran_yystype;
+union cmFortran_yystype_u
+{
+  char* string;
+};
+
+/* Setup the proper yylex interface.  */
+#define YY_EXTRA_TYPE cmFortranParser*
+#define YY_DECL \
+int cmFortran_yylex(YYSTYPE* yylvalp, yyscan_t yyscanner)
+#define YYSTYPE cmFortran_yystype
+#define YYSTYPE_IS_DECLARED 1
+#if !defined(cmFortranLexer_cxx)
+# include "cmFortranLexer.h"
+#endif
+#if !defined(cmFortranLexer_cxx)
+#if !defined(cmFortranParser_cxx)
+# undef YY_EXTRA_TYPE
+# undef YY_DECL
+# undef YYSTYPE
+# undef YYSTYPE_IS_DECLARED
+#endif
+#endif
+
+#if !defined(cmFortranLexer_cxx) && !defined(cmFortranParser_cxx)
+#include <stack>
+
+//----------------------------------------------------------------------------
+// Information about a single source file.
+class cmFortranSourceInfo
+{
+public:
+  // The name of the source file.
+  std::string Source;
+
+  // Set of provided and required modules.
+  std::set<std::string> Provides;
+  std::set<std::string> Requires;
+
+  // Set of files included in the translation unit.
+  std::set<std::string> Includes;
+};
+
+//----------------------------------------------------------------------------
+// Parser methods not included in generated interface.
+
+// Get the current buffer processed by the lexer.
+YY_BUFFER_STATE cmFortranLexer_GetCurrentBuffer(yyscan_t yyscanner);
+
+// The parser entry point.
+int cmFortran_yyparse(yyscan_t);
+
+//----------------------------------------------------------------------------
+// Define parser object internal structure.
+struct cmFortranFile
+{
+  cmFortranFile(FILE* file, YY_BUFFER_STATE buffer,
+                       const std::string& dir):
+    File(file), Buffer(buffer), Directory(dir) {}
+  FILE* File;
+  YY_BUFFER_STATE Buffer;
+  std::string Directory;
+};
+
+struct cmFortranParser_s
+{
+  cmFortranParser_s(std::vector<std::string> const& includes,
+                    std::set<std::string> const& defines,
+                    cmFortranSourceInfo& info);
+  ~cmFortranParser_s();
+
+  bool FindIncludeFile(const char* dir, const char* includeName,
+                       std::string& fileName);
+
+  // The include file search path.
+  std::vector<std::string> IncludePath;
+
+  // Lexical scanner instance.
+  yyscan_t Scanner;
+
+  // Stack of open files in the translation unit.
+  std::stack<cmFortranFile> FileStack;
+
+  // Buffer for string literals.
+  std::string TokenString;
+
+  // Flag for whether lexer is reading from inside an interface.
+  bool InInterface;
+
+  int OldStartcond;
+  std::set<std::string> PPDefinitions;
+  size_t InPPFalseBranch;
+  std::stack<bool> SkipToEnd;
+
+  // Information about the parsed source.
+  cmFortranSourceInfo& Info;
+};
+#endif
+
+#endif

+ 77 - 80
Source/cmDependsFortranParser.y → Source/cmFortranParser.y

@@ -26,42 +26,33 @@ This file must be translated to C and modified to build everywhere.
 
 Run bison like this:
 
-  bison --yacc --name-prefix=cmDependsFortran_yy
-        --defines=cmDependsFortranParserTokens.h
-         -ocmDependsFortranParser.cxx
-          cmDependsFortranParser.y
+  bison --yacc --name-prefix=cmFortran_yy
+        --defines=cmFortranParserTokens.h
+         -ocmFortranParser.cxx
+          cmFortranParser.y
 
-Modify cmDependsFortranParser.cxx:
-  - remove TABs
-  - remove use of the 'register' storage class specifier
-  - Remove the yyerrorlab block in range ["goto yyerrlab1", "yyerrlab1:"]
+Modify cmFortranParser.cxx:
+  - "#if 0" out yyerrorlab block in range ["goto yyerrlab1", "yyerrlab1:"]
 */
 
 /*-------------------------------------------------------------------------*/
-#define cmDependsFortranParser_cxx
-#include "cmDependsFortranParser.h" /* Interface to parser object.  */
-#include "cmDependsFortranParserTokens.h" /* Need YYSTYPE for YY_DECL.  */
+#define cmFortranParser_cxx
+#include "cmFortranParser.h" /* Interface to parser object.  */
+#include "cmFortranParserTokens.h" /* Need YYSTYPE for YY_DECL.  */
 
 #include <cmsys/String.h>
 
-/* Configure the parser to use a lexer object.  */
-#define YYPARSE_PARAM yyscanner
-#define YYLEX_PARAM yyscanner
-#define YYERROR_VERBOSE 1
-#define cmDependsFortran_yyerror(x) \
-        cmDependsFortranError(yyscanner, x)
-
 /* Forward declare the lexer entry point.  */
 YY_DECL;
 
-/* Helper function to forward error callback.  */
-static void cmDependsFortranError(yyscan_t yyscanner, const char* message)
+/* Helper function to forward error callback from parser.  */
+static void cmFortran_yyerror(yyscan_t yyscanner, const char* message)
 {
-  cmDependsFortranParser* parser = cmDependsFortran_yyget_extra(yyscanner);
-  cmDependsFortranParser_Error(parser, message);
+  cmFortranParser* parser = cmFortran_yyget_extra(yyscanner);
+  cmFortranParser_Error(parser, message);
 }
 
-static bool cmDependsFortranParserIsKeyword(const char* word,
+static bool cmFortranParserIsKeyword(const char* word,
                                             const char* keyword)
 {
   return cmsysString_strcasecmp(word, keyword) == 0;
@@ -79,7 +70,13 @@ static bool cmDependsFortranParserIsKeyword(const char* word,
 %}
 
 /* Generate a reentrant parser object.  */
-%pure-parser
+%define api.pure
+
+/* Configure the parser to use a lexer object.  */
+%lex-param   {yyscan_t yyscanner}
+%parse-param {yyscan_t yyscanner}
+
+%define parse.error verbose
 
 %union {
   char* string;
@@ -115,63 +112,63 @@ assignment_stmt: WORD ASSIGNMENT_OP other EOSTMT    /* Ignore */
 keyword_stmt:
   WORD EOSTMT
     {
-    if (cmDependsFortranParserIsKeyword($1, "interface"))
+    if (cmFortranParserIsKeyword($1, "interface"))
       {
-      cmDependsFortranParser* parser =
-        cmDependsFortran_yyget_extra(yyscanner);
-      cmDependsFortranParser_SetInInterface(parser, true);
+      cmFortranParser* parser =
+        cmFortran_yyget_extra(yyscanner);
+      cmFortranParser_SetInInterface(parser, true);
       }
     free($1);
     }
 | WORD WORD other EOSTMT
     {
-    if (cmDependsFortranParserIsKeyword($1, "use"))
+    if (cmFortranParserIsKeyword($1, "use"))
       {
-      cmDependsFortranParser* parser =
-        cmDependsFortran_yyget_extra(yyscanner);
-      cmDependsFortranParser_RuleUse(parser, $2);
+      cmFortranParser* parser =
+        cmFortran_yyget_extra(yyscanner);
+      cmFortranParser_RuleUse(parser, $2);
       }
-    else if (cmDependsFortranParserIsKeyword($1, "module"))
+    else if (cmFortranParserIsKeyword($1, "module"))
       {
-      cmDependsFortranParser* parser =
-        cmDependsFortran_yyget_extra(yyscanner);
-      cmDependsFortranParser_RuleModule(parser, $2);
+      cmFortranParser* parser =
+        cmFortran_yyget_extra(yyscanner);
+      cmFortranParser_RuleModule(parser, $2);
       }
-    else if (cmDependsFortranParserIsKeyword($1, "interface"))
+    else if (cmFortranParserIsKeyword($1, "interface"))
       {
-      cmDependsFortranParser* parser =
-        cmDependsFortran_yyget_extra(yyscanner);
-      cmDependsFortranParser_SetInInterface(parser, true);
+      cmFortranParser* parser =
+        cmFortran_yyget_extra(yyscanner);
+      cmFortranParser_SetInInterface(parser, true);
       }
-    else if (cmDependsFortranParserIsKeyword($2, "interface") &&
-             cmDependsFortranParserIsKeyword($1, "end"))
+    else if (cmFortranParserIsKeyword($2, "interface") &&
+             cmFortranParserIsKeyword($1, "end"))
       {
-      cmDependsFortranParser* parser =
-        cmDependsFortran_yyget_extra(yyscanner);
-      cmDependsFortranParser_SetInInterface(parser, false);
+      cmFortranParser* parser =
+        cmFortran_yyget_extra(yyscanner);
+      cmFortranParser_SetInInterface(parser, false);
       }
     free($1);
     free($2);
     }
 | WORD DCOLON WORD other EOSTMT
     {
-    if (cmDependsFortranParserIsKeyword($1, "use"))
+    if (cmFortranParserIsKeyword($1, "use"))
       {
-      cmDependsFortranParser* parser =
-        cmDependsFortran_yyget_extra(yyscanner);
-      cmDependsFortranParser_RuleUse(parser, $3);
+      cmFortranParser* parser =
+        cmFortran_yyget_extra(yyscanner);
+      cmFortranParser_RuleUse(parser, $3);
       }
     free($1);
     free($3);
     }
 | WORD COMMA WORD DCOLON WORD other EOSTMT
     {
-    if (cmDependsFortranParserIsKeyword($1, "use") &&
-        cmDependsFortranParserIsKeyword($3, "non_intrinsic") )
+    if (cmFortranParserIsKeyword($1, "use") &&
+        cmFortranParserIsKeyword($3, "non_intrinsic") )
       {
-      cmDependsFortranParser* parser =
-        cmDependsFortran_yyget_extra(yyscanner);
-      cmDependsFortranParser_RuleUse(parser, $5);
+      cmFortranParser* parser =
+        cmFortran_yyget_extra(yyscanner);
+      cmFortranParser_RuleUse(parser, $5);
       }
     free($1);
     free($3);
@@ -179,72 +176,72 @@ keyword_stmt:
     }
 | WORD STRING other EOSTMT /* Ignore */
     {
-    if (cmDependsFortranParserIsKeyword($1, "include"))
+    if (cmFortranParserIsKeyword($1, "include"))
       {
-      cmDependsFortranParser* parser =
-        cmDependsFortran_yyget_extra(yyscanner);
-      cmDependsFortranParser_RuleInclude(parser, $2);
+      cmFortranParser* parser =
+        cmFortran_yyget_extra(yyscanner);
+      cmFortranParser_RuleInclude(parser, $2);
       }
     free($1);
     free($2);
     }
 | CPP_INCLUDE_ANGLE other EOSTMT
     {
-    cmDependsFortranParser* parser =
-      cmDependsFortran_yyget_extra(yyscanner);
-    cmDependsFortranParser_RuleInclude(parser, $1);
+    cmFortranParser* parser =
+      cmFortran_yyget_extra(yyscanner);
+    cmFortranParser_RuleInclude(parser, $1);
     free($1);
     }
 | include STRING other EOSTMT
     {
-    cmDependsFortranParser* parser =
-      cmDependsFortran_yyget_extra(yyscanner);
-    cmDependsFortranParser_RuleInclude(parser, $2);
+    cmFortranParser* parser =
+      cmFortran_yyget_extra(yyscanner);
+    cmFortranParser_RuleInclude(parser, $2);
     free($2);
     }
 | define WORD other EOSTMT
     {
-    cmDependsFortranParser* parser = cmDependsFortran_yyget_extra(yyscanner);
-    cmDependsFortranParser_RuleDefine(parser, $2);
+    cmFortranParser* parser = cmFortran_yyget_extra(yyscanner);
+    cmFortranParser_RuleDefine(parser, $2);
     free($2);
     }
 | undef WORD other EOSTMT
     {
-    cmDependsFortranParser* parser = cmDependsFortran_yyget_extra(yyscanner);
-    cmDependsFortranParser_RuleUndef(parser, $2);
+    cmFortranParser* parser = cmFortran_yyget_extra(yyscanner);
+    cmFortranParser_RuleUndef(parser, $2);
     free($2);
     }
 | ifdef WORD other EOSTMT
     {
-    cmDependsFortranParser* parser = cmDependsFortran_yyget_extra(yyscanner);
-    cmDependsFortranParser_RuleIfdef(parser, $2);
+    cmFortranParser* parser = cmFortran_yyget_extra(yyscanner);
+    cmFortranParser_RuleIfdef(parser, $2);
     free($2);
     }
 | ifndef WORD other EOSTMT
     {
-    cmDependsFortranParser* parser = cmDependsFortran_yyget_extra(yyscanner);
-    cmDependsFortranParser_RuleIfndef(parser, $2);
+    cmFortranParser* parser = cmFortran_yyget_extra(yyscanner);
+    cmFortranParser_RuleIfndef(parser, $2);
     free($2);
     }
 | if other EOSTMT
     {
-    cmDependsFortranParser* parser = cmDependsFortran_yyget_extra(yyscanner);
-    cmDependsFortranParser_RuleIf(parser);
+    cmFortranParser* parser = cmFortran_yyget_extra(yyscanner);
+    cmFortranParser_RuleIf(parser);
     }
 | elif other EOSTMT
     {
-    cmDependsFortranParser* parser = cmDependsFortran_yyget_extra(yyscanner);
-    cmDependsFortranParser_RuleElif(parser);
+    cmFortranParser* parser = cmFortran_yyget_extra(yyscanner);
+    cmFortranParser_RuleElif(parser);
     }
 | else other EOSTMT
     {
-    cmDependsFortranParser* parser = cmDependsFortran_yyget_extra(yyscanner);
-    cmDependsFortranParser_RuleElse(parser);
+    cmFortranParser* parser = cmFortran_yyget_extra(yyscanner);
+    cmFortranParser_RuleElse(parser);
     }
 | endif other EOSTMT
     {
-    cmDependsFortranParser* parser = cmDependsFortran_yyget_extra(yyscanner);
-    cmDependsFortranParser_RuleEndif(parser);
+    cmFortranParser* parser = cmFortran_yyget_extra(yyscanner);
+    cmFortranParser_RuleEndif(parser);
     }
 | WORD GARBAGE other EOSTMT             /* Ignore */
     {

+ 408 - 0
Source/cmFortranParserImpl.cxx

@@ -0,0 +1,408 @@
+/*============================================================================
+  CMake - Cross Platform Makefile Generator
+  Copyright 2000-2015 Kitware, Inc., Insight Software Consortium
+
+  Distributed under the OSI-approved BSD License (the "License");
+  see accompanying file Copyright.txt for details.
+
+  This software is distributed WITHOUT ANY WARRANTY; without even the
+  implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+  See the License for more information.
+============================================================================*/
+#include "cmFortranParser.h"
+
+#include "cmSystemTools.h"
+#include <assert.h>
+
+//----------------------------------------------------------------------------
+bool cmFortranParser_s::FindIncludeFile(const char* dir,
+                                        const char* includeName,
+                                        std::string& fileName)
+{
+  // If the file is a full path, include it directly.
+  if(cmSystemTools::FileIsFullPath(includeName))
+    {
+    fileName = includeName;
+    return cmSystemTools::FileExists(fileName.c_str(), true);
+    }
+  else
+    {
+    // Check for the file in the directory containing the including
+    // file.
+    std::string fullName = dir;
+    fullName += "/";
+    fullName += includeName;
+    if(cmSystemTools::FileExists(fullName.c_str(), true))
+      {
+      fileName = fullName;
+      return true;
+      }
+
+    // Search the include path for the file.
+    for(std::vector<std::string>::const_iterator i =
+          this->IncludePath.begin(); i != this->IncludePath.end(); ++i)
+      {
+      fullName = *i;
+      fullName += "/";
+      fullName += includeName;
+      if(cmSystemTools::FileExists(fullName.c_str(), true))
+        {
+        fileName = fullName;
+        return true;
+        }
+      }
+    }
+  return false;
+}
+
+//----------------------------------------------------------------------------
+cmFortranParser_s
+::cmFortranParser_s(std::vector<std::string> const& includes,
+                    std::set<std::string> const& defines,
+                    cmFortranSourceInfo& info):
+  IncludePath(includes), PPDefinitions(defines), Info(info)
+{
+  this->InInterface = 0;
+  this->InPPFalseBranch = 0;
+
+  // Initialize the lexical scanner.
+  cmFortran_yylex_init(&this->Scanner);
+  cmFortran_yyset_extra(this, this->Scanner);
+
+  // Create a dummy buffer that is never read but is the fallback
+  // buffer when the last file is popped off the stack.
+  YY_BUFFER_STATE buffer =
+    cmFortran_yy_create_buffer(0, 4, this->Scanner);
+  cmFortran_yy_switch_to_buffer(buffer, this->Scanner);
+}
+
+//----------------------------------------------------------------------------
+cmFortranParser_s::~cmFortranParser_s()
+{
+  cmFortran_yylex_destroy(this->Scanner);
+}
+
+//----------------------------------------------------------------------------
+bool cmFortranParser_FilePush(cmFortranParser* parser,
+                                    const char* fname)
+{
+  // Open the new file and push it onto the stack.  Save the old
+  // buffer with it on the stack.
+  if(FILE* file = cmsys::SystemTools::Fopen(fname, "rb"))
+    {
+    YY_BUFFER_STATE current =
+      cmFortranLexer_GetCurrentBuffer(parser->Scanner);
+    std::string dir = cmSystemTools::GetParentDirectory(fname);
+    cmFortranFile f(file, current, dir);
+    YY_BUFFER_STATE buffer =
+      cmFortran_yy_create_buffer(0, 16384, parser->Scanner);
+    cmFortran_yy_switch_to_buffer(buffer, parser->Scanner);
+    parser->FileStack.push(f);
+    return 1;
+    }
+  else
+    {
+    return 0;
+    }
+}
+
+//----------------------------------------------------------------------------
+bool cmFortranParser_FilePop(cmFortranParser* parser)
+{
+  // Pop one file off the stack and close it.  Switch the lexer back
+  // to the next one on the stack.
+  if(parser->FileStack.empty())
+    {
+    return 0;
+    }
+  else
+    {
+    cmFortranFile f = parser->FileStack.top(); parser->FileStack.pop();
+    fclose(f.File);
+    YY_BUFFER_STATE current =
+      cmFortranLexer_GetCurrentBuffer(parser->Scanner);
+    cmFortran_yy_delete_buffer(current, parser->Scanner);
+    cmFortran_yy_switch_to_buffer(f.Buffer, parser->Scanner);
+    return 1;
+    }
+}
+
+//----------------------------------------------------------------------------
+int cmFortranParser_Input(cmFortranParser* parser,
+                                 char* buffer, size_t bufferSize)
+{
+  // Read from the file on top of the stack.  If the stack is empty,
+  // the end of the translation unit has been reached.
+  if(!parser->FileStack.empty())
+    {
+    FILE* file = parser->FileStack.top().File;
+    return (int)fread(buffer, 1, bufferSize, file);
+    }
+  return 0;
+}
+
+//----------------------------------------------------------------------------
+void cmFortranParser_StringStart(cmFortranParser* parser)
+{
+  parser->TokenString = "";
+}
+
+//----------------------------------------------------------------------------
+const char* cmFortranParser_StringEnd(cmFortranParser* parser)
+{
+  return parser->TokenString.c_str();
+}
+
+//----------------------------------------------------------------------------
+void cmFortranParser_StringAppend(cmFortranParser* parser,
+                                         char c)
+{
+  parser->TokenString += c;
+}
+
+//----------------------------------------------------------------------------
+void cmFortranParser_SetInInterface(cmFortranParser* parser,
+                                           bool in)
+{
+  if(parser->InPPFalseBranch)
+    {
+    return;
+    }
+
+  parser->InInterface = in;
+}
+
+//----------------------------------------------------------------------------
+bool cmFortranParser_GetInInterface(cmFortranParser* parser)
+{
+  return parser->InInterface;
+}
+
+//----------------------------------------------------------------------------
+void cmFortranParser_SetOldStartcond(cmFortranParser* parser,
+                                            int arg)
+{
+  parser->OldStartcond = arg;
+}
+
+//----------------------------------------------------------------------------
+int cmFortranParser_GetOldStartcond(cmFortranParser* parser)
+{
+  return parser->OldStartcond;
+}
+
+//----------------------------------------------------------------------------
+void cmFortranParser_Error(cmFortranParser*, const char*)
+{
+  // If there is a parser error just ignore it.  The source will not
+  // compile and the user will edit it.  Then dependencies will have
+  // to be regenerated anyway.
+}
+
+//----------------------------------------------------------------------------
+void cmFortranParser_RuleUse(cmFortranParser* parser,
+                                    const char* name)
+{
+  if(!parser->InPPFalseBranch)
+    {
+    parser->Info.Requires.insert(cmSystemTools::LowerCase(name) );
+    }
+}
+
+//----------------------------------------------------------------------------
+void cmFortranParser_RuleInclude(cmFortranParser* parser,
+                                        const char* name)
+{
+  if(parser->InPPFalseBranch)
+    {
+    return;
+    }
+
+  // If processing an include statement there must be an open file.
+  assert(!parser->FileStack.empty());
+
+  // Get the directory containing the source in which the include
+  // statement appears.  This is always the first search location for
+  // Fortran include files.
+  std::string dir = parser->FileStack.top().Directory;
+
+  // Find the included file.  If it cannot be found just ignore the
+  // problem because either the source will not compile or the user
+  // does not care about depending on this included source.
+  std::string fullName;
+  if(parser->FindIncludeFile(dir.c_str(), name, fullName))
+    {
+    // Found the included file.  Save it in the set of included files.
+    parser->Info.Includes.insert(fullName);
+
+    // Parse it immediately to translate the source inline.
+    cmFortranParser_FilePush(parser, fullName.c_str());
+    }
+}
+
+//----------------------------------------------------------------------------
+void cmFortranParser_RuleModule(cmFortranParser* parser,
+                                       const char* name)
+{
+  if(!parser->InPPFalseBranch && !parser->InInterface)
+    {
+    parser->Info.Provides.insert(cmSystemTools::LowerCase(name));
+    }
+}
+
+//----------------------------------------------------------------------------
+void cmFortranParser_RuleDefine(cmFortranParser* parser,
+                                       const char* macro)
+{
+  if(!parser->InPPFalseBranch)
+    {
+    parser->PPDefinitions.insert(macro);
+    }
+}
+
+//----------------------------------------------------------------------------
+void cmFortranParser_RuleUndef(cmFortranParser* parser,
+                                      const char* macro)
+{
+  if(!parser->InPPFalseBranch)
+    {
+    std::set<std::string>::iterator match;
+    match = parser->PPDefinitions.find(macro);
+    if(match != parser->PPDefinitions.end())
+      {
+      parser->PPDefinitions.erase(match);
+      }
+    }
+}
+
+//----------------------------------------------------------------------------
+void cmFortranParser_RuleIfdef(cmFortranParser* parser,
+                                      const char* macro)
+{
+  // A new PP branch has been opened
+  parser->SkipToEnd.push(false);
+
+  if (parser->InPPFalseBranch)
+    {
+    parser->InPPFalseBranch++;
+    }
+  else if(parser->PPDefinitions.find(macro) == parser->PPDefinitions.end())
+    {
+    parser->InPPFalseBranch=1;
+    }
+  else
+    {
+    parser->SkipToEnd.top() = true;
+    }
+}
+
+//----------------------------------------------------------------------------
+void cmFortranParser_RuleIfndef(cmFortranParser* parser,
+  const char* macro)
+{
+  // A new PP branch has been opened
+  parser->SkipToEnd.push(false);
+
+  if (parser->InPPFalseBranch)
+    {
+    parser->InPPFalseBranch++;
+    }
+  else if(parser->PPDefinitions.find(macro) != parser->PPDefinitions.end())
+    {
+    parser->InPPFalseBranch = 1;
+    }
+  else
+    {
+    // ignore other branches
+    parser->SkipToEnd.top() = true;
+    }
+}
+
+//----------------------------------------------------------------------------
+void cmFortranParser_RuleIf(cmFortranParser* parser)
+{
+  /* Note: The current parser is _not_ able to get statements like
+   *   #if 0
+   *   #if 1
+   *   #if MYSMBOL
+   *   #if defined(MYSYMBOL)
+   *   #if defined(MYSYMBOL) && ...
+   * right.  The same for #elif.  Thus in
+   *   #if SYMBOL_1
+   *     ..
+   *   #elif SYMBOL_2
+   *     ...
+   *     ...
+   *   #elif SYMBOL_N
+   *     ..
+   *   #else
+   *     ..
+   *   #endif
+   * _all_ N+1 branches are considered.  If you got something like this
+   *   #if defined(MYSYMBOL)
+   *   #if !defined(MYSYMBOL)
+   * use
+   *   #ifdef MYSYMBOL
+   *   #ifndef MYSYMBOL
+   * instead.
+   */
+
+  // A new PP branch has been opened
+  // Never skip!  See note above.
+  parser->SkipToEnd.push(false);
+}
+
+//----------------------------------------------------------------------------
+void cmFortranParser_RuleElif(cmFortranParser* parser)
+{
+  /* Note: There are parser limitations.  See the note at
+   * cmFortranParser_RuleIf(..)
+   */
+
+  // Always taken unless an #ifdef or #ifndef-branch has been taken
+  // already.  If the second condition isn't meet already
+  // (parser->InPPFalseBranch == 0) correct it.
+  if(!parser->SkipToEnd.empty() &&
+     parser->SkipToEnd.top() && !parser->InPPFalseBranch)
+    {
+    parser->InPPFalseBranch = 1;
+    }
+}
+
+//----------------------------------------------------------------------------
+void cmFortranParser_RuleElse(cmFortranParser* parser)
+{
+  // if the parent branch is false do nothing!
+  if(parser->InPPFalseBranch > 1)
+    {
+    return;
+    }
+
+  // parser->InPPFalseBranch is either 0 or 1.  We change it depending on
+  // parser->SkipToEnd.top()
+  if(!parser->SkipToEnd.empty() &&
+     parser->SkipToEnd.top())
+    {
+    parser->InPPFalseBranch = 1;
+    }
+  else
+    {
+    parser->InPPFalseBranch = 0;
+    }
+}
+
+//----------------------------------------------------------------------------
+void cmFortranParser_RuleEndif(cmFortranParser* parser)
+{
+  if(!parser->SkipToEnd.empty())
+    {
+    parser->SkipToEnd.pop();
+    }
+
+  // #endif doesn't know if there was a "#else" in before, so it
+  // always decreases InPPFalseBranch
+  if(parser->InPPFalseBranch)
+    {
+    parser->InPPFalseBranch--;
+    }
+}

+ 56 - 49
Source/cmDependsFortranParserTokens.h → Source/cmFortranParserTokens.h

@@ -1,8 +1,8 @@
-/* A Bison parser, made by GNU Bison 2.5.  */
+/* A Bison parser, made by GNU Bison 3.0.2.  */
 
 /* Bison interface for Yacc-like parsers in C
 
-      Copyright (C) 1984, 1989-1990, 2000-2011 Free Software Foundation, Inc.
+   Copyright (C) 1984, 1989-1990, 2000-2013 Free Software Foundation, Inc.
 
    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
@@ -30,43 +30,51 @@
    This special exception was added by the Free Software Foundation in
    version 2.2 of Bison.  */
 
+#ifndef YY_CMFORTRAN_YY_CMFORTRANPARSERTOKENS_H_INCLUDED
+# define YY_CMFORTRAN_YY_CMFORTRANPARSERTOKENS_H_INCLUDED
+/* Debug traces.  */
+#ifndef YYDEBUG
+# define YYDEBUG 0
+#endif
+#if YYDEBUG
+extern int cmFortran_yydebug;
+#endif
 
-/* Tokens.  */
+/* Token type.  */
 #ifndef YYTOKENTYPE
 # define YYTOKENTYPE
-   /* Put the tokens into the symbol table, so that GDB and other debuggers
-      know about them.  */
-   enum yytokentype {
-     EOSTMT = 258,
-     ASSIGNMENT_OP = 259,
-     GARBAGE = 260,
-     CPP_INCLUDE = 261,
-     F90PPR_INCLUDE = 262,
-     COCO_INCLUDE = 263,
-     F90PPR_DEFINE = 264,
-     CPP_DEFINE = 265,
-     F90PPR_UNDEF = 266,
-     CPP_UNDEF = 267,
-     CPP_IFDEF = 268,
-     CPP_IFNDEF = 269,
-     CPP_IF = 270,
-     CPP_ELSE = 271,
-     CPP_ELIF = 272,
-     CPP_ENDIF = 273,
-     F90PPR_IFDEF = 274,
-     F90PPR_IFNDEF = 275,
-     F90PPR_IF = 276,
-     F90PPR_ELSE = 277,
-     F90PPR_ELIF = 278,
-     F90PPR_ENDIF = 279,
-     COMMA = 280,
-     DCOLON = 281,
-     CPP_TOENDL = 282,
-     UNTERMINATED_STRING = 283,
-     STRING = 284,
-     WORD = 285,
-     CPP_INCLUDE_ANGLE = 286
-   };
+  enum yytokentype
+  {
+    EOSTMT = 258,
+    ASSIGNMENT_OP = 259,
+    GARBAGE = 260,
+    CPP_INCLUDE = 261,
+    F90PPR_INCLUDE = 262,
+    COCO_INCLUDE = 263,
+    F90PPR_DEFINE = 264,
+    CPP_DEFINE = 265,
+    F90PPR_UNDEF = 266,
+    CPP_UNDEF = 267,
+    CPP_IFDEF = 268,
+    CPP_IFNDEF = 269,
+    CPP_IF = 270,
+    CPP_ELSE = 271,
+    CPP_ELIF = 272,
+    CPP_ENDIF = 273,
+    F90PPR_IFDEF = 274,
+    F90PPR_IFNDEF = 275,
+    F90PPR_IF = 276,
+    F90PPR_ELSE = 277,
+    F90PPR_ELIF = 278,
+    F90PPR_ENDIF = 279,
+    COMMA = 280,
+    DCOLON = 281,
+    CPP_TOENDL = 282,
+    UNTERMINATED_STRING = 283,
+    STRING = 284,
+    WORD = 285,
+    CPP_INCLUDE_ANGLE = 286
+  };
 #endif
 /* Tokens.  */
 #define EOSTMT 258
@@ -99,24 +107,23 @@
 #define WORD 285
 #define CPP_INCLUDE_ANGLE 286
 
-
-
-
+/* Value type.  */
 #if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
-typedef union YYSTYPE
+typedef union YYSTYPE YYSTYPE;
+union YYSTYPE
 {
-
-/* Line 2068 of yacc.c  */
-#line 89 "cmDependsFortranParser.y"
+#line 81 "cmFortranParser.y" /* yacc.c:1909  */
 
   char* string;
 
-
-
-/* Line 2068 of yacc.c  */
-#line 118 "cmDependsFortranParserTokens.h"
-} YYSTYPE;
+#line 120 "cmFortranParserTokens.h" /* yacc.c:1909  */
+};
 # define YYSTYPE_IS_TRIVIAL 1
-# define yystype YYSTYPE /* obsolescent; will be withdrawn */
 # define YYSTYPE_IS_DECLARED 1
 #endif
+
+
+
+int cmFortran_yyparse (yyscan_t yyscanner);
+
+#endif /* !YY_CMFORTRAN_YY_CMFORTRANPARSERTOKENS_H_INCLUDED  */

Some files were not shown because too many files changed in this diff