Commit | Line | Data |
---|---|---|
7949e46e KM |
1 | /* awk.def 4.1 82/05/07 */ |
2 | ||
3 | #define hack int | |
4 | #define AWKFLOAT float | |
5 | #define xfree(a) { if(a!=NULL) { yfree(a); a=NULL;} } | |
6 | #define yfree free | |
7 | #ifdef DEBUG | |
8 | # define dprintf if(dbg)printf | |
9 | #else | |
10 | # define dprintf(x1, x2, x3, x4) | |
11 | #endif | |
12 | typedef AWKFLOAT awkfloat; | |
13 | ||
14 | extern char **FS; | |
15 | extern char **RS; | |
16 | extern char **ORS; | |
17 | extern char **OFS; | |
18 | extern char **OFMT; | |
19 | extern awkfloat *NR; | |
20 | extern awkfloat *NF; | |
21 | extern char **FILENAME; | |
22 | ||
23 | extern char record[]; | |
24 | extern int dbg; | |
25 | extern int lineno; | |
26 | extern int errorflag; | |
27 | extern int donefld; /* 1 if record broken into fields */ | |
28 | extern int donerec; /* 1 if record is valid (no fld has changed */ | |
29 | ||
30 | typedef struct val { /* general value during processing */ | |
31 | char *nval; /* name, for variables only */ | |
32 | char *sval; /* string value */ | |
33 | awkfloat fval; /* value as number */ | |
34 | unsigned tval; /* type info */ | |
35 | struct val *nextval; /* ptr to next if chained */ | |
36 | } cell; | |
37 | extern cell *symtab[]; | |
38 | cell *setsymtab(), *lookup(), **makesymtab(); | |
39 | ||
40 | extern cell *recloc; /* location of input record */ | |
41 | extern cell *nrloc; /* NR */ | |
42 | extern cell *nfloc; /* NF */ | |
43 | ||
44 | #define STR 01 /* string value is valid */ | |
45 | #define NUM 02 /* number value is valid */ | |
46 | #define FLD 04 /* FLD means don't free string space */ | |
47 | #define CON 010 /* this is a constant */ | |
48 | #define ARR 020 /* this is an array */ | |
49 | ||
50 | awkfloat setfval(), getfval(); | |
51 | char *setsval(), *getsval(); | |
52 | char *tostring(), *tokname(), *malloc(); | |
53 | double log(), sqrt(), exp(), atof(); | |
54 | ||
55 | /* function types */ | |
56 | #define FLENGTH 1 | |
57 | #define FSQRT 2 | |
58 | #define FEXP 3 | |
59 | #define FLOG 4 | |
60 | #define FINT 5 | |
61 | ||
62 | typedef struct { | |
63 | char otype; | |
64 | char osub; | |
65 | cell *optr; | |
66 | } obj; | |
67 | ||
68 | #define BOTCH 1 | |
69 | struct nd { | |
70 | char ntype; | |
71 | char subtype; | |
72 | struct nd *nnext; | |
73 | int nobj; | |
74 | struct nd *narg[BOTCH]; /* C won't take a zero length array */ | |
75 | }; | |
76 | typedef struct nd node; | |
77 | extern node *winner; | |
78 | extern node *nullstat; | |
79 | ||
80 | /* otypes */ | |
81 | #define OCELL 0 | |
82 | #define OEXPR 1 | |
83 | #define OBOOL 2 | |
84 | #define OJUMP 3 | |
85 | ||
86 | /* cell subtypes */ | |
87 | #define CTEMP 4 | |
88 | #define CNAME 3 | |
89 | #define CVAR 2 | |
90 | #define CFLD 1 | |
91 | #define CCON 0 | |
92 | ||
93 | /* bool subtypes */ | |
94 | #define BTRUE 1 | |
95 | #define BFALSE 2 | |
96 | ||
97 | /* jump subtypes */ | |
98 | #define JEXIT 1 | |
99 | #define JNEXT 2 | |
100 | #define JBREAK 3 | |
101 | #define JCONT 4 | |
102 | ||
103 | /* node types */ | |
104 | #define NVALUE 1 | |
105 | #define NSTAT 2 | |
106 | #define NEXPR 3 | |
107 | #define NPA2 4 | |
108 | ||
109 | extern obj (*proctab[])(); | |
110 | extern obj true, false; | |
111 | extern int pairstack[], paircnt; | |
112 | ||
113 | #define cantexec(n) (n->ntype == NVALUE) | |
114 | #define notlegal(n) (n <= FIRSTTOKEN || n >= LASTTOKEN || proctab[n-FIRSTTOKEN]== nullproc) | |
115 | #define isexpr(n) (n->ntype == NEXPR) | |
116 | #define isjump(n) (n.otype == OJUMP) | |
117 | #define isexit(n) (n.otype == OJUMP && n.osub == JEXIT) | |
118 | #define isbreak(n) (n.otype == OJUMP && n.osub == JBREAK) | |
119 | #define iscont(n) (n.otype == OJUMP && n.osub == JCONT) | |
120 | #define isnext(n) (n.otype == OJUMP && n.osub == JNEXT) | |
121 | #define isstr(n) (n.optr->tval & STR) | |
122 | #define istrue(n) (n.otype == OBOOL && n.osub == BTRUE) | |
123 | #define istemp(n) (n.otype == OCELL && n.osub == CTEMP) | |
124 | #define isfld(n) (!donefld && n.osub==CFLD && n.otype==OCELL && n.optr->nval==0) | |
125 | #define isrec(n) (donefld && n.osub==CFLD && n.otype==OCELL && n.optr->nval!=0) | |
126 | obj nullproc(); | |
127 | obj relop(); | |
128 | ||
129 | #define MAXSYM 50 | |
130 | #define HAT 0177 /* matches ^ in regular expr */ | |
131 | /* watch out for mach dep */ |