!+ ! Tools Group ! Space Telescope Science Institute ! 3700 San Martin Drive ! Baltimore, MD 21218 ! ! NAME ! FIND_C_DEPENDENCIES ! ! DESCRIPTION ! This module scans a C source file searching for VAX C include ! statements of all possible forms as descibed in the VAX C manual ! including: ! ! #include ssdef ! #include ! #include "sys$library:ssdef.h" ! ! Include statements in comments are ignored. Conditional ! compliations are not processed. ! ! RETURN VALUE ! ! HISTORY ! 11/88 Bauer First cut. ! !- MODULE FIND_C_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 { '#include' }; TOKEN comment_start_T ALIAS '/*' { '/*' }; TOKEN comment_end_T ALIAS '*/' { '*/' }; TOKEN double_quote_T { '"' }; TOKEN left_angle_T ALIAS '<' { '<' }; TOKEN right_angle_T ALIAS '>' { '>' }; 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 }... ] ] }; DECLARE problems_creating_complete_mms : EXTERNAL BOOLEAN; ! ! --- MACRO definitions --- ! ! ! MACROs to recognize and ignore C comment lines ! - Note this will screw up if a file has comment delimiters in a string ! MACRO ignore_comments_M TRIGGER { '/*' FIND('*/') '*/' }; END MACRO; ! ! MACRO to recognize the C include lines ! - Note this will not handle and conditional compilations ! MACRO include_statement_M TRIGGER { s1,s2,col: include_T d1: [ double_quote_T | left_angle_T ] include_file_name: { [disk] [directory] file_spec } d2: [ double_quote_T | right_angle_T ] FIND(s'eol') eol_T }; EXTERNAL PROCEDURE substitute_string (STRING, STRING, STRING); EXTERNAL PROCEDURE add_to_dependency_tree (STRING); EXTERNAL PROCEDURE add_to_plus_library_tree (STRING); EXTERNAL PROCEDURE filescan(STRING, STRING, STRING, STRING, STRING, STRING, STRING); EXTERNAL PROCEDURE search_libraries_for_module (STRING, STRING); EXTERNAL PROCEDURE find_module_in_library (STRING, STRING) OF BOOLEAN; DECLARE temp1, temp2 : STRING; DECLARE node, disk, dir, filename, ext, vers : STRING; IF col = 1 THEN CALL filescan (include_file_name, node, disk, dir, filename, ext, vers); d1 = TRIM(d1); IF d1 = '"' THEN temp1 = include_file_name; IF ext = '' THEN temp1 = temp1 & '.H'; END IF; CALL add_to_dependency_tree (temp1); ELSE IF d1 = '<' THEN IF disk='' THEN disk = 'SYS$LIBRARY:'; END IF; IF ext = '' THEN ext = '.H'; END IF; temp1 = disk & filename & ext; CALL add_to_dependency_tree (temp1); ELSE disk = 'SYS$LIBRARY:VAXCDEF.TLB'; filename = UPPER(filename); IF find_module_in_library (filename, disk) THEN temp1 = disk & '(' & filename & '=' & filename & '.H)'; ! temp1 = disk & '(' & filename & ')'; CALL add_to_dependency_tree (temp1); ELSE CALL search_libraries_for_module (filename, disk); IF disk <> '' THEN ! temp1 = disk & '(' & filename & '=' & filename & '.H)'; temp1 = disk & '(' & filename & ')'; CALL add_to_dependency_tree (temp1); CALL add_to_plus_library_tree (disk); ELSE WRITE '%MMSGEN-E-CANFINDLIB, Include module ', filename, ' must map to a library.'; WRITE ' This will be omitted from the dependency list.'; problems_creating_complete_mms = TRUE; END IF; END IF; END IF; END IF; END IF; END MACRO; ! ! --- PROCEDURE definitions --- ! PROCEDURE find_c_dependencies (what_file : STRING); DECLARE dump_output : FIXED STRING(1); START SCAN INPUT FILE what_file OUTPUT STRING dump_output; ! Ignore output END PROCEDURE; END MODULE;