home *** CD-ROM | disk | FTP | other *** search
/ The C Users' Group Library 1994 August / wc-cdrom-cusersgrouplibrary-1994-08.iso / vol_300 / 355_02 / slk2.exe / SPP / GLB.C < prev    next >
C/C++ Source or Header  |  1991-06-09  |  5KB  |  188 lines

  1. /*
  2.     New SPP -- global variable definitions.
  3.  
  4.     Source:  glb.c
  5.     Started: April 2, 1986
  6.     Version:
  7.         July 15, 1988
  8.         February 16, 1989
  9.             o s_disable added.
  10.             o fn_name made global.
  11.         June 22, 1989
  12.             o curly_ok_flag added.
  13.         Version 1.4A: July 28, 1989
  14.             o slc_flag added
  15.  
  16.  
  17.     PUBLIC DOMAIN SOFTWARE
  18.  
  19.     Sherlock, including the SPP, SDEL and SDIF programs, was placed in
  20.     the public domain on June 15, 1991, by its author,
  21.  
  22.         Edward K. Ream
  23.         166 North Prospect Ave.
  24.         Madison, WI 53705.
  25.         (608) 257-0802
  26.  
  27.     Sherlock may be used for any commercial or non-commercial purpose.
  28.  
  29.  
  30.     DISCLAIMER OF WARRANTIES
  31.  
  32.     Edward K. Ream (Ream) specifically disclaims all warranties,
  33.     expressed or implied, with respect to this computer software,
  34.     including but not limited to implied warranties of merchantability
  35.     and fitness for a particular purpose.  In no event shall Ream be
  36.     liable for any loss of profit or any commercial damage, including
  37.     but not limited to special, incidental consequential or other damages.
  38. */
  39. #define no_extern 1
  40. #include "spp.h"
  41.  
  42. /*
  43.     ========= increase stack size ========
  44. */
  45. #ifdef TURBOC
  46. extern unsigned _stklen = 0xf000;
  47. #endif
  48.  
  49. /*
  50.     ============= global variables =============
  51. */
  52.  
  53. /*
  54.     The next character of input.
  55. */
  56. char    ch = '@';
  57.  
  58. /*
  59.     Kludge for expr().
  60. */
  61. bool    curly_ok_flag = FALSE;    /* Allow { and } as valid delims.    */
  62.  
  63. /*
  64.     User Flags.
  65. */
  66. bool    insert_flag = FALSE;    /* TRUE if insert #include "sl.h"    */
  67. int    nest_flag   = FALSE;    /* TRUE if comments can nest.        */
  68. int     com_flag    = TRUE;    /* TRUE if comments are output.        */
  69. bool    entry_flag  = TRUE;    /* TRUE if Sherlock macros on entry.    */
  70. bool    exit_flag   = TRUE;    /* TRUE if Sherlock macros on exit.    */
  71. bool    loop_flag   = TRUE;    /* TRUE if Sherlock macros in loops.    */
  72. bool    printf_flag = TRUE;    /* TRUE if using printf for output.    */
  73. bool    usr_flag    = FALSE;    /* TRUE if using user output routines.    */
  74. bool    tick_flag   = FALSE;    /* TRUE if using count statistics only.    */
  75. bool    slc_flag    = TRUE;    /* TRUE if single-line comments valid.    */
  76.  
  77. /*
  78.     Spellings of ALL Sherlock macros.
  79. */
  80. char * mn_tab [] = {
  81.  
  82.     "RETURN_BOOL",    "RETURN_CHAR",     "RETURN_DOUBLE",
  83.     "RETURN_FLOAT",    "RETURN_INT",     "RETURN_LONG",
  84.     "RETURN_PTR",    "RETURN_STRING", "RETURN_UINT",
  85.     "RETURN_ULONG",    "RETURN_VOID",
  86.  
  87.     "SL_CLEAR",    "SL_DISABLE",    "SL_DUMP",    "SL_INIT",
  88.     "SL_NAME",    "SL_OFF",    "SL_ON",    "SL_PARSE",
  89.  
  90.     "STAT",        "STATB",    "STATX",
  91.     "TICK",        "TICKB",    "TICKN",    "TICKX",
  92.     "TRACE",    "TRACEB",    "TRACEN",    "TRACEX",
  93.     "TRACEP",    "TRACEPB",    "TRACEPN",    "TRACEPX",
  94.  
  95.     NULL
  96. };
  97.  
  98. /*
  99.     Spellings of macros generated by the code generators.
  100. */
  101. char *    r_bool    = "RETURN_BOOL";
  102. char *    r_char    = "RETURN_CHAR";
  103. char *    r_double= "RETURN_DOUBLE";
  104. char *    r_float    = "RETURN_FLOAT";
  105. char *    r_int    = "RETURN_INT";
  106. char *    r_long    = "RETURN_LONG";
  107. char *    r_ptr    = "RETURN_PTR";
  108. char *    r_string= "RETURN_STRING";
  109. char *    r_uint    = "RETURN_UINT";
  110. char *    r_ulong    = "RETURN_ULONG";
  111. char *    r_void    = "RETURN_VOID";
  112.  
  113. char *    s_init    = "SL_INIT";
  114. char *    s_parse    = "SL_PARSE";
  115.  
  116. char *    tick    = "TICK";
  117. char *    tickb    = "TICKB";
  118. char *    tickx    = "TICKX";
  119.  
  120. char *    pbtrace    = "TRACEPB";
  121. char *    ptrace    = "TRACEP";
  122.  
  123. /*
  124.     Globals for macro expansion.
  125.     p_rescan and m_flag are used by sysnext().
  126. */
  127. bool    m_flag = FALSE;        /* TRUE if expanding a macro.    */
  128. char    macro_buf[MAX_RTEXT];    /* Final macro buffer.        */
  129. char *    p_rescan;        /* Pointer into rescan_buf[].    */
  130.  
  131. /*
  132.     White space and held output.
  133. */
  134. char    hws_buf [MAX_HOLD];    /* Held white space.        */
  135. int    hws_count;        /* Count of held white space.    */
  136. char    hold_buf [MAX_HOLD];    /* Held non-white space.    */
  137. int    hold_count = 0;
  138. bool    hold_flag = TRUE;    /* TRUE if holding characters.    */
  139. int    ch_hold = FALSE;    /* TRUE if ch should be buffered. */
  140.  
  141. char    lws_buf [100];        /* Leading white space buffer.    */
  142. int    lws_count = 0;        /* Leading white space count.    */
  143. int    cnl_count = 0;        /* Consecutive newline count.    */
  144. int    last_tok  = NULL_TOK;    /* Previous token.        */
  145. int    last_ch   = '@';    /* Last char.            */
  146. bool    first_tok = FALSE;    /* True if token is first in line. */
  147. bool    con_flag = FALSE;    /* True if in PP constant expr. */
  148.  
  149. /*
  150.     The name of the current function, or NULL.
  151. */
  152. char *    fn_name = "";
  153.  
  154. /*
  155.     Globals describing tokens.
  156.  
  157.     The code assumes that no token or string will ever be longer than
  158.     MAX_SYMBOL.  If that ever is not so the program may crash.  Thus,
  159.     MAX_SYMBOL should be very large -- say 1000 or more.
  160. */
  161. en_tokens token = NULL_TOK;    /* The current token. */
  162. int    t_subtype;        /* The subtype of token class.        */
  163. char    t_symbol [MAX_SYMBOL];    /* The spelling of the token.        */
  164. int    t_length;        /* The length of the token (in the text)*/
  165. long    t_value;        /* Value of integer constants.        */
  166.  
  167. /*
  168.     The following globals are set ONLY by the system module and
  169.     used by the preprocessor.
  170. */
  171. char *    t_file    = NULL;    /* Name of current input file.    */
  172. int    t_line    = 0;        /* Line number within file.    */
  173. int    t_inlevel = -1;        /* Current input file level.    */
  174.  
  175. /*
  176.     Globals for use internally to the token routines.
  177. */
  178. bool    t_ifstack [MAX_IF];    /* Stack for nexted #if's    */
  179. int    t_iflevel  = 0;        /* Nexting depth of #if's    */
  180. long    t_errcount = 0;        /* Number of errors seen.    */
  181.  
  182. /*
  183.     Defines for the path table.
  184.     This table is used to search for #include files.
  185. */
  186. char *    paths [MAX_PATHS];    /* Pointers to path names.    */
  187. int    n_paths = 0;        /* Number of paths defined.    */
  188.