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