home *** CD-ROM | disk | FTP | other *** search
/ GRIPS 2: Government Rast…rocessing Software & Data / GRIPS_2.cdr / dos / imcomp / mac.h < prev    next >
Encoding:
C/C++ Source or Header  |  1990-12-29  |  5.0 KB  |  142 lines

  1. /*                   mac.h                       */
  2. /*                   rt1 macros                  */
  3.  
  4. #define PRNL    putcher('\012');    /* cr/lf */
  5. #define CLRERR  errix = errnum = 0;    /* reset errors */
  6.  
  7. /* character type macros*/
  8. /* char c;*/
  9. #define ISALPH(c)    (ctype[(c)]&ALPH)    /* alphabetic*/
  10. #define ISDIG(c)    (ctype[(c)]&DIG)    /* digit*/
  11. #define ISLDIG(c)    (ctype[(c)]&LDIG)    /* number for yylex*/
  12. #define ISLOW(c)    (ctype[(c)]&LOW)    /* lower case alpha*/
  13. #define ISOPR(c)    (ctype[(c)]&OPR)    /* operators */
  14. #define ISSTR(c)    (ctype[(c)]&STRD)    /*initial string delimiter*/
  15. #define ISLEXD(c)    (ctype[(c)]&LEXD)    /*for yylex*/
  16. #define ISDEL1(c)    (ctype[(c)]&DEL1)    /* ; \n \0 */
  17. #define ISDEL2(c)    (ctype[(c)]&DEL2)    /* \n \0*/
  18. #define ISDEL3(c)    (ctype[(c)]&DEL3)    /* for namadr */
  19. #define ISDELIM(c)    (!(ctype[(c)]&(ALPH|DIG)))    /* not alphanum*/
  20. #define ISLABEL(c)    (ctype[(c)]&DIG)    /* labels start with num*/
  21. #define ISALNUM(c)    (ctype[(c)]&(ALPH|DIG))    /* alphanumeric*/
  22. #define ISCMT(c)    (c == '.')        /* comment */
  23. #define ISWS(c)        (ctype[(c)]&WSP)    /* white space */
  24.  
  25. /* decrement the use count and unchain the temp block if
  26.    its use count is 0
  27.     NBLOCK *nb;    the argument type
  28. */
  29. /*    if (temptype & (1 << ((nb)->type)))\ */
  30. #define DECUSE(nb)\
  31.      if (((nb)->type == STRADR) ||\
  32.      ((nb)->type == AADR) ||\
  33.      ((nb)->type == CPLADR) ||\
  34.      ((nb)->type == CGR) ||\
  35.      ((nb)->type == SWAPADR))\
  36.         if (--((nb)->nvalue.tptr->use) <= 0)\
  37.             tmpunch((nb)->nvalue.tptr);
  38.  
  39. /* decrement the use count 
  40.    TEMP *tp;
  41. */
  42. #define DECRUSE(tp) if (--((tp)->use) <= 0) tmpunch(tp);
  43.  
  44. /* increment the use count
  45.    VAL *vp;
  46. */
  47. /*    if (temptype & (1 << ((vp)->valtype)))\*/
  48. #define INCUSE(vp)\
  49.     if ( ((vp)->valtype == STRADR) ||\
  50.              ((vp)->valtype == AADR) ||\
  51.          ((vp)->valtype == CPLADR) ||\
  52.          ((vp)->valtype == CGR) ||\
  53.              ((vp)->valtype == SWAPADR)   )\
  54.         ((vp)->value.tptr->use)++;
  55.  
  56. /* increment the use count
  57.     TEMP *tp;
  58. */
  59. #define INCRUSE(tp) ((tp)->use)++;
  60.  
  61. /* increment a character pointer over blanks and tabs
  62.     char *cp;
  63. */
  64. #define SKIPWS(cp) while(ISWS(*(cp))) ++(cp);
  65.  
  66.  
  67. #ifdef ZWHILE
  68. /********************************************
  69.  **   scan forward to and stop on nl or \0 **
  70.  **   IF within a block delimited by curly **
  71.  **   braces, ignore newlines until out of **
  72.  **   the block.  Simple rule, huh??       **     
  73.  **              char *c;                  **
  74.  ********************************************/
  75.                 /* sumit, 4/21/87 */
  76. #define MYSCAN(c)  \
  77.    do {                                                         \
  78.           while(*(c) != '{'  &&  !ISDEL2(*(c)))   ++(c);        \
  79.           while(*(c) == '{')  {                                  \
  80.                FINDEND(c);                                        \
  81.                while(*(c) != '{'  &&  !ISDEL2(*(c)))   ++(c);   \
  82.            }                                                    \
  83.       } while(0)
  84. #define FINDEND(c)                  /* sumit, 4/21/87 */     \
  85.    do {                                                       \
  86.            int _i;                                              \
  87.            ++(c);                                                \
  88.            for(_i=1 ; _i > 0 &&  *(c) != '\0' ; ++(c))  {    \
  89.                 if(*(c) == '{')     _i++;                    \
  90.                 else if(*(c) == '}')      _i--;              \
  91.             }                                                  \
  92.       } while(0)
  93.  /*********************************************
  94.   **  scan backwards to first \n or to the   **
  95.   **  starting address of the macro, which   **
  96.   **  is in 'stop'                           **
  97.   **  IF in a { block }, ignore newlines     **
  98.   *********************************************/
  99. #define MYBSCAN(c,stop)                       /* sumit, 4/21/87 */             \
  100.    do {                                                                     \
  101.           while ((c) >= stop && *(c) != '\n' && *(c) != '}') --(c);         \
  102.           while (*(c) == '}')  {                                        \
  103.                FINDSTART(c,stop);                                        \
  104.                while ((c) >= stop && *(c) != '\n' && *(c) != '}') --(c); \
  105.            }                                                             \
  106.       } while(0)
  107.  
  108.  /* sumit, 4/21/87 */
  109. #define FINDSTART(c,stop)                              \
  110.    do {                                                \
  111.            int _i = 1;                                   \
  112.            while((c) >= stop  &&  _i > 0)  {           \
  113.                 --(c);                                    \
  114.                 if(*(c) == '}')      _i++;             \
  115.                 else if(*(c) == '{')   _i--;           \
  116.             }                                              \
  117.       } while(0)
  118. #endif
  119.  
  120.  
  121. /* scan forward to and stop on nl or \0
  122.     char *c;
  123. */
  124. #define SCANNL(c) while(!ISDEL2(*(c))) ++(c);
  125.  
  126. /* scan over alphanumerics (for labels/names)
  127.     char *cp;
  128. */
  129. #define SCANALN(c)  while(ISALNUM(*(c))) ++(c);
  130.  
  131. /* scan backward to a \n and point at it, or to the address stop
  132.     char *c, *stop;
  133. */
  134. #define BACKNL(c,stop)\
  135.     while ((c) >= stop && *(c) != '\n') --(c);
  136.  
  137. /* call to convert arguments*/
  138. #define CARG(args)\
  139.     if (!convarg((args),v + 1))\
  140.         return(NULL);    /* couldn't convert */
  141.  
  142.