home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / fchek284.zip / symtab.h < prev    next >
C/C++ Source or Header  |  1996-03-29  |  21KB  |  770 lines

  1. /* symtab.h:
  2.  
  3.     Shared declarations for symbol-table routines.  Note: uses
  4.     declarations in ftnchek.h.
  5.  
  6.     Copyright (C) 1993 by Robert K. Moniot.
  7.     This program is free software.  Permission is granted to
  8.     modify it and/or redistribute it, retaining this notice.
  9.     No guarantees accompany this software.
  10.  
  11.  
  12. */
  13.  
  14. #ifdef SYMTAB            /* "home" for variables is symtab.c */
  15. #define SYM_SHARED
  16. #else
  17. #define SYM_SHARED extern
  18. #endif
  19.  
  20. #ifdef DYNAMIC_TABLES
  21. #ifdef __TURBOC__    /* Turbo C has only one free() */
  22. #define cfree free
  23. #endif
  24. #endif
  25.  
  26.         /* Definitions of symbol table information */
  27.  
  28. /*    Token subclasses (classes are in tokdefs.h)
  29.  */
  30.  
  31. #define relop_EQ    0
  32. #define relop_NE    1
  33. #define relop_LE    2
  34. #define relop_LT    3
  35. #define relop_GE    4
  36. #define relop_GT    5
  37.  
  38.  
  39.  
  40.     /* Storage Class types for variables, consts, and externals */
  41. #define class_VAR 0
  42. #define class_SUBPROGRAM 1
  43. #define class_COMMON_BLOCK 2
  44. #define class_STMT_FUNCTION 3
  45. #define class_LABEL 4
  46. #define class_NAMELIST 5
  47.  
  48.  
  49.     /* Data types for variables, consts, and externals */
  50.     /* N.B. 0 thru 7 are wired into lookup tables in exprtype.c */
  51. #define type_UNDECL 0
  52. #define type_ERROR 0        /* for result of erroneous operation */
  53. #define type_INTEGER 1
  54. #define type_REAL 2
  55. #define type_DP 3
  56. #define type_COMPLEX 4
  57. #define type_DCOMPLEX 5
  58. #define type_LOGICAL 6
  59. #define type_STRING 7
  60. #define type_HOLLERITH 8
  61. #define type_GENERIC 9
  62. #define type_SUBROUTINE 10
  63. #define type_COMMON_BLOCK 11
  64. #define type_PROGRAM 12
  65. #define type_BLOCK_DATA 13
  66. #define type_LABEL 14
  67. #define type_NAMELIST 15
  68.  
  69. #define size_DEFAULT    (0L)    /* code for standard numeric sizes */
  70. #define size_ADJUSTABLE    (-1L)    /* codes for special char string lengths */
  71. #define size_UNKNOWN    (-2L)
  72.  
  73.                 /* test for types usable in exprs */
  74. #define is_computational_type(t) ((unsigned)(t) <= (unsigned)type_HOLLERITH)
  75.                 /* test for numeric types */
  76. #define is_numeric_type(t) ((unsigned)(t) <= (unsigned)type_DCOMPLEX)
  77.                 /* test for arith, char, or logical type */
  78. #define is_const_type(t) (((t)>(unsigned)0) && ((t)<=(unsigned)type_STRING))
  79.                 /* test for numeric or logical type */
  80. #define is_num_log_type(t) ((t) <= type_LOGICAL)
  81.                 /* test for real/d.p./complex/d.complx type */
  82. #define is_float_type(t) ((t)>=type_REAL && (t)<=type_DCOMPLEX)
  83.  
  84.     /* Type categories equate DoubleP to Real, Double Complex
  85.        to Complex, and Hollerith to Int to simplify expression
  86.        type propagation and argument checking.  Computational
  87.        types only, except that since subroutine can be passed
  88.        as an argument, table goes up that high.  */
  89. SYM_SHARED
  90. unsigned char type_category[]
  91. #ifdef SYMTAB
  92. ={    type_UNDECL,
  93.     type_INTEGER,
  94.     type_REAL,
  95.     type_REAL,
  96.     type_COMPLEX,
  97.     type_COMPLEX,
  98.     type_LOGICAL,
  99.     type_STRING,
  100.     type_INTEGER,
  101.     type_GENERIC,
  102.     type_SUBROUTINE,
  103. }
  104. #endif
  105. ;
  106.     /* Equivalence types equate Real, DoubleP, Complex and Double
  107.        Complex, for use in checking mixed equivalence and mixed
  108.        common, since it is standard and portable to interpret complex
  109.        as a pair of real values: real part and imag part */
  110. SYM_SHARED
  111. unsigned char equiv_type[]
  112. #ifdef SYMTAB
  113. ={    type_UNDECL,
  114.     type_INTEGER,
  115.     type_REAL,
  116.     type_REAL,
  117.     type_REAL,
  118.     type_REAL,
  119.     type_LOGICAL,
  120.     type_STRING,
  121.     type_INTEGER}
  122. #endif
  123. ;
  124.  
  125. typedef unsigned char BYTE;
  126.  
  127.         /* Array of class and type name translations */
  128. SYM_SHARED
  129. char *class_name[]
  130. #ifdef SYMTAB
  131.  = {
  132.     "",
  133.     "subprog",
  134.     "common",
  135.     "stmt fun",
  136.     "label",
  137.     "namelist",
  138. }
  139. #endif
  140. ;
  141. SYM_SHARED
  142. char *type_name[]        /* Type names as used in warnings etc.  */
  143. #ifdef SYMTAB
  144.  = {
  145.     "undf",
  146.     "intg",
  147.     "real",
  148.     "dble",
  149.     "cplx",
  150.     "dcpx",
  151.     "logl",
  152.     "char",
  153.     "holl",
  154.     "genr",
  155.     "subr",
  156.     "comm",
  157.     "prog",
  158.     "data",
  159.     "labl",
  160.     "naml",
  161. }
  162. #endif
  163. ;
  164.  
  165. SYM_SHARED
  166. char *type_table[]        /* Names as used in FORTRAN statements */
  167. #ifdef SYMTAB
  168.  =  {
  169.     "??ERROR??",
  170.     "INTEGER",
  171.     "REAL",
  172.     "DOUBLE PRECISION",
  173.     "COMPLEX",
  174.     "DOUBLE COMPLEX",        /* could be "COMPLEX*16" too */
  175.     "LOGICAL",
  176.     "CHARACTER",
  177. /* The rest do not appear in actual use, here for completeness only */
  178.     "HOLLERITH",
  179.     "GENERIC",
  180.     "SUBROUTINE",
  181.     "COMMON",
  182.     "PROGRAM",
  183.     "BLOCK DATA",
  184.     "LABEL",
  185.     "NAMELIST",
  186.     }
  187. #endif
  188. ;
  189.  
  190.  
  191. /* Here declare typical sizes of objects of each data type, for use in
  192. checking argument and common block size matchups.  BpW (bytes per word)
  193. is defined in ftnchek.h */
  194.  
  195.  
  196. SYM_SHARED
  197. BYTE type_size[]
  198. #ifdef SYMTAB
  199. ={
  200.     0, /*undf*/
  201.       BpW, /*intg*/
  202.       BpW, /*real*/
  203.     2*BpW, /*dble*/
  204.     2*BpW, /*cplx*/
  205.     4*BpW, /*dcpx*/
  206.       BpW, /*logl*/
  207.     1, /*char*/
  208.       BpW, /*holl*/
  209.     0, /*genr*/
  210.     0, /*subr*/
  211.     0, /*comm*/
  212.     0, /*prog*/
  213.     0, /*data*/
  214.     0, /*labl*/
  215.     0, /*naml*/
  216. }
  217. #endif
  218. ;
  219.  
  220.  
  221.  
  222.         /* implicit and default typing lookup table.  Two extra spots
  223.            provided to accommodate '$' and '_' too.  The size defns
  224.            should accommodate EBCDIC as well as ASCII. */
  225. SYM_SHARED
  226. int implicit_type[('Z'-'A'+1)+2],    /* indexed by [char - 'A'] */
  227.     implicit_size[('Z'-'A'+1)+2];
  228. SYM_SHARED
  229. char *implicit_len_text[('Z'-'A'+1)+2];
  230.  
  231.  
  232.     /* Declaration of Token data structure.  N.B. do not change without
  233.        consulting preamble of fortran.y for uses with nonterminals.
  234.      */
  235.             /* temporary equivs for future separate fields */
  236. #ifndef TOKEN_TYPE_SEPARATE /* define this to unequivalence type==class */
  237. #define TOK_type class
  238. #endif
  239. #ifndef TOKEN_FLAGS_SEPARATE /* define this to unequivalence flags==subclass */
  240. #define TOK_flags subclass
  241. #endif
  242.                 /* these are for array-bounds tokens */
  243. #define TOK_dims TOK_type
  244. #define TOK_elts TOK_flags
  245.  
  246. #define TOK_start TOK_type
  247. #define TOK_end  TOK_flags
  248.  
  249.  
  250. struct tokstruct {
  251.     union {
  252.         long integer;
  253.         DBLVAL dbl;
  254.         char *string;
  255.     } value;
  256.     struct tokstruct
  257.       *left_token,        /* Left child in expr tree */
  258.       *next_token;        /* Right child or next in linked list */
  259.     char *src_text;        /* Original text string of token */
  260.     long size;
  261. #ifndef TOK_type
  262.     long TOK_type;
  263. #endif
  264. #ifndef TOK_flags
  265.     unsigned long TOK_flags;
  266. #endif
  267.     long class,subclass;
  268.     unsigned line_num;    /* Line and column where token occurred */
  269.     unsigned col_num : 8;
  270.     unsigned size_is_adjustable : 1;
  271.     unsigned size_is_expression : 1;
  272. };
  273.  
  274. typedef struct tokstruct Token;
  275.  
  276. #define YYSTYPE Token    /* Type defn for yylval and Yacc stack */
  277.  
  278.  
  279.  
  280. SYM_SHARED
  281. unsigned long loc_symtab_top,    /* Next avail spot in local symbol table */
  282.    glob_symtab_top;        /* Ditto global */
  283.  
  284. SYM_SHARED
  285. unsigned long loc_str_top;    /* Top of local stringspace */
  286.  
  287. SYM_SHARED
  288.    unsigned long srctextspace_top; /* Top of token src text space */
  289.  
  290. SYM_SHARED
  291.    unsigned long ptrspace_top;    /* Top of pointer space */
  292.  
  293. SYM_SHARED
  294.    unsigned long param_info_space_top;    /* Top of parameter info space */
  295.  
  296. SYM_SHARED
  297.    unsigned long token_space_top,    /* Top of token space */
  298.          token_head_space_top;    /* Top of TL_head space */
  299.  
  300.     /* Counts of extra items dynamically allocated, for -resource */
  301. SYM_SHARED
  302.   int extra_locstrspace,
  303.       extra_paraminfospace,
  304.       extra_srctextspace,
  305.       extra_tokheadspace,
  306.       extra_tokspace,
  307.       extra_ptrspace;
  308.  
  309. SYM_SHARED
  310.   unsigned top_file_line_num;
  311.  
  312. SYM_SHARED
  313.   int global_save;    /* module contains SAVE with no list */
  314.  
  315.         /* Define names for anonymous things */
  316. #ifdef SYMTAB
  317. char blank_com_name[] = "%BLANK",  /* id for blank common entry in symtab */
  318.      unnamed_prog[]="%MAIN",      /* id for unnamed program module */
  319.      unnamed_block_data[]="%DAT00";  /* id for unnamed block data module */
  320. int  block_data_number=0;       /* count of multiple anonymous block data */
  321. #else
  322. extern char blank_com_name[],
  323.         unnamed_prog[],
  324.         unnamed_block_data[];
  325. extern int block_data_number;
  326. #endif
  327.  
  328.                 /* Symbol table argument list declarations */
  329.  
  330. typedef union {        /* InfoUnion: misc info about symtab entry */
  331.          unsigned long array_dim;    /* array size and no. of dims */
  332.          struct ALHead *arglist;    /* ptr to func/subr argument list */
  333.          struct CMHead *comlist;    /* ptr to common block list */
  334.          struct TLHead *toklist;  /* ptr to token list */
  335.          struct IInfo *intrins_info;/* ptr to intrinsic func info */
  336.          struct PInfo *param;    /* parameter information field */
  337. } InfoUnion;
  338.  
  339. typedef struct {    /* ArgListElement: holds subprog argument data */
  340.     char *name;        /* name of dummy arg or text of actual arg */
  341.     InfoUnion info;
  342.     long size;
  343.     BYTE type;
  344.     unsigned is_lvalue: 1,
  345.          set_flag: 1,
  346.          assigned_flag: 1,
  347.          used_before_set: 1,
  348.          array_var: 1,
  349.          array_element: 1,
  350.          declared_external: 1;
  351. } ArgListElement;
  352.  
  353.  
  354. typedef struct ALHead {        /* ArgListHeader: head node of argument list */
  355.     long size;
  356.     BYTE type;
  357.     short numargs;
  358.     ArgListElement *arg_array;
  359.     struct gSymtEntry *module;
  360.     char *filename,*topfile;
  361.     unsigned
  362.          line_num,top_line_num,
  363.          is_defn: 1,
  364.          is_call: 1,
  365.          external_decl: 1,    /* EXTERNAL decl, not arg list */
  366.              actual_arg: 1;    /* subprog passed as arg */
  367.     struct ALHead *next;
  368. } ArgListHeader;
  369.  
  370.         /* Symbol table common block list declarations */
  371.  
  372. typedef struct {    /* ComListElement: holds common var data */
  373.     char *name;        /* name of common variable */
  374.     unsigned long dimen_info;
  375.     long size;
  376.     BYTE type;
  377.     unsigned        /* copies of flags from symtab */
  378.       used:1,
  379.       set:1,
  380.       used_before_set:1,
  381.       assigned:1;
  382. } ComListElement;
  383.  
  384. typedef struct CMHead {    /* ComListHeader: head node of common var list */
  385.     short numargs;
  386.     unsigned line_num,top_line_num;
  387.     ComListElement *com_list_array;
  388.     struct gSymtEntry *module;
  389.     char *filename,*topfile;
  390.     struct CMHead *next;
  391.     unsigned
  392.       any_used:1,        /* any of its variables accessed */
  393.       any_set:1,        /* any of its variables set */
  394.       saved:1;        /* declared in SAVE statement */
  395. } ComListHeader;
  396.  
  397.  
  398. typedef struct TLHead {    /* TokenListHeader: head node of token list */
  399.     Token *tokenlist;
  400.     struct TLHead *next;
  401.     char *filename;
  402.     unsigned line_num, top_line_num;
  403.     unsigned
  404.       external_decl:1,
  405.       actual_arg:1;
  406. } TokenListHeader;
  407.  
  408.  
  409.             /* Structure for intrinsic-function info */
  410. typedef struct IInfo{
  411.     char *name;
  412.     short num_args,
  413.           arg_type,
  414.           result_type;
  415.     unsigned short
  416.           intrins_flags;    /* nonstandard,  mixed arg types */
  417. } IntrinsInfo;
  418.  
  419.             /* Structure for parameter info */
  420. typedef struct PInfo{
  421.     char *src_text;        /* source text of parameter value */
  422.     union {
  423.       long integer;        /* integer value */
  424.       DBLVAL dbl;        /* float value */
  425.       char *string;        /* character string value */
  426.     } value;
  427.     int seq_num;        /* position in parameter definitions */
  428. } ParamInfo;
  429.     
  430.     /* Define special num_args values for intrinsics that have
  431.        variable numbers of arguments. */
  432. #define I_1or2    (-1)        /* 1 or 2 arguments */
  433. #define I_2up    (-2)        /* 2 or more arguments */
  434. #define I_0or1    (-3)        /* 0 or 1 argument */
  435.  
  436.             /* for intrins_flags field */
  437.  
  438.     /* Integer-valued intrinsics that are evaluated if args const */
  439. #define I_ABS        0x1
  440. #define I_SIGN        0x2
  441. #define I_DIM        0x3
  442. #define I_MOD        0x4
  443. #define I_MAX        0x5
  444. #define I_MIN        0x6
  445. #define I_ICHAR        0x7
  446. #define I_LEN        0x8
  447. #define I_INDEX        0x9
  448. #define I_EVALUATED    0xf    /* any bit of digit set */
  449.  
  450.         /* Various properties of intrinsics*/
  451. #define I_F77         0x00    /* Standard intrinsic (no flag: placeholder) */
  452. #define I_NONF77    0x10    /* Nonstandard */
  453. #define I_MIXED_ARGS    0x20    /* Has mixed arg types */
  454. #define I_NONPURE    0x40    /* Arg need not be set when called */
  455. #define I_C_TO_R    0x80    /* Complex -> real in generic form */
  456. #define I_NOTARG    0x100    /* Not allowed as actual argument */
  457. #define I_SP_R        0x200    /* special for REAL function */
  458. #define I_CHAR        0x400    /* special handling for CHAR function */
  459.  
  460.             /* Structure for call-tree child list */
  461. typedef struct childlist {
  462.   struct gSymtEntry *child;    /* Pointer to child's symtab entry */
  463.   struct childlist *next;/* Pointer to next child on list */
  464. } ChildList;
  465.  
  466.         /*  Identifier symbol table declaration */
  467.  
  468.  
  469. typedef struct lSymtEntry{
  470.     char *name;             /* Identifier name in stringspace */
  471.     InfoUnion info;
  472.     union{
  473.       char *text;        /* Source text string */
  474.       char **textvec;    /* List of source text strings */
  475.       TokenListHeader *toklist; /* for namelist & common block makedecls */
  476.     } src;
  477.     struct lSymtEntry *equiv_link;    /* Link for equivalence lists */
  478.     long size;        /* Size of object in bytes */
  479.     BYTE  type;        /* Type & storage class: see macros below */
  480.             /* Flags */
  481.     unsigned
  482.          used_flag: 1,    /* value is accessed (read from variable) */
  483.          set_flag: 1,    /* variable is set or passed as subr arg */
  484.          assigned_flag: 1,    /* value is really set (by assignment stmt) */
  485.          used_before_set: 1,/* set_flag is not set when used_flag is set */
  486.          is_current_module: 1, /* this symtab entry is the main module */
  487.          library_module: 1,    /* module was processed in -library mode */
  488.          array_var: 1,    /* variable is dimensioned */
  489.          common_var: 1,    /* variable is in common */
  490.          entry_point: 1,    /* name of an entry point */
  491.          parameter: 1,    /* name of a parameter */
  492.          argument: 1,    /* dummy argument */
  493.          external: 1,    /* function or subr called by this routine */
  494.          intrinsic: 1,    /* intrinsic function */
  495.          saved: 1,        /* named in SAVE statement */
  496.          invoked_as_func: 1, /* usage as f(x) was seen */
  497.          defined_in_include: 1, /* to suppress some warnings if unused */
  498.          declared_external: 1, /* explicitly declared external */
  499.          declared_intrinsic: 1; /* explicitly declared intrinsic */
  500.          unsigned size_is_adjustable : 1; /* CHARACTER*(*) declaration */
  501.          unsigned size_is_expression : 1; /* CHARACTER*(expr) declaration */
  502. } Lsymtab;
  503.  
  504. typedef struct gSymtEntry{    /* Global symbol table element */
  505.     char *name;             /* Identifier name in stringspace */
  506.     InfoUnion info;
  507.     union {
  508.       struct childlist *child_list; /* List of callees (for module) */
  509.       struct gSymtEntry *module; /* Module (for interior entry) */
  510.     } link;
  511.     long size;
  512.     BYTE  type;        /* Type & storage class: see macros below */
  513.             /* Flags.  See remarks above */
  514.     unsigned
  515.          used_flag: 1,
  516.          set_flag: 1,
  517.          assigned_flag: 1,
  518.          used_before_set: 1,
  519.          library_module: 1,
  520.          internal_entry: 1,    /* entry point other than at the top */
  521.          invoked_as_func: 1,
  522.          visited: 1,       /* this entry point is in call tree */
  523.          visited_somewhere: 1, /* some entry point of module is in call tree */
  524.          defined: 1,    /* is defined somewhere */
  525.          defined_in_include: 1,
  526.          declared_external: 1;
  527. } Gsymtab;
  528.  
  529.  
  530.         /*  Identifier hashtable declaration  */
  531.  
  532. typedef struct hashEntry {
  533.     char    *name;        /* Identifier name in stringspace */
  534.     Lsymtab    *loc_symtab,    /* Local symtab entry for vars etc. */
  535.         *com_loc_symtab;/* Local symtab entry for common blocks */
  536.     Gsymtab    *glob_symtab,    /* Global symtab entry for vars etc. */
  537.         *com_glob_symtab;/* Global symtab entry for common blocks */
  538. } HashTable;
  539.  
  540.  
  541.                 /* Struct for chunks of string space */
  542. typedef struct STSpace {
  543.   struct STSpace *next;
  544.   char strspace[STRSPACESZ];
  545. } StrSpace;
  546.  
  547.                 /* Struct for providing chunks of space
  548.                    for parameter info. */
  549. typedef struct PISpace {
  550.   struct PISpace *next;
  551.   ParamInfo paraminfospace[PARAMINFOSPACESZ];
  552. } ParamInfoSpace;
  553.  
  554.                 /* Struct for providing chunks of space
  555.                    for token list headers for arg lists etc. */
  556. typedef struct THSpace {
  557.   struct THSpace *next;
  558.   TokenListHeader tokheadspace[TOKHEADSPACESZ];
  559. } TokHeadSpace;
  560.  
  561.  
  562.                 /* Struct for providing chunks of space
  563.                    for tokens for arg lists etc.  */
  564. typedef struct TSpace {
  565.   struct TSpace *next;
  566.   Token tokenspace[TOKENSPACESZ];
  567. } TokenSpace;
  568.  
  569.                 /* Struct for providing chunks of space
  570.                    for pointers to array & param text */
  571. typedef struct PSpace {
  572.   struct PSpace *next;
  573.   char * ptrspace[PTRSPACESZ];
  574. } PtrSpace;
  575.  
  576.  
  577.         /* Macro to zero out symbol table entry */
  578.  
  579. #define clear_symtab_entry(S) {register int i;\
  580.                  for(i=0;i<sizeof(*S);i++)((char*)S)[i]=0;}
  581.  
  582.  
  583.     /* These macros pack and unpack datatype and storage class in type
  584.        field of symbol table entry. Datatype is least 4 bits. */
  585.  
  586. #define datatype_of(TYPE) ((unsigned)((TYPE) & 0xF))
  587. #define storage_class_of(TYPE) ((unsigned)((TYPE) >> 4))
  588. #define type_byte(SCLASS,DTYPE) ((unsigned)(((SCLASS)<<4) + (DTYPE)))
  589.  
  590.  
  591.     /* This macro is for pattern matching in flag checking */
  592.  
  593. #define flag_combo(A,B,C) (((A)<<2) | ((B)<<1) | (C))
  594.  
  595.  
  596.     /* These macros are for dimensions & sizes of arrays */
  597.  
  598. #define array_dims(dim_info) ((dim_info)&0xF)
  599. #define array_size(dim_info) ((dim_info)>>4)
  600. #define array_dim_info(dim,size) (((long)(size)<<4)+(dim))
  601.  
  602.  
  603.  
  604.         /* Defns used by expression type propagation mechanisms
  605.            in fortran.y and exprtype.c  The flags go in token.subclass
  606.          */
  607.  
  608. #define make_true(flag,x) ((x) |= (flag))        /* x.flag <-- true   */
  609. #define make_false(flag,x) ((x) &= ~(flag))        /* x.flag <-- false  */
  610. #define is_true(flag,x) ((x) & (flag))            /* x.flag == true?   */
  611. #define copy_flag(flag,x,y)  ((x) |= ((y)&(flag)))    /* x.flag <-- y.flag */
  612.  
  613. #define ID_EXPR            0x1    /* a variable */
  614. #define LVALUE_EXPR        0x2    /* assignable */
  615. #define CONST_EXPR        0x4    /* compile-time constant per std 6.7*/
  616. #define LIT_CONST        0x8    /* a number or string literal */
  617. #define ARRAY_ID_EXPR        0x10    /* an array or array element */
  618. #define ARRAY_ELEMENT_EXPR    0x20     /* an array element */
  619. #define INT_QUOTIENT_EXPR    0x40     /* contains INT/INT */
  620. #define STMT_FUNCTION_EXPR    0x80
  621. #define PARAMETER_EXPR        0x100/* == CONST_EXPR || intrinsic || **real */
  622. #define EVALUATED_EXPR        0x200  /* token.value has value of expr */
  623. #define SET_FLAG        0x400  /* id may be set */
  624. #define ASSIGNED_FLAG        0x800  /* id is set in assignment stmt */
  625. #define USED_BEFORE_SET        0x1000  /* id used beforre set */
  626. #define COMPLEX_FLAG        0x2000    /* remembers complex_const_allowed */
  627. #define CHAR_ID_EXPR        0x4000    /* char var or array elt not substr */
  628. #define IN_ASSIGN        0x8000    /* for tracking assgn stmt lhs */
  629. #define COMMA_FLAG         0x10000/* keeps track of extra or missing
  630.                          commas in exprlists (obsolete) */
  631. #define NONSTD_USAGE_FLAG    0x20000    /* concentrator for -f77 warnings */
  632. #define SYNTAX_ERROR_FLAG    0x40000    /* concentrator for syntax errors */
  633.  
  634. #ifdef DYNAMIC_TABLES        /* tables will be mallocked at runtime */
  635. SYM_SHARED
  636. Lsymtab    *loc_symtab
  637. #ifdef SYMTAB
  638.   =(Lsymtab *)NULL
  639. #endif
  640. ;
  641. SYM_SHARED
  642. Gsymtab *glob_symtab
  643. #ifdef SYMTAB
  644.   =(Gsymtab *)NULL
  645. #endif
  646. ;
  647. SYM_SHARED
  648. HashTable *hashtab
  649. #ifdef SYMTAB
  650.   =(HashTable *)NULL
  651. #endif
  652. ;
  653.  
  654. #else                /* static tables declared at compile time */
  655.         /* Each major table is housed in a separate file so that
  656.            on IBM PC architecture with huge memory model
  657.            each will be in its own 64K segment not all in one. */
  658. #ifndef PLSYMTAB
  659. extern
  660. #endif
  661. Lsymtab    loc_symtab[LOCSYMTABSZ]; /* Local identifiers */
  662. #ifndef PGSYMTAB
  663. extern
  664. #endif
  665. Gsymtab glob_symtab[GLOBSYMTABSZ]; /* Global identifiers: subrs and com blks */
  666. #ifndef EXPRTYPE
  667. extern
  668. #endif
  669. HashTable hashtab[HASHSZ];    /* Hash table for identifier lookup */
  670.  
  671. #endif/* end static tables */
  672.  
  673.     /* The following tables start life as statically declared
  674.        tables, but when add'l space is needed, new structs of same
  675.        kind will be allocated and linked via next field of struct.
  676.        Because they are dynamically extended, they are not in
  677.        the DYNAMIC_TABLES section or its complement above.  Note
  678.        that as global variables they start off at 0, so next field
  679.        of each is implicitly initialized to NULL.  */
  680.  
  681. #ifndef FORLEX
  682. extern
  683. #endif
  684. TokenSpace tokspace;    /* Tokens for arg lists etc */
  685.  
  686. #ifndef PROJECT
  687. extern
  688. #endif
  689. TokHeadSpace tokheadspace;/* Tokenlist headers */
  690.  
  691. #ifndef PROJECT
  692. extern
  693. #endif
  694. ParamInfoSpace paraminfospace;/* Parameter info structs */
  695.  
  696. #ifndef PROJECT
  697. extern
  698. #endif
  699. PtrSpace ptrspace;    /* Space for storing arrays of pointers */
  700.  
  701. #ifndef SYMTAB
  702. extern
  703. #endif
  704. StrSpace lstrspace;    /* String space for local identifiers */
  705.  
  706. #ifndef SYMTAB
  707. extern
  708. #endif
  709. StrSpace srctextspace;/* String space for token source text */
  710.  
  711.         /* Shared routines */
  712.  
  713.             /* in fortran.y/fortran.c */
  714. void
  715. check_seq_header();
  716.  
  717.             /* in plsymtab.c */
  718. void
  719. debug_symtabs(), print_loc_symbols();
  720.  
  721.             /* in symtab.c */
  722. void
  723. check_loose_ends(),
  724. call_func(), call_subr(), declare_type(), def_arg_name(),
  725. def_array_dim(), def_com_block(), def_com_variable(),
  726. def_equiv_name(), def_ext_name(), def_function(), def_intrins_name(),
  727. def_namelist(), def_namelist_item(), def_parameter(),
  728. def_stmt_function(), do_ASSIGN(), do_assigned_GOTO(), do_ENTRY(),
  729. do_RETURN(), equivalence(),
  730. process_lists(), ref_array(), ref_namelist(), ref_variable(),
  731. save_com_block(), save_variable(), set_implicit_type(),
  732. stmt_function_stmt(),use_actual_arg(), use_implied_do_index(),
  733. use_io_keyword(), use_special_open_keywd(),
  734. use_lvalue(), use_parameter(),
  735. use_variable();
  736.  
  737. Token
  738. *new_token();
  739.  
  740. Gsymtab
  741.  *install_global();
  742.  
  743. unsigned
  744. hash_lookup();
  745.  
  746. int
  747. def_curr_module(), get_size(), get_type(), int_expr_value(), substring_size();
  748.  
  749. char *
  750. char_expr_value();
  751.  
  752. DBLVAL
  753. float_expr_value();
  754.  
  755. char * get_size_text();
  756.  
  757. char *
  758. token_name();
  759.                 /* in hash.c (now symtab.c) */
  760. unsigned long
  761. hash(), rehash();
  762.  
  763.             /* in exprtype.c */
  764. void
  765. binexpr_type(),unexpr_type(),assignment_stmt_type(),
  766. func_ref_expr(),primary_id_expr(),stmt_fun_arg_cmp();
  767.  
  768. int
  769. intrins_arg_cmp();
  770.