Debian Codegraph @

terps/alan2/acode.h

raw symbols SCIP
1 #ifndef _ACODE_H_
2 #define _ACODE_H_
3
4 #include <stddef.h>
5 #include <stdint.h>
6
7 typedef size_t Aptr; /* Type for an ACODE memory address */
8
9 typedef uint32_t Aword; /* Type for an ACODE word */
10 typedef uint32_t Aaddr; /* Type for an ACODE address */
11 typedef uint32_t Abool; /* Type for an ACODE Boolean value */
12 typedef int32_t Aint; /* Type for an ACODE Integer value */
13
14 /* Constants for the Acode file, words/block & bytes/block */
15 #define BLOCKLEN 256L
16 #define BLOCKSIZE (BLOCKLEN*sizeof(Aword))
17
18
19 /* Definitions for the packing process */
20 typedef int32_t CodeValue;
21 #define VALUEBITS 16
22
23 #define EOFChar 256
24 #define TOPVALUE (((CodeValue)1<<VALUEBITS) - 1) /* Highest value possible */
25
26 /* Half and quarter points in the code value range */
27 #define ONEQUARTER (TOPVALUE/4+1) /* Point after first quarter */
28 #define HALF (2*ONEQUARTER) /* Point after first half */
29 #define THREEQUARTER (3*ONEQUARTER) /* Point after third quarter */
30
31
32 /* AMACHINE Word Classes */
33 typedef int WrdKind;
34 #define WRD_SYN 0 /* 1 - Synonym */
35 #define WRD_ADJ 1 /* 2 - Adjective */
36 #define WRD_ALL 2 /* 4 - All */
37 #define WRD_BUT 3 /* 8 - But */
38 #define WRD_CONJ 4 /* 16 - Conjunction */
39 #define WRD_PREP 5 /* 32 - Preposition */
40 #define WRD_DIR 6 /* 64 - Direction */
41 #define WRD_IT 7 /* 128 - It */
42 #define WRD_NOISE 8 /* 256 - Noise word */
43 #define WRD_NOUN 9 /* 512 - Noun */
44 #define WRD_ACT 10 /* 1024 - Actor */
45 #define WRD_THEM 11 /* 2048 - Them */
46 #define WRD_VRB 12 /* 4096 - Verb */
47 #define WRD_CLASSES 13
48
49
50
51 /* Syntax element classifications */
52 #define EOS (-2) /* End Of Syntax */
53
54 /* Syntax element flag bits */
55 #define MULTIPLEBIT 0x1
56 #define OMNIBIT 0x2
57
58
59 /* Parameter Classes */
60 typedef enum ClaKind { /* NOTE! These must have the same order as */
61 CLA_OBJ = 1, /* the name classes in NAM.H */
62 CLA_CNT = (int)CLA_OBJ<<1,
63 CLA_ACT = (int)CLA_CNT<<1,
64 CLA_NUM = (int)CLA_ACT<<1,
65 CLA_STR = (int)CLA_NUM<<1,
66 CLA_COBJ = (int)CLA_STR<<1,
67 CLA_CACT = (int)CLA_COBJ<<1
68 } ClaKind;
69
70
71 /* Verb Qualifiers */
72 typedef enum QualClass {
73 Q_DEFAULT,
74 Q_AFTER,
75 Q_BEFORE,
76 Q_ONLY
77 } QualClass;
78
79
80 /* The AMACHINE Operations */
81 typedef enum OpClass {
82 C_CONST,
83 C_STMOP,
84 C_CURVAR
85 } OpClass;
86
87 typedef enum InstClass {
88 I_PRINT, /* Print a string from the text file */
89 I_QUIT,
90 I_LOOK,
91 I_SAVE,
92 I_RESTORE,
93 I_LIST, /* List contents of a container */
94 I_EMPTY,
95 I_SCORE,
96 I_VISITS,
97 I_SCHEDULE,
98 I_CANCEL,
99 I_LOCATE,
100 I_MAKE,
101 I_SET, /* Set a numeric attribute to the */
102 /* value on top of stack */
103 I_STRSET, /* Set a string valued attribute to a */
104 /* copy of the string on top of stack, */
105 /* deallocate current contents first */
106 I_GETSTR, /* Get a string contents from text */
107 /* file, create a copy and push it */
108 /* on top of stack */
109 I_INCR, /* Increment an attribute */
110 I_DECR, /* Decrement a numeric attribute */
111 I_USE,
112 I_IN,
113 I_DESCRIBE,
114 I_SAY,
115 I_SAYINT,
116 I_SAYSTR,
117 I_IF,
118 I_ELSE,
119 I_ENDIF,
120 I_ATTRIBUTE,
121 I_STRATTR, /* Push a copy of a string attribute */
122 I_HERE,
123 I_NEAR,
124 I_WHERE,
125 I_AND,
126 I_OR,
127 I_NE,
128 I_EQ,
129 I_STREQ, /* String compare */
130 I_STREXACT,
131 I_LE,
132 I_GE,
133 I_LT,
134 I_GT,
135 I_PLUS,
136 I_MINUS,
137 I_MULT,
138 I_DIV,
139 I_NOT,
140 I_UMINUS,
141 I_RND,
142 I_SUM, /* SUM-aggregate */
143 I_MAX, /* MAX-aggregate */
144 I_COUNT, /* COUNT-aggregate */
145 I_RETURN,
146 I_SYSTEM,
147 I_RESTART, /* INTRODUCED: v2.7 */
148 I_BTW, /* INTRODUCED: v2.8 */
149 I_CONTAINS, /* -""- */
150 I_DEPSTART, /* -""- */
151 I_DEPCASE, /* -""- */
152 I_DEPEXEC, /* -""- */
153 I_DEPELSE, /* -""- */
154 I_DEPEND /* -""- */
155 } InstClass;
156
157
158 typedef enum VarClass {
159 V_PARAM,
160 V_CURLOC,
161 V_CURACT,
162 V_CURVRB,
163 V_SCORE
164 } VarClass;
165
166
167 #define I_CLASS(x) ((x)>>28)
168 #define I_OP(x) ((x&0x8000000)?(x)|0x0f0000000:(x)&0x0fffffff)
169
170
171 typedef struct AcdHdr {
172 /* Important info */
173 char vers[4]; /* 01 - Version of compiler */
174 Aword size; /* 02 - Size of ACD-file in Awords */
175 /* Options */
176 Abool pack; /* 03 - Is the text packed ? */
177 Aword paglen; /* 04 - Length of a page */
178 Aword pagwidth; /* 05 - and width */
179 Aword debug; /* 06 - Option debug */
180 /* Data structures */
181 Aaddr dict; /* 07 - Dictionary */
182 Aaddr oatrs; /* 08 - Object default attributes */
183 Aaddr latrs; /* 09 - Location default attributes */
184 Aaddr aatrs; /* 0a - Actor default attributes */
185 Aaddr acts; /* 0b - Actor table */
186 Aaddr objs; /* 0c - Object table */
187 Aaddr locs; /* 0d - Location table */
188 Aaddr stxs; /* 0e - Syntax table */
189 Aaddr vrbs; /* 0f - Verb table */
190 Aaddr evts; /* 10 - Event table */
191 Aaddr cnts; /* 11 - Container table */
192 Aaddr ruls; /* 12 - Rule table */
193 Aaddr init; /* 13 - String init table */
194 Aaddr start; /* 14 - Start code */
195 Aword msgs; /* 15 - Messages table */
196 /* Miscellaneous */
197 Aword objmin, objmax; /* 16 - Interval for object codes */
198 Aword actmin, actmax; /* 18 - Interval for actor codes */
199 Aword cntmin, cntmax; /* 1a - Interval for container codes */
200 Aword locmin, locmax; /* 1c - Interval for location codes */
201 Aword dirmin, dirmax; /* 1e - Interval for direction codes */
202 Aword evtmin, evtmax; /* 20 - Interval for event codes */
203 Aword rulmin, rulmax; /* 22 - Interval for rule codes */
204 Aword maxscore; /* 24 - Maximum score */
205 Aaddr scores; /* 25 - Score table */
206 Aaddr freq; /* 26 - Address to Char freq's for coding */
207 Aword acdcrc; /* 27 - Checksum for acd code (excl. hdr) */
208 Aword txtcrc; /* 28 - Checksum for text data file */
209 } AcdHdr;
210
211 /* Error message numbers */
212 typedef enum MsgKind {
213 M_HUH, /* Obsolete */
214 M_WHAT,
215 M_WHAT_ALL,
216 M_WHAT_IT,
217 M_WHAT_THEM,
218 M_MULTIPLE,
219 M_WANT,
220 M_NOUN,
221 M_AFTER_BUT,
222 M_BUT_ALL,
223 M_NOT_MUCH,
224 M_WHICH_ONE,
225 M_NO_SUCH,
226 M_NO_WAY,
227 M_CANT0,
228 M_CANT,
229 M_NOTHING, /* Obsolete */
230 M_SEEOBJ1,
231 M_SEEOBJ2,
232 M_SEEOBJ3,
233 M_SEEOBJ4,
234 M_SEEACT,
235 M_CONTAINS1,
236 M_CONTAINS2,
237 M_CONTAINS3,
238 M_CONTAINS4,
239 M_CONTAINS5,
240 M_EMPTY1,
241 M_EMPTY2,
242 M_SCORE1,
243 M_SCORE2,
244 M_UNKNOWN_WORD,
245 M_MORE,
246 M_AGAIN,
247 M_SAVEWHERE,
248 M_SAVEOVERWRITE,
249 M_SAVEFAILED,
250 M_SAVEMISSING,
251 M_SAVEVERS,
252 M_SAVENAME,
253 M_RESTOREFROM,
254 M_REALLY, /* CHANGED: v2.7 from M_RESTART */
255 M_QUITACTION, /* INTRODUCED: v2.7, so M_ARTICLE moved */
256 M_ARTICLE, /* INTRODUCED: v2.6 but replaced the M_NOMSG*/
257 MSGMAX
258 } MsgKind;
259
260 #define M_ARTICLE26 M_QUITACTION
261 #define M_MSGMAX26 M_ARTICLE
262
263 #endif