home *** CD-ROM | disk | FTP | other *** search
/ The C Users' Group Library 1994 August / wc-cdrom-cusersgrouplibrary-1994-08.iso / vol_100 / 163_01 / cc1.c < prev    next >
Text File  |  1991-01-06  |  7KB  |  175 lines

  1. /*
  2. ** Small-C Compiler Version 2.0
  3. **
  4. ** Portions Copyright 1982 J. E. Hendrix
  5. **
  6. ** Converted to 8088/PCDOS by D. R. Hicks
  7. **
  8. ** Part 1
  9. */
  10. #include "errno.h"
  11. #include "stdio.h"
  12. #include "cc.def"
  13.  
  14. /*
  15. ** miscellaneous storege
  16. */
  17. char
  18.   alarm,            /* audible alarm on errors?              */
  19.   monitor,          /* monitor function headers?             */
  20.   pause,            /* pause for operator on errors?         */
  21. #ifdef DYNAMIC
  22.   *stage,           /* output staging buffer                 */
  23.   *symtab,          /* symbol table                          */
  24.   *litq,            /* literal pool                          */
  25. #ifdef HASH
  26.   *macn,            /* macro name buffer                     */
  27. #endif
  28.   *macq,            /* macro string buffer                   */
  29.   *pline,           /* parsing buffer                        */
  30.   *mline,           /* macro buffer                          */
  31. #else
  32.   stage[STAGESIZE],
  33.   symtab[SYMTBSZ],
  34.   litq[LITABSZ],
  35. #ifdef HASH
  36.   mac[MACNSIZE],
  37. #endif
  38.  macq[MACQSIZE],
  39.  pline[LINESIZE],
  40.  mline[LINESIZE],
  41.  swq[SWTABSZ],
  42. #endif
  43.  *line,             /* points to pline or mline              */
  44.  *lptr,             /* ptr to either                         */
  45.  *glbptr,           /* points to next entries                */
  46.  *locptr,           /* ptr to next local symbol              */
  47.  *stagenext,        /* next addr in stage                    */
  48.  *stagelast,        /* last addr in stage                    */
  49.  quote[2],          /* literal string for '"'                */
  50.  *cptr,             /* work ptrs to any char buffer          */
  51.  *cptr2,
  52.  *cptr3,
  53.  msname[NAMESIZE],  /* macro symbol name array               */
  54.  ssname[NAMESIZE];  /* static symbol name array              */
  55.  int
  56. #ifdef STGOTO
  57.    nogo,            /* >0 disables goto statements           */
  58.    noloc,           /* >0 disables block locals              */
  59. #endif
  60.    op[16],          /* function addresses of binary operators */
  61.    op2[16],         /* same for unsigned operators           */
  62.    opindex,         /* index to matched operator             */
  63.    opsize,          /* size of operator in bytes             */
  64.    swactive,        /* true inside a switch                  */
  65.    swdefault,       /* default label #, else 0               */
  66.   *swnext,          /* address of next entry                 */
  67.   *swend,           /* address of last table entry           */
  68. #ifdef DYNAMIC
  69.   *wq,              /* while queue                           */
  70. #else
  71.    wq[WQTABSZ],
  72. #endif
  73. #ifdef CMD_LINE
  74.    argcs,           /* static argc                           */
  75.   *argvs,           /* static argv                           */
  76. #endif
  77.   *wqptr,           /* ptr to next entry                     */
  78.   litptr,           /* ptr to next entry                     */
  79.   macptr,           /* macro buffer index                    */
  80. #ifndef HASH
  81.   mack,             /* variable k for findmac routine        */
  82. #endif
  83.   pptr,             /* ptr to parsing buffer                 */
  84.   oper,             /* address of binary operator function   */
  85.   ch,               /* current character of line being scanned */
  86.   nch,              /* next character of line being scanned  */
  87.   declared,         /* # of local bytes declared, else -1 when done */
  88.   iflevel,          /* if... nest level                      */
  89.   skiplevel,        /* level at which #if... skipping started */
  90.   nxtlab,           /* next available label                  */
  91.   litlab,           /* label # assigned to literal pool      */
  92.   csp,              /* compiler relative stk ptr             */
  93.                     /*
  94.                      * set to zero at start of function
  95.                      * (after BP is pushed)
  96.                      * decremented by push
  97.                      * incremented by pop
  98.                      * top of stack is addressed by
  99.                      *   "[BP]-" outdec(-csp)
  100.                      */
  101.   argstk,           /* function arg sp                       */
  102.   argtop,
  103.   ncmp,             /* #open compound statements             */
  104.   errcnt,           /* error count */
  105.   errflag,          /* non-zero after 1st error in statement */
  106.   eof,              /* set non-zero on final input eof       */
  107.   input,            /* fd # for input file                   */
  108.   input2,           /* fd # for "include" file               */
  109.   output,           /* fd # for output file                  */
  110.   files,            /* non-zero if file list specified on command line */
  111.   filearg,          /* cur file arg index                    */
  112.   glbflag,          /* non-zero if internal globals          */
  113.   ctext,            /* non-zero to intermix c-source         */
  114.   ccode,            /* non-zero while parsing c-code         */
  115.                     /*     zero when passing assembly code   */
  116.   dmode,            /* non-zero when in DATASEG segment      */
  117.                     /*     zero when in CODESEG segment      */
  118.   listfp,           /* file pointer to list device           */
  119.   lastst,           /* last executed statement type          */
  120.  *iptr;             /* work ptr to any int buffer            */
  121.  
  122. #ifdef SEPARATE
  123. /*
  124. ** external references in part 2
  125. */
  126. extern int
  127.   addmac(), addsym(), addwhile(), alpha(), amatch(), blanks(),
  128.   bump(), clearstage(), col(), delwhile(), endst(), errdec(),
  129.   error(), externs(), findglb(), findloc(), gch(), getint(),
  130.   getlabel(), illname(), inbyte(), inline(), junk(),
  131.   kill(), lout(), match(), multidef(), needtoken(),
  132.   nextsym(), nl(), numeric(), outbyte(), outdec(), outstr(),
  133.   postlabel(), preprocess(), printlabel(), putint(),
  134.   readwhile(), setstage(), sout(), streq(), symname(),
  135.   upper();
  136.  
  137. /*
  138. ** external references in part 3
  139. */
  140. extern int
  141.   constexpr(), expression(), number(), qstr(),
  142.   test(), stowlit();
  143.  
  144. /*
  145. ** external references in part 4
  146. */
  147. extern int
  148.   add(), and(), asl(), asr(), comment2(), endfun(), defstora(),
  149.   div(), eq(), entry(), ge(), genzeros(),
  150.   gt(), header(), jump(), le(), lt(), mod(), modstk(),
  151.   mult(), ne(), or(), point(), ret(), sub(), startfun(), startglob(),
  152.   startlit(), sw(), trailer(), uge(), ugt(), ule(), ult(), xor();
  153. #endif
  154.  
  155. /*
  156. ** external references in C.LIB
  157. */
  158. extern int
  159.   index(), rindex(), strcpy(), strncpy(), strlen();
  160.  
  161. #include "cc11.c"
  162. #include "cc12.c"
  163. #include "cc13.c"
  164.  
  165. #ifndef SEPARATE
  166. #include "cc21.c"
  167. #include "cc22.c"
  168. #include "cc31.c"
  169. #include "cc32.c"
  170. #include "cc33.c"
  171. #include "cc41.c"
  172. #include "cc42.c"
  173. #endif
  174.  
  175.