Mercurial > ~dholland > hg > ag > index.cgi
diff 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 |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tests/agcl/parsifal/good/xml3.c Sat Dec 22 17:52:45 2007 -0500 @@ -0,0 +1,1135 @@ + +/* + * AnaGram, A System for Syntax Directed Programming + * File generated by: ... + * + * AnaGram Parsing Engine + * Copyright 1993-2002 Parsifal Software. All Rights Reserved. + * + * This software is provided 'as-is', without any express or implied + * warranty. In no event will the authors be held liable for any damages + * arising from the use of this software. + * + * Permission is granted to anyone to use this software for any purpose, + * including commercial applications, and to alter it and redistribute it + * freely, subject to the following restrictions: + * + * 1. The origin of this software must not be misrepresented; you must not + * claim that you wrote the original software. If you use this software + * in a product, an acknowledgment in the product documentation would be + * appreciated but is not required. + * 2. Altered source versions must be plainly marked as such, and must not be + * misrepresented as being the original software. + * 3. This notice may not be removed or altered from any source distribution. + */ + +#ifndef XML3_H +#include "xml3.h" +#endif + +#ifndef XML3_H +#error Mismatched header file +#endif + +#include <ctype.h> +#include <stdio.h> + +#define RULE_CONTEXT (&((PCB).cs[(PCB).ssx])) +#define ERROR_CONTEXT ((PCB).cs[(PCB).error_frame_ssx]) +#define CONTEXT ((PCB).cs[(PCB).ssx]) + + + +xml3_pcb_type xml3_pcb; +#define PCB xml3_pcb + +#ifndef CONVERT_CASE +#define CONVERT_CASE(c) (c) +#endif +#ifndef TAB_SPACING +#define TAB_SPACING 8 +#endif + + +#define READ_COUNTS +#define WRITE_COUNTS +#undef V +#define V(i,t) (*t (&(PCB).vs[(PCB).ssx + i])) +#undef VS +#define VS(i) (PCB).vs[(PCB).ssx + i] + +#ifndef GET_CONTEXT +#define GET_CONTEXT CONTEXT = (PCB).input_context +#endif + +typedef enum { + ag_action_1, + ag_action_2, + ag_action_3, + ag_action_4, + ag_action_5, + ag_action_6, + ag_action_7, + ag_action_8, + ag_action_9, + ag_action_10, + ag_action_11, + ag_action_12 +} ag_parser_action; + + +#ifndef NULL_VALUE_INITIALIZER +#define NULL_VALUE_INITIALIZER = 0 +#endif + +static int const ag_null_value NULL_VALUE_INITIALIZER; + +static const unsigned char ag_rpx[] = { + 0 +}; + +static const unsigned char ag_key_itt[] = { + 0 +}; + +static const unsigned short ag_key_pt[] = { +0 +}; + +static const unsigned char ag_key_ch[] = { + 0, 45, 68,255,120,255, 33, 63,255, 60,255, 45, 68,255, 33, 63,255, 60, + 255, 39, 63,115,118,255,118,255,110,121,255, 34, 39, 63,255, 45,255, 60, + 255, 60,255, 33, 63,255, 60,255, 63,255, 63,115,255, 39,255 +}; + +static const unsigned char ag_key_act[] = { + 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, + 3,4,3,4,3,0,4,2,4,3,4,3,3,4,3,4 +}; + +static const unsigned char ag_key_parm[] = { + 0, 62,100, 0, 86, 0, 0, 69, 0, 0, 0, 62,100, 0, 0, 69, 0, 0, + 0,124, 75,123, 93, 0, 93, 0,127,125, 0, 0,126, 75, 0, 66, 0,100, + 0,152, 0, 62, 69, 0, 0, 0, 75, 0, 75,123, 0,124, 0 +}; + +static const unsigned char ag_key_jmp[] = { + 0, 0, 2, 0, 9, 0, 1, 4, 0, 6, 0, 12, 14, 0, 11, 0, 0, 14, + 0, 21, 26, 28, 38, 0, 45, 0, 52, 55, 0, 26, 59, 63, 0, 65, 0, 67, + 0, 76, 0, 78, 0, 0, 39, 0, 81, 0, 83, 85, 0, 95, 0 +}; + +static const unsigned char ag_key_index[] = { + 9, 0, 17, 0, 19, 24, 29, 0, 33, 17, 35, 0, 37, 42, 0, 29, 44, 44, + 33, 33, 0, 42, 0, 37, 37, 0, 0, 46, 44, 44, 44, 44, 44, 0, 0, 0, + 0, 0, 0, 49, 0, 0, 0, 44, 0, 0, 0, 0, 0, 0, 0, 49, 0, 0, + 0, 0, 0, 42, 0, 0, 0, 42, 0, 0, 0, 0, 0, 0 +}; + +static const unsigned char ag_key_ends[] = { +45,0, 79,67,84,89,80,69,0, 109,108,0, 45,0, 79,67,84,89,80,69,0, +121,101,115,39,0, 62,0, 116,97,110,100,97,108,111,110,101,0, +101,114,115,105,111,110,0, 101,114,115,105,111,110,0, 111,34,0, +101,115,34,0, 110,111,39,0, 62,0, 45,0, +33,68,79,67,84,89,80,69,0, 47,0, 45,45,0, 62,0, 62,0, +116,97,110,100,97,108,111,110,101,0, 121,101,115,39,0, +}; +#define AG_TCV(x) (((int)(x) >= 0 && (int)(x) <= 255) ? ag_tcv[(x)] : 0) + +static const unsigned char ag_tcv[] = { + 162,162,162,162,162,162,162,162,162,156,157,162,162,158,162,162,162,162, + 162,162,162,162,162,162,162,162,162,162,162,162,162,162,157,163, 26,163, + 163,166,167, 33,163,163,163,163,163,130,161,163,164,164,164,164,164,164, + 164,164,164,164,159,163,147, 97, 67,163,163,138,138,138,138,138,138,138, + 138,140,138,138,138,138,138,138,138,138,138,138,138,138,138,138,142,138, + 138,104,165,109,165,160,165,138,138,138,138,138,138,138,138,140,138,138, + 138,138,138,138,138,138,138,138,138,138,138,138,142,138,138,165,165,165, + 165,165,165,165,165,165,165,165,165,165,165,165,165,165,165,165,165,165, + 165,165,165,165,165,165,165,165,165,165,165,165,165,165,165,165,165,165, + 165,165,165,165,165,165,165,165,165,165,165,165,165,165,165,165,165,165, + 165,165,165,165,165,165,165,165,165,165,165,165,165,165,165,165,165,165, + 165,165,165,165,165,165,165,165,165,165,165,165,165,165,165,165,165,165, + 165,165,165,165,165,165,165,165,165,165,165,165,165,165,165,165,165,165, + 165,165,165,165,165,165,165,165,165,165,165,165,165,165,165,165,165,165, + 165,165,165,165 +}; + +#ifndef SYNTAX_ERROR +#define SYNTAX_ERROR fprintf(stderr,"%s, line %d, column %d\n", \ + (PCB).error_message, (PCB).line, (PCB).column) +#endif + +#ifndef FIRST_LINE +#define FIRST_LINE 1 +#endif + +#ifndef FIRST_COLUMN +#define FIRST_COLUMN 1 +#endif + +#ifndef PARSER_STACK_OVERFLOW +#define PARSER_STACK_OVERFLOW {fprintf(stderr, \ + "\nParser stack overflow, line %d, column %d\n",\ + (PCB).line, (PCB).column);} +#endif + +#ifndef REDUCTION_TOKEN_ERROR +#define REDUCTION_TOKEN_ERROR {fprintf(stderr, \ + "\nReduction token error, line %d, column %d\n", \ + (PCB).line, (PCB).column);} +#endif + + +typedef enum + {ag_accept_key, ag_set_key, ag_jmp_key, ag_end_key, ag_no_match_key, + ag_cf_accept_key, ag_cf_set_key, ag_cf_end_key} key_words; + +#ifndef GET_INPUT +#define GET_INPUT ((PCB).input_code = getchar()) +#endif + + +static int ag_look_ahead(void) { + if ((PCB).rx < (PCB).fx) { + return CONVERT_CASE((PCB).lab[(PCB).rx++]); + } + GET_INPUT; + (PCB).fx++; + return CONVERT_CASE((PCB).lab[(PCB).rx++] = (PCB).input_code); +} + +static void ag_get_key_word(int ag_k) { + int save_index = (PCB).rx; + const unsigned char *sp; + int ag_ch; + while (1) { + switch (ag_key_act[ag_k]) { + case ag_cf_end_key: + sp = ag_key_ends + ag_key_jmp[ag_k]; + do { + if ((ag_ch = *sp++) == 0) { + int ag_k1 = ag_key_parm[ag_k]; + int ag_k2 = ag_key_pt[ag_k1]; + if (ag_key_itt[ag_k2 + ag_look_ahead()]) goto ag_fail; + (PCB).rx--; + (PCB).token_number = (xml3_token_type) ag_key_pt[ag_k1 + 1]; + return; + } + } while (ag_look_ahead() == ag_ch); + goto ag_fail; + case ag_end_key: + sp = ag_key_ends + ag_key_jmp[ag_k]; + do { + if ((ag_ch = *sp++) == 0) { + (PCB).token_number = (xml3_token_type) ag_key_parm[ag_k]; + return; + } + } while (ag_look_ahead() == ag_ch); + case ag_no_match_key: +ag_fail: + (PCB).rx = save_index; + return; + case ag_cf_set_key: { + int ag_k1 = ag_key_parm[ag_k]; + int ag_k2 = ag_key_pt[ag_k1]; + ag_k = ag_key_jmp[ag_k]; + if (ag_key_itt[ag_k2 + (ag_ch = ag_look_ahead())]) break; + save_index = --(PCB).rx; + (PCB).token_number = (xml3_token_type) ag_key_pt[ag_k1+1]; + break; + } + case ag_set_key: + save_index = (PCB).rx; + (PCB).token_number = (xml3_token_type) ag_key_parm[ag_k]; + case ag_jmp_key: + ag_k = ag_key_jmp[ag_k]; + ag_ch = ag_look_ahead(); + break; + case ag_accept_key: + (PCB).token_number = (xml3_token_type) ag_key_parm[ag_k]; + return; + case ag_cf_accept_key: { + int ag_k1 = ag_key_parm[ag_k]; + int ag_k2 = ag_key_pt[ag_k1]; + if (ag_key_itt[ag_k2 + ag_look_ahead()]) (PCB).rx = save_index; + else { + (PCB).rx--; + (PCB).token_number = (xml3_token_type) ag_key_pt[ag_k1+1]; + } + return; + } + default: + /* not reachable; here to suppress compiler warnings */ + goto ag_fail; + } + if (ag_ch <= 255) while (ag_key_ch[ag_k] < ag_ch) ag_k++; + if (ag_ch > 255 || ag_key_ch[ag_k] != ag_ch) { + (PCB).rx = save_index; + return; + } + } +} + + +#ifndef AG_NEWLINE +#define AG_NEWLINE 10 +#endif + +#ifndef AG_RETURN +#define AG_RETURN 13 +#endif + +#ifndef AG_FORMFEED +#define AG_FORMFEED 12 +#endif + +#ifndef AG_TABCHAR +#define AG_TABCHAR 9 +#endif + +static void ag_track(void) { + int ag_k = 0; + while (ag_k < (PCB).rx) { + int ag_ch = (PCB).lab[ag_k++]; + switch (ag_ch) { + case AG_NEWLINE: + (PCB).column = 1, (PCB).line++; + case AG_RETURN: + case AG_FORMFEED: + break; + case AG_TABCHAR: + (PCB).column += (TAB_SPACING) - ((PCB).column - 1) % (TAB_SPACING); + break; + default: + (PCB).column++; + } + } + ag_k = 0; + while ((PCB).rx < (PCB).fx) (PCB).lab[ag_k++] = (PCB).lab[(PCB).rx++]; + (PCB).fx = ag_k; + (PCB).rx = 0; +} + + +static void ag_prot(void) { + int ag_k; + ag_k = 128 - ++(PCB).btsx; + if (ag_k <= (PCB).ssx) { + (PCB).exit_flag = AG_STACK_ERROR_CODE; + PARSER_STACK_OVERFLOW; + return; + } + (PCB).bts[(PCB).btsx] = (PCB).sn; + (PCB).bts[ag_k] = (PCB).ssx; + (PCB).vs[ag_k] = (PCB).vs[(PCB).ssx]; + (PCB).ss[ag_k] = (PCB).ss[(PCB).ssx]; +} + +static void ag_undo(void) { + if ((PCB).drt == -1) return; + while ((PCB).btsx) { + int ag_k = 128 - (PCB).btsx; + (PCB).sn = (PCB).bts[(PCB).btsx--]; + (PCB).ssx = (PCB).bts[ag_k]; + (PCB).vs[(PCB).ssx] = (PCB).vs[ag_k]; + (PCB).ss[(PCB).ssx] = (PCB).ss[ag_k]; + } + (PCB).token_number = (xml3_token_type) (PCB).drt; + (PCB).ssx = (PCB).dssx; + (PCB).sn = (PCB).dsn; + (PCB).drt = -1; +} + + +static const unsigned char ag_tstt[] = { +158,157,156,147,143,100,86,69,62,0,1,2,82,83, +158,157,156,0,7,9,10,87, +158,157,156,147,143,100,69,62,0,4,5,6,7,61,68, +147,143,0,3,144, +158,157,156,0,7, +93,0, +158,157,156,127,126,125,88,75,0,89, +160,159,0,11,70, +167,166,165,164,163,161,160,159,157,156,147,142,140,138,130,109,104,97,67, + 66,33,26,0,64,65, +158,157,156,69,62,0,4,7,61,68, +147,143,100,0,84,85, +160,159,0,11, +166,165,164,163,162,161,160,159,158,157,156,152,147,143,142,140,138,130,109, + 104,97,67,33,26,0,3,56,144,145,153,154,155, +158,157,156,69,62,0,4,5,6,7,61,68, +158,157,156,97,0,7,9,10,91,94, +158,157,156,127,126,125,75,0,7,9,10,90,92, +161,159,158,157,156,130,104,97,75,67,0,14,15, +158,157,156,75,0,7,9,10,74, +167,166,165,164,163,161,160,159,157,156,147,142,140,138,130,109,104,97,67, + 33,26,0, +66,0, +158,157,156,0,7,9,10, +158,157,156,147,143,69,62,0,4,5,6,7,61,68, +158,157,156,67,0,7,9,10,149,150,151, +166,165,164,163,162,161,160,159,158,157,156,147,143,142,140,138,130,109,104, + 97,67,33,26,0,3,56,144,153, +152,0,146, +97,0, +33,26,0,96, +123,0, +158,157,156,75,0,7,9,10,91, +75,0, +161,159,130,0, +75,71,0,72,73, +75,0, +67,0, +160,159,0,11, +160,159,0,11,148, +158,157,156,0,7,9,10,149, +67,0, +160,159,0,11, +158,157,156,124,33,26,0,7,9,10,91, +164,161,160,159,142,140,138,130,0,95,99, +164,161,160,159,142,140,138,130,0,95,99, +158,157,156,97,0,7,9,10,91,94, +71,0, +158,157,156,104,67,0,7,9,10,103, +158,157,156,97,0,7,9,10,91,94, +160,159,0,11,148, +158,157,156,67,0,7,9,10,91, +164,161,160,159,142,140,138,130,0, +26,0, +33,0, +124,0, +104,101,67,0,102, +104,67,0,110, +33,26,0,38, +67,0, +158,157,156,104,67,0,7,9,10,91, +158,157,156,114,113,112,111,109,69,62,28,0,7,61,68,105,106,107,108, +67,0, +165,164,163,162,161,160,159,158,157,156,147,142,140,138,130,109,104,97,67, + 33,29,26,0,42,43,44, +165,164,163,162,161,160,159,158,157,156,147,142,140,138,130,109,104,97,67, + 33,29,26,0,39,40,41, +158,157,156,114,113,112,111,69,62,28,0,7,61,68,105,106, +109,0, +165,164,163,162,161,160,159,158,157,156,147,142,140,138,130,109,104,97,67, + 29,26,0,42, +33,0, +165,164,163,162,161,160,159,158,157,156,147,142,140,138,130,109,104,97,67, + 33,29,0,39, +26,0, +158,157,156,67,0,7,9,10,91, + +}; + + +static unsigned const char ag_astt[609] = { + 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, + 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, + 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, + 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, + 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, + 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, + 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, + 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, + 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, + 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, + 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, + 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, + 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, + 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, + 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, + 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, + 9,9,9,9,5,3,3,7,1,1,1,5,7,1,3,1,3 +}; + + +static const unsigned char ag_pstt[] = { +2,2,2,97,97,97,1,2,2,0,0,3,2,2, +4,4,4,1,4,5,4,6, +9,9,9,3,3,10,7,8,2,9,9,10,9,9,9, +11,13,3,13,12, +8,8,8,9,8, +14,5, +15,15,15,15,15,15,15,102,6,15, +16,16,7,17,17, +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, +2,2,2,7,8,4,2,2,2,2, +99,99,20,10,21,101, +16,16,11,22, +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, + 23,23,12,24,23,23,24, +9,9,9,7,8,3,9,9,5,9,9,9, +4,4,4,25,14,4,25,4,25,26, +4,4,4,28,28,28,29,15,4,27,4,28,29, +30,30,12,12,12,30,12,12,12,12,16,30,14, +4,4,4,32,17,4,31,4,32, +81,81,81,81,81,81,81,81,81,81,81,81,81,81,81,81,81,81,81,81,81,83, +33,19, +4,4,4,20,4,34,4, +9,9,9,3,3,7,8,21,9,9,100,9,9,9, +4,4,4,37,22,4,35,4,36,36,37, +185,185,185,185,185,185,185,185,185,185,185,11,185,185,185,185,185,185,185, + 185,185,185,185,187,185,185,12,185, +38,24,172, +39,25, +41,40,26,112, +42,108, +4,4,4,104,28,4,107,4,107, +109,29, +11,11,11,13, +87,43,31,43,90, +91,32, +84,33, +16,16,34,44, +16,16,178,45,173, +4,4,4,177,4,46,4,175, +179,37, +16,16,38,47, +4,4,4,104,104,104,39,4,113,4,113, +48,48,48,48,48,48,48,48,40,49,48, +48,48,48,48,48,48,48,48,41,50,48, +4,4,4,25,42,4,25,4,25,51, +86,88, +4,4,4,53,122,44,4,52,4,53, +4,4,4,25,45,4,25,4,25,54, +16,16,46,45,173, +4,4,4,55,47,4,55,4,55, +115,115,115,115,115,115,115,115,116, +111,49, +110,50, +152,51, +120,56,120,52,123, +57,58,53,58, +59,60,54,180, +181,55, +4,4,4,104,104,56,4,121,4,121, +61,61,61,61,61,61,61,62,7,8,61,57,61,61,61,61,61,61,62, +133,58, +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, + 64, +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, + 66, +128,128,128,128,128,128,128,7,8,128,130,128,128,128,128,128, +67,62, +54,54,54,54,54,54,54,54,54,54,54,54,54,54,54,54,54,54,54,54,54,56,54, +57,64, +47,47,47,47,47,47,47,47,47,47,47,47,47,47,47,47,47,47,47,47,47,49,47, +50,66, +4,4,4,104,67,4,132,4,132, + +}; + + +static const unsigned short ag_sbt[] = { + 0, 14, 22, 37, 42, 47, 49, 59, 64, 89, 99, 105, 109, 141, + 153, 163, 176, 189, 198, 220, 222, 229, 243, 254, 282, 285, 287, 291, + 293, 302, 304, 308, 313, 315, 317, 321, 326, 334, 336, 340, 351, 362, + 373, 383, 385, 395, 405, 410, 419, 428, 430, 432, 434, 439, 443, 447, + 449, 459, 478, 480, 506, 532, 548, 550, 573, 575, 598, 600, 609 +}; + + +static const unsigned short ag_sbe[] = { + 9, 17, 30, 39, 45, 48, 57, 61, 86, 94, 102, 107, 133, 146, + 157, 170, 186, 193, 219, 221, 225, 236, 247, 277, 283, 286, 289, 292, + 297, 303, 307, 310, 314, 316, 319, 323, 329, 335, 338, 346, 359, 370, + 377, 384, 390, 399, 407, 414, 427, 429, 431, 433, 437, 441, 445, 448, + 454, 470, 479, 502, 528, 542, 549, 571, 574, 596, 599, 604, 609 +}; + + +static const unsigned char ag_fl[] = { + 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, + 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, + 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, + 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, + 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, + 2,0,1,1,4,3,4,1,1,1,2,0,1,1 +}; + +static const unsigned char ag_ptt[] = { + 0, 5, 5, 6, 6, 1, 7, 10, 10, 9, 14, 14, 15, 15, 11, 17, 18, 18, + 19, 19, 16, 20, 22, 23, 23, 24, 24, 21, 30, 30, 30, 31, 31, 32, 32, 25, + 35, 35, 35, 36, 36, 37, 37, 25, 39, 39, 40, 40, 41, 41, 38, 42, 42, 43, + 43, 44, 44, 38, 47, 47, 48, 48, 45, 50, 50, 51, 51, 45, 54, 54, 55, 55, + 52, 52, 56, 59, 59, 60, 60, 58, 64, 64, 65, 65, 61, 72, 72, 73, 73, 74, + 74, 68, 70, 76, 77, 78, 78, 83, 83, 85, 85, 2, 89, 89, 91, 91, 92, 92, + 92, 82, 96, 96, 87, 94, 99, 99, 95, 4, 4, 4,102,102,103,103,106,106, + 106,107,107,108,108,110,110, 84,105,105,105,105,105,105,117,117,115,120, + 120,120,120,121,121,122,122,118, 90, 90, 90, 90,132,133,133,134,134,128, + 129,129,129,135,141,141,136,137,131, 3, 3,149,150,150,151,151,151,144, + 148,146,153,153,154,154,155,155,145 +}; + + +static void ag_ra(void) +{ +} + +#define TOKEN_NAMES xml3_token_names +const char *const xml3_token_names[168] = { + "document", + "document", + "prolog", + "element", + "Misc", + "", + "", + "SpaceChar", + "", + "S", + "", + "Name", + "", + "NameChar", + "", + "", + "Names", + "", + "", + "", + "Nmtoken", + "Nmtokens", + "", + "", + "", + "EntityValue", + "'\\\"'", + "", + "PEReference", + "Reference", + "", + "", + "", + "'\\''", + "", + "", + "", + "", + "AttValue", + "", + "", + "", + "", + "", + "", + "SystemLiteral", + "", + "", + "", + "", + "", + "", + "PubidLiteral", + "PubidChar", + "", + "", + "DataChar", + "", + "CharData", + "", + "", + "Comment", + "\"<!--\"", + "Char", + "", + "", + "\"--\"", + "'>'", + "PI", + "\"<?\"", + "PITarget", + "char", + "", + "", + "", + "\"?>\"", + "CDSect", + "CDStart", + "CData", + "CDEnd", + "\"<![CDATA[\"", + "\"]]>\"", + "XMLDecl", + "", + "doctypedecl", + "", + "\"<?xml\"", + "VersionInfo", + "EncodingDecl", + "", + "SDDecl", + "", + "", + "\"version\"", + "Eq", + "VersionNum", + "", + "'='", + "", + "", + "\"<!DOCTYPE\"", + "ExternalID", + "", + "", + "'['", + "markupdecl", + "", + "", + "", + "']'", + "", + "elementdecl", + "AttlistDecl", + "EntityDecl", + "NotationDecl", + "extSubset", + "TextDecl", + "", + "extSubsetDecl", + "conditionalSect", + "", + "", + "", + "\"standalone\"", + "\"\\'yes\\'\"", + "\"\\\"yes\\\"\"", + "\"\\'no\\'\"", + "\"\\\"no\\\"\"", + "Language Id", + "Langcode", + "'-'", + "Subcode", + "", + "", + "", + "ISO639Code", + "IanaCode", + "UserCode", + "", + "", + "", + "", + "", + "EmptyElemTag", + "STag", + "content", + "ETag", + "'<'", + "Attribute", + "", + "", + "", + "\"</\"", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + +}; + +#ifndef MISSING_FORMAT +#define MISSING_FORMAT "Missing %s" +#endif +#ifndef UNEXPECTED_FORMAT +#define UNEXPECTED_FORMAT "Unexpected %s" +#endif +#ifndef UNNAMED_TOKEN +#define UNNAMED_TOKEN "input" +#endif + + +static void ag_diagnose(void) { + int ag_snd = (PCB).sn; + int ag_k = ag_sbt[ag_snd]; + + if (*TOKEN_NAMES[ag_tstt[ag_k]] && ag_astt[ag_k + 1] == ag_action_8) { + sprintf((PCB).ag_msg, MISSING_FORMAT, TOKEN_NAMES[ag_tstt[ag_k]]); + } + else if (ag_astt[ag_sbe[(PCB).sn]] == ag_action_8 + && (ag_k = (int) ag_sbe[(PCB).sn] + 1) == (int) ag_sbt[(PCB).sn+1] - 1 + && *TOKEN_NAMES[ag_tstt[ag_k]]) { + sprintf((PCB).ag_msg, MISSING_FORMAT, TOKEN_NAMES[ag_tstt[ag_k]]); + } + else if ((PCB).token_number && *TOKEN_NAMES[(PCB).token_number]) { + sprintf((PCB).ag_msg, UNEXPECTED_FORMAT, TOKEN_NAMES[(PCB).token_number]); + } + else if (isprint((*(PCB).lab)) && (*(PCB).lab) != '\\') { + char buf[20]; + sprintf(buf, "\'%c\'", (char) (*(PCB).lab)); + sprintf((PCB).ag_msg, UNEXPECTED_FORMAT, buf); + } + else sprintf((PCB).ag_msg, UNEXPECTED_FORMAT, UNNAMED_TOKEN); + (PCB).error_message = (PCB).ag_msg; + + +} +static int ag_action_1_r_proc(void); +static int ag_action_2_r_proc(void); +static int ag_action_3_r_proc(void); +static int ag_action_4_r_proc(void); +static int ag_action_1_s_proc(void); +static int ag_action_3_s_proc(void); +static int ag_action_1_proc(void); +static int ag_action_2_proc(void); +static int ag_action_3_proc(void); +static int ag_action_4_proc(void); +static int ag_action_5_proc(void); +static int ag_action_6_proc(void); +static int ag_action_7_proc(void); +static int ag_action_8_proc(void); +static int ag_action_9_proc(void); +static int ag_action_10_proc(void); +static int ag_action_11_proc(void); +static int ag_action_8_proc(void); + + +static int (*const ag_r_procs_scan[])(void) = { + ag_action_1_r_proc, + ag_action_2_r_proc, + ag_action_3_r_proc, + ag_action_4_r_proc +}; + +static int (*const ag_s_procs_scan[])(void) = { + ag_action_1_s_proc, + ag_action_2_r_proc, + ag_action_3_s_proc, + ag_action_4_r_proc +}; + +static int (*const ag_gt_procs_scan[])(void) = { + ag_action_1_proc, + ag_action_2_proc, + ag_action_3_proc, + ag_action_4_proc, + ag_action_5_proc, + ag_action_6_proc, + ag_action_7_proc, + ag_action_8_proc, + ag_action_9_proc, + ag_action_10_proc, + ag_action_11_proc, + ag_action_8_proc +}; + + +static int ag_action_10_proc(void) { + int ag_t = (PCB).token_number; + (PCB).btsx = 0, (PCB).drt = -1; + do { + ag_track(); + if ((PCB).rx < (PCB).fx) { + (PCB).input_code = (PCB).lab[(PCB).rx++]; + (PCB).token_number = (xml3_token_type) AG_TCV((PCB).input_code);} + else { + GET_INPUT; + (PCB).lab[(PCB).fx++] = (PCB).input_code; + (PCB).token_number = (xml3_token_type) AG_TCV((PCB).input_code); + (PCB).rx++; + } + if (ag_key_index[(PCB).sn]) { + unsigned ag_k = ag_key_index[(PCB).sn]; + int ag_ch = CONVERT_CASE((PCB).input_code); + if (ag_ch < 255) { + while (ag_key_ch[ag_k] < ag_ch) ag_k++; + if (ag_key_ch[ag_k] == ag_ch) ag_get_key_word(ag_k); + } + } + } while ((PCB).token_number == (xml3_token_type) ag_t); + (PCB).rx = 0; + return 1; +} + +static int ag_action_11_proc(void) { + int ag_t = (PCB).token_number; + + (PCB).btsx = 0, (PCB).drt = -1; + do { + (PCB).vs[(PCB).ssx] = *(PCB).lab; + (PCB).ssx--; + ag_track(); + ag_ra(); + if ((PCB).exit_flag != AG_RUNNING_CODE) return 0; + (PCB).ssx++; + if ((PCB).rx < (PCB).fx) { + (PCB).input_code = (PCB).lab[(PCB).rx++]; + (PCB).token_number = (xml3_token_type) AG_TCV((PCB).input_code);} + else { + GET_INPUT; + (PCB).lab[(PCB).fx++] = (PCB).input_code; + (PCB).token_number = (xml3_token_type) AG_TCV((PCB).input_code); + (PCB).rx++; + } + if (ag_key_index[(PCB).sn]) { + unsigned ag_k = ag_key_index[(PCB).sn]; + int ag_ch = CONVERT_CASE((PCB).input_code); + if (ag_ch < 255) { + while (ag_key_ch[ag_k] < ag_ch) ag_k++; + if (ag_key_ch[ag_k] == ag_ch) ag_get_key_word(ag_k); + } + } + } + while ((PCB).token_number == (xml3_token_type) ag_t); + (PCB).rx = 0; + return 1; +} + +static int ag_action_3_r_proc(void) { + int ag_sd = ag_fl[(PCB).ag_ap] - 1; + if (ag_sd) (PCB).sn = (PCB).ss[(PCB).ssx -= ag_sd]; + (PCB).btsx = 0, (PCB).drt = -1; + (PCB).reduction_token = (xml3_token_type) ag_ptt[(PCB).ag_ap]; + ag_ra(); + return (PCB).exit_flag == AG_RUNNING_CODE; +} + +static int ag_action_3_s_proc(void) { + int ag_sd = ag_fl[(PCB).ag_ap] - 1; + if (ag_sd) (PCB).sn = (PCB).ss[(PCB).ssx -= ag_sd]; + (PCB).btsx = 0, (PCB).drt = -1; + (PCB).reduction_token = (xml3_token_type) ag_ptt[(PCB).ag_ap]; + ag_ra(); + return (PCB).exit_flag == AG_RUNNING_CODE; +} + +static int ag_action_4_r_proc(void) { + int ag_sd = ag_fl[(PCB).ag_ap] - 1; + if (ag_sd) (PCB).sn = (PCB).ss[(PCB).ssx -= ag_sd]; + (PCB).reduction_token = (xml3_token_type) ag_ptt[(PCB).ag_ap]; + return 1; +} + +static int ag_action_2_proc(void) { + (PCB).btsx = 0, (PCB).drt = -1; + if ((PCB).ssx >= 128) { + (PCB).exit_flag = AG_STACK_ERROR_CODE; + PARSER_STACK_OVERFLOW; + } + (PCB).vs[(PCB).ssx] = *(PCB).lab; + (PCB).ss[(PCB).ssx] = (PCB).sn; + (PCB).ssx++; + (PCB).sn = (PCB).ag_ap; + ag_track(); + return 0; +} + +static int ag_action_9_proc(void) { + if ((PCB).drt == -1) { + (PCB).drt=(PCB).token_number; + (PCB).dssx=(PCB).ssx; + (PCB).dsn=(PCB).sn; + } + ag_prot(); + (PCB).vs[(PCB).ssx] = ag_null_value; + (PCB).ss[(PCB).ssx] = (PCB).sn; + (PCB).ssx++; + (PCB).sn = (PCB).ag_ap; + (PCB).rx = 0; + return (PCB).exit_flag == AG_RUNNING_CODE; +} + +static int ag_action_2_r_proc(void) { + (PCB).ssx++; + (PCB).sn = (PCB).ag_ap; + return 0; +} + +static int ag_action_7_proc(void) { + --(PCB).ssx; + (PCB).rx = 0; + (PCB).exit_flag = AG_SUCCESS_CODE; + return 0; +} + +static int ag_action_1_proc(void) { + ag_track(); + (PCB).exit_flag = AG_SUCCESS_CODE; + return 0; +} + +static int ag_action_1_r_proc(void) { + (PCB).exit_flag = AG_SUCCESS_CODE; + return 0; +} + +static int ag_action_1_s_proc(void) { + (PCB).exit_flag = AG_SUCCESS_CODE; + return 0; +} + +static int ag_action_4_proc(void) { + int ag_sd = ag_fl[(PCB).ag_ap] - 1; + (PCB).reduction_token = (xml3_token_type) ag_ptt[(PCB).ag_ap]; + (PCB).btsx = 0, (PCB).drt = -1; + (PCB).vs[(PCB).ssx] = *(PCB).lab; + if (ag_sd) (PCB).sn = (PCB).ss[(PCB).ssx -= ag_sd]; + else (PCB).ss[(PCB).ssx] = (PCB).sn; + ag_track(); + while ((PCB).exit_flag == AG_RUNNING_CODE) { + unsigned ag_t1 = ag_sbe[(PCB).sn] + 1; + unsigned ag_t2 = ag_sbt[(PCB).sn+1] - 1; + do { + unsigned ag_tx = (ag_t1 + ag_t2)/2; + if (ag_tstt[ag_tx] < (unsigned char)(PCB).reduction_token) ag_t1 = ag_tx + 1; + else ag_t2 = ag_tx; + } while (ag_t1 < ag_t2); + (PCB).ag_ap = ag_pstt[ag_t1]; + if ((ag_s_procs_scan[ag_astt[ag_t1]])() == 0) break; + } + return 0; +} + +static int ag_action_3_proc(void) { + int ag_sd = ag_fl[(PCB).ag_ap] - 1; + (PCB).btsx = 0, (PCB).drt = -1; + (PCB).vs[(PCB).ssx] = *(PCB).lab; + if (ag_sd) (PCB).sn = (PCB).ss[(PCB).ssx -= ag_sd]; + else (PCB).ss[(PCB).ssx] = (PCB).sn; + ag_track(); + (PCB).reduction_token = (xml3_token_type) ag_ptt[(PCB).ag_ap]; + ag_ra(); + while ((PCB).exit_flag == AG_RUNNING_CODE) { + unsigned ag_t1 = ag_sbe[(PCB).sn] + 1; + unsigned ag_t2 = ag_sbt[(PCB).sn+1] - 1; + do { + unsigned ag_tx = (ag_t1 + ag_t2)/2; + if (ag_tstt[ag_tx] < (unsigned char)(PCB).reduction_token) ag_t1 = ag_tx + 1; + else ag_t2 = ag_tx; + } while (ag_t1 < ag_t2); + (PCB).ag_ap = ag_pstt[ag_t1]; + if ((ag_s_procs_scan[ag_astt[ag_t1]])() == 0) break; + } + return 0; +} + +static int ag_action_8_proc(void) { + ag_undo(); + (PCB).rx = 0; + (PCB).exit_flag = AG_SYNTAX_ERROR_CODE; + ag_diagnose(); + SYNTAX_ERROR; + {(PCB).rx = 1; ag_track();} + return (PCB).exit_flag == AG_RUNNING_CODE; +} + +static int ag_action_5_proc(void) { + int ag_sd = ag_fl[(PCB).ag_ap]; + (PCB).btsx = 0, (PCB).drt = -1; + if (ag_sd) (PCB).sn = (PCB).ss[(PCB).ssx -= ag_sd]; + else { + (PCB).ss[(PCB).ssx] = (PCB).sn; + } + (PCB).rx = 0; + (PCB).reduction_token = (xml3_token_type) ag_ptt[(PCB).ag_ap]; + ag_ra(); + while ((PCB).exit_flag == AG_RUNNING_CODE) { + unsigned ag_t1 = ag_sbe[(PCB).sn] + 1; + unsigned ag_t2 = ag_sbt[(PCB).sn+1] - 1; + do { + unsigned ag_tx = (ag_t1 + ag_t2)/2; + if (ag_tstt[ag_tx] < (unsigned char)(PCB).reduction_token) ag_t1 = ag_tx + 1; + else ag_t2 = ag_tx; + } while (ag_t1 < ag_t2); + (PCB).ag_ap = ag_pstt[ag_t1]; + if ((ag_r_procs_scan[ag_astt[ag_t1]])() == 0) break; + } + return (PCB).exit_flag == AG_RUNNING_CODE; +} + +static int ag_action_6_proc(void) { + int ag_sd = ag_fl[(PCB).ag_ap]; + (PCB).reduction_token = (xml3_token_type) ag_ptt[(PCB).ag_ap]; + if ((PCB).drt == -1) { + (PCB).drt=(PCB).token_number; + (PCB).dssx=(PCB).ssx; + (PCB).dsn=(PCB).sn; + } + if (ag_sd) { + (PCB).sn = (PCB).ss[(PCB).ssx -= ag_sd]; + } + else { + ag_prot(); + (PCB).vs[(PCB).ssx] = ag_null_value; + (PCB).ss[(PCB).ssx] = (PCB).sn; + } + (PCB).rx = 0; + while ((PCB).exit_flag == AG_RUNNING_CODE) { + unsigned ag_t1 = ag_sbe[(PCB).sn] + 1; + unsigned ag_t2 = ag_sbt[(PCB).sn+1] - 1; + do { + unsigned ag_tx = (ag_t1 + ag_t2)/2; + if (ag_tstt[ag_tx] < (unsigned char)(PCB).reduction_token) ag_t1 = ag_tx + 1; + else ag_t2 = ag_tx; + } while (ag_t1 < ag_t2); + (PCB).ag_ap = ag_pstt[ag_t1]; + if ((ag_r_procs_scan[ag_astt[ag_t1]])() == 0) break; + } + return (PCB).exit_flag == AG_RUNNING_CODE; +} + + +void init_xml3(void) { + (PCB).rx = (PCB).fx = 0; + (PCB).ss[0] = (PCB).sn = (PCB).ssx = 0; + (PCB).exit_flag = AG_RUNNING_CODE; + (PCB).line = FIRST_LINE; + (PCB).column = FIRST_COLUMN; + (PCB).btsx = 0, (PCB).drt = -1; +} + +void xml3(void) { + init_xml3(); + (PCB).exit_flag = AG_RUNNING_CODE; + while ((PCB).exit_flag == AG_RUNNING_CODE) { + unsigned ag_t1 = ag_sbt[(PCB).sn]; + if (ag_tstt[ag_t1]) { + unsigned ag_t2 = ag_sbe[(PCB).sn] - 1; + if ((PCB).rx < (PCB).fx) { + (PCB).input_code = (PCB).lab[(PCB).rx++]; + (PCB).token_number = (xml3_token_type) AG_TCV((PCB).input_code);} + else { + GET_INPUT; + (PCB).lab[(PCB).fx++] = (PCB).input_code; + (PCB).token_number = (xml3_token_type) AG_TCV((PCB).input_code); + (PCB).rx++; + } + if (ag_key_index[(PCB).sn]) { + unsigned ag_k = ag_key_index[(PCB).sn]; + int ag_ch = CONVERT_CASE((PCB).input_code); + if (ag_ch < 255) { + while (ag_key_ch[ag_k] < ag_ch) ag_k++; + if (ag_key_ch[ag_k] == ag_ch) ag_get_key_word(ag_k); + } + } + do { + unsigned ag_tx = (ag_t1 + ag_t2)/2; + if (ag_tstt[ag_tx] > (unsigned char)(PCB).token_number) + ag_t1 = ag_tx + 1; + else ag_t2 = ag_tx; + } while (ag_t1 < ag_t2); + if (ag_tstt[ag_t1] != (unsigned char)(PCB).token_number) + ag_t1 = ag_sbe[(PCB).sn]; + } + (PCB).ag_ap = ag_pstt[ag_t1]; + (ag_gt_procs_scan[ag_astt[ag_t1]])(); + } +} + + + +int main(void) { + xml3(); + return 0; +}