996
|
1 /*
|
|
2 * Copyright (c) 2005 Gregor Richards
|
|
3 *
|
|
4 * This file is part of egobfi.
|
|
5 *
|
|
6 * egobfi is free software; you can redistribute it and/or modify
|
|
7 * it under the terms of the GNU General Public License as published by
|
|
8 * the Free Software Foundation; either version 2 of the License, or
|
|
9 * (at your option) any later version.
|
|
10 *
|
|
11 * egobfi is distributed in the hope that it will be useful,
|
|
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
14 * GNU General Public License for more details.
|
|
15 *
|
|
16 * You should have received a copy of the GNU General Public License
|
|
17 * along with egobfi; if not, write to the Free Software
|
|
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
|
19 */
|
|
20
|
|
21 #ifndef EGOBFI_H
|
|
22 #define EGOBFI_H
|
|
23
|
|
24 #include <stdint.h>
|
|
25
|
|
26 struct bfi {
|
|
27 enum { NIL,
|
|
28 ADD,
|
|
29 RHT,
|
|
30 LPO,
|
|
31 LPC,
|
|
32 OUT,
|
|
33 INP,
|
|
34 DBG,
|
|
35 ZRO,
|
|
36 ADDTO,
|
|
37 FIN
|
|
38 } cmd;
|
|
39 int arg1;
|
|
40 int arg2;
|
|
41 };
|
|
42
|
|
43
|
|
44 #define CHKIPSZ(a) if ((a) >= iplen) { \
|
|
45 iplen += 3000; \
|
|
46 iprog = (char *) realloc(iprog, iplen); \
|
|
47 if (iprog == NULL) { perror("realloc"); exit(1); } \
|
|
48 memset(iprog + iplen - 3000, 0, 3000); \
|
|
49 }
|
|
50
|
|
51 #ifndef EGOBFC2M
|
|
52 #define CHKPSZ(a) if ((a) >= plen) { \
|
|
53 plen += 3000; \
|
|
54 prog = (struct bfi *) realloc(prog, plen * sizeof(struct bfi)); \
|
|
55 if (prog == NULL) { perror("realloc"); exit(1); } \
|
|
56 memset(prog + plen - 3000, 0, 3000 * sizeof(struct bfi)); \
|
|
57 }
|
|
58 #else
|
|
59 #define CHKPSZ(a) if ((a) >= plen) { \
|
|
60 plen += 10000; \
|
|
61 prog = realloc(prog, plen); \
|
|
62 if (prog == NULL) { perror("realloc"); exit(1); } \
|
|
63 }
|
|
64 #endif
|
|
65
|
|
66 #define CHKMSZ(a) if ((a) >= mend) { \
|
|
67 mlen += 3000; \
|
|
68 mptr = (USEINT *) ((int) mptr - (int) mem); \
|
|
69 mem = (USEINT *) realloc(mem, mlen * sizeof(USEINT)); \
|
|
70 if (mem == NULL) { perror("realloc"); exit(1); } \
|
|
71 mend = mem + mlen; \
|
|
72 mptr = (USEINT *) ((int) mem + (int) mptr); \
|
|
73 memset(mem + mlen - 3000, 0, 3000 * sizeof(USEINT)); \
|
|
74 }
|
|
75
|
|
76 #define ISBF(a) ((a) == '+' || \
|
|
77 (a) == '-' || \
|
|
78 (a) == '>' || \
|
|
79 (a) == '<' || \
|
|
80 (a) == ']' || \
|
|
81 (a) == '[' || \
|
|
82 (a) == '.' || \
|
|
83 (a) == ',' || \
|
|
84 (a) == '#')
|
|
85
|
|
86 extern int wrapping;
|
|
87 extern int debug;
|
|
88 extern int eof;
|
|
89 extern int compile;
|
|
90 extern int unicode;
|
|
91
|
|
92 #ifdef EGOBFC
|
|
93 extern int bytewidth;
|
|
94 #else
|
|
95 extern USEINT bwmax;
|
|
96 extern USEINT *mem;
|
|
97 extern int mlen;
|
|
98 extern USEINT *mend;
|
|
99 extern USEINT *mptr;
|
|
100 #endif
|
|
101
|
|
102 extern char *iprog;
|
|
103 extern int iplen;
|
|
104 extern int ipptr;
|
|
105
|
|
106 #ifndef EGOBFC2M
|
|
107 extern struct bfi *prog;
|
|
108 extern int plen;
|
|
109 extern int pptr;
|
|
110 #else
|
|
111 extern void (*prog)();
|
|
112 extern void (*tprog)();
|
|
113 extern int plen;
|
|
114 extern int pptr;
|
|
115 #endif
|
|
116
|
|
117 #endif
|