home *** CD-ROM | disk | FTP | other *** search
/ messroms.de / 2007-01-13_www.messroms.de.zip / VZ200 / TOOLS / ZCCSRC.ZIP / scc / while.c < prev   
C/C++ Source or Header  |  2000-03-01  |  1KB  |  81 lines

  1. /*    File while.c: 2.1 (83/03/20,16:02:22) */
  2. /*% cc -O -c %
  3.  *
  4.  */
  5.  
  6. #include <stdio.h>
  7. #include "defs.h"
  8. #include "data.h"
  9. #include "proto.h"
  10.  
  11. void addwhile(int ptr[])
  12. {
  13.     int k;
  14.  
  15.     if (wsptr == WSMAX)
  16.     {
  17.         error("too many active whiles");
  18.         return;
  19.     }
  20.     k = 0;
  21.     while (k < WSSIZ)
  22.         *wsptr++ = ptr[k++];
  23. }
  24.  
  25. void delwhile(void)
  26. {
  27.     if (readwhile())
  28.         wsptr = wsptr - WSSIZ;
  29. }
  30.  
  31. int *readwhile(void)
  32. {
  33.     if (wsptr == ws)
  34.     {
  35.         error("no active do/for/while/switch");
  36.         return NULL;
  37.     }
  38.     else
  39.         return (wsptr - WSSIZ);
  40. }
  41.  
  42. int *findwhile(void)
  43. {
  44.     int *ptr;
  45.  
  46.     for (ptr = wsptr; ptr != ws;)
  47.     {
  48.         ptr = ptr - WSSIZ;
  49.         if (ptr[WSTYP] != WSSWITCH)
  50.             return (ptr);
  51.     }
  52.     error("no active do/for/while");
  53.     return NULL;
  54. }
  55.  
  56. int *readswitch(void)
  57. {
  58.     int *ptr;
  59.  
  60.     if (NULL!=(ptr = readwhile()))
  61.         if (ptr[WSTYP] == WSSWITCH)
  62.             return (ptr);
  63.     return NULL;
  64. }
  65.  
  66. void addcase(int val)
  67. {
  68.     int lab;
  69.  
  70.     if (swstp == SWSTSZ)
  71.         error("too many case labels");
  72.     else
  73.     {
  74.         swstcase[swstp] = val;
  75.         swstlab[swstp++] = lab = getlabel();
  76.         printlabel(lab);
  77.         col();
  78.         nl();
  79.     }
  80. }
  81.