home *** CD-ROM | disk | FTP | other *** search
/ The C Users' Group Library 1994 August / wc-cdrom-cusersgrouplibrary-1994-08.iso / vol_200 / 204_01 / intexpr.c < prev    next >
Text File  |  1979-12-31  |  2KB  |  55 lines

  1. #include        <stdio.h>
  2. #include        "c.h"
  3. #include        "expr.h"
  4. #include        "gen.h"
  5. #include        "cglbdec.h"
  6.  
  7. /*
  8.  *    68000 C compiler
  9.  *
  10.  *    Copyright 1984, 1985, 1986 Matthew Brandt.
  11.  *  all commercial rights reserved.
  12.  *
  13.  *    This compiler is intended as an instructive tool for personal use. Any
  14.  *    use for profit without the written consent of the author is prohibited.
  15.  *
  16.  *    This compiler may be distributed freely for non-commercial use as long
  17.  *    as this notice stays intact. Please forward any enhancements or questions
  18.  *    to:
  19.  *
  20.  *        Matthew Brandt
  21.  *        Box 920337
  22.  *        Norcross, Ga 30092
  23.  */
  24.  
  25. intexpr()       /* simple integer value */
  26. {       int     temp;
  27.         SYM     *sp;
  28.         if(lastst == id) {
  29.                 sp = search(lastid,lsyms.head);
  30.                 if( sp == NULL)
  31.                         sp = search(lastid,gsyms.head);
  32.                 if(sp == NULL) {
  33.                         error(ERR_UNDEFINED);
  34.                         getsym();
  35.                         return 0;
  36.                         }
  37.                 if(sp->storage_class != sc_const) {
  38.                         error(ERR_SYNTAX);
  39.                         getsym();
  40.                         return 0;
  41.                         }
  42.                 getsym();
  43.                 return sp->value.i;
  44.                 }
  45.         else if(lastst == iconst) {
  46.                 temp = ival;
  47.                 getsym();
  48.                 return temp;
  49.                 }
  50.         getsym();
  51.         error(ERR_SYNTAX);
  52.         return 0;
  53. }
  54.  
  55.