Commit | Line | Data |
a559c259 |
1 | /* $Header: arg.h,v 1.0.1.1 88/01/28 10:22:40 root Exp $ |
8d063cd8 |
2 | * |
3 | * $Log: arg.h,v $ |
a559c259 |
4 | * Revision 1.0.1.1 88/01/28 10:22:40 root |
5 | * patch8: added eval operator. |
6 | * |
8d063cd8 |
7 | * Revision 1.0 87/12/18 13:04:39 root |
8 | * Initial revision |
9 | * |
10 | */ |
11 | |
12 | #define O_NULL 0 |
13 | #define O_ITEM 1 |
14 | #define O_ITEM2 2 |
15 | #define O_ITEM3 3 |
16 | #define O_CONCAT 4 |
17 | #define O_MATCH 5 |
18 | #define O_NMATCH 6 |
19 | #define O_SUBST 7 |
20 | #define O_NSUBST 8 |
21 | #define O_ASSIGN 9 |
22 | #define O_MULTIPLY 10 |
23 | #define O_DIVIDE 11 |
24 | #define O_MODULO 12 |
25 | #define O_ADD 13 |
26 | #define O_SUBTRACT 14 |
27 | #define O_LEFT_SHIFT 15 |
28 | #define O_RIGHT_SHIFT 16 |
29 | #define O_LT 17 |
30 | #define O_GT 18 |
31 | #define O_LE 19 |
32 | #define O_GE 20 |
33 | #define O_EQ 21 |
34 | #define O_NE 22 |
35 | #define O_BIT_AND 23 |
36 | #define O_XOR 24 |
37 | #define O_BIT_OR 25 |
38 | #define O_AND 26 |
39 | #define O_OR 27 |
40 | #define O_COND_EXPR 28 |
41 | #define O_COMMA 29 |
42 | #define O_NEGATE 30 |
43 | #define O_NOT 31 |
44 | #define O_COMPLEMENT 32 |
45 | #define O_WRITE 33 |
46 | #define O_OPEN 34 |
47 | #define O_TRANS 35 |
48 | #define O_NTRANS 36 |
49 | #define O_CLOSE 37 |
50 | #define O_ARRAY 38 |
51 | #define O_HASH 39 |
52 | #define O_LARRAY 40 |
53 | #define O_LHASH 41 |
54 | #define O_PUSH 42 |
55 | #define O_POP 43 |
56 | #define O_SHIFT 44 |
57 | #define O_SPLIT 45 |
58 | #define O_LENGTH 46 |
59 | #define O_SPRINTF 47 |
60 | #define O_SUBSTR 48 |
61 | #define O_JOIN 49 |
62 | #define O_SLT 50 |
63 | #define O_SGT 51 |
64 | #define O_SLE 52 |
65 | #define O_SGE 53 |
66 | #define O_SEQ 54 |
67 | #define O_SNE 55 |
68 | #define O_SUBR 56 |
69 | #define O_PRINT 57 |
70 | #define O_CHDIR 58 |
71 | #define O_DIE 59 |
72 | #define O_EXIT 60 |
73 | #define O_RESET 61 |
74 | #define O_LIST 62 |
75 | #define O_SELECT 63 |
76 | #define O_EOF 64 |
77 | #define O_TELL 65 |
78 | #define O_SEEK 66 |
79 | #define O_LAST 67 |
80 | #define O_NEXT 68 |
81 | #define O_REDO 69 |
82 | #define O_GOTO 70 |
83 | #define O_INDEX 71 |
84 | #define O_TIME 72 |
85 | #define O_TMS 73 |
86 | #define O_LOCALTIME 74 |
87 | #define O_GMTIME 75 |
88 | #define O_STAT 76 |
89 | #define O_CRYPT 77 |
90 | #define O_EXP 78 |
91 | #define O_LOG 79 |
92 | #define O_SQRT 80 |
93 | #define O_INT 81 |
94 | #define O_PRTF 82 |
95 | #define O_ORD 83 |
96 | #define O_SLEEP 84 |
97 | #define O_FLIP 85 |
98 | #define O_FLOP 86 |
99 | #define O_KEYS 87 |
100 | #define O_VALUES 88 |
101 | #define O_EACH 89 |
102 | #define O_CHOP 90 |
103 | #define O_FORK 91 |
104 | #define O_EXEC 92 |
105 | #define O_SYSTEM 93 |
106 | #define O_OCT 94 |
107 | #define O_HEX 95 |
108 | #define O_CHMOD 96 |
109 | #define O_CHOWN 97 |
110 | #define O_KILL 98 |
111 | #define O_RENAME 99 |
112 | #define O_UNLINK 100 |
113 | #define O_UMASK 101 |
114 | #define O_UNSHIFT 102 |
115 | #define O_LINK 103 |
116 | #define O_REPEAT 104 |
a559c259 |
117 | #define O_EVAL 105 |
118 | #define MAXO 106 |
8d063cd8 |
119 | |
120 | #ifndef DOINIT |
121 | extern char *opname[]; |
122 | #else |
123 | char *opname[] = { |
124 | "NULL", |
125 | "ITEM", |
126 | "ITEM2", |
127 | "ITEM3", |
128 | "CONCAT", |
129 | "MATCH", |
130 | "NMATCH", |
131 | "SUBST", |
132 | "NSUBST", |
133 | "ASSIGN", |
134 | "MULTIPLY", |
135 | "DIVIDE", |
136 | "MODULO", |
137 | "ADD", |
138 | "SUBTRACT", |
139 | "LEFT_SHIFT", |
140 | "RIGHT_SHIFT", |
141 | "LT", |
142 | "GT", |
143 | "LE", |
144 | "GE", |
145 | "EQ", |
146 | "NE", |
147 | "BIT_AND", |
148 | "XOR", |
149 | "BIT_OR", |
150 | "AND", |
151 | "OR", |
152 | "COND_EXPR", |
153 | "COMMA", |
154 | "NEGATE", |
155 | "NOT", |
156 | "COMPLEMENT", |
157 | "WRITE", |
158 | "OPEN", |
159 | "TRANS", |
160 | "NTRANS", |
161 | "CLOSE", |
162 | "ARRAY", |
163 | "HASH", |
164 | "LARRAY", |
165 | "LHASH", |
166 | "PUSH", |
167 | "POP", |
168 | "SHIFT", |
169 | "SPLIT", |
170 | "LENGTH", |
171 | "SPRINTF", |
172 | "SUBSTR", |
173 | "JOIN", |
174 | "SLT", |
175 | "SGT", |
176 | "SLE", |
177 | "SGE", |
178 | "SEQ", |
179 | "SNE", |
180 | "SUBR", |
181 | "PRINT", |
182 | "CHDIR", |
183 | "DIE", |
184 | "EXIT", |
185 | "RESET", |
186 | "LIST", |
187 | "SELECT", |
188 | "EOF", |
189 | "TELL", |
190 | "SEEK", |
191 | "LAST", |
192 | "NEXT", |
193 | "REDO", |
194 | "GOTO",/* shudder */ |
195 | "INDEX", |
196 | "TIME", |
197 | "TIMES", |
198 | "LOCALTIME", |
199 | "GMTIME", |
200 | "STAT", |
201 | "CRYPT", |
202 | "EXP", |
203 | "LOG", |
204 | "SQRT", |
205 | "INT", |
206 | "PRINTF", |
207 | "ORD", |
208 | "SLEEP", |
209 | "FLIP", |
210 | "FLOP", |
211 | "KEYS", |
212 | "VALUES", |
213 | "EACH", |
214 | "CHOP", |
215 | "FORK", |
216 | "EXEC", |
217 | "SYSTEM", |
218 | "OCT", |
219 | "HEX", |
220 | "CHMOD", |
221 | "CHOWN", |
222 | "KILL", |
223 | "RENAME", |
224 | "UNLINK", |
225 | "UMASK", |
226 | "UNSHIFT", |
227 | "LINK", |
228 | "REPEAT", |
a559c259 |
229 | "EVAL", |
230 | "106" |
8d063cd8 |
231 | }; |
232 | #endif |
233 | |
234 | #define A_NULL 0 |
235 | #define A_EXPR 1 |
236 | #define A_CMD 2 |
237 | #define A_STAB 3 |
238 | #define A_LVAL 4 |
239 | #define A_SINGLE 5 |
240 | #define A_DOUBLE 6 |
241 | #define A_BACKTICK 7 |
242 | #define A_READ 8 |
243 | #define A_SPAT 9 |
244 | #define A_LEXPR 10 |
245 | #define A_ARYLEN 11 |
246 | #define A_NUMBER 12 |
247 | |
248 | #ifndef DOINIT |
249 | extern char *argname[]; |
250 | #else |
251 | char *argname[] = { |
252 | "A_NULL", |
253 | "EXPR", |
254 | "CMD", |
255 | "STAB", |
256 | "LVAL", |
257 | "SINGLE", |
258 | "DOUBLE", |
259 | "BACKTICK", |
260 | "READ", |
261 | "SPAT", |
262 | "LEXPR", |
263 | "ARYLEN", |
264 | "NUMBER", |
265 | "13" |
266 | }; |
267 | #endif |
268 | |
269 | #ifndef DOINIT |
270 | extern bool hoistable[]; |
271 | #else |
272 | bool hoistable[] = {0, 0, 1, 1, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0}; |
273 | #endif |
274 | |
275 | struct arg { |
276 | union argptr { |
277 | ARG *arg_arg; |
278 | char *arg_cval; |
279 | STAB *arg_stab; |
280 | SPAT *arg_spat; |
281 | CMD *arg_cmd; |
282 | STR *arg_str; |
283 | double arg_nval; |
284 | } arg_ptr; |
285 | short arg_len; |
286 | char arg_type; |
287 | char arg_flags; |
288 | }; |
289 | |
290 | #define AF_SPECIAL 1 /* op wants to evaluate this arg itself */ |
291 | #define AF_POST 2 /* post *crement this item */ |
292 | #define AF_PRE 4 /* pre *crement this item */ |
293 | #define AF_UP 8 /* increment rather than decrement */ |
294 | #define AF_COMMON 16 /* left and right have symbols in common */ |
295 | #define AF_NUMERIC 32 /* return as numeric rather than string */ |
296 | #define AF_LISTISH 64 /* turn into list if important */ |
297 | |
298 | /* |
299 | * Most of the ARG pointers are used as pointers to arrays of ARG. When |
300 | * so used, the 0th element is special, and represents the operator to |
301 | * use on the list of arguments following. The arg_len in the 0th element |
302 | * gives the maximum argument number, and the arg_str is used to store |
303 | * the return value in a more-or-less static location. Sorry it's not |
304 | * re-entrant, but it sure makes it efficient. The arg_type of the |
305 | * 0th element is an operator (O_*) rather than an argument type (A_*). |
306 | */ |
307 | |
308 | #define Nullarg Null(ARG*) |
309 | |
310 | EXT char opargs[MAXO]; |
311 | |
312 | int do_trans(); |
313 | int do_split(); |
314 | bool do_eof(); |
315 | long do_tell(); |
316 | bool do_seek(); |
317 | int do_tms(); |
318 | int do_time(); |
319 | int do_stat(); |