home *** CD-ROM | disk | FTP | other *** search
/ Acorn User 11 / AUCD11B.iso / LANGUAGES / WraithSet / AwkStuff / MawkSrc / h / mawk < prev    next >
Text File  |  1996-11-08  |  5KB  |  178 lines

  1.  
  2. /********************************************
  3. mawk.h
  4. copyright 1991-94, Michael D. Brennan
  5.  
  6. This is a source file for mawk, an implementation of
  7. the AWK programming language.
  8.  
  9. Mawk is distributed without warranty under the terms of
  10. the GNU General Public License, version 2, 1991.
  11. ********************************************/
  12.  
  13.  
  14. /*   $Log: mawk.h,v $
  15.  *   Revision 1.10  1996/08/25 19:31:04  mike
  16.  *   Added work-around for solaris strtod overflow bug.
  17.  *
  18.  * Revision 1.9  1995/06/18  19:42:21  mike
  19.  * Remove some redundant declarations and add some prototypes
  20.  *
  21.  * Revision 1.8  1995/06/18  19:17:48  mike
  22.  * Create a type Int which on most machines is an int, but on machines
  23.  * with 16bit ints, i.e., the PC is a long.  This fixes implicit assumption
  24.  * that int==long.
  25.  *
  26.  * Revision 1.7  1995/06/09  22:57:17  mike
  27.  * parse() no longer returns on error
  28.  *
  29.  * Revision 1.6  1994/12/13  00:09:55  mike
  30.  * rt_nr and rt_fnr for run-time error messages
  31.  *
  32.  * Revision 1.5  1994/12/11  23:25:09  mike
  33.  * -Wi option
  34.  *
  35.  * Revision 1.4  1994/12/11  22:14:18  mike
  36.  * remove THINK_C #defines.  Not a political statement, just no indication
  37.  * that anyone ever used it.
  38.  *
  39.  * Revision 1.3  1993/07/07  00:07:41  mike
  40.  * more work on 1.2
  41.  *
  42.  * Revision 1.2  1993/07/04  12:52:06  mike
  43.  * start on autoconfig changes
  44.  *
  45. */
  46.  
  47.  
  48. /*  mawk.h  */
  49.  
  50. #ifndef  MAWK_H
  51. #define  MAWK_H   
  52.  
  53. #include  "nstd.h"
  54. #include <stdio.h>
  55. #include "types.h"
  56.  
  57. #ifdef   DEBUG
  58. #define  YYDEBUG  1
  59. extern  int   yydebug ;  /* print parse if on */
  60. extern  int   dump_RE ;
  61. #endif
  62.  
  63. extern  short  posix_space_flag , interactive_flag ;
  64.  
  65.  
  66. /*----------------
  67.  *  GLOBAL VARIABLES
  68.  *----------------*/
  69.  
  70. /* a well known string */
  71. extern STRING  null_str ;
  72.  
  73. #ifndef TEMPBUFF_GOES_HERE
  74. #define EXTERN    extern
  75. #else
  76. #define EXTERN   /* empty */
  77. #endif
  78.  
  79. /* a useful scratch area */
  80. EXTERN  union {
  81. STRING  *_split_buff[MAX_SPLIT] ;
  82. char    _string_buff[MIN_SPRINTF] ;
  83. } tempbuff ;
  84.  
  85. /* anonymous union */
  86. #define  string_buff    tempbuff._string_buff
  87. #define  split_buff    tempbuff._split_buff
  88.  
  89. #define  SPRINTF_SZ    sizeof(tempbuff)
  90.  
  91. /* help with casts */
  92. extern int mpow2[] ;
  93.  
  94.  
  95.  /* these are used by the parser, scanner and error messages
  96.     from the compile  */
  97.  
  98. extern  char *pfile_name ; /* program input file */
  99. extern  int current_token ;
  100. extern  unsigned  token_lineno ; /* lineno of current token */
  101. extern  unsigned  compile_error_count ;
  102. extern  int  paren_cnt, brace_cnt ;
  103. extern  int  print_flag, getline_flag ;
  104. extern  short mawk_state ;
  105. #define EXECUTION       1  /* other state is 0 compiling */
  106.  
  107.  
  108. extern  char *progname ; /* for error messages */
  109. extern  unsigned rt_nr , rt_fnr ; /* ditto */
  110.  
  111. /* macro to test the type of two adjacent cells */
  112. #define TEST2(cp)  (mpow2[(cp)->type]+mpow2[((cp)+1)->type])
  113.  
  114. /* macro to get at the string part of a CELL */
  115. #define string(cp) ((STRING *)(cp)->ptr)
  116.  
  117. #ifdef   DEBUG
  118. #define cell_destroy(cp)  DB_cell_destroy(cp)
  119. #else
  120.  
  121. #define cell_destroy(cp)   if ( (cp)->type >= C_STRING &&\
  122.                            -- string(cp)->ref_cnt == 0 )\
  123.                         zfree(string(cp),string(cp)->len+STRING_OH);else
  124. #endif
  125.  
  126. /*  prototypes  */
  127.  
  128. void  PROTO( cast1_to_s, (CELL *) ) ;
  129. void  PROTO( cast1_to_d, (CELL *) ) ;
  130. void  PROTO( cast2_to_s, (CELL *) ) ;
  131. void  PROTO( cast2_to_d, (CELL *) ) ;
  132. void  PROTO( cast_to_RE, (CELL *) ) ;
  133. void  PROTO( cast_for_split, (CELL *) ) ;
  134. void  PROTO( check_strnum, (CELL *) ) ;
  135. void  PROTO( cast_to_REPL, (CELL *) ) ;
  136. Int   PROTO( d_to_I, (double)) ;
  137.  
  138. #define d_to_i(d)     ((int)d_to_I(d))
  139.  
  140.  
  141. int   PROTO( test, (CELL *) ) ; /* test for null non-null */
  142. CELL *PROTO( cellcpy, (CELL *, CELL *) ) ;
  143. CELL *PROTO( repl_cpy, (CELL *, CELL *) ) ;
  144. void  PROTO( DB_cell_destroy, (CELL *) ) ;
  145. void  PROTO( overflow, (char *, unsigned) ) ;
  146. void  PROTO( rt_overflow, (char *, unsigned) ) ;
  147. void  PROTO( rt_error, ( char *, ...) ) ;
  148. void  PROTO( mawk_exit, (int) ) ;
  149. void PROTO( da, (INST *, FILE *)) ;
  150. char *PROTO( str_str, (char*, char*, unsigned) ) ;
  151. char *PROTO( rm_escape, (char *) ) ;
  152. char *PROTO( re_pos_match, (char *, PTR, unsigned *) ) ;
  153. int   PROTO( binmode, (void)) ;
  154.  
  155.  
  156. int   PROTO( close, (int) ) ;
  157. int   PROTO( read, (int , PTR, unsigned) ) ;
  158.  
  159. void PROTO ( parse, (void) ) ;
  160. int  PROTO ( yylex, (void) ) ;
  161. int  PROTO( yyparse, (void) ) ;
  162. void PROTO( yyerror, (char *) ) ;
  163. void PROTO( scan_cleanup, (void)) ;
  164.  
  165. void PROTO( bozo, (char *) ) ;
  166. void PROTO( errmsg , (int, char*, ...) ) ;
  167. void PROTO( compile_error, ( char *, ...) ) ;
  168.  
  169. void  PROTO( execute, (INST *, CELL *, CELL *) ) ;
  170. char *PROTO( find_kw_str, (int) ) ;
  171.  
  172. #ifdef HAVE_STRTOD_OVF_BUG
  173. double PROTO(strtod_with_ovf_bug, (const char*, char**)) ;
  174. #define strtod  strtod_with_ovf_bug
  175. #endif
  176.  
  177. #endif  /* MAWK_H */
  178.