home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 January / usenetsourcesnewsgroupsinfomagicjanuary1994.iso / sources / misc / volume26 / unproto / part01 / token.h < prev    next >
Encoding:
C/C++ Source or Header  |  1991-12-07  |  1.5 KB  |  48 lines

  1. /* @(#) token.h 1.3 91/11/30 21:10:37 */
  2.  
  3. typedef struct token {
  4.     int     tokno;            /* token value, see below */
  5.     int     len;            /* string or list length */
  6.     struct vstring *vstr;        /* token contents */
  7.     struct token *next;
  8.     struct token *head;
  9.     struct token *tail;
  10. };
  11.  
  12. /* Special token values */
  13.  
  14. #define    TOK_LIST    256        /* () delimited list */
  15. #define    TOK_WORD    257        /* keyword or identifier */
  16. #define    TOK_NUMBER    258        /* number */
  17. #define    TOK_WSPACE    259        /* white space except newline */
  18. #define    TOK_OTHER    260        /* other multi-char token */
  19. #define    TOK_CONTROL    261        /* flow control keyword */
  20. #define    TOK_COMPOSITE    262        /* struct or union */
  21.  
  22. /* Input/output functions and macros */
  23.  
  24. extern struct token *tok_get();        /* read next single token */
  25. extern void tok_show();            /* display (composite) token */
  26. extern struct token *tok_class();    /* classify tokens */
  27. extern void put_ch();            /* write character */
  28. extern void put_str();            /* write string */
  29. extern void tok_unget();        /* stuff token back into input */
  30.  
  31. #define    tok_flush(t)    (tok_show(t), tok_free(t))
  32.  
  33. /* tok_get() and tok_class() options */
  34.  
  35. #define    DO_WSPACE    0        /* retain space, tab */
  36. #define    NO_WSPACE    1        /* skip space, tab */
  37.  
  38. /* Memory management */
  39.  
  40. struct token *tok_alloc();        /* allocate token storage */
  41. extern void tok_free();            /* re-cycle storage */
  42.  
  43. /* Context */
  44.  
  45. extern char curr_path[];        /* current path name */
  46. extern int curr_line;            /* current line number */
  47. #define    show_line_control() printf("# %d %s\n", curr_line, curr_path);
  48.