home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 January / usenetsourcesnewsgroupsinfomagicjanuary1994.iso / sources / unix / volume26 / cforms / part01 / src / get_ccode.c < prev    next >
Encoding:
C/C++ Source or Header  |  1992-05-18  |  1.0 KB  |  56 lines

  1. /*******************************************************************************
  2.  *
  3.  *        G E T _ C C O D E . C
  4.  *        ---------------------
  5.  *
  6.  * Description:
  7.  *    Compiles a C-code statement.
  8.  *
  9.  * Included functions:
  10.  *    get_ccode    - Does the job
  11.  *
  12.  * Revision:
  13.  *    Ver    Date    By        Reason
  14.  *    ---    ----    --        ------
  15.  *    1.00    90730    Lars Berntzon    Created
  16.  *
  17.  ******************************************************************************/
  18.  
  19. #include <stdio.h>
  20. #include <ctype.h>
  21. #include <string.h>
  22.  
  23. #include "token.h"
  24. #include "comp.h"
  25.  
  26. struct ccode *get_ccode()
  27. {
  28.     struct ccode *cp = NULL;
  29.     struct stmt *stmt;
  30.  
  31.     if ((stmt = get_stmt()) == NULL) {
  32.         error("expected C-code statements");
  33.         return NULL;
  34.     }
  35.     
  36.     cp = memalloc(sizeof *cp);
  37.     cp->stmt = stmt;
  38.     
  39.     return cp;
  40. }
  41.  
  42. struct ccode *unget_ccode(struct ccode *cp)
  43. {
  44.     struct ccode *next;
  45.     
  46.     if (cp == NULL) return NULL;
  47.     
  48.     next = NEXT_CCODE(cp);
  49.     if (cp->stmt) unget_stmt(cp->stmt);
  50.     if (cp->link.name) free(cp->link.name);
  51.     free(cp);
  52.     
  53.     return next;
  54. }
  55.     
  56.