!+ ! Tools Group ! Space Telescope Science Institute ! 3700 San Martin Drive ! Baltimore, MD 21218 ! ! NAME ! FIND_FORTRAN_DEPENDENCIES ! ! DESCRIPTION ! This module scans a FORTRAN source file searching for VAX FORTRAN ! include statements of all possible forms as descibed in the VAX ! FORTRAN manual including: ! ! INCLUDE '($SSDEF)' ! INCLUDE 'SYS$LIBRARY:FORSYSDEF.TLB($SSDEF)' ! INCLUDE '(ABCD)' ! INCLUDE 'DIRDDL:ZIPPIE.FOR' ! ! Include statements in comments are ignored. Conditional ! compliations (DLINES) are not processed. ! ! This routine is also called to parse .FBL, .EQE, and .EQF ! source which are VAX FORTRAN source with some minor ! variations (to non-include statements). ! ! RETURN VALUE ! ! HISTORY ! 11/88 Bauer First cut. ! !- MODULE FIND_FORTRAN_DEPENDENCIES; ! ! --- Set definitions --- ! SET blank ( ' ' ); SET horizontal_tab ( s'ht' ); SET form_feed ( s'ff' ); SET end_of_line ( s'eol' ); SET end_of_stream ( s'eos' ); SET open_paren ( '(' ); SET close_paren ( ')' ); SET open_bracket ( '[' ); SET close_bracket ( ']' ); SET ampersand ( '&' ); SET asterisk ( '*' ); SET colon ( ':' ); SET semi_colon ( ';' ); SET equal ( '=' ); SET comma ( ',' ); SET period ( '.' ); SET single_quote ( '''' ); SET double_quote ( '"' ); SET underscore ( '_' ); SET hyphen ( '-' ); SET dollar_sign ( '$' ); SET numeric_char ( '0'..'9' ); SET lower_alpha_char ( 'a'..'z' ); SET upper_alpha_char ( 'A'..'Z' ); SET alpha_char ( lower_alpha_char OR upper_alpha_char ); SET white_space ( blank OR horizontal_tab OR form_feed ); SET non_white_space ( NOT ( blank OR horizontal_tab OR form_feed OR end_of_line OR end_of_stream ) ); SET any ( NOT ( end_of_line or end_of_stream ) ); ! ! --- Token definitions --- ! TOKEN ignore_spaces IGNORE { { white_space }... }; TOKEN include_T CASELESS { 'INCLUDE' }; TOKEN list_T CASELESS { '/NOLIST' | '/LIST' }; TOKEN exclamation_T ALIAS '!' { '!' }; TOKEN start_T ALIAS '*' { '*' }; TOKEN single_quote_T { '''' }; TOKEN eol_T { end_of_line }; ! ! VMS file specification tokens. ! TOKEN disk { { alpha_char | numeric_char | underscore | dollar_sign } [ { alpha_char | numeric_char | underscore | dollar_sign | hyphen }... ] colon }; TOKEN directory { open_bracket { { alpha_char | numeric_char | underscore | dollar_sign } [ { alpha_char | numeric_char | underscore | dollar_sign | hyphen }... ] [ period ] }... close_bracket }; TOKEN file_spec { { alpha_char | numeric_char | underscore | dollar_sign } [ { alpha_char | numeric_char | underscore | dollar_sign | hyphen }... ] [ period { alpha_char | numeric_char | underscore | dollar_sign } [ { alpha_char | numeric_char | underscore | dollar_sign | hyphen }... ] ] }; TOKEN module_name { open_paren { alpha_char | numeric_char | underscore | dollar_sign } [ { alpha_char | numeric_char | underscore | dollar_sign }... ] close_paren }; DECLARE problems_creating_complete_mms : EXTERNAL BOOLEAN; ! ! --- MACRO definitions --- ! MACRO comment_M SYNTAX { s1,s2,col : { file_spec | '*' | '!' } }; ! IF LENGTH(s1) = 1 AND col = 1 IF col = 1 THEN s1 = UPPER(TRIM(s1)); IF s1[1..1] = 'C' OR s1[1..1] = 'D' OR s1[1..1] = '*' OR s1[1..] = '!' THEN ANSWER s1; ELSE FAIL; END IF; ELSE IF s1 = '!' THEN ANSWER s1; ELSE FAIL; END IF; END IF; END MACRO; ! ! MACROs to recognize and ignore FORTRAN comment lines ! MACRO ignore_comments_M TRIGGER { comment_M FIND(s'eol') }; END MACRO; ! ! MACRO to recognize the FORTRAN include lines ! MACRO include_statement_M TRIGGER { include_T single_quote_T { include_module_name : { [ mpath: { [disk] [directory] file_spec } ] mod_name: module_name } | include_file_name: { [disk] [directory] file_spec } } [ list_T ] single_quote_T FIND(s'eol') eol_T }; EXTERNAL PROCEDURE substitute_string (STRING, STRING, STRING); EXTERNAL PROCEDURE add_to_dependency_tree (STRING); EXTERNAL PROCEDURE search_libraries_for_module (STRING, STRING); EXTERNAL PROCEDURE add_to_plus_library_tree (STRING); DECLARE temp1, temp2 : STRING; DECLARE what_library : STRING; IF include_file_name <> '' THEN CALL add_to_dependency_tree (include_file_name); ELSE temp1 = TRIM(include_module_name); IF temp1[1..2] = '($' THEN temp2 = TRIM(include_module_name); CALL substitute_string ('(', '', temp2); CALL substitute_string (')', '', temp2); include_module_name = 'SYS$LIBRARY:FORSYSDEF.TLB(' & temp2 & '=' & temp2 & '.FOR)'; CALL add_to_dependency_tree (include_module_name); ELSE mod_name = TRIM(mod_name); CALL substitute_string ('(', '', mod_name); CALL substitute_string (')', '', mod_name); include_module_name = temp1[1..LENGTH(temp1)-1] & '=' & mod_name & '.FOR)'; IF mpath = '' THEN CALL search_libraries_for_module (mod_name, what_library); IF what_library <> '' THEN CALL add_to_dependency_tree (what_library & '(' & mod_name & ')' ); CALL add_to_plus_library_tree (what_library); ELSE WRITE '%MMSGEN-E-CANFINDLIB, Include module ', UPPER(mod_name), ' must map to a library. '; WRITE ' This will be omitted from dependency list.'; problems_creating_complete_mms = TRUE; END IF; END IF; END IF; END IF; END MACRO; ! ! --- PROCEDURE definitions --- ! PROCEDURE find_fortran_dependencies (what_fortran_file : STRING); DECLARE dump_output : FIXED STRING(1); START SCAN INPUT FILE what_fortran_file OUTPUT STRING dump_output; END PROCEDURE; END MODULE; /* find_fortran_dependencies */