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

  1. /******************************************************************************
  2.  *
  3.  *        S K I P _ S T M T . C
  4.  *        ---------------------
  5.  *
  6.  * Description:
  7.  *    Skips a C-statement block.
  8.  *
  9.  * Included functions:
  10.  *    skip_stmt    - Does the job
  11.  *
  12.  * Revision:
  13.  *    Ver    Date    By        Reason
  14.  *    ---    ----    --        ------
  15.  *    1.00    900625    Lars Berntzon    Created
  16.  *
  17.  ******************************************************************************/
  18.  
  19. #include "config.h"
  20.  
  21. #include <stdio.h>
  22. #include <ctype.h>
  23. #include <string.h>
  24. #ifdef STDLIB_H
  25. #include <stdlib.h>
  26. #endif
  27. #ifdef MALLOC_H
  28. #include <malloc.h>
  29. #endif
  30.  
  31. #include "token.h"
  32. #include "comp.h"
  33.  
  34. #define isnormal(ch) (isalnum(ch) || (ch) == '_')
  35.  
  36. skip_stmt()
  37. {
  38.     char token[TOKENSIZE];
  39.     int nesting;
  40.     
  41.     if (GetTokNC(token) == NULL) {
  42.         error("premature end of file for C-statement");
  43.         return FAIL;
  44.     }
  45.  
  46.     if (strcmp(token, "{") != 0) {
  47.         error("expected '{' for C-statement");
  48.         return FAIL;
  49.     }
  50.     
  51.     for(nesting = 1; nesting != 0;) {
  52.         if(GetTokNC(token) == NULL) {
  53.             error("premature end of file for C-statement");
  54.             return FAIL;
  55.         }
  56.         
  57.     if (strcmp(token, "{") == 0) nesting++;
  58.     else if (strcmp(token, "}") == 0) nesting--;
  59.     }
  60.  
  61.     return OK;
  62.