comparison tests/agcl/parsifal/good/rfc822a.c @ 0:13d2b8934445

Import AnaGram (near-)release tree into Mercurial.
author David A. Holland
date Sat, 22 Dec 2007 17:52:45 -0500
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:13d2b8934445
1 #define GET_CONTEXT CONTEXT = PCB.pointer
2
3 /*
4 * AnaGram, A System for Syntax Directed Programming
5 * File generated by: ...
6 *
7 * AnaGram Parsing Engine
8 * Copyright 1993-2002 Parsifal Software. All Rights Reserved.
9 *
10 * This software is provided 'as-is', without any express or implied
11 * warranty. In no event will the authors be held liable for any damages
12 * arising from the use of this software.
13 *
14 * Permission is granted to anyone to use this software for any purpose,
15 * including commercial applications, and to alter it and redistribute it
16 * freely, subject to the following restrictions:
17 *
18 * 1. The origin of this software must not be misrepresented; you must not
19 * claim that you wrote the original software. If you use this software
20 * in a product, an acknowledgment in the product documentation would be
21 * appreciated but is not required.
22 * 2. Altered source versions must be plainly marked as such, and must not be
23 * misrepresented as being the original software.
24 * 3. This notice may not be removed or altered from any source distribution.
25 */
26
27 #ifndef RFC822A_H
28 #include "rfc822a.h"
29 #endif
30
31 #ifndef RFC822A_H
32 #error Mismatched header file
33 #endif
34
35 #include <ctype.h>
36 #include <stdio.h>
37
38 #define RULE_CONTEXT (&((PCB).cs[(PCB).ssx]))
39 #define ERROR_CONTEXT ((PCB).cs[(PCB).error_frame_ssx])
40 #define CONTEXT ((PCB).cs[(PCB).ssx])
41
42
43
44 rfc822a_pcb_type rfc822a_pcb;
45 #define PCB rfc822a_pcb
46
47 /* Line -, rfc822a.syn */
48 /**************************************************************
49 * Input function to the parsing engine.
50 *
51 * It takse a pointer to a string and a ponter to a Request Object
52 * that will be populated
53 ***************************************************************/
54 /*INT rfc822_parser(char *buffer, CRfc822Req *Request)
55 {
56 PCB.pointer = (unsigned char *)buffer;
57 pRequest = Request;
58 rfc822parse();
59 return PCB.exit_flag;
60
61 }*/
62
63 #ifndef CONVERT_CASE
64
65 static const char agCaseTable[31] = {
66 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
67 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
68 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0,
69 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20
70 };
71
72 static int agConvertCase(int c) {
73 if (c >= 'a' && c <= 'z') return c ^= 0x20;
74 if (c >= 0xe0 && c < 0xff) c ^= agCaseTable[c-0xe0];
75 return c;
76 }
77
78 #define CONVERT_CASE(c) agConvertCase(c)
79
80 #endif
81
82
83 #ifndef TAB_SPACING
84 #define TAB_SPACING 8
85 #endif
86
87
88 #define READ_COUNTS
89 #define WRITE_COUNTS
90 #undef V
91 #define V(i,t) (*t (&(PCB).vs[(PCB).ssx + i]))
92 #undef VS
93 #define VS(i) (PCB).vs[(PCB).ssx + i]
94
95 #ifndef GET_CONTEXT
96 #define GET_CONTEXT CONTEXT = (PCB).input_context
97 #endif
98
99 typedef enum {
100 ag_action_1,
101 ag_action_2,
102 ag_action_3,
103 ag_action_4,
104 ag_action_5,
105 ag_action_6,
106 ag_action_7,
107 ag_action_8,
108 ag_action_9,
109 ag_action_10,
110 ag_action_11,
111 ag_action_12
112 } ag_parser_action;
113
114
115 #ifndef NULL_VALUE_INITIALIZER
116 #define NULL_VALUE_INITIALIZER = 0
117 #endif
118
119 static int const ag_null_value NULL_VALUE_INITIALIZER;
120
121 static const unsigned char ag_rpx[] = {
122 0
123 };
124
125 static const unsigned char ag_key_itt[] = {
126 0
127 };
128
129 static const unsigned short ag_key_pt[] = {
130 0
131 };
132
133 static const unsigned char ag_key_ch[] = {
134 0, 66, 84,255, 45,255, 84,255, 78,255, 69,255, 67, 83, 84,255, 69,255,
135 66, 67, 68, 70, 77, 82, 84,255, 70,255, 66, 84,255, 45,255, 84,255, 78,
136 255, 69,255, 67, 83, 84,255, 69,255, 13, 66, 67, 68, 70, 77, 82, 84,255,
137 82,255, 65, 85,255, 72, 85,255, 70, 77, 83, 84, 87,255, 66, 84,255, 45,
138 255, 84,255, 78,255, 69,255, 67, 83, 84,255, 69,255, 13, 66, 67, 68, 70,
139 77, 80, 82, 84,255, 80,255, 83,255, 66, 70, 83, 84,255, 45,255, 84,255,
140 78,255, 69,255, 67, 80, 83, 84,255, 69,255, 13, 66, 67, 68, 70, 77, 82,
141 84,255, 66, 70, 83, 84,255, 45,255, 84,255, 78,255, 69,255, 67, 83, 84,
142 255, 69,255, 13, 66, 67, 68, 70, 77, 82, 84,255, 82,255, 13,255, 70, 82,
143 255, 66, 82, 84,255, 45,255, 84,255, 78,255, 69,255, 67, 83, 84,255, 69,
144 255, 13, 66, 67, 68, 70, 77, 82, 84,255, 79, 82,255, 66, 70, 73, 86, 87,
145 255, 67, 89,255, 79, 82,255, 66, 70, 82, 83, 84,255, 45,255, 84,255, 78,
146 255, 69,255, 67, 80, 83, 84,255, 69,255, 13, 66, 67, 68, 70, 73, 77, 80,
147 82, 84, 86, 87,255, 80, 85,255, 76, 78,255, 65, 85,255, 82, 89,255, 65,
148 255, 65, 68, 70, 74, 77, 78, 79, 83,255, 66, 82, 84,255, 45,255, 84,255,
149 78,255, 69,255, 67, 83, 84,255, 69,255, 13, 66, 67, 68, 70, 77, 80, 82,
150 84,255, 68, 83,255, 68, 83,255, 68, 83,255, 68, 83,255, 67, 69, 71, 77,
151 80, 85,255
152 };
153
154 static const unsigned char ag_key_act[] = {
155 0,3,3,4,2,4,2,4,2,4,2,4,3,2,3,4,2,4,3,3,3,3,3,2,3,4,3,4,3,3,4,2,4,2,4,
156 2,4,2,4,3,2,3,4,2,4,3,3,3,3,3,3,2,3,4,3,4,3,3,4,3,3,4,3,3,2,2,3,4,3,3,
157 4,2,4,2,4,2,4,2,4,3,2,3,4,2,4,3,3,3,3,3,3,3,2,3,4,3,4,3,4,3,3,3,3,4,2,
158 4,2,4,2,4,2,4,3,3,2,3,4,2,4,3,3,3,3,3,3,2,3,4,3,3,3,3,4,2,4,2,4,2,4,2,
159 4,3,2,3,4,2,4,3,3,3,3,3,3,2,3,4,3,4,3,4,3,3,4,3,3,3,4,2,4,2,4,2,4,2,4,
160 3,2,3,4,2,4,3,3,3,3,3,3,2,3,4,3,3,4,3,2,3,3,3,4,3,0,4,3,3,4,3,3,3,3,3,
161 4,2,4,2,4,2,4,2,4,3,3,2,3,4,2,4,3,2,3,3,2,3,3,3,2,3,3,3,4,3,3,4,0,0,4,
162 3,2,4,0,0,4,2,4,2,3,3,2,2,3,3,3,4,3,3,3,4,2,4,2,4,2,4,2,4,3,2,3,4,2,4,
163 3,3,3,3,3,3,3,2,3,4,3,3,4,3,3,4,3,3,4,3,3,4,2,2,3,2,2,3,4
164 };
165
166 static const unsigned char ag_key_parm[] = {
167 0, 63, 58, 0, 0, 0, 0, 0, 0, 0, 0, 0, 60, 0,156, 0, 0, 0,
168 61, 59,117, 18,116, 0, 56, 0, 18, 0, 63, 58, 0, 0, 0, 0, 0, 0,
169 0, 0, 0, 60, 0,156, 0, 0, 0, 30, 61, 59,117, 18,116, 0, 56, 0,
170 132, 0, 51, 52, 0, 49, 47, 0, 50, 46, 0, 0, 48, 0, 63, 58, 0, 0,
171 0, 0, 0, 0, 0, 0, 0, 60, 0,156, 0, 0, 0, 30, 61, 59,117, 18,
172 116, 89, 0, 56, 0, 89, 0, 21, 0, 63,153,152, 58, 0, 0, 0, 0, 0,
173 0, 0, 0, 0, 60,119, 0,156, 0, 0, 0, 30, 61, 59,117, 18,116, 0,
174 56, 0, 63,153,152, 58, 0, 0, 0, 0, 0, 0, 0, 0, 0, 60, 0,156,
175 0, 0, 0, 30, 61, 59,117, 18,116, 0, 56, 0,154, 0, 30, 0, 18,132,
176 0, 63,150, 58, 0, 0, 0, 0, 0, 0, 0, 0, 0, 60, 0,156, 0, 0,
177 0, 30, 61, 59,117, 18,116, 0, 56, 0,146, 18, 0,138, 0,144,140,142,
178 0, 61,138, 0,146, 18, 0, 63,153,150,152, 58, 0, 0, 0, 0, 0, 0,
179 0, 0, 0, 60,119, 0,156, 0, 0, 0, 30, 0, 59,117, 0,144,116, 89,
180 0, 56,140,142, 0,103,107, 0,106,105, 0,100, 0, 0,102,104, 0, 0,
181 0, 0,111,101, 0, 0,110,109,108, 0, 63,150, 58, 0, 0, 0, 0, 0,
182 0, 0, 0, 0, 60, 0,156, 0, 0, 0, 30, 61, 59,117, 18,116, 89, 0,
183 56, 0,173,172, 0,171,170, 0,175,174, 0,177,176, 0, 0, 0,169, 0,
184 0,168, 0
185 };
186
187 static const unsigned short ag_key_jmp[] = {
188 0, 30, 33, 0, 1, 0, 4, 0, 6, 0, 8, 0, 23, 10, 35, 0, 12, 0,
189 0, 3, 5, 9, 13, 16, 44, 0, 46, 0, 82, 85, 0, 28, 0, 31, 0, 33,
190 0, 35, 0, 75, 37, 87, 0, 39, 0, 50, 52, 55, 57, 61, 65, 43, 96, 0,
191 98, 0,112,114, 0,116,118, 0,106,109, 56, 59,120, 0,161,164, 0, 68,
192 0, 71, 0, 73, 0, 75, 0,154, 77,166, 0, 79, 0,123,125,128,130,134,
193 138,148, 83,175, 0,177, 0,183, 0,227,230,234,240, 0, 99, 0,104, 0,
194 106, 0,108, 0,214,221,110,242, 0,112, 0,189,191,194,196,200,204,117,
195 251, 0,285,288,292,298, 0,128, 0,133, 0,135, 0,137, 0,278,139,300,
196 0,141, 0,253,255,258,260,264,268,145,309, 0,311, 0,322, 0,324,328,
197 0,368,371,379, 0,163, 0,167, 0,169, 0,171, 0,361,173,381, 0,175,
198 0,336,338,341,343,347,351,179,390, 0,394,396, 0,392,190,399,401,404,
199 0,410, 0, 0,418,420, 0,454,457,461,469,475, 0,205, 0,211, 0,213,
200 0,215, 0,441,448,217,477, 0,219, 0,408,199,412,414,202,423,425,435,
201 224,486,488,491, 0,495,497, 0, 0, 0, 0,505,242, 0, 0, 0, 0,248,
202 0,239,499,502,245,251,507,510,513, 0,554,557,565, 0,262, 0,266, 0,
203 268, 0,270, 0,547,272,567, 0,274, 0,516,518,521,523,527,531,541,278,
204 576, 0,578,580, 0,582,584, 0,589,591, 0,593,595, 0,290,293,586,296,
205 299,597, 0
206 };
207
208 static const unsigned short ag_key_index[] = {
209 18, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 26, 45, 45, 0, 54, 0, 62,
210 85, 85, 95, 95, 95, 95, 97, 0,119,147,156,158,158, 0, 0,160, 0, 0,
211 0,158, 0, 0, 0, 0, 45, 45, 45, 45, 0, 95, 0, 0, 0,181, 0, 0,
212 0, 0,193, 0, 0, 0, 0, 0,158, 0,158, 0, 0, 0, 0, 95, 95, 95,
213 0, 95, 95, 95, 0, 62,158,158,226, 0, 0, 0, 0, 0, 0, 0,193,253,
214 0, 0, 0, 0, 95, 0,147,280, 95,158, 0, 0, 0, 62, 0, 0,302, 95,
215 26, 45, 0, 0, 0, 0, 0, 95, 0, 95, 0, 0
216 };
217
218 static const unsigned char ag_key_ends[] = {
219 67,67,0, 67,0, 65,84,69,0, 82,79,77,0,
220 69,83,83,65,71,69,45,73,68,0, 69,78,84,45,67,67,0, 67,67,0, 79,0,
221 85,82,78,45,80,65,84,72,0, 79,0, 82,79,77,0, 10,0, 67,67,0,
222 67,0, 65,84,69,0, 82,79,77,0, 69,83,83,65,71,69,45,73,68,0,
223 69,78,84,45,67,67,0, 67,67,0, 79,0, 85,82,78,45,80,65,84,72,0,
224 79,0, 69,67,69,73,86,69,68,0, 82,73,0, 79,78,0, 84,0, 78,0,
225 85,0, 69,0, 69,68,0, 10,0, 67,67,0, 67,0, 65,84,69,0,
226 82,79,77,0, 69,83,83,65,71,69,45,73,68,0, 72,82,65,83,69,0,
227 69,78,84,45,67,67,0, 67,67,0, 79,0, 85,82,78,45,80,65,84,72,0,
228 79,0, 72,82,65,83,69,0, 69,78,68,69,82,0, 10,0, 67,67,0, 67,0,
229 65,84,69,0, 82,79,77,0, 69,83,83,65,71,69,45,73,68,0,
230 69,78,84,45,67,67,0, 76,89,45,84,79,0, 67,67,0, 82,79,77,0,
231 69,78,68,69,82,0, 79,0, 85,82,78,45,80,65,84,72,0, 79,0, 10,0,
232 67,67,0, 67,0, 65,84,69,0, 82,79,77,0,
233 69,83,83,65,71,69,45,73,68,0, 69,78,84,45,67,67,0, 67,67,0,
234 82,79,77,0, 69,78,68,69,82,0, 79,0, 85,82,78,45,80,65,84,72,0,
235 79,0, 69,83,69,78,84,45,68,65,84,69,0, 10,0, 82,79,77,0,
236 69,67,69,73,86,69,68,0, 10,0, 67,67,0, 67,0, 65,84,69,0,
237 82,79,77,0, 69,83,83,65,71,69,45,73,68,0, 69,78,84,45,67,67,0,
238 67,67,0, 69,80,76,89,45,84,79,0, 79,0, 85,82,78,45,80,65,84,72,0,
239 79,0, 89,0, 82,0, 79,77,0, 68,0, 73,65,0, 73,84,72,0, 10,0,
240 67,0, 67,0, 65,84,69,0, 82,0, 79,77,0, 68,0,
241 69,83,83,65,71,69,45,73,68,0, 72,82,65,83,69,0,
242 69,78,84,45,67,67,0, 76,89,45,84,79,0, 67,67,0, 82,79,77,0,
243 69,80,76,89,45,84,79,0, 69,78,68,69,82,0, 79,0,
244 85,82,78,45,80,65,84,72,0, 79,0, 73,65,0, 73,84,72,0, 82,0,
245 71,0, 69,67,0, 69,66,0, 78,0, 79,86,0, 67,84,0, 69,80,0, 10,0,
246 67,67,0, 67,0, 65,84,69,0, 82,79,77,0,
247 69,83,83,65,71,69,45,73,68,0, 72,82,65,83,69,0,
248 69,78,84,45,67,67,0, 67,67,0, 69,80,76,89,45,84,79,0, 79,0,
249 85,82,78,45,80,65,84,72,0, 79,0, 84,0, 84,0, 84,0, 84,0,
250 77,84,0, 84,0, 84,0, 84,0, 84,0, 84,0,
251 };
252
253 #define AG_TCV(x) ag_tcv[(x)]
254
255 static const unsigned char ag_tcv[] = {
256 182,182,182,182,182,182,182,182,182,183,182,182,182,184,182,182,182,182,
257 182,182,182,182,182,182,182,182,182,182,182,182,182,182, 22,181,180,181,
258 181,181,181,181, 20, 24,181,181, 43,181, 66,181, 37, 37, 37, 37, 37, 37,
259 37, 37, 37, 37, 19, 90,113,181,114,181, 14,178,178,178,178,178,178,178,
260 178,178,178,178,178,178,178,178,178,178,178,178,178,178,178,178,178,178,
261 178, 68,125, 71,181,181,181,178,178,178,178,178,178,178,178,178,178,178,
262 178,178,178,178,178,178,178,178,178,178,178,178,178,178,178,181,181,181,
263 181,182, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
264 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
265 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
266 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
267 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
268 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
269 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
270 0, 0, 0, 0
271 };
272
273 #ifndef SYNTAX_ERROR
274 #define SYNTAX_ERROR fprintf(stderr,"%s, line %d, column %d\n", \
275 (PCB).error_message, (PCB).line, (PCB).column)
276 #endif
277
278 #ifndef FIRST_LINE
279 #define FIRST_LINE 1
280 #endif
281
282 #ifndef FIRST_COLUMN
283 #define FIRST_COLUMN 1
284 #endif
285
286 #ifndef PARSER_STACK_OVERFLOW
287 #define PARSER_STACK_OVERFLOW {fprintf(stderr, \
288 "\nParser stack overflow, line %d, column %d\n",\
289 (PCB).line, (PCB).column);}
290 #endif
291
292 #ifndef REDUCTION_TOKEN_ERROR
293 #define REDUCTION_TOKEN_ERROR {fprintf(stderr, \
294 "\nReduction token error, line %d, column %d\n", \
295 (PCB).line, (PCB).column);}
296 #endif
297
298
299 #ifndef INPUT_CODE
300 #define INPUT_CODE(T) (T)
301 #endif
302
303 typedef enum
304 {ag_accept_key, ag_set_key, ag_jmp_key, ag_end_key, ag_no_match_key,
305 ag_cf_accept_key, ag_cf_set_key, ag_cf_end_key} key_words;
306
307 static void ag_get_key_word(int ag_k) {
308 int ag_save = (int) ((PCB).la_ptr - (PCB).pointer);
309 const unsigned char *ag_p;
310 int ag_ch;
311 while (1) {
312 switch (ag_key_act[ag_k]) {
313 case ag_cf_end_key: {
314 const unsigned char *sp = ag_key_ends + ag_key_jmp[ag_k];
315 do {
316 if ((ag_ch = *sp++) == 0) {
317 int ag_k1 = ag_key_parm[ag_k];
318 int ag_k2 = ag_key_pt[ag_k1];
319 if (ag_key_itt[ag_k2 + CONVERT_CASE(*(PCB).la_ptr)]) goto ag_fail;
320 (PCB).token_number = (rfc822a_token_type) ag_key_pt[ag_k1 + 1];
321 return;
322 }
323 } while (CONVERT_CASE(*(PCB).la_ptr++) == ag_ch);
324 goto ag_fail;
325 }
326 case ag_end_key: {
327 const unsigned char *sp = ag_key_ends + ag_key_jmp[ag_k];
328 do {
329 if ((ag_ch = *sp++) == 0) {
330 (PCB).token_number = (rfc822a_token_type) ag_key_parm[ag_k];
331 return;
332 }
333 } while (CONVERT_CASE(*(PCB).la_ptr++) == ag_ch);
334 }
335 case ag_no_match_key:
336 ag_fail:
337 (PCB).la_ptr = (PCB).pointer + ag_save;
338 return;
339 case ag_cf_set_key: {
340 int ag_k1 = ag_key_parm[ag_k];
341 int ag_k2 = ag_key_pt[ag_k1];
342 ag_k = ag_key_jmp[ag_k];
343 if (ag_key_itt[ag_k2 + CONVERT_CASE(*(PCB).la_ptr)]) break;
344 ag_save = (int) ((PCB).la_ptr - (PCB).pointer);
345 (PCB).token_number = (rfc822a_token_type) ag_key_pt[ag_k1+1];
346 break;
347 }
348 case ag_set_key:
349 ag_save = (int) ((PCB).la_ptr - (PCB).pointer);
350 (PCB).token_number = (rfc822a_token_type) ag_key_parm[ag_k];
351 case ag_jmp_key:
352 ag_k = ag_key_jmp[ag_k];
353 break;
354 case ag_accept_key:
355 (PCB).token_number = (rfc822a_token_type) ag_key_parm[ag_k];
356 return;
357 case ag_cf_accept_key: {
358 int ag_k1 = ag_key_parm[ag_k];
359 int ag_k2 = ag_key_pt[ag_k1];
360 if (ag_key_itt[ag_k2 + CONVERT_CASE(*(PCB).la_ptr)])
361 (PCB).la_ptr = (PCB).pointer + ag_save;
362 else (PCB).token_number = (rfc822a_token_type) ag_key_pt[ag_k1+1];
363 return;
364 }
365 }
366 ag_ch = CONVERT_CASE(*(PCB).la_ptr++);
367 ag_p = &ag_key_ch[ag_k];
368 if (ag_ch <= 255) while (*ag_p < ag_ch) ag_p++;
369 if (ag_ch > 255 || *ag_p != ag_ch) {
370 (PCB).la_ptr = (PCB).pointer + ag_save;
371 return;
372 }
373 ag_k = (int) (ag_p - ag_key_ch);
374 }
375 }
376
377
378 #ifndef AG_NEWLINE
379 #define AG_NEWLINE 10
380 #endif
381
382 #ifndef AG_RETURN
383 #define AG_RETURN 13
384 #endif
385
386 #ifndef AG_FORMFEED
387 #define AG_FORMFEED 12
388 #endif
389
390 #ifndef AG_TABCHAR
391 #define AG_TABCHAR 9
392 #endif
393
394 static void ag_track(void) {
395 int ag_k = (int) ((PCB).la_ptr - (PCB).pointer);
396 while (ag_k--) {
397 switch (*(PCB).pointer++) {
398 case AG_NEWLINE:
399 (PCB).column = 1, (PCB).line++;
400 case AG_RETURN:
401 case AG_FORMFEED:
402 break;
403 case AG_TABCHAR:
404 (PCB).column += (TAB_SPACING) - ((PCB).column - 1) % (TAB_SPACING);
405 break;
406 default:
407 (PCB).column++;
408 }
409 }
410 }
411
412
413 static void ag_prot(void) {
414 int ag_k;
415 ag_k = 128 - ++(PCB).btsx;
416 if (ag_k <= (PCB).ssx) {
417 (PCB).exit_flag = AG_STACK_ERROR_CODE;
418 PARSER_STACK_OVERFLOW;
419 return;
420 }
421 (PCB).bts[(PCB).btsx] = (PCB).sn;
422 (PCB).bts[ag_k] = (PCB).ssx;
423 (PCB).vs[ag_k] = (PCB).vs[(PCB).ssx];
424 (PCB).ss[ag_k] = (PCB).ss[(PCB).ssx];
425 (PCB).cs[ag_k] = (PCB).cs[(PCB).ssx];
426 }
427
428 static void ag_undo(void) {
429 if ((PCB).drt == -1) return;
430 while ((PCB).btsx) {
431 int ag_k = 128 - (PCB).btsx;
432 (PCB).sn = (PCB).bts[(PCB).btsx--];
433 (PCB).ssx = (PCB).bts[ag_k];
434 (PCB).vs[(PCB).ssx] = (PCB).vs[ag_k];
435 (PCB).ss[(PCB).ssx] = (PCB).ss[ag_k];
436 (PCB).cs[(PCB).ssx] = (PCB).cs[ag_k];
437 }
438 (PCB).token_number = (rfc822a_token_type) (PCB).drt;
439 (PCB).ssx = (PCB).dssx;
440 (PCB).sn = (PCB).dsn;
441 (PCB).drt = -1;
442 }
443
444
445 static const unsigned char ag_tstt[] = {
446 156,117,116,63,61,60,59,58,56,20,18,0,1,38,39,55,79,80,81,82,115,155,161,
447 162,
448 19,0,
449 22,0,
450 19,0,
451 19,0,
452 19,0,
453 19,0,
454 19,0,
455 19,0,
456 19,0,
457 19,0,
458 20,18,0,17,118,
459 22,0,
460 156,117,116,63,61,60,59,58,56,30,20,18,0,2,38,39,55,80,81,82,98,99,115,155,
461 161,162,
462 113,0,95,
463 132,0,131,167,
464 113,0,112,
465 52,51,50,49,48,47,46,37,0,41,42,44,
466 181,180,178,156,117,116,89,63,61,60,59,58,56,37,30,20,18,0,3,4,9,10,11,12,
467 13,62,126,
468 181,180,178,156,117,116,89,63,61,60,59,58,56,37,30,20,18,0,3,4,9,10,11,12,
469 13,62,126,
470 181,180,178,89,37,0,3,4,9,10,11,12,13,57,126,
471 181,180,178,89,37,0,3,4,9,10,11,12,13,57,126,
472 181,180,178,89,37,0,3,4,9,10,11,12,13,57,126,
473 181,180,178,89,37,0,3,4,9,10,11,12,13,57,126,
474 21,0,
475 19,0,
476 156,153,152,119,117,116,63,61,60,59,58,56,30,20,18,0,120,
477 156,153,152,117,116,63,61,60,59,58,56,30,20,18,0,148,149,163,
478 154,0,40,
479 184,183,182,181,180,178,125,114,113,90,71,68,66,43,37,30,24,22,20,19,14,0,
480 96,97,164,
481 30,0,2,98,
482 181,180,178,37,14,0,157,158,159,160,
483 19,0,
484 132,0,131,
485 181,180,178,37,0,3,4,12,13,126,
486 43,0,
487 37,0,8,33,34,
488 183,182,181,180,178,125,114,113,90,71,68,66,43,37,30,24,22,20,19,14,0,2,5,6,
489 7,29,32,123,128,129,130,
490 181,178,37,0,
491 22,0,
492 14,0,
493 22,19,0,
494 22,0,
495 22,0,
496 22,0,
497 22,0,
498 19,0,
499 181,180,178,89,37,0,3,4,10,12,13,126,
500 19,0,
501 19,0,
502 19,0,
503 156,150,117,116,63,61,60,59,58,56,30,20,18,0,151,
504 19,0,
505 181,178,68,37,0,3,15,64,65,67,73,
506 19,14,0,159,
507 181,180,178,37,0,3,4,12,13,126,
508 146,144,142,140,138,18,0,133,134,136,
509 114,0,
510 37,0,
511 22,0,
512 37,0,45,91,
513 183,22,0,
514 183,30,22,0,2,5,6,
515 184,183,182,181,180,178,125,114,113,90,71,68,66,43,37,24,22,20,19,14,0,86,
516 183,182,181,178,125,114,113,90,71,68,66,43,37,30,24,22,20,19,14,0,2,5,6,7,
517 29,32,123,128,
518 180,0,
519 66,0,93,94,
520 181,178,68,37,0,3,15,64,65,67,73,
521 113,0,95,
522 181,180,178,89,37,0,3,4,10,12,13,23,126,
523 181,180,178,89,37,0,3,4,9,10,11,12,13,126,
524 181,180,178,89,37,0,3,4,10,12,13,126,
525 22,0,
526 181,180,178,89,37,0,3,4,9,10,11,12,13,57,126,
527 181,180,178,89,37,0,3,4,10,12,13,23,126,
528 181,180,178,89,37,0,3,4,10,12,13,126,
529 19,0,
530 52,51,50,49,48,47,46,37,0,41,42,44,
531 183,182,181,180,178,125,114,113,90,66,43,37,30,24,22,20,19,14,0,2,5,6,7,29,
532 32,69,70,72,
533 181,178,37,0,
534 66,0,
535 114,0,
536 181,180,178,37,0,3,4,12,13,126,147,
537 113,0,112,145,
538 181,178,37,0,3,143,
539 181,178,37,0,3,141,
540 181,178,68,37,0,3,15,64,65,67,73,139,
541 181,178,68,37,0,3,15,64,65,67,73,137,
542 146,144,142,140,138,90,18,0,133,136,
543 111,110,109,108,107,106,105,104,103,102,101,100,0,35,
544 37,0,
545 22,0,
546 181,180,178,37,0,3,4,126,
547 66,0,93,
548 181,180,178,90,89,37,22,0,25,
549 22,0,
550 22,0,
551 181,180,178,156,150,117,116,89,63,61,60,59,58,56,37,30,22,20,18,0,25,
552 181,180,178,89,37,0,3,4,9,10,11,12,13,57,126,
553 183,182,181,180,178,125,114,113,90,71,66,43,37,30,24,22,20,19,14,0,2,5,6,7,
554 29,32,69,72,
555 181,178,68,37,0,3,65,67,73,
556 181,178,37,0,
557 181,178,37,0,
558 52,51,50,49,48,47,46,37,0,41,42,44,135,
559 22,0,
560 19,0,
561 180,178,177,176,175,174,173,172,171,170,169,168,0,166,
562 181,180,178,89,37,0,3,4,10,12,13,126,
563 18,0,
564 22,0,
565 37,0,8,36,
566 37,0,
567 19,0,
568 37,0,
569 37,0,
570 181,180,178,89,37,0,3,4,10,12,13,23,126,
571 22,19,0,92,
572 181,180,178,89,37,24,22,0,25,
573 37,0,
574 37,0,
575
576 };
577
578
579 static unsigned const char ag_astt[932] = {
580 1,1,1,1,1,1,1,1,1,8,8,7,0,1,1,1,1,1,1,1,1,1,1,1,1,7,1,7,1,7,1,7,1,7,1,7,1,
581 7,1,7,1,7,1,7,1,1,7,1,1,1,5,1,1,1,1,1,1,1,1,1,1,8,8,7,1,3,1,3,3,3,3,1,1,3,
582 1,1,1,1,7,3,1,7,1,1,1,7,3,1,1,1,1,1,1,1,8,7,3,1,1,1,1,1,5,5,5,1,5,5,5,5,5,
583 5,1,5,5,5,7,1,1,3,3,3,3,1,3,1,1,1,1,5,5,5,1,5,5,5,5,5,5,1,5,5,5,7,1,1,3,3,
584 3,3,1,3,1,1,1,1,1,1,7,1,1,1,1,1,1,1,1,1,1,1,1,1,1,7,1,1,1,1,1,1,1,1,1,1,1,
585 1,1,1,7,1,1,1,1,1,1,1,1,1,1,1,1,1,1,7,1,1,1,1,1,1,1,1,1,1,7,1,7,5,5,5,1,5,
586 5,5,5,5,5,5,5,5,5,5,7,3,5,1,1,5,5,5,5,5,5,5,5,5,5,5,7,3,1,3,1,7,3,3,3,3,3,
587 3,3,3,3,3,3,3,3,3,3,3,5,3,3,3,3,3,7,3,3,3,1,5,1,3,8,8,8,8,1,7,1,1,1,1,1,7,
588 1,5,3,1,1,1,1,7,1,1,1,1,1,3,7,1,7,1,1,1,1,1,1,8,1,1,1,1,1,1,1,1,1,1,1,1,1,
589 1,1,1,7,1,1,1,1,1,1,1,1,1,1,9,9,9,5,1,7,1,7,1,1,7,1,5,1,5,1,5,1,5,1,7,1,1,
590 1,1,1,7,1,1,3,3,1,1,1,7,1,7,1,7,5,1,5,5,5,5,5,5,5,5,5,5,5,7,3,1,7,1,1,1,1,
591 7,1,3,1,1,1,1,3,1,7,3,1,1,1,1,7,1,1,1,1,1,1,1,1,1,1,1,7,1,1,1,3,7,9,5,1,7,
592 1,7,3,1,3,3,7,9,1,9,5,1,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,7,3,1,
593 9,9,9,1,9,9,9,9,9,9,9,9,1,9,1,9,9,9,5,1,1,1,1,3,3,3,3,3,7,1,7,1,1,1,1,1,1,
594 7,1,3,1,1,1,1,1,7,3,1,1,1,1,1,7,1,1,1,1,1,1,1,1,1,1,1,1,7,1,1,3,3,3,3,1,1,
595 1,1,1,1,1,7,1,1,1,1,1,1,1,7,1,1,1,1,1,7,1,1,1,1,1,1,1,1,1,1,1,1,1,1,7,1,1,
596 1,1,1,1,1,1,1,1,1,1,7,1,1,3,3,1,1,1,7,1,1,1,1,1,1,1,8,7,3,1,1,1,1,1,1,1,1,
597 1,1,1,1,1,1,1,1,1,1,1,1,7,1,1,1,1,1,1,1,1,1,9,9,9,5,1,5,3,7,1,1,1,1,7,1,1,
598 3,1,1,3,1,7,3,3,1,1,1,7,1,3,1,1,1,7,1,3,1,1,1,1,7,1,3,1,1,1,1,3,1,1,1,1,7,
599 1,3,1,1,1,1,3,1,1,1,1,1,1,1,7,3,1,1,1,1,1,1,1,1,1,1,1,1,1,7,1,1,7,1,7,1,1,
600 1,1,7,1,3,3,1,5,3,8,8,8,3,8,8,1,7,1,1,7,1,5,8,8,8,5,5,5,5,8,5,5,5,5,5,5,8,
601 5,1,5,5,7,1,1,1,1,1,1,7,1,1,1,1,1,1,1,1,1,1,9,9,9,9,1,9,9,9,3,9,9,9,1,9,1,
602 9,9,9,7,1,1,1,1,3,3,3,3,1,1,1,1,7,1,3,3,3,9,9,9,5,9,9,9,5,1,1,1,1,1,1,1,8,
603 7,3,1,1,3,1,7,1,7,3,3,3,3,3,3,3,3,3,3,3,3,7,3,1,1,1,1,1,7,1,1,3,3,1,1,1,7,
604 1,5,1,7,1,3,1,7,1,7,9,5,1,7,1,1,1,1,1,7,1,1,1,1,1,1,1,5,1,7,3,8,8,8,8,8,3,
605 1,7,1,1,7,3,7
606 };
607
608
609 static const unsigned char ag_pstt[] = {
610 1,4,3,5,6,7,8,9,10,11,11,0,0,13,12,13,13,13,13,13,13,2,11,11,
611 14,1,
612 15,2,
613 16,3,
614 17,4,
615 18,5,
616 19,6,
617 20,7,
618 21,8,
619 22,9,
620 23,10,
621 24,25,11,26,27,
622 28,27,
623 1,4,3,5,6,7,8,9,10,29,11,11,13,29,67,12,67,67,67,67,30,30,67,2,11,11,
624 31,14,153,
625 32,15,33,33,
626 34,16,112,
627 35,35,35,35,35,35,35,36,17,113,35,36,
628 38,37,38,46,46,46,41,46,46,46,46,46,46,38,46,46,46,18,38,39,49,49,49,49,40,
629 49,39,
630 38,37,38,46,46,46,41,46,46,46,46,46,46,38,46,46,46,19,38,39,48,48,48,48,40,
631 48,39,
632 38,37,38,41,38,20,38,39,42,42,42,42,40,42,39,
633 38,37,38,41,38,21,38,39,43,43,43,43,40,43,39,
634 38,37,38,41,38,22,38,39,44,44,44,44,40,44,39,
635 38,37,38,41,38,23,38,39,45,45,45,45,40,45,39,
636 46,24,
637 47,25,
638 114,114,114,48,114,114,114,114,114,114,114,114,114,114,114,26,116,
639 163,49,50,163,163,163,163,163,163,163,163,163,163,163,27,165,51,165,
640 52,28,28,
641 94,94,94,94,94,94,94,94,94,94,94,94,94,94,94,92,94,94,94,94,94,29,94,94,94,
642 29,97,29,96,
643 55,55,55,55,53,31,55,54,54,55,
644 56,32,
645 32,173,172,
646 38,37,38,38,34,38,39,57,40,39,
647 30,35,
648 58,36,58,60,59,
649 62,64,64,65,64,63,64,64,64,64,64,64,64,64,61,64,62,64,64,64,37,61,62,62,62,
650 64,64,64,64,64,65,
651 8,8,8,174,
652 66,39,
653 67,40,
654 68,69,41,
655 70,45,
656 70,44,
657 70,43,
658 70,42,
659 71,46,
660 38,37,38,72,38,47,38,39,9,9,40,39,
661 73,48,
662 74,49,
663 75,50,
664 147,76,147,147,147,147,147,147,147,147,147,147,147,51,149,
665 77,52,
666 79,79,78,79,53,79,155,80,80,80,80,
667 154,53,54,157,
668 38,37,38,38,55,38,39,81,40,39,
669 82,83,84,85,86,87,56,88,88,87,
670 110,57,
671 26,23,
672 89,59,
673 90,60,31,91,
674 84,84,61,
675 3,61,3,83,61,3,3,
676 122,122,122,122,122,122,122,122,122,122,122,122,122,122,122,122,122,122,122,
677 122,63,122,
678 62,124,124,124,63,124,124,124,124,124,124,124,124,61,124,62,124,124,124,126,
679 61,62,62,62,124,124,124,124,
680 127,65,
681 92,66,93,93,
682 79,79,78,79,67,79,6,80,80,80,80,
683 31,68,91,
684 38,37,38,72,38,69,38,39,94,94,40,94,39,
685 38,37,38,41,38,70,38,39,51,51,51,51,40,39,
686 38,37,38,72,38,71,38,39,95,95,40,39,
687 68,72,
688 38,37,38,41,38,73,38,39,96,96,96,96,40,96,39,
689 38,37,38,72,38,74,38,39,97,97,40,97,39,
690 38,37,38,72,38,75,38,39,150,150,40,39,
691 98,76,
692 35,35,35,35,35,35,35,36,77,152,35,36,
693 62,99,99,99,99,63,99,99,99,99,99,99,61,99,62,99,99,99,78,61,62,62,62,99,99,
694 99,99,99,
695 8,8,8,60,
696 100,52,
697 160,81,
698 38,37,38,38,82,38,39,138,40,39,138,
699 34,83,137,137,
700 101,101,101,84,101,136,
701 102,102,102,85,102,135,
702 79,79,78,79,86,79,134,80,80,80,80,134,
703 79,79,78,79,87,79,133,80,80,80,80,133,
704 82,83,84,85,86,103,87,88,131,87,
705 104,104,104,104,104,104,104,104,104,104,104,104,89,104,
706 105,90,
707 106,91,
708 38,37,38,38,92,38,86,86,
709 92,89,88,
710 107,107,107,79,107,107,107,94,107,
711 108,95,
712 70,115,
713 107,107,107,151,151,151,151,107,151,151,151,151,151,151,107,151,107,151,151,
714 97,107,
715 38,37,38,41,38,98,38,39,109,109,109,109,40,109,39,
716 62,56,56,56,56,63,56,56,56,57,56,56,56,61,56,62,56,56,56,99,61,62,62,62,56,
717 56,56,56,
718 79,79,78,79,100,79,54,54,54,
719 8,8,8,143,
720 8,8,8,142,
721 35,35,35,35,35,35,35,36,103,132,35,36,132,
722 110,104,
723 111,105,
724 170,170,170,170,170,170,170,170,170,170,170,170,106,170,
725 38,37,38,72,38,107,38,39,14,14,40,39,
726 112,108,
727 70,148,
728 113,110,113,22,
729 114,111,
730 115,112,
731 26,24,
732 116,114,
733 38,37,38,72,38,115,38,39,117,117,40,117,39,
734 80,118,116,82,
735 107,107,107,107,107,10,107,117,107,
736 119,118,
737 81,119,
738
739 };
740
741
742 static const unsigned short ag_sbt[] = {
743 0, 24, 26, 28, 30, 32, 34, 36, 38, 40, 42, 44, 49, 51,
744 77, 80, 84, 87, 99, 126, 153, 168, 183, 198, 213, 215, 217, 234,
745 252, 255, 280, 284, 294, 296, 299, 309, 311, 316, 347, 351, 353, 355,
746 358, 360, 362, 364, 366, 368, 380, 382, 384, 386, 401, 403, 414, 418,
747 428, 438, 440, 442, 444, 448, 451, 458, 480, 508, 510, 514, 525, 528,
748 541, 555, 567, 569, 584, 597, 609, 611, 623, 651, 655, 657, 659, 670,
749 674, 680, 686, 698, 710, 720, 734, 736, 738, 746, 749, 758, 760, 762,
750 783, 798, 826, 835, 839, 843, 856, 858, 860, 874, 886, 888, 890, 894,
751 896, 898, 900, 902, 915, 919, 928, 930, 932
752 };
753
754
755 static const unsigned short ag_sbe[] = {
756 11, 25, 27, 29, 31, 33, 35, 37, 39, 41, 43, 46, 50, 63,
757 78, 81, 85, 95, 116, 143, 158, 173, 188, 203, 214, 216, 232, 248,
758 253, 276, 281, 289, 295, 297, 303, 310, 312, 336, 350, 352, 354, 357,
759 359, 361, 363, 365, 367, 373, 381, 383, 385, 399, 402, 407, 416, 422,
760 434, 439, 441, 443, 445, 450, 454, 478, 499, 509, 511, 518, 526, 533,
761 546, 560, 568, 574, 589, 602, 610, 619, 641, 654, 656, 658, 663, 671,
762 677, 683, 690, 702, 717, 732, 735, 737, 742, 747, 756, 759, 761, 781,
763 788, 817, 830, 838, 842, 851, 857, 859, 872, 879, 887, 889, 891, 895,
764 897, 899, 901, 907, 917, 926, 929, 931, 932
765 };
766
767
768 static const unsigned char ag_fl[] = {
769 1,1,1,2,1,1,3,1,2,3,9,1,0,1,3,3,1,1,1,1,1,1,5,1,1,1,2,1,3,0,2,3,1,1,1,
770 1,1,1,1,1,1,1,3,3,3,3,0,1,3,3,1,3,1,1,3,1,2,3,1,1,1,1,1,0,1,4,1,2,1,1,
771 1,1,0,3,2,1,2,1,1,4,0,3,6,1,2,1,2,1,2,3,1,3,0,1,2,1,2,2,1,1,1,1,1,1,1,
772 1,1,1,1,1,3,1,3,3,0,3,2,1,2,1,1,1,2,1,2,0,1,3,1,1,1,2,5,2,2,2,2,2,2,1,
773 1,1,1,1,1,1,1,0,3,2,3,3,3,3,2,2,1,2,0,1,4,0,1,0,1,3,1,1,1,1,3,1,2,3,1,
774 1,1,1,1,1,1,1,1,1,1,1,1,1,1
775 };
776
777 static const unsigned char ag_ptt[] = {
778 0, 6, 7, 7, 9, 9, 12, 3, 3, 17, 17, 23, 25, 25, 23, 26, 27, 27,
779 27, 2, 28, 28, 33, 34, 36, 8, 8, 38, 38, 44, 44, 41, 42, 42, 42, 42,
780 42, 42, 42, 53, 53, 53, 55, 55, 55, 55, 62, 62, 55, 55, 57, 57, 15, 64,
781 64, 70, 70, 67, 69, 69, 73, 72, 72, 78, 78, 75, 79, 79, 80, 80, 80, 80,
782 85, 85, 77, 87, 87, 83, 76, 11, 92, 92, 91, 32, 5, 5, 93, 94, 94, 13,
783 10, 10, 97, 97, 98, 99, 99, 1, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35,
784 35, 35,112, 82,115, 39,120,120,118,122,122,121,123,123, 29,129,129,130,
785 130,126,128,128,134,134,131,133,133,133,133,133,133,136,137,139,141,143,
786 145,147,135,151,151,148,149,149, 40,155,157,159,158,158,160,160, 95,162,
787 162,163,163, 81, 65, 65, 96,164, 45,167,167,161, 4, 4,166,166,166,166,
788 166,166,166,166,166,166,166,166, 86
789 };
790
791
792 static void ag_ra(void)
793 {
794 }
795
796 #define TOKEN_NAMES rfc822a_token_names
797 const char *const rfc822a_token_names[185] = {
798 "message",
799 "message",
800 "CRLF",
801 "atom",
802 "word",
803 "linear_space",
804 "",
805 "",
806 "number",
807 "address",
808 "mailbox",
809 "group",
810 "addr_spec",
811 "local_part",
812 "'@'",
813 "domain",
814 "ATOM_CHAR",
815 "authentic",
816 "\"FROM\"",
817 "':'",
818 "'('",
819 "\"SENDER\"",
820 "SPACE",
821 "multiple_mailboxes",
822 "')'",
823 "",
824 "comment",
825 "comment_choice",
826 "ctext",
827 "quoted_pair",
828 "\"\\r\\n\"",
829 "",
830 "linear_white_space",
831 "date",
832 "day_numb",
833 "month",
834 "year",
835 "DIGIT",
836 "dates",
837 "orig_date",
838 "resent_date",
839 "date_time",
840 "day",
841 "','",
842 "",
843 "time",
844 "\"MON\"",
845 "\"TUE\"",
846 "\"WED\"",
847 "\"THU\"",
848 "\"FRI\"",
849 "\"SAT\"",
850 "\"SUN\"",
851 "delimeters",
852 "specials",
853 "destination",
854 "\"TO\"",
855 "addresses",
856 "\"RESENT-TO\"",
857 "\"CC\"",
858 "\"RECENT-CC\"",
859 "\"BCC\"",
860 "",
861 "\"RESENT-BCC\"",
862 "multiple_sub_domains",
863 "sub_domain",
864 "'.'",
865 "domain_literal",
866 "'['",
867 "literal_fill",
868 "",
869 "']'",
870 "dtext",
871 "domain_ref",
872 "",
873 "field",
874 "field_name",
875 "field_body",
876 "",
877 "fields",
878 "fields_makeup",
879 "source",
880 "optional_field",
881 "field_body_contents",
882 "LWSP_char",
883 "",
884 "CHAR",
885 "",
886 "",
887 "\"PHRASE\"",
888 "';'",
889 "hour",
890 "",
891 "",
892 "",
893 "route_addr",
894 "text",
895 "",
896 "",
897 "",
898 "\"JAN\"",
899 "\"FEB\"",
900 "\"MAR\"",
901 "\"APR\"",
902 "\"MAY\"",
903 "\"JUN\"",
904 "\"JUL\"",
905 "\"AUG\"",
906 "\"SEP\"",
907 "\"OCT\"",
908 "\"NOV\"",
909 "\"DEC\"",
910 "msg_id",
911 "'<'",
912 "'>'",
913 "optional_fields",
914 "\"MESSAGE-ID\"",
915 "\"DATE\"",
916 "originator",
917 "\"REPLY-TO\"",
918 "",
919 "phrase",
920 "",
921 "qtext",
922 "",
923 "'\\\\'",
924 "quoted_string",
925 "'\\\"'",
926 "QUOTED",
927 "",
928 "",
929 "received",
930 "\"RECEIVED\"",
931 "received_fields",
932 "",
933 "rec_date_time",
934 "from",
935 "from_domain",
936 "\"BY\"",
937 "by_domain",
938 "\"VIA\"",
939 "via_atom",
940 "\"WITH\"",
941 "with_atom",
942 "\"ID\"",
943 "rec_msg_id",
944 "\"FOR\"",
945 "for_addr_spec",
946 "resent",
947 "resent_authentic",
948 "\"RESENT-REPLY-TO\"",
949 "",
950 "\"RESENT-SENDER\"",
951 "\"RESENT-FROM\"",
952 "\"RESENT-DATE\"",
953 "return",
954 "\"RETURN-PATH\"",
955 "route",
956 "route_list",
957 "sub_route",
958 "",
959 "trace",
960 "",
961 "",
962 "text_char",
963 "",
964 "zone",
965 "",
966 "\"UT\"",
967 "\"GMT\"",
968 "\"EST\"",
969 "\"EDT\"",
970 "\"CST\"",
971 "\"CDT\"",
972 "\"MST\"",
973 "\"MDT\"",
974 "\"PST\"",
975 "\"PDT\"",
976 "ALPHA",
977 "",
978 "",
979 "",
980 "",
981 "",
982 "",
983
984 };
985
986 #ifndef MISSING_FORMAT
987 #define MISSING_FORMAT "Missing %s"
988 #endif
989 #ifndef UNEXPECTED_FORMAT
990 #define UNEXPECTED_FORMAT "Unexpected %s"
991 #endif
992 #ifndef UNNAMED_TOKEN
993 #define UNNAMED_TOKEN "input"
994 #endif
995
996
997 static void ag_diagnose(void) {
998 int ag_snd = (PCB).sn;
999 int ag_k = ag_sbt[ag_snd];
1000
1001 if (*TOKEN_NAMES[ag_tstt[ag_k]] && ag_astt[ag_k + 1] == ag_action_8) {
1002 sprintf((PCB).ag_msg, MISSING_FORMAT, TOKEN_NAMES[ag_tstt[ag_k]]);
1003 }
1004 else if (ag_astt[ag_sbe[(PCB).sn]] == ag_action_8
1005 && (ag_k = (int) ag_sbe[(PCB).sn] + 1) == (int) ag_sbt[(PCB).sn+1] - 1
1006 && *TOKEN_NAMES[ag_tstt[ag_k]]) {
1007 sprintf((PCB).ag_msg, MISSING_FORMAT, TOKEN_NAMES[ag_tstt[ag_k]]);
1008 }
1009 else if ((PCB).token_number && *TOKEN_NAMES[(PCB).token_number]) {
1010 sprintf((PCB).ag_msg, UNEXPECTED_FORMAT, TOKEN_NAMES[(PCB).token_number]);
1011 }
1012 else if (isprint(INPUT_CODE((*(PCB).pointer))) && INPUT_CODE((*(PCB).pointer)) != '\\') {
1013 char buf[20];
1014 sprintf(buf, "\'%c\'", (char) INPUT_CODE((*(PCB).pointer)));
1015 sprintf((PCB).ag_msg, UNEXPECTED_FORMAT, buf);
1016 }
1017 else sprintf((PCB).ag_msg, UNEXPECTED_FORMAT, UNNAMED_TOKEN);
1018 (PCB).error_message = (PCB).ag_msg;
1019
1020
1021 }
1022 static int ag_action_1_r_proc(void);
1023 static int ag_action_2_r_proc(void);
1024 static int ag_action_3_r_proc(void);
1025 static int ag_action_4_r_proc(void);
1026 static int ag_action_1_s_proc(void);
1027 static int ag_action_3_s_proc(void);
1028 static int ag_action_1_proc(void);
1029 static int ag_action_2_proc(void);
1030 static int ag_action_3_proc(void);
1031 static int ag_action_4_proc(void);
1032 static int ag_action_5_proc(void);
1033 static int ag_action_6_proc(void);
1034 static int ag_action_7_proc(void);
1035 static int ag_action_8_proc(void);
1036 static int ag_action_9_proc(void);
1037 static int ag_action_10_proc(void);
1038 static int ag_action_11_proc(void);
1039 static int ag_action_8_proc(void);
1040
1041
1042 static int (*const ag_r_procs_scan[])(void) = {
1043 ag_action_1_r_proc,
1044 ag_action_2_r_proc,
1045 ag_action_3_r_proc,
1046 ag_action_4_r_proc
1047 };
1048
1049 static int (*const ag_s_procs_scan[])(void) = {
1050 ag_action_1_s_proc,
1051 ag_action_2_r_proc,
1052 ag_action_3_s_proc,
1053 ag_action_4_r_proc
1054 };
1055
1056 static int (*const ag_gt_procs_scan[])(void) = {
1057 ag_action_1_proc,
1058 ag_action_2_proc,
1059 ag_action_3_proc,
1060 ag_action_4_proc,
1061 ag_action_5_proc,
1062 ag_action_6_proc,
1063 ag_action_7_proc,
1064 ag_action_8_proc,
1065 ag_action_9_proc,
1066 ag_action_10_proc,
1067 ag_action_11_proc,
1068 ag_action_8_proc
1069 };
1070
1071
1072 static int ag_action_10_proc(void) {
1073 int ag_t = (PCB).token_number;
1074 (PCB).btsx = 0, (PCB).drt = -1;
1075 do {
1076 ag_track();
1077 (PCB).token_number = (rfc822a_token_type) AG_TCV(INPUT_CODE(*(PCB).la_ptr));
1078 (PCB).la_ptr++;
1079 if (ag_key_index[(PCB).sn]) {
1080 unsigned ag_k = ag_key_index[(PCB).sn];
1081 int ag_ch = CONVERT_CASE(INPUT_CODE(*(PCB).pointer));
1082 if (ag_ch <= 255) {
1083 while (ag_key_ch[ag_k] < ag_ch) ag_k++;
1084 if (ag_key_ch[ag_k] == ag_ch) ag_get_key_word(ag_k);
1085 }
1086 }
1087 } while ((PCB).token_number == (rfc822a_token_type) ag_t);
1088 (PCB).la_ptr = (PCB).pointer;
1089 return 1;
1090 }
1091
1092 static int ag_action_11_proc(void) {
1093 int ag_t = (PCB).token_number;
1094
1095 (PCB).btsx = 0, (PCB).drt = -1;
1096 do {
1097 (PCB).vs[(PCB).ssx] = *(PCB).pointer;
1098 (PCB).ssx--;
1099 ag_track();
1100 ag_ra();
1101 if ((PCB).exit_flag != AG_RUNNING_CODE) return 0;
1102 (PCB).ssx++;
1103 (PCB).token_number = (rfc822a_token_type) AG_TCV(INPUT_CODE(*(PCB).la_ptr));
1104 (PCB).la_ptr++;
1105 if (ag_key_index[(PCB).sn]) {
1106 unsigned ag_k = ag_key_index[(PCB).sn];
1107 int ag_ch = CONVERT_CASE(INPUT_CODE(*(PCB).pointer));
1108 if (ag_ch <= 255) {
1109 while (ag_key_ch[ag_k] < ag_ch) ag_k++;
1110 if (ag_key_ch[ag_k] == ag_ch) ag_get_key_word(ag_k);
1111 }
1112 }
1113 }
1114 while ((PCB).token_number == (rfc822a_token_type) ag_t);
1115 (PCB).la_ptr = (PCB).pointer;
1116 return 1;
1117 }
1118
1119 static int ag_action_3_r_proc(void) {
1120 int ag_sd = ag_fl[(PCB).ag_ap] - 1;
1121 if (ag_sd) (PCB).sn = (PCB).ss[(PCB).ssx -= ag_sd];
1122 (PCB).btsx = 0, (PCB).drt = -1;
1123 (PCB).reduction_token = (rfc822a_token_type) ag_ptt[(PCB).ag_ap];
1124 ag_ra();
1125 return (PCB).exit_flag == AG_RUNNING_CODE;
1126 }
1127
1128 static int ag_action_3_s_proc(void) {
1129 int ag_sd = ag_fl[(PCB).ag_ap] - 1;
1130 if (ag_sd) (PCB).sn = (PCB).ss[(PCB).ssx -= ag_sd];
1131 (PCB).btsx = 0, (PCB).drt = -1;
1132 (PCB).reduction_token = (rfc822a_token_type) ag_ptt[(PCB).ag_ap];
1133 ag_ra();
1134 return (PCB).exit_flag == AG_RUNNING_CODE;
1135 }
1136
1137 static int ag_action_4_r_proc(void) {
1138 int ag_sd = ag_fl[(PCB).ag_ap] - 1;
1139 if (ag_sd) (PCB).sn = (PCB).ss[(PCB).ssx -= ag_sd];
1140 (PCB).reduction_token = (rfc822a_token_type) ag_ptt[(PCB).ag_ap];
1141 return 1;
1142 }
1143
1144 static int ag_action_2_proc(void) {
1145 (PCB).btsx = 0, (PCB).drt = -1;
1146 if ((PCB).ssx >= 128) {
1147 (PCB).exit_flag = AG_STACK_ERROR_CODE;
1148 PARSER_STACK_OVERFLOW;
1149 }
1150 (PCB).vs[(PCB).ssx] = *(PCB).pointer;
1151 GET_CONTEXT;
1152 (PCB).ss[(PCB).ssx] = (PCB).sn;
1153 (PCB).ssx++;
1154 (PCB).sn = (PCB).ag_ap;
1155 ag_track();
1156 return 0;
1157 }
1158
1159 static int ag_action_9_proc(void) {
1160 if ((PCB).drt == -1) {
1161 (PCB).drt=(PCB).token_number;
1162 (PCB).dssx=(PCB).ssx;
1163 (PCB).dsn=(PCB).sn;
1164 }
1165 ag_prot();
1166 (PCB).vs[(PCB).ssx] = ag_null_value;
1167 GET_CONTEXT;
1168 (PCB).ss[(PCB).ssx] = (PCB).sn;
1169 (PCB).ssx++;
1170 (PCB).sn = (PCB).ag_ap;
1171 (PCB).la_ptr = (PCB).pointer;
1172 return (PCB).exit_flag == AG_RUNNING_CODE;
1173 }
1174
1175 static int ag_action_2_r_proc(void) {
1176 (PCB).ssx++;
1177 (PCB).sn = (PCB).ag_ap;
1178 return 0;
1179 }
1180
1181 static int ag_action_7_proc(void) {
1182 --(PCB).ssx;
1183 (PCB).la_ptr = (PCB).pointer;
1184 (PCB).exit_flag = AG_SUCCESS_CODE;
1185 return 0;
1186 }
1187
1188 static int ag_action_1_proc(void) {
1189 ag_track();
1190 (PCB).exit_flag = AG_SUCCESS_CODE;
1191 return 0;
1192 }
1193
1194 static int ag_action_1_r_proc(void) {
1195 (PCB).exit_flag = AG_SUCCESS_CODE;
1196 return 0;
1197 }
1198
1199 static int ag_action_1_s_proc(void) {
1200 (PCB).exit_flag = AG_SUCCESS_CODE;
1201 return 0;
1202 }
1203
1204 static int ag_action_4_proc(void) {
1205 int ag_sd = ag_fl[(PCB).ag_ap] - 1;
1206 (PCB).reduction_token = (rfc822a_token_type) ag_ptt[(PCB).ag_ap];
1207 (PCB).btsx = 0, (PCB).drt = -1;
1208 (PCB).vs[(PCB).ssx] = *(PCB).pointer;
1209 if (ag_sd) (PCB).sn = (PCB).ss[(PCB).ssx -= ag_sd];
1210 else GET_CONTEXT;
1211 (PCB).ss[(PCB).ssx] = (PCB).sn;
1212 ag_track();
1213 while ((PCB).exit_flag == AG_RUNNING_CODE) {
1214 unsigned ag_t1 = ag_sbe[(PCB).sn] + 1;
1215 unsigned ag_t2 = ag_sbt[(PCB).sn+1] - 1;
1216 do {
1217 unsigned ag_tx = (ag_t1 + ag_t2)/2;
1218 if (ag_tstt[ag_tx] < (unsigned char)(PCB).reduction_token) ag_t1 = ag_tx + 1;
1219 else ag_t2 = ag_tx;
1220 } while (ag_t1 < ag_t2);
1221 (PCB).ag_ap = ag_pstt[ag_t1];
1222 if ((ag_s_procs_scan[ag_astt[ag_t1]])() == 0) break;
1223 }
1224 return 0;
1225 }
1226
1227 static int ag_action_3_proc(void) {
1228 int ag_sd = ag_fl[(PCB).ag_ap] - 1;
1229 (PCB).btsx = 0, (PCB).drt = -1;
1230 (PCB).vs[(PCB).ssx] = *(PCB).pointer;
1231 if (ag_sd) (PCB).sn = (PCB).ss[(PCB).ssx -= ag_sd];
1232 else GET_CONTEXT;
1233 (PCB).ss[(PCB).ssx] = (PCB).sn;
1234 ag_track();
1235 (PCB).reduction_token = (rfc822a_token_type) ag_ptt[(PCB).ag_ap];
1236 ag_ra();
1237 while ((PCB).exit_flag == AG_RUNNING_CODE) {
1238 unsigned ag_t1 = ag_sbe[(PCB).sn] + 1;
1239 unsigned ag_t2 = ag_sbt[(PCB).sn+1] - 1;
1240 do {
1241 unsigned ag_tx = (ag_t1 + ag_t2)/2;
1242 if (ag_tstt[ag_tx] < (unsigned char)(PCB).reduction_token) ag_t1 = ag_tx + 1;
1243 else ag_t2 = ag_tx;
1244 } while (ag_t1 < ag_t2);
1245 (PCB).ag_ap = ag_pstt[ag_t1];
1246 if ((ag_s_procs_scan[ag_astt[ag_t1]])() == 0) break;
1247 }
1248 return 0;
1249 }
1250
1251 static int ag_action_8_proc(void) {
1252 ag_undo();
1253 (PCB).la_ptr = (PCB).pointer;
1254 (PCB).exit_flag = AG_SYNTAX_ERROR_CODE;
1255 ag_diagnose();
1256 SYNTAX_ERROR;
1257 {(PCB).la_ptr = (PCB).pointer + 1; ag_track();}
1258 return (PCB).exit_flag == AG_RUNNING_CODE;
1259 }
1260
1261 static int ag_action_5_proc(void) {
1262 int ag_sd = ag_fl[(PCB).ag_ap];
1263 (PCB).btsx = 0, (PCB).drt = -1;
1264 if (ag_sd) (PCB).sn = (PCB).ss[(PCB).ssx -= ag_sd];
1265 else {
1266 GET_CONTEXT;
1267 (PCB).ss[(PCB).ssx] = (PCB).sn;
1268 }
1269 (PCB).la_ptr = (PCB).pointer;
1270 (PCB).reduction_token = (rfc822a_token_type) ag_ptt[(PCB).ag_ap];
1271 ag_ra();
1272 while ((PCB).exit_flag == AG_RUNNING_CODE) {
1273 unsigned ag_t1 = ag_sbe[(PCB).sn] + 1;
1274 unsigned ag_t2 = ag_sbt[(PCB).sn+1] - 1;
1275 do {
1276 unsigned ag_tx = (ag_t1 + ag_t2)/2;
1277 if (ag_tstt[ag_tx] < (unsigned char)(PCB).reduction_token) ag_t1 = ag_tx + 1;
1278 else ag_t2 = ag_tx;
1279 } while (ag_t1 < ag_t2);
1280 (PCB).ag_ap = ag_pstt[ag_t1];
1281 if ((ag_r_procs_scan[ag_astt[ag_t1]])() == 0) break;
1282 }
1283 return (PCB).exit_flag == AG_RUNNING_CODE;
1284 }
1285
1286 static int ag_action_6_proc(void) {
1287 int ag_sd = ag_fl[(PCB).ag_ap];
1288 (PCB).reduction_token = (rfc822a_token_type) ag_ptt[(PCB).ag_ap];
1289 if ((PCB).drt == -1) {
1290 (PCB).drt=(PCB).token_number;
1291 (PCB).dssx=(PCB).ssx;
1292 (PCB).dsn=(PCB).sn;
1293 }
1294 if (ag_sd) {
1295 (PCB).sn = (PCB).ss[(PCB).ssx -= ag_sd];
1296 }
1297 else {
1298 ag_prot();
1299 (PCB).vs[(PCB).ssx] = ag_null_value;
1300 GET_CONTEXT;
1301 (PCB).ss[(PCB).ssx] = (PCB).sn;
1302 }
1303 (PCB).la_ptr = (PCB).pointer;
1304 while ((PCB).exit_flag == AG_RUNNING_CODE) {
1305 unsigned ag_t1 = ag_sbe[(PCB).sn] + 1;
1306 unsigned ag_t2 = ag_sbt[(PCB).sn+1] - 1;
1307 do {
1308 unsigned ag_tx = (ag_t1 + ag_t2)/2;
1309 if (ag_tstt[ag_tx] < (unsigned char)(PCB).reduction_token) ag_t1 = ag_tx + 1;
1310 else ag_t2 = ag_tx;
1311 } while (ag_t1 < ag_t2);
1312 (PCB).ag_ap = ag_pstt[ag_t1];
1313 if ((ag_r_procs_scan[ag_astt[ag_t1]])() == 0) break;
1314 }
1315 return (PCB).exit_flag == AG_RUNNING_CODE;
1316 }
1317
1318
1319 void init_rfc822a(void) {
1320 (PCB).la_ptr = (PCB).pointer;
1321 (PCB).ss[0] = (PCB).sn = (PCB).ssx = 0;
1322 (PCB).exit_flag = AG_RUNNING_CODE;
1323 (PCB).line = FIRST_LINE;
1324 (PCB).column = FIRST_COLUMN;
1325 (PCB).btsx = 0, (PCB).drt = -1;
1326 }
1327
1328 void rfc822a(void) {
1329 init_rfc822a();
1330 (PCB).exit_flag = AG_RUNNING_CODE;
1331 while ((PCB).exit_flag == AG_RUNNING_CODE) {
1332 unsigned ag_t1 = ag_sbt[(PCB).sn];
1333 if (ag_tstt[ag_t1]) {
1334 unsigned ag_t2 = ag_sbe[(PCB).sn] - 1;
1335 (PCB).token_number = (rfc822a_token_type) AG_TCV(INPUT_CODE(*(PCB).la_ptr));
1336 (PCB).la_ptr++;
1337 if (ag_key_index[(PCB).sn]) {
1338 unsigned ag_k = ag_key_index[(PCB).sn];
1339 int ag_ch = CONVERT_CASE(INPUT_CODE(*(PCB).pointer));
1340 if (ag_ch <= 255) {
1341 while (ag_key_ch[ag_k] < ag_ch) ag_k++;
1342 if (ag_key_ch[ag_k] == ag_ch) ag_get_key_word(ag_k);
1343 }
1344 }
1345 do {
1346 unsigned ag_tx = (ag_t1 + ag_t2)/2;
1347 if (ag_tstt[ag_tx] > (unsigned char)(PCB).token_number)
1348 ag_t1 = ag_tx + 1;
1349 else ag_t2 = ag_tx;
1350 } while (ag_t1 < ag_t2);
1351 if (ag_tstt[ag_t1] != (unsigned char)(PCB).token_number)
1352 ag_t1 = ag_sbe[(PCB).sn];
1353 }
1354 (PCB).ag_ap = ag_pstt[ag_t1];
1355 (ag_gt_procs_scan[ag_astt[ag_t1]])();
1356 }
1357 }
1358
1359