home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / FTNCHK32.ZIP / ftnchek.h < prev    next >
C/C++ Source or Header  |  1993-02-16  |  12KB  |  351 lines

  1. /* ftnchek.h:
  2.  
  3.     Common definitions for Fortran Program Checker
  4.  
  5.     Copyright (C) 1993 by Robert K. Moniot.
  6.     This program is free software.  Permission is granted to
  7.     modify it and/or redistribute it, retaining this notice.
  8.     No guarantees accompany this software.
  9.  
  10. */
  11.  
  12. #define VERSION_NUMBER        "FTNCHEK Version 2.6 January 1993"
  13.  
  14.     /* The following system defines should be defined with the -D
  15.        (for UNIX) or /DEFINE (for VMS) compiler options in the makefile,
  16.        not here.  They are shown here so you know what to define.
  17.     */
  18.  
  19. /*#define VMS*/        /* Set flag for VAX/VMS   system-dependent defns. */
  20. /*#define UNIX*/    /* Set flag for UNIX (ATT or BSD) defns. */
  21. #ifdef __TURBOC__
  22. #define MSDOS        /* Set flag for MSDOS (IBM PC) */
  23. #endif
  24.  
  25. #ifdef VMS
  26.     /* If VMS system, define flag for extra VMS-isms in
  27.        iokeywds.h table unless NO_VMS_IO is defined. These
  28.        can be independently enabled by defining VMS_IO. */
  29. #ifndef NO_VMS_IO
  30. #define VMS_IO
  31. #endif /*NO_VMS_IO*/
  32.     /* Likewise define flag for VMS behavior in INCLUDE stmt
  33.        (defaulting extension, /NOLIST feature) unless
  34.        NO_VMS_INCLUDE is defined.  */
  35. #ifndef NO_VMS_INCLUDE
  36. #define VMS_INCLUDE
  37. #endif /*NO_VMS_INCLUDE*/
  38. #endif /*VMS*/
  39.  
  40.     /* set flag to allow options to start with '/' */
  41. #ifdef VMS
  42. #define OPTION_PREFIX_SLASH 1
  43. #endif
  44. #ifdef MSDOS
  45. #define OPTION_PREFIX_SLASH 1
  46. #endif
  47.  
  48.         /* The following defines cause Ftnchek to permit various
  49.            nonstandard things.  Purists can remove these defines
  50.            to disable them.
  51.            Disable all by defining STRICT_SYNTAX.
  52.         */
  53.  
  54. #ifndef STRICT_SYNTAX
  55. #define ALLOW_UNDERSCORES 1    /* Underscores in variable names */
  56. #ifdef VMS
  57. #define ALLOW_DOLLARSIGNS 1    /* VMS allows $ in identifiers too */
  58. #endif
  59. #define INLINE_COMMENT_CHAR '!' /* Inline comments starting with '!' */
  60. #define ALLOW_INCLUDE 1        /* The INCLUDE statement */
  61. #define ALLOW_DO_ENDO 1    /* The various DO loop extensions (including WHILE) */
  62. #endif
  63.  
  64.         /* Define to tolerate embedded blanks in numeric consts unless
  65.            feature turned off by defining NO_BLANKS_IN_NUMBERS. */
  66. #ifndef NO_BLANKS_IN_NUMBERS
  67. #define BLANKS_IN_NUMBERS
  68. #endif
  69.  
  70.         /* Define default source and output file extensions.  These
  71.          * can be overridden by defines on compiler commandline.
  72.          */
  73. #ifndef DEF_SRC_EXTENSION
  74. #ifdef VMS
  75. #define DEF_SRC_EXTENSION ".for"        /* VMS default extension */
  76. #endif
  77. #ifdef MSDOS
  78. #define DEF_SRC_EXTENSION ".for"        /* IBM PC default extension */
  79. #endif
  80. #endif /* DEF_SRC_EXTENSION */
  81.  
  82. #ifndef DEF_SRC_EXTENSION
  83. #define DEF_SRC_EXTENSION ".f"        /* Unix and all others */
  84. #endif
  85.         /* define default list-file extension */
  86. #ifndef DEF_LIST_EXTENSION
  87. #define DEF_LIST_EXTENSION ".lis"
  88. #endif
  89.         /* define default project-file extension */
  90. #ifndef DEF_PROJ_EXTENSION
  91. #define DEF_PROJ_EXTENSION ".prj"
  92. #endif
  93.         /* define project-file name for case of input from stdin */
  94. #ifndef STDIN_PROJ_FILENAME
  95. #define STDIN_PROJ_FILENAME "ftnchek.prj"
  96. #endif
  97.  
  98. #ifndef ENV_PREFIX        /* prefix for option environment variables */
  99. #define ENV_PREFIX "FTNCHEK_"
  100. #endif
  101.  
  102. #ifndef MAXLINE
  103. #define MAXLINE 132    /* Maximum input line length.  Ignores past this. */
  104. #endif
  105. #ifndef MAXSTR
  106. #define MAXSTR 200    /* Longest string constant allowed */
  107. #endif
  108. #ifndef MAXIDSIZE
  109. #define MAXIDSIZE 31    /* Longest identifier allowed */
  110. #endif
  111.  
  112. #ifndef MAX_INCLUDE_DEPTH
  113. #define MAX_INCLUDE_DEPTH 16    /* Max nesting depth of include files */
  114. #endif
  115.  
  116. #ifndef ENV_INCLUDE_VAR
  117. #define ENV_INCLUDE_VAR "INCLUDE" /* name of env variable for include dir */
  118. #endif
  119.  
  120. #ifndef DEFAULT_INCLUDE_DIR
  121. #ifdef UNIX
  122. #define DEFAULT_INCLUDE_DIR "/usr/include"
  123. #endif
  124. #ifdef VMS
  125. #define DEFAULT_INCLUDE_DIR "SYS$LIBRARY:"
  126. #endif
  127. #ifdef MSDOS
  128. #define DEFAULT_INCLUDE_DIR "\\include"
  129. #endif
  130. #endif
  131.  
  132. #define KEYHASHSZ 195    /* Size of keyword hashtable -- do not change */
  133. #define INTRINS_HASHSZ 261 /* Chosen to give few clashes -- change with care */
  134.  
  135. #ifdef SMALL_MACHINE        /* Use these for e.g. IBM PC */
  136. #ifndef HASHSZ            /* Hint: pick one with no square factors */
  137. #define HASHSZ 798     /* Size of symbol hashtable */
  138. #endif
  139. #ifndef STRSPACESZ
  140. #define STRSPACESZ 2000    /* Size of identifier string space */
  141. #endif
  142. #ifndef LOCSYMTABSZ
  143. #define LOCSYMTABSZ 200 /* Size of local symbol table */
  144. #endif
  145. #ifndef GLOBSYMTABSZ
  146. #define GLOBSYMTABSZ 200 /* Size of global symbol table */
  147. #endif
  148. #ifndef TOKENSPACESZ
  149. #define TOKENSPACESZ 200 /* Max number of tokens in token lists */
  150. #endif
  151.  
  152. #else  /* end if SMALL_MACHINE */
  153.  
  154. #ifdef LARGE_MACHINE        /* use these if space is no problem */
  155. #ifndef HASHSZ
  156. #define HASHSZ 20930     /* Size of symbol hashtable: must be <= max int */
  157. #endif
  158. #ifndef STRSPACESZ
  159. #define STRSPACESZ 40000    /* Size of identifier string space */
  160. #endif
  161. #ifndef LOCSYMTABSZ
  162. #define LOCSYMTABSZ 6000 /* Size of local symbol table */
  163. #endif
  164. #ifndef GLOBSYMTABSZ
  165. #define GLOBSYMTABSZ 4000 /* Size of global symbol table */
  166. #endif
  167. #ifndef TOKENSPACESZ
  168. #define TOKENSPACESZ 10000 /* Max number of tokens in token lists */
  169. #endif
  170.  
  171. #else        /* Defaults: Use these for average-size applications */
  172.  
  173. #ifndef HASHSZ
  174. #define HASHSZ 2002     /* Size of symbol hashtable: must be <= max int */
  175. #endif
  176. #ifndef STRSPACESZ
  177. #define STRSPACESZ 4000    /* Size of identifier string space */
  178. #endif
  179. #ifndef LOCSYMTABSZ
  180. #define LOCSYMTABSZ 600 /* Size of local symbol table */
  181. #endif
  182. #ifndef GLOBSYMTABSZ
  183. #define GLOBSYMTABSZ 400 /* Size of global symbol table */
  184. #endif
  185. #ifndef TOKENSPACESZ
  186. #define TOKENSPACESZ 1000 /* Max number of tokens in token lists */
  187. #endif
  188.  
  189. #endif /* end if LARGE_MACHINE else */
  190.  
  191. #endif/*end if SMALL_MACHINE else*/
  192.  
  193.  
  194. #define FALSE 0
  195. #define TRUE 1
  196.  
  197. #define NO_COL_NUM 999        /* impossible column number to suppress
  198.                  * printing in error messages
  199.                  */
  200.  
  201. /* Shared variable and function defns start here */
  202.  
  203. #ifdef MAIN
  204. #define SHARED        /* (nothing) */
  205. #else
  206. #define SHARED extern    /* Non-main routines declare shared vars extern */
  207. #endif
  208.  
  209. #define PRIVATE static    /* For non-shared functions */
  210.  
  211.  
  212. SHARED FILE
  213.             *input_fd,  /* Input file */
  214.             *list_fd,    /* Output file for listing */
  215.         *project_fd;/* Project file for symtab info summary */
  216. SHARED char *current_filename,    /* name of current input file */
  217.         *top_filename;    /* name of toplevel parent input file */
  218. SHARED int incdepth;
  219.  
  220.  
  221.         /* Declare variables for command line options */
  222. #ifdef MAIN
  223. #define OPT(Type,Name,Value) Type Name=Value
  224. #else
  225. #define OPT(Type,Name,Value) extern Type Name
  226. #endif
  227.  
  228. OPT(int,print_call_tree,FALSE);    /* Print the call tree */
  229. OPT(int,decls_required,FALSE);    /* List all undeclared identifiers */
  230. OPT(int,div_check,FALSE);    /* Check for possible division by zero */
  231. OPT(int,ext_def_check,TRUE);    /* Check defined status of externals*/
  232. OPT(int,f77_standard,FALSE);    /* Warn of non-f77 constructs */
  233. OPT(int,help_screen,FALSE);    /* Print out help screen */
  234. OPT(int,hollerith_check,TRUE);    /* Warn about holleriths under -port */
  235. OPT(int,library_mode,FALSE);    /* Set used-flag for all modules in file */
  236. OPT(int,eol_is_space,TRUE);    /* Treat contd stmt linebreaks as space */
  237. OPT(int,do_list,FALSE);    /* Listing-file flag */
  238. OPT(int,novice_help,TRUE);    /* Extra help for novices */
  239. OPT(int,port_check,FALSE);    /* Portability warnings */
  240. OPT(int,pretty_flag,TRUE);    /* Warnings on deceiving appearances */
  241. OPT(int,make_project_file,FALSE);/* Save symtab defns in .prj file */
  242. OPT(int,pure_functions,TRUE);    /* Assume functions are pure */
  243. OPT(int,sixclash,FALSE);    /* To check if names unique in 1st 6 chars */
  244. OPT(int,do_symtab,FALSE);    /* For symbol table printout */
  245. OPT(int,trunc_check,TRUE);    /* Check for truncation pitfalls */
  246. OPT(int,verbose,TRUE);    /* Verbose output format */
  247.         /* Debugging flags */
  248. OPT(int,debug_latest,FALSE);    /* debug the latest addition */
  249. OPT(int,debug_glob_symtab,FALSE);/* global symtab contents */
  250. OPT(int,debug_parser,FALSE);    /* grammar debug via DBG statements */
  251. OPT(int,debug_hashtab,FALSE);    /* hash table contents */
  252. OPT(int,debug_loc_symtab,FALSE); /* local symtab contents */
  253. OPT(int,show_resources,FALSE);    /* space avail and used */
  254. OPT(int,debug_lexer,FALSE);    /* list of tokens as scanned */
  255. #ifdef MAIN
  256. #ifdef YYDEBUG
  257. extern int yydebug;        /* grammar debug via yydebug */
  258. #endif
  259. #endif
  260.         /* Declare variables for commandline settings */
  261. OPT(int,array_arg_check,3);/* Check array argument dims & size  */
  262. OPT(int,max_stmt_col,72);    /* End of statement field ( <= MAXLINE )*/
  263. OPT(int,comcheck_strictness,3);    /* 0 (no check) to 3 (exact type & size) */
  264. OPT(int,usage_check,3);        /* Print set/used/ubs checks on variables */
  265.  
  266.         /* Declare variables for commandline StrSettings */
  267. OPT(char,*out_fname,(char *)NULL);    /* Output filename */
  268. #ifdef ALLOW_INCLUDE
  269. OPT(char,*include_path,(char *)NULL);    /* An include-file directory */
  270. #endif
  271.  
  272. SHARED unsigned
  273.     line_num,        /* line num of current char */
  274.     col_num,        /* column num of current char */
  275.     next_line_num,    /* line num of lookahead char */
  276.     next_col_num;    /* column num of lookahead char */
  277.  
  278. SHARED unsigned
  279.     tab_count,        /* Count of tabs in noncomment lines exc in strings */
  280.     error_count,    /* Count of syntax error messages per file */
  281.     warning_count;    /* Count of warning messages per file */
  282.  
  283.         /* Resource usage information: */
  284. SHARED unsigned long
  285.     max_loc_symtab,    /* amt of local symtab used */
  286.     max_glob_symtab,    /* amt of global symtab used */
  287.     max_loc_strings,    /* amt of local stringspace used */
  288.     max_glob_strings,    /* amt of global stringspace used */
  289.     max_token_space;    /* amt of token space used */
  290.  
  291. SHARED int
  292.     equivalence_flag,   /* true while parsing EQUIVALENCE statement */
  293.     initial_flag,    /* true while only label or initial keywords read */
  294.     implicit_flag,    /* true while parsing IMPLICIT statement */
  295.     implicit_letter_flag, /* true while getting letters in IMPLICIT list */
  296.     implicit_type_given,/* true if IMPLICIT type statement found */
  297.     implicit_none,    /* true if IMPLICIT NONE statement found */
  298.     prev_token_class,    /* token class of last-returned token */
  299.     curr_stmt_class;    /* Token class of current stmt's leading token */
  300.  
  301.         /* Define linked-list structure for include-path list */
  302. #ifdef ALLOW_INCLUDE
  303. typedef struct IPNode {
  304.   struct IPNode *link;        /* next path on the list */
  305.   char *include_path;        /* one path (full directory name) */
  306. } IncludePathNode;
  307.  
  308. SHARED IncludePathNode *include_path_list; /* header to the list */
  309. #endif
  310.  
  311.         /* Declare shared routines */
  312.     /* in advance.c */
  313. void init_scan(),finish_scan(),open_include_file();
  314. int flush_line_out();
  315.  
  316.  
  317.     /* in ftnchek.c */
  318. void print_a_line(), yyerror(), syntax_error(), msg_tail(),
  319.      warning(), nonstandard(), nonportable();
  320. char *add_ext(),*new_ext();
  321. int has_extension();
  322.  
  323.     /* in forlex.c */
  324. int yylex();
  325. void implied_id_token();
  326.  
  327.     /* in fortran.y/fortran.c */
  328. int yyparse();
  329. void init_parser();
  330.  
  331.     /* in intrinsics.c */
  332. unsigned long init_intrins_hashtab();
  333.  
  334.     /* in keywords.c */
  335. void init_keyhashtab();
  336.  
  337.     /* in prsymtab.c */
  338.  
  339. void check_arglists(),check_comlists(),visit_children();
  340.  
  341.     /* in symtab.c */
  342.  
  343. char *new_local_string(),*new_global_string();
  344. void init_globals(), init_symtab(), note_filename();
  345. char * token_name();
  346.  
  347.  
  348.     /* in symtab2.c */
  349. void                /* project file routines */
  350.  proj_file_out(),proj_file_in();
  351.