summaryrefslogtreecommitdiff
path: root/Source/cmFortranParserImpl.cxx
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2015-11-02 15:29:52 -0500
committerBrad King <brad.king@kitware.com>2015-11-02 15:29:52 -0500
commitba819f49df33b546072a5928de3253770c4716b9 (patch)
treeb281ef543d802a53a9c7a438947003a997401b8d /Source/cmFortranParserImpl.cxx
parent7748a02c3f7d028af13d4fc2c83e7181d11397e9 (diff)
downloadcmake-ba819f49df33b546072a5928de3253770c4716b9.tar.gz
cmFortranParser: Parse #line directives
Teach the lexer to extract the #line directive prefix and line number as a new token type. Teach the parser to recognize this token followed by a string as the file name (plus possibly other content). Report the named file as included by the source file.
Diffstat (limited to 'Source/cmFortranParserImpl.cxx')
-rw-r--r--Source/cmFortranParserImpl.cxx26
1 files changed, 26 insertions, 0 deletions
diff --git a/Source/cmFortranParserImpl.cxx b/Source/cmFortranParserImpl.cxx
index a09c54598a..c175e62085 100644
--- a/Source/cmFortranParserImpl.cxx
+++ b/Source/cmFortranParserImpl.cxx
@@ -210,6 +210,32 @@ void cmFortranParser_RuleUse(cmFortranParser* parser,
}
//----------------------------------------------------------------------------
+void cmFortranParser_RuleLineDirective(cmFortranParser* parser,
+ const char* filename)
+{
+ // This is a #line directive naming a file encountered during preprocessing.
+ std::string included = filename;
+
+ // Skip #line directives referencing non-files like
+ // "<built-in>" or "<command-line>".
+ if (included.empty() || included[0] == '<')
+ {
+ return;
+ }
+
+ // Fix windows file path separators since our lexer does not
+ // process escape sequences in string literals.
+ cmSystemTools::ReplaceString(included, "\\\\", "\\");
+ cmSystemTools::ConvertToUnixSlashes(included);
+
+ // Save the named file as included in the source.
+ if (cmSystemTools::FileExists(included))
+ {
+ parser->Info.Includes.insert(included);
+ }
+}
+
+//----------------------------------------------------------------------------
void cmFortranParser_RuleInclude(cmFortranParser* parser,
const char* name)
{