1 /* Copyright (c) 1988 Bellcore
3 ** Permission is granted to copy or use this program, EXCEPT that it
4 ** may not be sold for profit, the copyright notice must be reproduced
5 ** on copies, and credit should be given to Bellcore where it is due.
6 ** BELLCORE MAKES NO WARRANTY AND ACCEPTS NO LIABILITY FOR THIS PROGRAM.
15 #define K_MAXTOKENS 50000
17 ** values for token type
24 int linenum; /* line that the token started on */
25 int pos; /* position on the line where token started */
26 int type; /* token type */
27 char *text; /* literal token text */
29 ** canonical floationg point representation
36 ** this should really be a two dimensional array
37 ** but i'm too lazy to recode it
39 extern K_token _K_ato[]; /* storage for the tokens */
40 extern K_token _K_bto[];
42 ** save token X from file
44 extern void K_settoken(/*file,X,ptr*/);
45 #define K_gettoken(file, X) (file?(_K_bto[X]):(_K_ato[X]))
47 extern int _K_atm; /* count of tokens */
51 ** get token number X from file
53 #define K_get_token(file, X) (file?(_K_bto[X]):(_K_ato[X]))
55 #define K_gettmax(file) (file?_K_btm:_K_atm)
56 #define K_settmax(file,value) (file?(_K_btm=(value)):(_K_atm=(value)))
58 ** increment and return true on overflow
60 #define K_inctmax(file) ((file?(++_K_btm):(++_K_atm))>=K_MAXTOKENS)
62 #define K_setline(x,y) (x->linenum = y)
63 #define K_setpos(x,y) (x->pos = y)
64 #define K_settext(x,y) (x->text = y)
65 #define K_savetext(x,y,z) S_savestr(&(x->text),y)
66 #define K_saventext(x,y,z) S_savenstr(&(x->text),y,z)
67 #define K_setfloat(x,y) (x->flo_num = y)
68 #define K_settol(x,y) (x->tolerance = y)
69 #define K_settype(x,y) (x->type = y)
71 #define K_getline(x) (x->linenum)
72 #define K_getpos(x) (x->pos)
73 #define K_gettext(x) (x->text)
74 #define K_getfloat(x) (x->flo_num)
75 #define K_gettol(x) (x->tolerance)
76 #define K_gettype(x) (x->type)
78 #define K_maketoken() (Z_ALLOC(1,_K_str))