diff options
author | Brad King <brad.king@kitware.com> | 2016-09-05 20:46:42 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2016-09-20 13:18:47 (GMT) |
commit | b5ac8b8aa778c7ad612a20deb04a2efafa386d9d (patch) | |
tree | 3f0fb4c12b0c363d4c014a29634223c11d0967da /Source/cmFortranParser.y | |
parent | bdcc1f517ed8a513f8c156d83f0244c1b9e98703 (diff) | |
download | CMake-b5ac8b8aa778c7ad612a20deb04a2efafa386d9d.zip CMake-b5ac8b8aa778c7ad612a20deb04a2efafa386d9d.tar.gz CMake-b5ac8b8aa778c7ad612a20deb04a2efafa386d9d.tar.bz2 |
Fortran: Add support for submodule syntax in dependency scanning
Fortran 2008 [1] adds support for a new syntax related to modules:
submodule ( ParentModule ) SubModule
submodule ( ParentModule : SubModule ) NestedSubModule
Both of these mean that the current source file requires the module
`ParentModule` to be available if it is not provided in the current
file. Teach our Fortran dependency scanner to parse this syntax to
extract this relationship. For now simply tolerate the nested submodule
case and extract only the dependency it expresses on the main module.
Further work will be needed to extract dependencies among nested
submodules.
[1] http://fortranwiki.org/fortran/show/Fortran+2008
Closes: #16234
Diffstat (limited to 'Source/cmFortranParser.y')
-rw-r--r-- | Source/cmFortranParser.y | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/Source/cmFortranParser.y b/Source/cmFortranParser.y index 7cf7619..d3327e9 100644 --- a/Source/cmFortranParser.y +++ b/Source/cmFortranParser.y @@ -85,7 +85,7 @@ static void cmFortran_yyerror(yyscan_t yyscanner, const char* message) %token CPP_IFDEF CPP_IFNDEF CPP_IF CPP_ELSE CPP_ELIF CPP_ENDIF %token F90PPR_IFDEF F90PPR_IFNDEF F90PPR_IF %token F90PPR_ELSE F90PPR_ELIF F90PPR_ENDIF -%token COMMA DCOLON +%token COMMA COLON DCOLON LPAREN RPAREN %token <number> UNTERMINATED_STRING %token <string> STRING WORD %token <string> CPP_INCLUDE_ANGLE @@ -93,6 +93,7 @@ static void cmFortran_yyerror(yyscan_t yyscanner, const char* message) %token INCLUDE %token INTERFACE %token MODULE +%token SUBMODULE %token USE /*-------------------------------------------------------------------------*/ @@ -120,6 +121,19 @@ stmt: } free($2); } +| SUBMODULE LPAREN WORD RPAREN WORD other EOSTMT { + cmFortranParser* parser = cmFortran_yyget_extra(yyscanner); + cmFortranParser_RuleUse(parser, $3); + free($3); + free($5); + } +| SUBMODULE LPAREN WORD COLON WORD RPAREN WORD other EOSTMT { + cmFortranParser* parser = cmFortran_yyget_extra(yyscanner); + cmFortranParser_RuleUse(parser, $3); + free($3); + free($5); + free($7); + } | INTERFACE WORD other EOSTMT { cmFortranParser* parser = cmFortran_yyget_extra(yyscanner); cmFortranParser_SetInInterface(parser, true); @@ -221,11 +235,15 @@ misc_code: | INCLUDE | INTERFACE | MODULE +| SUBMODULE | USE | STRING { free ($1); } | GARBAGE | ASSIGNMENT_OP +| COLON | DCOLON +| LPAREN +| RPAREN | COMMA | UNTERMINATED_STRING ; |