home *** CD-ROM | disk | FTP | other *** search
/ Oakland CPM Archive / oakcpm.iso / cpm / misc / smc203.ark / CC1.C < prev    next >
Encoding:
C/C++ Source or Header  |  1983-07-28  |  5.5 KB  |  204 lines

  1.  
  2. /*
  3. ** Small-C Compiler Version 2.0
  4. **
  5. ** Copyright 1982 J. E. Hendrix
  6. **
  7. ** Part 1
  8. */
  9.  
  10. #include "stdiol.h"
  11. #include "cc.def"
  12.  
  13. /*
  14. ** miscellaneous storage
  15. */
  16. char
  17.  
  18. #ifdef OPTIMIZE
  19.   optimize, /* optimize output of staging buffer */
  20. #endif /* OPTIMIZE */
  21.  
  22.   alarm,    /* audible alarm on errors? */
  23.   monitor,  /* monitor function headers? */
  24.   pause,    /* pause for operator on errors? */
  25.   m80flg,   /* compile for M80 assembler? */
  26.  
  27. #ifdef DYNAMIC
  28.  *stage,    /* output staging buffer */
  29.  *symtab,   /* symbol table */
  30.  *litq,     /* literal pool */
  31.  
  32. #ifdef HASH
  33.  *macn,     /* macro name buffer */
  34. #endif /* HASH */
  35.  
  36.  *macq,     /* macro string buffer */
  37.  *pline,    /* parsing buffer */
  38.  *mline,    /* macro buffer */
  39.  
  40. #else /* DYNAMIC */
  41.   stage[STAGESIZE],
  42.   symtab[SYMTBSZ],
  43.   litq[LITABSZ],
  44.  
  45. #ifdef HASH
  46.   macn[MACNSIZE],
  47. #endif /* HASH */
  48.  
  49.   macq[MACQSIZE],
  50.   pline[LINESIZE],
  51.   mline[LINESIZE],
  52.   swq[SWTABSZ],
  53. #endif /* DYNAMIC */
  54.  
  55.  *line,     /* points to pline or mline */
  56.  *lptr,     /* ptr to either */
  57.  *glbptr,   /* ptrs to next entries */
  58.  *locptr,   /* ptr to next local symbol */
  59.  *stagenext,/* next addr in stage */
  60.  *stagelast,/* last addr in stage */
  61.   quote[2], /* literal string for '"' */
  62.  *cptr,     /* work ptrs to any char buffer */
  63.  *cptr2,
  64.  *cptr3,
  65.  
  66. #ifdef CMD_LINE
  67. #ifdef FULLC
  68.  *argvs[MAXARGS],   /* static copy of argv */
  69. #endif  /* FULLC */
  70. #endif  /* CMD_LINE */
  71.  
  72.   msname[NAMESIZE], /* macro symbol name array */
  73.   ssname[NAMESIZE]; /* static symbol name array */
  74.  
  75.  
  76. int
  77.  
  78. #ifdef STGOTO
  79.   nogo,     /* > 0 disables goto statements */
  80.   noloc,    /* > 0 disables block locals */
  81. #endif /* STGOTO */
  82.  
  83. /*
  84. ** the following two definitions are arrays of pointers to functions
  85. ** and should look like this:
  86. **      (*op)()[16],
  87. **      (*op2)()[16],
  88. ** but small-c cheats and declares an array of ints
  89. */
  90.   op[16],   /* function addresses of binary operators */
  91.   op2[16],  /* same for unsigned operators */
  92.   opindex,  /* index to matched operator */
  93.   opsize,   /* size of operator in bytes */
  94.   swactive, /* true inside a switch */
  95.   swdefault,/* default label #, else 0 */
  96.  *swnext,   /* address of next entry */
  97.  *swend,    /* address of last table entry */
  98.  
  99. #ifdef DYNAMIC
  100.  *wq,       /* while queue */
  101. #else /* DYNAMIC */
  102.   wq[WQTABSZ],
  103. #endif /* DYNAMIC */
  104.  
  105. #ifdef CMD_LINE
  106.   argcs,    /* static argc */
  107.  
  108. #ifdef N_CMD_LN
  109.  
  110. #ifndef FULLC
  111.   argvs[MAXARGS], /* static argv (new_cmd_line && !full_c) */
  112. #endif  /* FULLC */
  113.  
  114. #else  /* N_CMD_LN */
  115.  *argvs,    /* static argv (original version) */
  116. #endif  /* N_CMD_LN */
  117.  
  118. #endif /* CMD_LINE */
  119.  
  120.  *wqptr,    /* ptr to next entry */
  121.   litptr,   /* ptr to next entry */
  122.   macptr,   /* macro buffer index */
  123.  
  124. #ifndef HASH
  125.   mack,     /* variable k for findmac routine */
  126. #endif /* HASH */
  127.  
  128.   pptr,     /* ptr to parsing buffer */
  129.   oper,     /* address of binary operator function */
  130.   ch,       /* current character of line being scanned */
  131.   nch,      /* next character of line being scanned */
  132.   declared, /* # of local bytes declared, else -1 when done */
  133.   iflevel,  /* #if... nest level */
  134.   skiplevel,/* level at which #if... skipping started */
  135.   func1,    /* true for first function */
  136.   nxtlab,   /* next avail label # */
  137.   litlab,   /* label # assigned to literal pool */
  138.   beglab,   /* beginning label -- first function */
  139.   csp,      /* compiler relative stk ptr */
  140.   argstk,   /* function arg sp */
  141.   argtop,
  142.   ncmp,     /* # open compound statements */
  143.   errflag,  /* non-zero after 1st error in statement */
  144.   eof,      /* set non-zero on final input eof */
  145.   input,    /* fd # for input file */
  146.   input2,   /* fd # for "include" file */
  147.   output,   /* fd # for output file */
  148.   files,    /* non-zero if file list specified on cmd line */
  149.   filearg,  /* cur file arg index */
  150.   glbflag,  /* non-zero if internal globals */
  151.   ctext,    /* non-zero to intermix c-source */
  152.   ccode,    /* non-zero while parsing c-code */
  153.             /* zero when passing assembly code */
  154.   listfp,   /* file pointer to list device */
  155.   lastst,   /* last executed statement type */
  156.  *iptr;     /* work ptr to any int buffer */
  157.  
  158. #ifdef C80
  159. extern int fin, fout;
  160. #endif /* C80 */
  161.  
  162. #ifdef SEPARATE
  163.  
  164. extern int
  165.   addmac(),  addsym(),  addwhile(),  amatch(),  blanks(),
  166.   bump(),  clearstage(),  col(),  delwhile(),  endst(),
  167.   error(),  findglb(),  findloc(),  gch(),  getint(),
  168.   getlabel(),  illname(),  inbyte(),  inline(),  junk(),
  169.   kill(),  lout(),  match(),  multidef(),  needtoken(),
  170.   nextsym(),  nl(),  numeric(),  outbyte(),  outdec(),
  171.   postlabel(),  preprocess(),  printlabel(),  putint(),
  172.   readwhile(),  setstage(),  sout(),  streq(),  symname(),
  173.   upper(), xgets();
  174.  
  175. extern int
  176.   constexpr(),  expression(),  number(),  qstr(),
  177.   test(),  stowlit();
  178.  
  179. extern int
  180.   /*
  181.   ** arithmetic routines prefaced with "zz" to keep M80
  182.   ** assembler from generating error msgs when this is compiled
  183.   */
  184.   zzadd(),  zzand(),  zzasl(),  zzasr(),  defstora(),
  185.   zzdiv(),  zzeq(),  entry(),  external(),  zzge(),
  186.   zzgt(),  header(),  jump(),  zzle(),  zzlt(),  zzmod(),  modstk(),
  187.   zzmult(),  zzne(),  zzor(),  point(),  zzret(),  zzsub(),  sw(),
  188.   trailer(),  uge(),  ugt(),  ule(),  ult(),  zzxor();
  189. #endif /* SEPARATE */
  190.  
  191. #include "cc11.c"
  192. #include "cc12.c"
  193. #include "cc13.c"
  194.  
  195. #ifndef SEPARATE
  196. #include "cc21.c"
  197. #include "cc22.c"
  198. #include "cc31.c"
  199. #include "cc32.c"
  200. #include "cc33.c"
  201. #include "cc41.c"
  202. #include "cc42.c"
  203. #endif /* SEPARATE */
  204. σσσσσσσσσσσσ