diff options
Diffstat (limited to 'unproto/token.h')
-rw-r--r-- | unproto/token.h | 38 |
1 files changed, 23 insertions, 15 deletions
diff --git a/unproto/token.h b/unproto/token.h index 672039d..bb2f50a 100644 --- a/unproto/token.h +++ b/unproto/token.h @@ -1,8 +1,10 @@ -/* @(#) token.h 1.3 91/11/30 21:10:37 */ +/* @(#) token.h 1.4 92/01/15 21:53:17 */ struct token { int tokno; /* token value, see below */ - int len; /* string or list length */ + char *path; /* file name */ + int line; /* line number at token start */ + int end_line; /* line number at token end */ struct vstring *vstr; /* token contents */ struct token *next; struct token *head; @@ -13,27 +15,33 @@ struct token { #define TOK_LIST 256 /* () delimited list */ #define TOK_WORD 257 /* keyword or identifier */ -#define TOK_NUMBER 258 /* number */ -#define TOK_WSPACE 259 /* white space except newline */ -#define TOK_OTHER 260 /* other multi-char token */ +#define TOK_NUMBER 258 /* one or more digits */ +#define TOK_WSPACE 259 /* comment, white space, not newline */ +#define TOK_OTHER 260 /* other token */ #define TOK_CONTROL 261 /* flow control keyword */ -#define TOK_COMPOSITE 262 /* struct or union */ +#define TOK_COMPOSITE 262 /* struct or union keyword */ +#define TOK_DATE 263 /* date: Mmm dd yyyy */ +#define TOK_TIME 264 /* time: hh:mm:ss */ +#define TOK_VOID 265 /* void keyword */ /* Input/output functions and macros */ extern struct token *tok_get(); /* read next single token */ extern void tok_show(); /* display (composite) token */ extern struct token *tok_class(); /* classify tokens */ -extern void put_ch(); /* write character */ -extern void put_str(); /* write string */ extern void tok_unget(); /* stuff token back into input */ +extern void put_nl(); /* print newline character */ +extern void tok_show_ch(); /* emit single-character token */ #define tok_flush(t) (tok_show(t), tok_free(t)) -/* tok_get() and tok_class() options */ - -#define DO_WSPACE 0 /* retain space, tab */ -#define NO_WSPACE 1 /* skip space, tab */ +#ifdef DEBUG +#define put_ch(c) (putchar(last_ch = c),fflush(stdout)) +#define put_str(s) (fputs(s,stdout),last_ch = 0,fflush(stdout)) +#else +#define put_ch(c) putchar(last_ch = c) +#define put_str(s) (fputs(s,stdout),last_ch = 0) +#endif /* Memory management */ @@ -42,6 +50,6 @@ extern void tok_free(); /* re-cycle storage */ /* Context */ -extern char curr_path[]; /* current path name */ -extern int curr_line; /* current line number */ -#define show_line_control() printf("# %d %s\n", curr_line, curr_path); +extern char *in_path; /* current input path name */ +extern int in_line; /* current input line number */ +extern int last_ch; /* type of last output */ |