!+ ! Tools Group ! Space Telescope Science Institute ! 3700 San Martin Drive ! Baltimore, MD 21218 ! ! NAME ! FIND_X_DEPENDENCIES ! ! DESCRIPTION ! This module scans an X source file searching for X include ! statements of all possible forms. These are a subset of those ! descibed in the VAX C manual including: ! ! #include ! #include "iraflib:irafdefs.h" ! ! Include statements in X comments are ignored. ! ! RETURN VALUE ! ! HISTORY ! 11/88 Bauer First cut. ! !- MODULE FIND_X_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 exclamation_T ALIAS '!' { '!' }; TOKEN start_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 }... ] ] }; ! ! --- MACRO definitions --- ! MACRO comment_M SYNTAX { s1,s2,col : { file_spec | '#' | '!' } }; IF LENGTH(s1) = 1 AND col = 1 THEN s1 = UPPER(TRIM(s1)); IF s1 = 'C' OR s1 = 'D' OR s1 = '#' OR s1 = '!' 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 X comment lines ! MACRO ignore_comments_M TRIGGER { comment_M FIND(s'eol') }; END MACRO; ! ! MACRO to recognize the FORTRAN 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 = 'IRAFLIB:'; END IF; IF ext = '' THEN ext = '.H'; END IF; temp1 = disk & filename & ext; CALL add_to_dependency_tree (temp1); END IF; END IF; END IF; END MACRO; ! ! --- PROCEDURE definitions --- ! PROCEDURE find_x_dependencies (what_file : STRING); DECLARE dump_output : FIXED STRING(1); START SCAN INPUT FILE what_file OUTPUT STRING dump_output; END PROCEDURE; END MODULE;