|
|
1.1 root 1: #include <stdio.h>
2:
3: double *test1;
4: double gamma();
5: /*
6: * A P L
7: */
8:
9: /*
10: * Magic numbers
11: */
12:
13: #define OPERBOXSIZE 76
14:
15: #define MRANK 8 /* Size of dimension buffer */
16: #define CANBS 300 /* Size of input buffer */
17: #define STKS 50 /* Size of stack increment */
18: #define NLS 100 /* Size of namelist */
19: #define NAMS 24 /* Size of name buffer */
20: #define OBJS 500 /* Size of compiled expr buffer */
21: #define MAGIC 0100554 /* Magic word for WS file */
22:
23: /*
24: * Magic words
25: */
26:
27: #define EDIT_ED "/usr/bin/ed"
28: #define EDIT_EX "/usr/ucb/ex"
29: #define EDIT_VI "/usr/ucb/vi"
30:
31: /*
32: * Debug modes
33: */
34: #define FULLD 1
35:
36: #ifdef FULLD
37: #define SOMED SOMED
38: #endif
39:
40: #ifdef SHORTD
41: #define SOMED SOMED
42: #endif
43:
44: /*
45: * Derived constants
46: */
47:
48: #define SDAT sizeof datum
49: #define SINT sizeof integ
50:
51: /*
52: * Interpreter Op Codes
53: */
54:
55: #define EOF (-1)
56: #define EOL 0
57:
58: #define ADD 1
59: #define PLUS 2
60: #define SUB 3
61: #define MINUS 4
62: #define MUL 5
63: #define SGN 6
64: #define DIV 7
65: #define RECIP 8
66: #define MOD 9
67: #define ABS 10
68: #define MIN 11
69: #define FLOOR 12
70: #define MAX 13
71: #define CEIL 14
72: #define PWR 15
73: #define EXP 16
74: #define LOG 17
75: #define LOGE 18
76: #define CIR 19
77: #define PI 20
78: #define COMB 21
79: #define FAC 22
80:
81: #define DEAL 23
82: #define RAND 24
83: #define DRHO 25
84: #define MRHO 26
85: #define DIOT 27
86: #define MIOT 28
87: #define ROT0 29
88: #define REV0 30
89: #define DTRN 31
90: #define MTRN 32
91: #define DIBM 33
92: #define MIBM 34
93:
94: #define GDU 35
95: #define GDUK 36
96: #define GDD 37
97: #define GDDK 38
98: #define EXD 39
99: #define SCAN 40
100: #define EXDK 41
101: #define SCANK 42
102: #define IPROD 43
103: #define OPROD 44
104: #define QUAD 45
105: #define QQUAD 46
106: #define BRAN0 47
107: #define BRAN 48
108: #define DDOM 49
109: #define MDOM 50
110:
111: #define COM 51
112: #define RED 52
113: #define COMK 53
114: #define REDK 54
115: #define ROT 55
116: #define REV 56
117: #define ROTK 57
118: #define REVK 58
119: #define CAT 59
120: #define RAV 60
121: #define CATK 61
122: #define RAVK 62
123:
124: #define PRINT 63
125: #define QUOT 64
126: #define ELID 65
127: #define CQUAD 66
128: #define COMNT 67
129: #define INDEX 68
130: #define HPRINT 69
131:
132: #define LT 71
133: #define LE 72
134: #define GT 73
135: #define GE 74
136: #define EQ 75
137: #define NE 76
138: #define AND 77
139: #define OR 78
140: #define NAND 79
141: #define NOR 80
142: #define NOT 81
143: #define EPS 82
144: #define MEPS 83
145: #define REP 84
146: #define TAKE 85
147: #define DROP 86
148: #define ASGN 88
149: #define IMMED 89
150:
151:
152: #define NAME 90
153: #define CONST 91
154: #define FUN 92
155: #define ARG1 93
156: #define ARG2 94
157: #define AUTO 95
158: #define REST 96
159:
160: #define COM0 97
161: #define RED0 98
162: #define EXD0 99
163: #define SCAN0 100
164: #define BASE 101
165: #define MENC 102 /* monadic encode */
166:
167: /*
168: * Immediate sub-op codes
169: */
170:
171: #define CLEAR 1
172: #define DIGITS 2
173: #define ED_IT 3
174: #define ERASE 4
175: #define FNS 5
176: #define FUZZ 6
177: #define READ 7
178: #define ORIGIN 8
179: #define VARS 9
180: #define WIDTH 10
181: #define DEBUG 11
182: #define OFF 12
183: #define LOAD 13
184: #define SAVE 14
185: #define COPY 15
186: #define CONTIN 16
187: #define LIB 17
188: #define DROPC 18
189: #ifdef SOMED
190: #define SYMBOLS 19
191: #endif
192: #define EX_IT 20
193: #define EX_VI 21
194: #define ASCII 22
195: #define APL 23
196: #define CSH 24
197:
198: /*
199: * Types
200: */
201:
202: #define DA 1 /* Numeric data (?) */
203: #define CH 2 /* Character data (?) */
204: #define LV 3 /* Used for most data items */
205: #define QD 4 /* Quad (assignment to (?)) */
206: #define QQ 5 /* Quote-quad */
207: #define IN 6 /* ??? */
208: #define EL 7 /* Literal data (??) */
209: #define NF 8 /* Name of function with no args */
210: #define MF 9 /* Monadic function */
211: #define DF 10 /* Dyadic function */
212: #define QC 11
213:
214: /*
215: * Idiosyncracies
216: */
217:
218: #define data double
219: #define unsignd unsigned
220:
221: /*
222: * Structures
223: */
224:
225: struct {
226: char c[8];
227: };
228:
229: struct env {
230: double fuzz;
231: int iorg;
232: int digits;
233: int width;
234: } thread;
235:
236: struct item {
237: char rank;
238: char type;
239: int size;
240: int index;
241: data *datap;
242: int dim[MRANK];
243: };
244:
245: struct nlist {
246: char use;
247: char type; /* == LV */
248: int *itemp;
249: char *namep;
250: int label;
251: } nlist[NLS];
252:
253: struct lablist {
254: char *lname;
255: int lno;
256: struct lablist *nextll;
257: } labldefs;
258:
259: struct {
260: char rank;
261: char type;
262: int size;
263: int dimk;
264: int delk;
265: int dim[MRANK];
266: int del[MRANK];
267: int idx[MRANK];
268: } idx;
269:
270: struct {
271: char *name;
272: int line;
273: } now_xeq;
274:
275: struct item **sp, **stack, **staktop; /* Internal run-time stack */
276:
277: /*
278: * Externals
279: */
280:
281: data zero;
282: data one;
283: data pi;
284: data maxexp;
285: data datum;
286: data getdat();
287:
288: int cs_size; /* Current stack size */
289:
290: int (*exop[])();
291:
292: double floor();
293: double ceil();
294: double log();
295: double sin();
296: double cos();
297: double atan();
298: double atan2();
299: double sqrt();
300: double exp();
301: double gamma();
302: double ltod();
303:
304: int integ;
305: int signgam;
306: int column;
307: int intflg;
308: int echoflg;
309: int ifile;
310: int wfile;
311: int ofile;
312: int funlc;
313: int debug;
314: int ttystat[3];
315: int stime[2];
316: char *pcp;
317: int rowsz;
318: int mencflg;
319: char *mencptr;
320: char *memstart;
321: int pt;
322: int syze;
323: int pas1;
324:
325: char *continu;
326:
327: struct charbox {
328: char a1,a2;
329: };
330:
331: struct asoperbox {
332: unsigned char letters[2];
333: int returnchar
334: };
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.