home *** CD-ROM | disk | FTP | other *** search
/ Frozen Fish 1: Amiga / FrozenFish-Apr94.iso / bbs / alib / d1xx / d110 / pdc.lha / Pdc / src / Intexpr.c < prev    next >
C/C++ Source or Header  |  1987-10-28  |  2KB  |  57 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. extern SYM    *search();
  26.  
  27. long intexpr()       /* simple integer value */
  28. {       long     temp;
  29.         SYM     *sp;
  30.         if(lastst == id) {
  31.                 sp = search(lastid,lsyms.head);
  32.                 if( sp == NULL)
  33.                         sp = search(lastid,gsyms.head);
  34.                 if(sp == NULL) {
  35.                         error(ERR_UNDEFINED);
  36.                         getsym();
  37.                         return 0;
  38.                         }
  39.                 if(sp->storage_class != sc_const) {
  40.                         error(ERR_SYNTAX);
  41.                         getsym();
  42.                         return 0;
  43.                         }
  44.                 getsym();
  45.                 return sp->value.i;
  46.                 }
  47.         else if(lastst == iconst) {
  48.                 temp = ival;
  49.                 getsym();
  50.                 return temp;
  51.                 }
  52.         getsym();
  53.         error(ERR_SYNTAX);
  54.         return 0;
  55. }
  56.  
  57.