Mercurial > ~dholland > hg > ag > index.cgi
comparison tests/agcl/parsifal/good/xml3.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 | |
2 /* | |
3 * AnaGram, A System for Syntax Directed Programming | |
4 * File generated by: ... | |
5 * | |
6 * AnaGram Parsing Engine | |
7 * Copyright 1993-2002 Parsifal Software. All Rights Reserved. | |
8 * | |
9 * This software is provided 'as-is', without any express or implied | |
10 * warranty. In no event will the authors be held liable for any damages | |
11 * arising from the use of this software. | |
12 * | |
13 * Permission is granted to anyone to use this software for any purpose, | |
14 * including commercial applications, and to alter it and redistribute it | |
15 * freely, subject to the following restrictions: | |
16 * | |
17 * 1. The origin of this software must not be misrepresented; you must not | |
18 * claim that you wrote the original software. If you use this software | |
19 * in a product, an acknowledgment in the product documentation would be | |
20 * appreciated but is not required. | |
21 * 2. Altered source versions must be plainly marked as such, and must not be | |
22 * misrepresented as being the original software. | |
23 * 3. This notice may not be removed or altered from any source distribution. | |
24 */ | |
25 | |
26 #ifndef XML3_H | |
27 #include "xml3.h" | |
28 #endif | |
29 | |
30 #ifndef XML3_H | |
31 #error Mismatched header file | |
32 #endif | |
33 | |
34 #include <ctype.h> | |
35 #include <stdio.h> | |
36 | |
37 #define RULE_CONTEXT (&((PCB).cs[(PCB).ssx])) | |
38 #define ERROR_CONTEXT ((PCB).cs[(PCB).error_frame_ssx]) | |
39 #define CONTEXT ((PCB).cs[(PCB).ssx]) | |
40 | |
41 | |
42 | |
43 xml3_pcb_type xml3_pcb; | |
44 #define PCB xml3_pcb | |
45 | |
46 #ifndef CONVERT_CASE | |
47 #define CONVERT_CASE(c) (c) | |
48 #endif | |
49 #ifndef TAB_SPACING | |
50 #define TAB_SPACING 8 | |
51 #endif | |
52 | |
53 | |
54 #define READ_COUNTS | |
55 #define WRITE_COUNTS | |
56 #undef V | |
57 #define V(i,t) (*t (&(PCB).vs[(PCB).ssx + i])) | |
58 #undef VS | |
59 #define VS(i) (PCB).vs[(PCB).ssx + i] | |
60 | |
61 #ifndef GET_CONTEXT | |
62 #define GET_CONTEXT CONTEXT = (PCB).input_context | |
63 #endif | |
64 | |
65 typedef enum { | |
66 ag_action_1, | |
67 ag_action_2, | |
68 ag_action_3, | |
69 ag_action_4, | |
70 ag_action_5, | |
71 ag_action_6, | |
72 ag_action_7, | |
73 ag_action_8, | |
74 ag_action_9, | |
75 ag_action_10, | |
76 ag_action_11, | |
77 ag_action_12 | |
78 } ag_parser_action; | |
79 | |
80 | |
81 #ifndef NULL_VALUE_INITIALIZER | |
82 #define NULL_VALUE_INITIALIZER = 0 | |
83 #endif | |
84 | |
85 static int const ag_null_value NULL_VALUE_INITIALIZER; | |
86 | |
87 static const unsigned char ag_rpx[] = { | |
88 0 | |
89 }; | |
90 | |
91 static const unsigned char ag_key_itt[] = { | |
92 0 | |
93 }; | |
94 | |
95 static const unsigned short ag_key_pt[] = { | |
96 0 | |
97 }; | |
98 | |
99 static const unsigned char ag_key_ch[] = { | |
100 0, 45, 68,255,120,255, 33, 63,255, 60,255, 45, 68,255, 33, 63,255, 60, | |
101 255, 39, 63,115,118,255,118,255,110,121,255, 34, 39, 63,255, 45,255, 60, | |
102 255, 60,255, 33, 63,255, 60,255, 63,255, 63,115,255, 39,255 | |
103 }; | |
104 | |
105 static const unsigned char ag_key_act[] = { | |
106 0,3,3,4,3,4,2,1,4,2,4,3,3,4,2,0,4,2,4,3,3,3,3,4,3,4,3,3,4,2,3,3,4,3,4, | |
107 3,4,3,4,3,0,4,2,4,3,4,3,3,4,3,4 | |
108 }; | |
109 | |
110 static const unsigned char ag_key_parm[] = { | |
111 0, 62,100, 0, 86, 0, 0, 69, 0, 0, 0, 62,100, 0, 0, 69, 0, 0, | |
112 0,124, 75,123, 93, 0, 93, 0,127,125, 0, 0,126, 75, 0, 66, 0,100, | |
113 0,152, 0, 62, 69, 0, 0, 0, 75, 0, 75,123, 0,124, 0 | |
114 }; | |
115 | |
116 static const unsigned char ag_key_jmp[] = { | |
117 0, 0, 2, 0, 9, 0, 1, 4, 0, 6, 0, 12, 14, 0, 11, 0, 0, 14, | |
118 0, 21, 26, 28, 38, 0, 45, 0, 52, 55, 0, 26, 59, 63, 0, 65, 0, 67, | |
119 0, 76, 0, 78, 0, 0, 39, 0, 81, 0, 83, 85, 0, 95, 0 | |
120 }; | |
121 | |
122 static const unsigned char ag_key_index[] = { | |
123 9, 0, 17, 0, 19, 24, 29, 0, 33, 17, 35, 0, 37, 42, 0, 29, 44, 44, | |
124 33, 33, 0, 42, 0, 37, 37, 0, 0, 46, 44, 44, 44, 44, 44, 0, 0, 0, | |
125 0, 0, 0, 49, 0, 0, 0, 44, 0, 0, 0, 0, 0, 0, 0, 49, 0, 0, | |
126 0, 0, 0, 42, 0, 0, 0, 42, 0, 0, 0, 0, 0, 0 | |
127 }; | |
128 | |
129 static const unsigned char ag_key_ends[] = { | |
130 45,0, 79,67,84,89,80,69,0, 109,108,0, 45,0, 79,67,84,89,80,69,0, | |
131 121,101,115,39,0, 62,0, 116,97,110,100,97,108,111,110,101,0, | |
132 101,114,115,105,111,110,0, 101,114,115,105,111,110,0, 111,34,0, | |
133 101,115,34,0, 110,111,39,0, 62,0, 45,0, | |
134 33,68,79,67,84,89,80,69,0, 47,0, 45,45,0, 62,0, 62,0, | |
135 116,97,110,100,97,108,111,110,101,0, 121,101,115,39,0, | |
136 }; | |
137 #define AG_TCV(x) (((int)(x) >= 0 && (int)(x) <= 255) ? ag_tcv[(x)] : 0) | |
138 | |
139 static const unsigned char ag_tcv[] = { | |
140 162,162,162,162,162,162,162,162,162,156,157,162,162,158,162,162,162,162, | |
141 162,162,162,162,162,162,162,162,162,162,162,162,162,162,157,163, 26,163, | |
142 163,166,167, 33,163,163,163,163,163,130,161,163,164,164,164,164,164,164, | |
143 164,164,164,164,159,163,147, 97, 67,163,163,138,138,138,138,138,138,138, | |
144 138,140,138,138,138,138,138,138,138,138,138,138,138,138,138,138,142,138, | |
145 138,104,165,109,165,160,165,138,138,138,138,138,138,138,138,140,138,138, | |
146 138,138,138,138,138,138,138,138,138,138,138,138,142,138,138,165,165,165, | |
147 165,165,165,165,165,165,165,165,165,165,165,165,165,165,165,165,165,165, | |
148 165,165,165,165,165,165,165,165,165,165,165,165,165,165,165,165,165,165, | |
149 165,165,165,165,165,165,165,165,165,165,165,165,165,165,165,165,165,165, | |
150 165,165,165,165,165,165,165,165,165,165,165,165,165,165,165,165,165,165, | |
151 165,165,165,165,165,165,165,165,165,165,165,165,165,165,165,165,165,165, | |
152 165,165,165,165,165,165,165,165,165,165,165,165,165,165,165,165,165,165, | |
153 165,165,165,165,165,165,165,165,165,165,165,165,165,165,165,165,165,165, | |
154 165,165,165,165 | |
155 }; | |
156 | |
157 #ifndef SYNTAX_ERROR | |
158 #define SYNTAX_ERROR fprintf(stderr,"%s, line %d, column %d\n", \ | |
159 (PCB).error_message, (PCB).line, (PCB).column) | |
160 #endif | |
161 | |
162 #ifndef FIRST_LINE | |
163 #define FIRST_LINE 1 | |
164 #endif | |
165 | |
166 #ifndef FIRST_COLUMN | |
167 #define FIRST_COLUMN 1 | |
168 #endif | |
169 | |
170 #ifndef PARSER_STACK_OVERFLOW | |
171 #define PARSER_STACK_OVERFLOW {fprintf(stderr, \ | |
172 "\nParser stack overflow, line %d, column %d\n",\ | |
173 (PCB).line, (PCB).column);} | |
174 #endif | |
175 | |
176 #ifndef REDUCTION_TOKEN_ERROR | |
177 #define REDUCTION_TOKEN_ERROR {fprintf(stderr, \ | |
178 "\nReduction token error, line %d, column %d\n", \ | |
179 (PCB).line, (PCB).column);} | |
180 #endif | |
181 | |
182 | |
183 typedef enum | |
184 {ag_accept_key, ag_set_key, ag_jmp_key, ag_end_key, ag_no_match_key, | |
185 ag_cf_accept_key, ag_cf_set_key, ag_cf_end_key} key_words; | |
186 | |
187 #ifndef GET_INPUT | |
188 #define GET_INPUT ((PCB).input_code = getchar()) | |
189 #endif | |
190 | |
191 | |
192 static int ag_look_ahead(void) { | |
193 if ((PCB).rx < (PCB).fx) { | |
194 return CONVERT_CASE((PCB).lab[(PCB).rx++]); | |
195 } | |
196 GET_INPUT; | |
197 (PCB).fx++; | |
198 return CONVERT_CASE((PCB).lab[(PCB).rx++] = (PCB).input_code); | |
199 } | |
200 | |
201 static void ag_get_key_word(int ag_k) { | |
202 int save_index = (PCB).rx; | |
203 const unsigned char *sp; | |
204 int ag_ch; | |
205 while (1) { | |
206 switch (ag_key_act[ag_k]) { | |
207 case ag_cf_end_key: | |
208 sp = ag_key_ends + ag_key_jmp[ag_k]; | |
209 do { | |
210 if ((ag_ch = *sp++) == 0) { | |
211 int ag_k1 = ag_key_parm[ag_k]; | |
212 int ag_k2 = ag_key_pt[ag_k1]; | |
213 if (ag_key_itt[ag_k2 + ag_look_ahead()]) goto ag_fail; | |
214 (PCB).rx--; | |
215 (PCB).token_number = (xml3_token_type) ag_key_pt[ag_k1 + 1]; | |
216 return; | |
217 } | |
218 } while (ag_look_ahead() == ag_ch); | |
219 goto ag_fail; | |
220 case ag_end_key: | |
221 sp = ag_key_ends + ag_key_jmp[ag_k]; | |
222 do { | |
223 if ((ag_ch = *sp++) == 0) { | |
224 (PCB).token_number = (xml3_token_type) ag_key_parm[ag_k]; | |
225 return; | |
226 } | |
227 } while (ag_look_ahead() == ag_ch); | |
228 case ag_no_match_key: | |
229 ag_fail: | |
230 (PCB).rx = save_index; | |
231 return; | |
232 case ag_cf_set_key: { | |
233 int ag_k1 = ag_key_parm[ag_k]; | |
234 int ag_k2 = ag_key_pt[ag_k1]; | |
235 ag_k = ag_key_jmp[ag_k]; | |
236 if (ag_key_itt[ag_k2 + (ag_ch = ag_look_ahead())]) break; | |
237 save_index = --(PCB).rx; | |
238 (PCB).token_number = (xml3_token_type) ag_key_pt[ag_k1+1]; | |
239 break; | |
240 } | |
241 case ag_set_key: | |
242 save_index = (PCB).rx; | |
243 (PCB).token_number = (xml3_token_type) ag_key_parm[ag_k]; | |
244 case ag_jmp_key: | |
245 ag_k = ag_key_jmp[ag_k]; | |
246 ag_ch = ag_look_ahead(); | |
247 break; | |
248 case ag_accept_key: | |
249 (PCB).token_number = (xml3_token_type) ag_key_parm[ag_k]; | |
250 return; | |
251 case ag_cf_accept_key: { | |
252 int ag_k1 = ag_key_parm[ag_k]; | |
253 int ag_k2 = ag_key_pt[ag_k1]; | |
254 if (ag_key_itt[ag_k2 + ag_look_ahead()]) (PCB).rx = save_index; | |
255 else { | |
256 (PCB).rx--; | |
257 (PCB).token_number = (xml3_token_type) ag_key_pt[ag_k1+1]; | |
258 } | |
259 return; | |
260 } | |
261 default: | |
262 /* not reachable; here to suppress compiler warnings */ | |
263 goto ag_fail; | |
264 } | |
265 if (ag_ch <= 255) while (ag_key_ch[ag_k] < ag_ch) ag_k++; | |
266 if (ag_ch > 255 || ag_key_ch[ag_k] != ag_ch) { | |
267 (PCB).rx = save_index; | |
268 return; | |
269 } | |
270 } | |
271 } | |
272 | |
273 | |
274 #ifndef AG_NEWLINE | |
275 #define AG_NEWLINE 10 | |
276 #endif | |
277 | |
278 #ifndef AG_RETURN | |
279 #define AG_RETURN 13 | |
280 #endif | |
281 | |
282 #ifndef AG_FORMFEED | |
283 #define AG_FORMFEED 12 | |
284 #endif | |
285 | |
286 #ifndef AG_TABCHAR | |
287 #define AG_TABCHAR 9 | |
288 #endif | |
289 | |
290 static void ag_track(void) { | |
291 int ag_k = 0; | |
292 while (ag_k < (PCB).rx) { | |
293 int ag_ch = (PCB).lab[ag_k++]; | |
294 switch (ag_ch) { | |
295 case AG_NEWLINE: | |
296 (PCB).column = 1, (PCB).line++; | |
297 case AG_RETURN: | |
298 case AG_FORMFEED: | |
299 break; | |
300 case AG_TABCHAR: | |
301 (PCB).column += (TAB_SPACING) - ((PCB).column - 1) % (TAB_SPACING); | |
302 break; | |
303 default: | |
304 (PCB).column++; | |
305 } | |
306 } | |
307 ag_k = 0; | |
308 while ((PCB).rx < (PCB).fx) (PCB).lab[ag_k++] = (PCB).lab[(PCB).rx++]; | |
309 (PCB).fx = ag_k; | |
310 (PCB).rx = 0; | |
311 } | |
312 | |
313 | |
314 static void ag_prot(void) { | |
315 int ag_k; | |
316 ag_k = 128 - ++(PCB).btsx; | |
317 if (ag_k <= (PCB).ssx) { | |
318 (PCB).exit_flag = AG_STACK_ERROR_CODE; | |
319 PARSER_STACK_OVERFLOW; | |
320 return; | |
321 } | |
322 (PCB).bts[(PCB).btsx] = (PCB).sn; | |
323 (PCB).bts[ag_k] = (PCB).ssx; | |
324 (PCB).vs[ag_k] = (PCB).vs[(PCB).ssx]; | |
325 (PCB).ss[ag_k] = (PCB).ss[(PCB).ssx]; | |
326 } | |
327 | |
328 static void ag_undo(void) { | |
329 if ((PCB).drt == -1) return; | |
330 while ((PCB).btsx) { | |
331 int ag_k = 128 - (PCB).btsx; | |
332 (PCB).sn = (PCB).bts[(PCB).btsx--]; | |
333 (PCB).ssx = (PCB).bts[ag_k]; | |
334 (PCB).vs[(PCB).ssx] = (PCB).vs[ag_k]; | |
335 (PCB).ss[(PCB).ssx] = (PCB).ss[ag_k]; | |
336 } | |
337 (PCB).token_number = (xml3_token_type) (PCB).drt; | |
338 (PCB).ssx = (PCB).dssx; | |
339 (PCB).sn = (PCB).dsn; | |
340 (PCB).drt = -1; | |
341 } | |
342 | |
343 | |
344 static const unsigned char ag_tstt[] = { | |
345 158,157,156,147,143,100,86,69,62,0,1,2,82,83, | |
346 158,157,156,0,7,9,10,87, | |
347 158,157,156,147,143,100,69,62,0,4,5,6,7,61,68, | |
348 147,143,0,3,144, | |
349 158,157,156,0,7, | |
350 93,0, | |
351 158,157,156,127,126,125,88,75,0,89, | |
352 160,159,0,11,70, | |
353 167,166,165,164,163,161,160,159,157,156,147,142,140,138,130,109,104,97,67, | |
354 66,33,26,0,64,65, | |
355 158,157,156,69,62,0,4,7,61,68, | |
356 147,143,100,0,84,85, | |
357 160,159,0,11, | |
358 166,165,164,163,162,161,160,159,158,157,156,152,147,143,142,140,138,130,109, | |
359 104,97,67,33,26,0,3,56,144,145,153,154,155, | |
360 158,157,156,69,62,0,4,5,6,7,61,68, | |
361 158,157,156,97,0,7,9,10,91,94, | |
362 158,157,156,127,126,125,75,0,7,9,10,90,92, | |
363 161,159,158,157,156,130,104,97,75,67,0,14,15, | |
364 158,157,156,75,0,7,9,10,74, | |
365 167,166,165,164,163,161,160,159,157,156,147,142,140,138,130,109,104,97,67, | |
366 33,26,0, | |
367 66,0, | |
368 158,157,156,0,7,9,10, | |
369 158,157,156,147,143,69,62,0,4,5,6,7,61,68, | |
370 158,157,156,67,0,7,9,10,149,150,151, | |
371 166,165,164,163,162,161,160,159,158,157,156,147,143,142,140,138,130,109,104, | |
372 97,67,33,26,0,3,56,144,153, | |
373 152,0,146, | |
374 97,0, | |
375 33,26,0,96, | |
376 123,0, | |
377 158,157,156,75,0,7,9,10,91, | |
378 75,0, | |
379 161,159,130,0, | |
380 75,71,0,72,73, | |
381 75,0, | |
382 67,0, | |
383 160,159,0,11, | |
384 160,159,0,11,148, | |
385 158,157,156,0,7,9,10,149, | |
386 67,0, | |
387 160,159,0,11, | |
388 158,157,156,124,33,26,0,7,9,10,91, | |
389 164,161,160,159,142,140,138,130,0,95,99, | |
390 164,161,160,159,142,140,138,130,0,95,99, | |
391 158,157,156,97,0,7,9,10,91,94, | |
392 71,0, | |
393 158,157,156,104,67,0,7,9,10,103, | |
394 158,157,156,97,0,7,9,10,91,94, | |
395 160,159,0,11,148, | |
396 158,157,156,67,0,7,9,10,91, | |
397 164,161,160,159,142,140,138,130,0, | |
398 26,0, | |
399 33,0, | |
400 124,0, | |
401 104,101,67,0,102, | |
402 104,67,0,110, | |
403 33,26,0,38, | |
404 67,0, | |
405 158,157,156,104,67,0,7,9,10,91, | |
406 158,157,156,114,113,112,111,109,69,62,28,0,7,61,68,105,106,107,108, | |
407 67,0, | |
408 165,164,163,162,161,160,159,158,157,156,147,142,140,138,130,109,104,97,67, | |
409 33,29,26,0,42,43,44, | |
410 165,164,163,162,161,160,159,158,157,156,147,142,140,138,130,109,104,97,67, | |
411 33,29,26,0,39,40,41, | |
412 158,157,156,114,113,112,111,69,62,28,0,7,61,68,105,106, | |
413 109,0, | |
414 165,164,163,162,161,160,159,158,157,156,147,142,140,138,130,109,104,97,67, | |
415 29,26,0,42, | |
416 33,0, | |
417 165,164,163,162,161,160,159,158,157,156,147,142,140,138,130,109,104,97,67, | |
418 33,29,0,39, | |
419 26,0, | |
420 158,157,156,67,0,7,9,10,91, | |
421 | |
422 }; | |
423 | |
424 | |
425 static unsigned const char ag_astt[609] = { | |
426 8,8,8,5,5,5,1,8,8,7,0,1,1,1,1,1,1,7,1,1,1,1,1,1,1,5,5,8,1,1,7,1,1,1,1,1,1, | |
427 1,1,7,1,1,9,9,9,5,3,1,7,8,8,8,8,8,8,1,5,7,1,1,1,7,1,1,1,1,1,1,1,1,1,1,1,1, | |
428 1,1,1,1,1,1,1,1,1,8,1,1,7,1,1,9,9,9,1,1,5,3,3,3,3,5,5,1,7,1,3,1,1,7,1,1,1, | |
429 1,1,1,1,1,1,1,1,1,5,1,1,1,1,1,1,1,1,1,1,1,1,7,1,1,1,1,1,1,1,1,1,1,1,1,5,1, | |
430 1,3,1,1,1,1,1,1,8,7,1,1,1,1,1,1,1,1,1,1,1,8,7,1,1,1,1,1,1,1,5,5,5,1,5,5,5, | |
431 5,7,1,3,1,1,1,8,7,1,1,1,1,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,5,1,7, | |
432 1,1,1,7,1,1,1,1,1,1,5,5,1,1,7,1,1,3,1,1,1,1,1,1,8,7,1,1,1,1,1,1,9,9,9,9,9, | |
433 9,9,9,9,9,9,1,9,9,9,9,9,9,9,9,9,9,9,5,3,3,1,3,1,7,3,1,7,1,1,7,3,1,5,1,1,1, | |
434 5,7,1,3,1,3,3,7,9,9,9,5,5,1,7,1,3,3,7,3,7,1,1,7,1,1,1,5,1,3,1,1,1,5,1,1,1, | |
435 3,3,7,1,1,7,1,1,1,1,5,5,5,7,1,3,1,3,1,1,1,1,1,1,1,1,7,1,1,1,1,1,1,1,1,1,1, | |
436 7,1,1,1,1,1,8,7,1,1,1,1,1,9,5,1,1,1,8,5,7,1,1,1,1,1,1,1,8,7,1,1,1,1,1,1,1, | |
437 7,1,3,1,1,1,8,7,1,1,1,1,9,9,9,9,9,9,9,9,5,3,7,3,7,3,7,5,1,5,7,3,1,8,7,1,1, | |
438 1,7,3,3,7,1,1,1,5,5,7,1,3,1,3,1,1,1,1,1,1,1,8,1,1,1,7,1,1,1,1,1,1,1,3,7,1, | |
439 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,8,1,1,7,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, | |
440 1,1,1,1,1,1,1,1,1,8,7,1,1,1,9,9,9,9,9,9,9,1,1,9,5,3,3,3,3,3,1,7,9,9,9,9,9, | |
441 9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,5,3,3,7,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9, | |
442 9,9,9,9,5,3,3,7,1,1,1,5,7,1,3,1,3 | |
443 }; | |
444 | |
445 | |
446 static const unsigned char ag_pstt[] = { | |
447 2,2,2,97,97,97,1,2,2,0,0,3,2,2, | |
448 4,4,4,1,4,5,4,6, | |
449 9,9,9,3,3,10,7,8,2,9,9,10,9,9,9, | |
450 11,13,3,13,12, | |
451 8,8,8,9,8, | |
452 14,5, | |
453 15,15,15,15,15,15,15,102,6,15, | |
454 16,16,7,17,17, | |
455 18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,19,18,18,8,18,19, | |
456 2,2,2,7,8,4,2,2,2,2, | |
457 99,99,20,10,21,101, | |
458 16,16,11,22, | |
459 23,23,23,23,23,23,23,23,23,23,23,186,11,23,23,23,23,23,23,23,23,23,23,23,12, | |
460 23,23,12,24,23,23,24, | |
461 9,9,9,7,8,3,9,9,5,9,9,9, | |
462 4,4,4,25,14,4,25,4,25,26, | |
463 4,4,4,28,28,28,29,15,4,27,4,28,29, | |
464 30,30,12,12,12,30,12,12,12,12,16,30,14, | |
465 4,4,4,32,17,4,31,4,32, | |
466 81,81,81,81,81,81,81,81,81,81,81,81,81,81,81,81,81,81,81,81,81,83, | |
467 33,19, | |
468 4,4,4,20,4,34,4, | |
469 9,9,9,3,3,7,8,21,9,9,100,9,9,9, | |
470 4,4,4,37,22,4,35,4,36,36,37, | |
471 185,185,185,185,185,185,185,185,185,185,185,11,185,185,185,185,185,185,185, | |
472 185,185,185,185,187,185,185,12,185, | |
473 38,24,172, | |
474 39,25, | |
475 41,40,26,112, | |
476 42,108, | |
477 4,4,4,104,28,4,107,4,107, | |
478 109,29, | |
479 11,11,11,13, | |
480 87,43,31,43,90, | |
481 91,32, | |
482 84,33, | |
483 16,16,34,44, | |
484 16,16,178,45,173, | |
485 4,4,4,177,4,46,4,175, | |
486 179,37, | |
487 16,16,38,47, | |
488 4,4,4,104,104,104,39,4,113,4,113, | |
489 48,48,48,48,48,48,48,48,40,49,48, | |
490 48,48,48,48,48,48,48,48,41,50,48, | |
491 4,4,4,25,42,4,25,4,25,51, | |
492 86,88, | |
493 4,4,4,53,122,44,4,52,4,53, | |
494 4,4,4,25,45,4,25,4,25,54, | |
495 16,16,46,45,173, | |
496 4,4,4,55,47,4,55,4,55, | |
497 115,115,115,115,115,115,115,115,116, | |
498 111,49, | |
499 110,50, | |
500 152,51, | |
501 120,56,120,52,123, | |
502 57,58,53,58, | |
503 59,60,54,180, | |
504 181,55, | |
505 4,4,4,104,104,56,4,121,4,121, | |
506 61,61,61,61,61,61,61,62,7,8,61,57,61,61,61,61,61,61,62, | |
507 133,58, | |
508 63,63,63,63,63,63,63,63,63,63,63,63,63,63,63,63,63,63,63,64,63,63,59,63,63, | |
509 64, | |
510 65,65,65,65,65,65,65,65,65,65,65,65,65,65,65,65,65,65,65,65,65,66,60,65,65, | |
511 66, | |
512 128,128,128,128,128,128,128,7,8,128,130,128,128,128,128,128, | |
513 67,62, | |
514 54,54,54,54,54,54,54,54,54,54,54,54,54,54,54,54,54,54,54,54,54,56,54, | |
515 57,64, | |
516 47,47,47,47,47,47,47,47,47,47,47,47,47,47,47,47,47,47,47,47,47,49,47, | |
517 50,66, | |
518 4,4,4,104,67,4,132,4,132, | |
519 | |
520 }; | |
521 | |
522 | |
523 static const unsigned short ag_sbt[] = { | |
524 0, 14, 22, 37, 42, 47, 49, 59, 64, 89, 99, 105, 109, 141, | |
525 153, 163, 176, 189, 198, 220, 222, 229, 243, 254, 282, 285, 287, 291, | |
526 293, 302, 304, 308, 313, 315, 317, 321, 326, 334, 336, 340, 351, 362, | |
527 373, 383, 385, 395, 405, 410, 419, 428, 430, 432, 434, 439, 443, 447, | |
528 449, 459, 478, 480, 506, 532, 548, 550, 573, 575, 598, 600, 609 | |
529 }; | |
530 | |
531 | |
532 static const unsigned short ag_sbe[] = { | |
533 9, 17, 30, 39, 45, 48, 57, 61, 86, 94, 102, 107, 133, 146, | |
534 157, 170, 186, 193, 219, 221, 225, 236, 247, 277, 283, 286, 289, 292, | |
535 297, 303, 307, 310, 314, 316, 319, 323, 329, 335, 338, 346, 359, 370, | |
536 377, 384, 390, 399, 407, 414, 427, 429, 431, 433, 437, 441, 445, 448, | |
537 454, 470, 479, 502, 528, 542, 549, 571, 574, 596, 599, 604, 609 | |
538 }; | |
539 | |
540 | |
541 static const unsigned char ag_fl[] = { | |
542 1,1,2,0,1,3,1,1,2,1,1,2,0,1,2,2,1,2,0,1,2,1,2,1,2,0,1,2,1,1,1,1,2,0,1, | |
543 3,1,1,1,1,2,0,1,3,1,1,1,2,0,1,3,1,1,1,2,0,1,3,1,2,0,1,3,1,2,0,1,3,1,2, | |
544 0,1,3,3,1,1,2,0,1,1,1,2,0,1,4,1,2,0,1,0,2,4,1,3,1,1,1,0,1,0,2,3,0,1,0, | |
545 1,0,2,1,5,3,3,4,3,1,2,1,1,1,1,0,2,0,2,1,1,1,1,2,0,1,0,4,6,1,1,1,1,1,1, | |
546 0,1,2,1,1,1,1,1,2,0,1,1,4,1,1,1,2,1,2,0,1,2,1,1,1,2,1,2,3,3,1,1,3,2,1, | |
547 2,0,1,1,4,3,4,1,1,1,2,0,1,1 | |
548 }; | |
549 | |
550 static const unsigned char ag_ptt[] = { | |
551 0, 5, 5, 6, 6, 1, 7, 10, 10, 9, 14, 14, 15, 15, 11, 17, 18, 18, | |
552 19, 19, 16, 20, 22, 23, 23, 24, 24, 21, 30, 30, 30, 31, 31, 32, 32, 25, | |
553 35, 35, 35, 36, 36, 37, 37, 25, 39, 39, 40, 40, 41, 41, 38, 42, 42, 43, | |
554 43, 44, 44, 38, 47, 47, 48, 48, 45, 50, 50, 51, 51, 45, 54, 54, 55, 55, | |
555 52, 52, 56, 59, 59, 60, 60, 58, 64, 64, 65, 65, 61, 72, 72, 73, 73, 74, | |
556 74, 68, 70, 76, 77, 78, 78, 83, 83, 85, 85, 2, 89, 89, 91, 91, 92, 92, | |
557 92, 82, 96, 96, 87, 94, 99, 99, 95, 4, 4, 4,102,102,103,103,106,106, | |
558 106,107,107,108,108,110,110, 84,105,105,105,105,105,105,117,117,115,120, | |
559 120,120,120,121,121,122,122,118, 90, 90, 90, 90,132,133,133,134,134,128, | |
560 129,129,129,135,141,141,136,137,131, 3, 3,149,150,150,151,151,151,144, | |
561 148,146,153,153,154,154,155,155,145 | |
562 }; | |
563 | |
564 | |
565 static void ag_ra(void) | |
566 { | |
567 } | |
568 | |
569 #define TOKEN_NAMES xml3_token_names | |
570 const char *const xml3_token_names[168] = { | |
571 "document", | |
572 "document", | |
573 "prolog", | |
574 "element", | |
575 "Misc", | |
576 "", | |
577 "", | |
578 "SpaceChar", | |
579 "", | |
580 "S", | |
581 "", | |
582 "Name", | |
583 "", | |
584 "NameChar", | |
585 "", | |
586 "", | |
587 "Names", | |
588 "", | |
589 "", | |
590 "", | |
591 "Nmtoken", | |
592 "Nmtokens", | |
593 "", | |
594 "", | |
595 "", | |
596 "EntityValue", | |
597 "'\\\"'", | |
598 "", | |
599 "PEReference", | |
600 "Reference", | |
601 "", | |
602 "", | |
603 "", | |
604 "'\\''", | |
605 "", | |
606 "", | |
607 "", | |
608 "", | |
609 "AttValue", | |
610 "", | |
611 "", | |
612 "", | |
613 "", | |
614 "", | |
615 "", | |
616 "SystemLiteral", | |
617 "", | |
618 "", | |
619 "", | |
620 "", | |
621 "", | |
622 "", | |
623 "PubidLiteral", | |
624 "PubidChar", | |
625 "", | |
626 "", | |
627 "DataChar", | |
628 "", | |
629 "CharData", | |
630 "", | |
631 "", | |
632 "Comment", | |
633 "\"<!--\"", | |
634 "Char", | |
635 "", | |
636 "", | |
637 "\"--\"", | |
638 "'>'", | |
639 "PI", | |
640 "\"<?\"", | |
641 "PITarget", | |
642 "char", | |
643 "", | |
644 "", | |
645 "", | |
646 "\"?>\"", | |
647 "CDSect", | |
648 "CDStart", | |
649 "CData", | |
650 "CDEnd", | |
651 "\"<![CDATA[\"", | |
652 "\"]]>\"", | |
653 "XMLDecl", | |
654 "", | |
655 "doctypedecl", | |
656 "", | |
657 "\"<?xml\"", | |
658 "VersionInfo", | |
659 "EncodingDecl", | |
660 "", | |
661 "SDDecl", | |
662 "", | |
663 "", | |
664 "\"version\"", | |
665 "Eq", | |
666 "VersionNum", | |
667 "", | |
668 "'='", | |
669 "", | |
670 "", | |
671 "\"<!DOCTYPE\"", | |
672 "ExternalID", | |
673 "", | |
674 "", | |
675 "'['", | |
676 "markupdecl", | |
677 "", | |
678 "", | |
679 "", | |
680 "']'", | |
681 "", | |
682 "elementdecl", | |
683 "AttlistDecl", | |
684 "EntityDecl", | |
685 "NotationDecl", | |
686 "extSubset", | |
687 "TextDecl", | |
688 "", | |
689 "extSubsetDecl", | |
690 "conditionalSect", | |
691 "", | |
692 "", | |
693 "", | |
694 "\"standalone\"", | |
695 "\"\\'yes\\'\"", | |
696 "\"\\\"yes\\\"\"", | |
697 "\"\\'no\\'\"", | |
698 "\"\\\"no\\\"\"", | |
699 "Language Id", | |
700 "Langcode", | |
701 "'-'", | |
702 "Subcode", | |
703 "", | |
704 "", | |
705 "", | |
706 "ISO639Code", | |
707 "IanaCode", | |
708 "UserCode", | |
709 "", | |
710 "", | |
711 "", | |
712 "", | |
713 "", | |
714 "EmptyElemTag", | |
715 "STag", | |
716 "content", | |
717 "ETag", | |
718 "'<'", | |
719 "Attribute", | |
720 "", | |
721 "", | |
722 "", | |
723 "\"</\"", | |
724 "", | |
725 "", | |
726 "", | |
727 "", | |
728 "", | |
729 "", | |
730 "", | |
731 "", | |
732 "", | |
733 "", | |
734 "", | |
735 "", | |
736 "", | |
737 "", | |
738 "", | |
739 | |
740 }; | |
741 | |
742 #ifndef MISSING_FORMAT | |
743 #define MISSING_FORMAT "Missing %s" | |
744 #endif | |
745 #ifndef UNEXPECTED_FORMAT | |
746 #define UNEXPECTED_FORMAT "Unexpected %s" | |
747 #endif | |
748 #ifndef UNNAMED_TOKEN | |
749 #define UNNAMED_TOKEN "input" | |
750 #endif | |
751 | |
752 | |
753 static void ag_diagnose(void) { | |
754 int ag_snd = (PCB).sn; | |
755 int ag_k = ag_sbt[ag_snd]; | |
756 | |
757 if (*TOKEN_NAMES[ag_tstt[ag_k]] && ag_astt[ag_k + 1] == ag_action_8) { | |
758 sprintf((PCB).ag_msg, MISSING_FORMAT, TOKEN_NAMES[ag_tstt[ag_k]]); | |
759 } | |
760 else if (ag_astt[ag_sbe[(PCB).sn]] == ag_action_8 | |
761 && (ag_k = (int) ag_sbe[(PCB).sn] + 1) == (int) ag_sbt[(PCB).sn+1] - 1 | |
762 && *TOKEN_NAMES[ag_tstt[ag_k]]) { | |
763 sprintf((PCB).ag_msg, MISSING_FORMAT, TOKEN_NAMES[ag_tstt[ag_k]]); | |
764 } | |
765 else if ((PCB).token_number && *TOKEN_NAMES[(PCB).token_number]) { | |
766 sprintf((PCB).ag_msg, UNEXPECTED_FORMAT, TOKEN_NAMES[(PCB).token_number]); | |
767 } | |
768 else if (isprint((*(PCB).lab)) && (*(PCB).lab) != '\\') { | |
769 char buf[20]; | |
770 sprintf(buf, "\'%c\'", (char) (*(PCB).lab)); | |
771 sprintf((PCB).ag_msg, UNEXPECTED_FORMAT, buf); | |
772 } | |
773 else sprintf((PCB).ag_msg, UNEXPECTED_FORMAT, UNNAMED_TOKEN); | |
774 (PCB).error_message = (PCB).ag_msg; | |
775 | |
776 | |
777 } | |
778 static int ag_action_1_r_proc(void); | |
779 static int ag_action_2_r_proc(void); | |
780 static int ag_action_3_r_proc(void); | |
781 static int ag_action_4_r_proc(void); | |
782 static int ag_action_1_s_proc(void); | |
783 static int ag_action_3_s_proc(void); | |
784 static int ag_action_1_proc(void); | |
785 static int ag_action_2_proc(void); | |
786 static int ag_action_3_proc(void); | |
787 static int ag_action_4_proc(void); | |
788 static int ag_action_5_proc(void); | |
789 static int ag_action_6_proc(void); | |
790 static int ag_action_7_proc(void); | |
791 static int ag_action_8_proc(void); | |
792 static int ag_action_9_proc(void); | |
793 static int ag_action_10_proc(void); | |
794 static int ag_action_11_proc(void); | |
795 static int ag_action_8_proc(void); | |
796 | |
797 | |
798 static int (*const ag_r_procs_scan[])(void) = { | |
799 ag_action_1_r_proc, | |
800 ag_action_2_r_proc, | |
801 ag_action_3_r_proc, | |
802 ag_action_4_r_proc | |
803 }; | |
804 | |
805 static int (*const ag_s_procs_scan[])(void) = { | |
806 ag_action_1_s_proc, | |
807 ag_action_2_r_proc, | |
808 ag_action_3_s_proc, | |
809 ag_action_4_r_proc | |
810 }; | |
811 | |
812 static int (*const ag_gt_procs_scan[])(void) = { | |
813 ag_action_1_proc, | |
814 ag_action_2_proc, | |
815 ag_action_3_proc, | |
816 ag_action_4_proc, | |
817 ag_action_5_proc, | |
818 ag_action_6_proc, | |
819 ag_action_7_proc, | |
820 ag_action_8_proc, | |
821 ag_action_9_proc, | |
822 ag_action_10_proc, | |
823 ag_action_11_proc, | |
824 ag_action_8_proc | |
825 }; | |
826 | |
827 | |
828 static int ag_action_10_proc(void) { | |
829 int ag_t = (PCB).token_number; | |
830 (PCB).btsx = 0, (PCB).drt = -1; | |
831 do { | |
832 ag_track(); | |
833 if ((PCB).rx < (PCB).fx) { | |
834 (PCB).input_code = (PCB).lab[(PCB).rx++]; | |
835 (PCB).token_number = (xml3_token_type) AG_TCV((PCB).input_code);} | |
836 else { | |
837 GET_INPUT; | |
838 (PCB).lab[(PCB).fx++] = (PCB).input_code; | |
839 (PCB).token_number = (xml3_token_type) AG_TCV((PCB).input_code); | |
840 (PCB).rx++; | |
841 } | |
842 if (ag_key_index[(PCB).sn]) { | |
843 unsigned ag_k = ag_key_index[(PCB).sn]; | |
844 int ag_ch = CONVERT_CASE((PCB).input_code); | |
845 if (ag_ch < 255) { | |
846 while (ag_key_ch[ag_k] < ag_ch) ag_k++; | |
847 if (ag_key_ch[ag_k] == ag_ch) ag_get_key_word(ag_k); | |
848 } | |
849 } | |
850 } while ((PCB).token_number == (xml3_token_type) ag_t); | |
851 (PCB).rx = 0; | |
852 return 1; | |
853 } | |
854 | |
855 static int ag_action_11_proc(void) { | |
856 int ag_t = (PCB).token_number; | |
857 | |
858 (PCB).btsx = 0, (PCB).drt = -1; | |
859 do { | |
860 (PCB).vs[(PCB).ssx] = *(PCB).lab; | |
861 (PCB).ssx--; | |
862 ag_track(); | |
863 ag_ra(); | |
864 if ((PCB).exit_flag != AG_RUNNING_CODE) return 0; | |
865 (PCB).ssx++; | |
866 if ((PCB).rx < (PCB).fx) { | |
867 (PCB).input_code = (PCB).lab[(PCB).rx++]; | |
868 (PCB).token_number = (xml3_token_type) AG_TCV((PCB).input_code);} | |
869 else { | |
870 GET_INPUT; | |
871 (PCB).lab[(PCB).fx++] = (PCB).input_code; | |
872 (PCB).token_number = (xml3_token_type) AG_TCV((PCB).input_code); | |
873 (PCB).rx++; | |
874 } | |
875 if (ag_key_index[(PCB).sn]) { | |
876 unsigned ag_k = ag_key_index[(PCB).sn]; | |
877 int ag_ch = CONVERT_CASE((PCB).input_code); | |
878 if (ag_ch < 255) { | |
879 while (ag_key_ch[ag_k] < ag_ch) ag_k++; | |
880 if (ag_key_ch[ag_k] == ag_ch) ag_get_key_word(ag_k); | |
881 } | |
882 } | |
883 } | |
884 while ((PCB).token_number == (xml3_token_type) ag_t); | |
885 (PCB).rx = 0; | |
886 return 1; | |
887 } | |
888 | |
889 static int ag_action_3_r_proc(void) { | |
890 int ag_sd = ag_fl[(PCB).ag_ap] - 1; | |
891 if (ag_sd) (PCB).sn = (PCB).ss[(PCB).ssx -= ag_sd]; | |
892 (PCB).btsx = 0, (PCB).drt = -1; | |
893 (PCB).reduction_token = (xml3_token_type) ag_ptt[(PCB).ag_ap]; | |
894 ag_ra(); | |
895 return (PCB).exit_flag == AG_RUNNING_CODE; | |
896 } | |
897 | |
898 static int ag_action_3_s_proc(void) { | |
899 int ag_sd = ag_fl[(PCB).ag_ap] - 1; | |
900 if (ag_sd) (PCB).sn = (PCB).ss[(PCB).ssx -= ag_sd]; | |
901 (PCB).btsx = 0, (PCB).drt = -1; | |
902 (PCB).reduction_token = (xml3_token_type) ag_ptt[(PCB).ag_ap]; | |
903 ag_ra(); | |
904 return (PCB).exit_flag == AG_RUNNING_CODE; | |
905 } | |
906 | |
907 static int ag_action_4_r_proc(void) { | |
908 int ag_sd = ag_fl[(PCB).ag_ap] - 1; | |
909 if (ag_sd) (PCB).sn = (PCB).ss[(PCB).ssx -= ag_sd]; | |
910 (PCB).reduction_token = (xml3_token_type) ag_ptt[(PCB).ag_ap]; | |
911 return 1; | |
912 } | |
913 | |
914 static int ag_action_2_proc(void) { | |
915 (PCB).btsx = 0, (PCB).drt = -1; | |
916 if ((PCB).ssx >= 128) { | |
917 (PCB).exit_flag = AG_STACK_ERROR_CODE; | |
918 PARSER_STACK_OVERFLOW; | |
919 } | |
920 (PCB).vs[(PCB).ssx] = *(PCB).lab; | |
921 (PCB).ss[(PCB).ssx] = (PCB).sn; | |
922 (PCB).ssx++; | |
923 (PCB).sn = (PCB).ag_ap; | |
924 ag_track(); | |
925 return 0; | |
926 } | |
927 | |
928 static int ag_action_9_proc(void) { | |
929 if ((PCB).drt == -1) { | |
930 (PCB).drt=(PCB).token_number; | |
931 (PCB).dssx=(PCB).ssx; | |
932 (PCB).dsn=(PCB).sn; | |
933 } | |
934 ag_prot(); | |
935 (PCB).vs[(PCB).ssx] = ag_null_value; | |
936 (PCB).ss[(PCB).ssx] = (PCB).sn; | |
937 (PCB).ssx++; | |
938 (PCB).sn = (PCB).ag_ap; | |
939 (PCB).rx = 0; | |
940 return (PCB).exit_flag == AG_RUNNING_CODE; | |
941 } | |
942 | |
943 static int ag_action_2_r_proc(void) { | |
944 (PCB).ssx++; | |
945 (PCB).sn = (PCB).ag_ap; | |
946 return 0; | |
947 } | |
948 | |
949 static int ag_action_7_proc(void) { | |
950 --(PCB).ssx; | |
951 (PCB).rx = 0; | |
952 (PCB).exit_flag = AG_SUCCESS_CODE; | |
953 return 0; | |
954 } | |
955 | |
956 static int ag_action_1_proc(void) { | |
957 ag_track(); | |
958 (PCB).exit_flag = AG_SUCCESS_CODE; | |
959 return 0; | |
960 } | |
961 | |
962 static int ag_action_1_r_proc(void) { | |
963 (PCB).exit_flag = AG_SUCCESS_CODE; | |
964 return 0; | |
965 } | |
966 | |
967 static int ag_action_1_s_proc(void) { | |
968 (PCB).exit_flag = AG_SUCCESS_CODE; | |
969 return 0; | |
970 } | |
971 | |
972 static int ag_action_4_proc(void) { | |
973 int ag_sd = ag_fl[(PCB).ag_ap] - 1; | |
974 (PCB).reduction_token = (xml3_token_type) ag_ptt[(PCB).ag_ap]; | |
975 (PCB).btsx = 0, (PCB).drt = -1; | |
976 (PCB).vs[(PCB).ssx] = *(PCB).lab; | |
977 if (ag_sd) (PCB).sn = (PCB).ss[(PCB).ssx -= ag_sd]; | |
978 else (PCB).ss[(PCB).ssx] = (PCB).sn; | |
979 ag_track(); | |
980 while ((PCB).exit_flag == AG_RUNNING_CODE) { | |
981 unsigned ag_t1 = ag_sbe[(PCB).sn] + 1; | |
982 unsigned ag_t2 = ag_sbt[(PCB).sn+1] - 1; | |
983 do { | |
984 unsigned ag_tx = (ag_t1 + ag_t2)/2; | |
985 if (ag_tstt[ag_tx] < (unsigned char)(PCB).reduction_token) ag_t1 = ag_tx + 1; | |
986 else ag_t2 = ag_tx; | |
987 } while (ag_t1 < ag_t2); | |
988 (PCB).ag_ap = ag_pstt[ag_t1]; | |
989 if ((ag_s_procs_scan[ag_astt[ag_t1]])() == 0) break; | |
990 } | |
991 return 0; | |
992 } | |
993 | |
994 static int ag_action_3_proc(void) { | |
995 int ag_sd = ag_fl[(PCB).ag_ap] - 1; | |
996 (PCB).btsx = 0, (PCB).drt = -1; | |
997 (PCB).vs[(PCB).ssx] = *(PCB).lab; | |
998 if (ag_sd) (PCB).sn = (PCB).ss[(PCB).ssx -= ag_sd]; | |
999 else (PCB).ss[(PCB).ssx] = (PCB).sn; | |
1000 ag_track(); | |
1001 (PCB).reduction_token = (xml3_token_type) ag_ptt[(PCB).ag_ap]; | |
1002 ag_ra(); | |
1003 while ((PCB).exit_flag == AG_RUNNING_CODE) { | |
1004 unsigned ag_t1 = ag_sbe[(PCB).sn] + 1; | |
1005 unsigned ag_t2 = ag_sbt[(PCB).sn+1] - 1; | |
1006 do { | |
1007 unsigned ag_tx = (ag_t1 + ag_t2)/2; | |
1008 if (ag_tstt[ag_tx] < (unsigned char)(PCB).reduction_token) ag_t1 = ag_tx + 1; | |
1009 else ag_t2 = ag_tx; | |
1010 } while (ag_t1 < ag_t2); | |
1011 (PCB).ag_ap = ag_pstt[ag_t1]; | |
1012 if ((ag_s_procs_scan[ag_astt[ag_t1]])() == 0) break; | |
1013 } | |
1014 return 0; | |
1015 } | |
1016 | |
1017 static int ag_action_8_proc(void) { | |
1018 ag_undo(); | |
1019 (PCB).rx = 0; | |
1020 (PCB).exit_flag = AG_SYNTAX_ERROR_CODE; | |
1021 ag_diagnose(); | |
1022 SYNTAX_ERROR; | |
1023 {(PCB).rx = 1; ag_track();} | |
1024 return (PCB).exit_flag == AG_RUNNING_CODE; | |
1025 } | |
1026 | |
1027 static int ag_action_5_proc(void) { | |
1028 int ag_sd = ag_fl[(PCB).ag_ap]; | |
1029 (PCB).btsx = 0, (PCB).drt = -1; | |
1030 if (ag_sd) (PCB).sn = (PCB).ss[(PCB).ssx -= ag_sd]; | |
1031 else { | |
1032 (PCB).ss[(PCB).ssx] = (PCB).sn; | |
1033 } | |
1034 (PCB).rx = 0; | |
1035 (PCB).reduction_token = (xml3_token_type) ag_ptt[(PCB).ag_ap]; | |
1036 ag_ra(); | |
1037 while ((PCB).exit_flag == AG_RUNNING_CODE) { | |
1038 unsigned ag_t1 = ag_sbe[(PCB).sn] + 1; | |
1039 unsigned ag_t2 = ag_sbt[(PCB).sn+1] - 1; | |
1040 do { | |
1041 unsigned ag_tx = (ag_t1 + ag_t2)/2; | |
1042 if (ag_tstt[ag_tx] < (unsigned char)(PCB).reduction_token) ag_t1 = ag_tx + 1; | |
1043 else ag_t2 = ag_tx; | |
1044 } while (ag_t1 < ag_t2); | |
1045 (PCB).ag_ap = ag_pstt[ag_t1]; | |
1046 if ((ag_r_procs_scan[ag_astt[ag_t1]])() == 0) break; | |
1047 } | |
1048 return (PCB).exit_flag == AG_RUNNING_CODE; | |
1049 } | |
1050 | |
1051 static int ag_action_6_proc(void) { | |
1052 int ag_sd = ag_fl[(PCB).ag_ap]; | |
1053 (PCB).reduction_token = (xml3_token_type) ag_ptt[(PCB).ag_ap]; | |
1054 if ((PCB).drt == -1) { | |
1055 (PCB).drt=(PCB).token_number; | |
1056 (PCB).dssx=(PCB).ssx; | |
1057 (PCB).dsn=(PCB).sn; | |
1058 } | |
1059 if (ag_sd) { | |
1060 (PCB).sn = (PCB).ss[(PCB).ssx -= ag_sd]; | |
1061 } | |
1062 else { | |
1063 ag_prot(); | |
1064 (PCB).vs[(PCB).ssx] = ag_null_value; | |
1065 (PCB).ss[(PCB).ssx] = (PCB).sn; | |
1066 } | |
1067 (PCB).rx = 0; | |
1068 while ((PCB).exit_flag == AG_RUNNING_CODE) { | |
1069 unsigned ag_t1 = ag_sbe[(PCB).sn] + 1; | |
1070 unsigned ag_t2 = ag_sbt[(PCB).sn+1] - 1; | |
1071 do { | |
1072 unsigned ag_tx = (ag_t1 + ag_t2)/2; | |
1073 if (ag_tstt[ag_tx] < (unsigned char)(PCB).reduction_token) ag_t1 = ag_tx + 1; | |
1074 else ag_t2 = ag_tx; | |
1075 } while (ag_t1 < ag_t2); | |
1076 (PCB).ag_ap = ag_pstt[ag_t1]; | |
1077 if ((ag_r_procs_scan[ag_astt[ag_t1]])() == 0) break; | |
1078 } | |
1079 return (PCB).exit_flag == AG_RUNNING_CODE; | |
1080 } | |
1081 | |
1082 | |
1083 void init_xml3(void) { | |
1084 (PCB).rx = (PCB).fx = 0; | |
1085 (PCB).ss[0] = (PCB).sn = (PCB).ssx = 0; | |
1086 (PCB).exit_flag = AG_RUNNING_CODE; | |
1087 (PCB).line = FIRST_LINE; | |
1088 (PCB).column = FIRST_COLUMN; | |
1089 (PCB).btsx = 0, (PCB).drt = -1; | |
1090 } | |
1091 | |
1092 void xml3(void) { | |
1093 init_xml3(); | |
1094 (PCB).exit_flag = AG_RUNNING_CODE; | |
1095 while ((PCB).exit_flag == AG_RUNNING_CODE) { | |
1096 unsigned ag_t1 = ag_sbt[(PCB).sn]; | |
1097 if (ag_tstt[ag_t1]) { | |
1098 unsigned ag_t2 = ag_sbe[(PCB).sn] - 1; | |
1099 if ((PCB).rx < (PCB).fx) { | |
1100 (PCB).input_code = (PCB).lab[(PCB).rx++]; | |
1101 (PCB).token_number = (xml3_token_type) AG_TCV((PCB).input_code);} | |
1102 else { | |
1103 GET_INPUT; | |
1104 (PCB).lab[(PCB).fx++] = (PCB).input_code; | |
1105 (PCB).token_number = (xml3_token_type) AG_TCV((PCB).input_code); | |
1106 (PCB).rx++; | |
1107 } | |
1108 if (ag_key_index[(PCB).sn]) { | |
1109 unsigned ag_k = ag_key_index[(PCB).sn]; | |
1110 int ag_ch = CONVERT_CASE((PCB).input_code); | |
1111 if (ag_ch < 255) { | |
1112 while (ag_key_ch[ag_k] < ag_ch) ag_k++; | |
1113 if (ag_key_ch[ag_k] == ag_ch) ag_get_key_word(ag_k); | |
1114 } | |
1115 } | |
1116 do { | |
1117 unsigned ag_tx = (ag_t1 + ag_t2)/2; | |
1118 if (ag_tstt[ag_tx] > (unsigned char)(PCB).token_number) | |
1119 ag_t1 = ag_tx + 1; | |
1120 else ag_t2 = ag_tx; | |
1121 } while (ag_t1 < ag_t2); | |
1122 if (ag_tstt[ag_t1] != (unsigned char)(PCB).token_number) | |
1123 ag_t1 = ag_sbe[(PCB).sn]; | |
1124 } | |
1125 (PCB).ag_ap = ag_pstt[ag_t1]; | |
1126 (ag_gt_procs_scan[ag_astt[ag_t1]])(); | |
1127 } | |
1128 } | |
1129 | |
1130 | |
1131 | |
1132 int main(void) { | |
1133 xml3(); | |
1134 return 0; | |
1135 } |