Mercurial > ~dholland > hg > ag > index.cgi
diff tests/agcl/oldagsrc/good/cf-old.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/oldagsrc/good/cf-old.c Sat Dec 22 17:52:45 2007 -0500 @@ -0,0 +1,2224 @@ +/* + AnaGram Syntax Analyzer. + Copyright (c) Parsifal Software, 1993. + All Rights Reserved. + + Configuration file module +*/ +#include HEADERS + +#include DATA +#include ASSERT +#include CTYPE +#include STDLIB +#include STRING +#include ARRAYS +#include MYALLOC +#include CF +#include PARAMS +#include PF + + +/* + * 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 CF-OLD_H +#include "cf-old.h" +#endif + +#ifndef CF-OLD_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]) + + +#define CHANGE_REDUCTION(x) cf-old_change_reduction(cf-old_##x##_token) +int cf-old_change_reduction(cf-old_token_type); + + +int cf-old_value(void); + +#define TOKEN_NAMES cf-old_token_names +const char *const cf-old_token_names[108] = { + "config file", + "config file", + "equals", + "'='", + "", + "", + "minus", + "'-'", + "plus", + "'+'", + "tilde", + "'~'", + "", + "'('", + "", + "')'", + "blank", + "", + "", + "global parameter", + "end of line", + "", + "", + "", + "eof", + "name", + "data type", + "keyword string", + "number", + "\"trial\"", + "\"copy\"", + "\"code\"", + "trial copy code", + "", + "abstract declarator", + "", + "direct abstract declarator", + "", + "", + "star", + "'*'", + "", + "letter", + "", + "blank char", + "c comment", + "continuation", + "comment", + "", + "carriage return", + "", + "newline", + "white", + "vertical space", + "\"//\"", + "", + "", + "", + "decimal number", + "", + "octal number", + "'0'", + "", + "hex number", + "\"0x\"", + "\"0X\"", + "", + "simple number", + "", + "", + "keyword string head", + "string", + "double quote", + "", + "", + "", + "string char", + "simple string char", + "", + "\"\\\\a\"", + "\"\\\\b\"", + "\"\\\\f\"", + "\"\\\\n\"", + "\"\\\\r\"", + "\"\\\\t\"", + "\"\\\\v\"", + "\"\\\\\\\\\"", + "\"\\\\?\"", + "\"\\\\\\'\"", + "\"\\\\\\\"\"", + "", + "", + "backslash", + "", + "", + "", + "", + "\"\\\\x\"", + "any digit", + "nonoctal digit", + "", + "\"*/\"", + "\"/*\"", + "", + "", + "", + "", + "", + +}; + + +#line - "cf-old.syn" +#define PARSE_STACK_OVERFLOW\ + {fprintf(stderr,"Parse stack overflow\n");myabort();} +#define SYNTAX_ERROR cf_syn_error() +#define GET_CONTEXT CONTEXT.x = PCB.column, CONTEXT.y = PCB.line + +#define N_PARAMS 80 + + +static cf_pcb_type cfcb; +#define PCB cfcb + +extern string_dict *param_dict; +extern unsigned char *input_base; +extern int precedence_level; +extern int int_token_type; + +void reset_stack(void); +void log_error(void); + +static void cf_gp2(void); +static void cf_gp3(void); +static void cf_gp4(int); +static void cf_gp5(int); + +void acs(int); +void scs(int); + +void init_params(void); + +unsigned char *read_file(char *); + +static char *config_file; + +static void cf_error(char *); + +static void cf_bad_param(int pn) { + char *dm; + if (pn) dm = "Inappropriate value"; + else dm = "No such parameter"; + cf_error(dm); + rcs(); + return; +} + +void xgp5(int, void bad(int), int); + +static void cf_gp5(int tv) { + xgp5(tv,cf_bad_param,0); +} + +void xgp4(int, void bad(int), int); + +static void cf_gp4(int tv) { + xgp4(tv,cf_bad_param,0); +} + +void xgp2(void bad(int), int); + +static void cf_gp2(void) { + xgp2(cf_bad_param,0); +} + +void xgp3(void bad(int), int); + +static void cf_gp3(void) { + xgp3(cf_bad_param,0); +} + +static int read_config_file(char *path) { + char* file_name = allocate(strlen(path)+20,char); + char *cp; + + strcpy(file_name, path); + cp = strrchr(file_name,PATH_DELIMITER); +/* + assert(cp != NULL); + strcpy(cp+1,"AnaGram.cfg"); +*/ + if (cp) cp++; + else cp = file_name; + strcpy(cp,"AnaGram.cfg"); + config_file = file_name; + cfcb.pointer = input_base = read_file(file_name); + return input_base != NULL; +} + +static void get_config(char *path) { + cfcb.pointer = input_base = read_file(path); + if (input_base != NULL) { + cf(); + free(input_base); + } + input_base = NULL; +} +int in_cur_dir(char *); + +void read_config(char *path) { + if (read_config_file(path)) { + cf(); + free(input_base); + free(config_file); + } + if (in_cur_dir(path)) return; + config_file = "AnaGram.cfg"; + get_config("anagram.cfg"); +} + +static void cf_error(char *msg) { + int eline = PCB.line, ecol = PCB.column; + + if (PCB.token_number == cf_eof_token) { + eline = ERROR_CONTEXT.y; + ecol = ERROR_CONTEXT.x; + } + ssprintf("%s, Line %d, Col %d: %s", config_file, + eline, ecol, msg); + log_error(); +} + +static void cf_syn_error(void) { + reset_stk(); + cf_error(PCB.error_message); +} + +param_number_map *map_param_number; + +static void init_param_val_proc(int *pn, char *name, int v) { + param_number_map *mpn; + + *pn = add_string_dict(name,param_dict); + check_size(map_param_number,*pn,*pn); + mpn = &map_param_number[*pn]; +/* mpn->value_name = 1; */ + mpn->value = v; +} + + +#define init_param_val(p,v) \ + init_param_val_proc(&p##_pn, #p,v) + +static param_number_map *id_param(int *pn, void *p, char *name) { + int k = add_string_dict(name,param_dict); + param_number_map *mpn; + + check_size(map_param_number, k,3*k/2); + *pn = k; + mpn = &map_param_number[k]; + mpn->param = p; + return mpn; +} + +#define init_param(p, global, implicit)\ + {param_number_map *mpn = id_param(&p##_pn,&p, #p);\ + mpn->global = 1;\ + mpn->implicit = 1;} + +#define init_param_co(p, global, implicit)\ + {param_number_map *mpn = id_param(&p##_pn,&p, #p);\ + mpn->global = mpn->config_only = 1;\ + mpn->implicit = 1;} + +/* +#define init_verb(p,param)\ + {param_number_map *mpn =\ + &map_param_number[p##_pn = add_string_dict(#p, param_dict)];\ + mpn->verb = 1;\ + mpn->value = param##_pn;} +*/ +/* +#define init_token_param(p,implicit)\ + {param_number_map *mpn =\ + &map_param_number[p##_pn = add_string_dict(#p, param_dict)];\ + mpn->token = 1;\ + mpn->implicit = 1;} +*/ + +#define init_dict_param(p,global,dict_name)\ + {param_number_map *mpn = id_param(&p##_pn,&p, #p);\ + mpn->global = 1;\ + mpn->dict = dict_name;\ + mpn->value_id = 1;} +/* +#define init_literal_param(p,global,first_value)\ + {param_number_map *mpn = id_param(&p##_pn,&p, #p);\ + mpn->value = first_value##_pn;\ + mpn->global = 1;\ + mpn->dict = param_dict;\ + mpn->literal = 1;} +*/ + +#define init_proc_param(p,global,proc_name)\ + {param_number_map *mpn = id_param(&p##_pn,&p, #p);\ + mpn->global = 1;\ + mpn->proc = proc_name;\ + mpn->proc_call = 1;} + +#define init_token_id_param(p,global)\ + {param_number_map *mpn = id_param(&p##_pn,&p, #p);\ + mpn->global = 1;\ + mpn->proc = name_token;\ + mpn->proc_call = 1;\ + mpn->token_id = 1;} + +#define dp(p)\ +static int p##_pn + +dp(on); +dp(off); + +extern int allow_macros; dp(allow_macros); + int auto_init = 1; dp(auto_init); + int auto_resynch = 0; dp(auto_resynch); +extern int backtrack; dp(backtrack); + int bottom_margin = 3; dp(bottom_margin); + int bright_background = 1; dp(bright_background); + + int case_sensitive = 1; dp(case_sensitive); + char *compile_command = ""; dp(compile_command); + char *context_type = NULL; dp(context_type); + char *coverage_file_name = "#.nrc"; dp(coverage_file_name); + + int declare_pcb = 1; dp(declare_pcb); +extern int default_input_type; dp(default_input_type); +extern int default_token_type; dp(default_token_type); +extern int default_reductions; dp(default_reductions); + int diagnose_errors = 1; dp(diagnose_errors); + +extern char *edit_command; dp(edit_command); + char *enum_constant_name = "$_%_token"; dp(enum_constant_name); + int error_frame = 0; dp(error_frame); + int error_trace = 0; dp(error_trace); + int escape_backslashes = 0; dp(escape_backslashes); + int event_driven = 0; dp(event_driven); + +extern int far_tables; dp(far_tables); + +extern int grammar_token; dp(grammar_token); +extern char *header_file_name; dp(header_file_name); + int input_values = 0; dp(input_values); + + int line_length = 80; dp(line_length); +extern int line_numbers; dp(line_numbers); + char *line_numbers_path = NULL; dp(line_numbers_path); +extern int lines_and_columns; dp(lines_and_columns); + + int main_program = 1; dp(main_program); + int max_conflicts = 50; dp(max_conflicts); + + int near_functions = 0; dp(near_functions); + int nest_comments = 0; dp(nest_comments); + + int old_style = 0; dp(old_style); + + int page_length = 66; dp(page_length); +extern char *parser_file_name; dp(parser_file_name); + char *parser_name = "#"; dp(parser_name); + int parser_stack_alignment; dp(parser_stack_alignment); + int parser_stack_size = 32; dp(parser_stack_size); + int pointer_input = 0; dp(pointer_input); + char *pointer_type = "unsigned char *"; dp(pointer_type); + char *print_file_name = "LPT1"; dp(print_file_name); + + int quick_reference = 1; dp(quick_reference); + + int reduction_choices =0; dp(reduction_choices); + int rule_coverage = 0; dp(rule_coverage); + + int tab_spacing = 8; dp(tab_spacing); + int test_file_binary = 0; dp(test_file_binary); + char *test_file_mask = "*.*"; dp(test_file_mask); +extern int test_range; dp(test_range); +extern int token_names; dp(token_names); + int top_margin = 3; dp(top_margin); +extern int traditional_engine; dp(traditional_engine); + +extern int video_mode; dp(video_mode); + + unsigned long trial_copy_code = 0; + + +/* char *note_file_name = "$.nf"; dp(note_file_name); */ + + char *input_type_name = "$_it_type"; /* dp(input_type_name); */ + + +char *control_block_type = "$_pcb_type"; +char *typedef_name = "$_token_type"; +char *value_stack_type = "$_vs_type"; + + +extern string_dict *cast_dict; +extern string_dict *proc_dict; + + +extern string_dict *tkn_dict; + +extern int error_token; dp(error_token); +/* extern int noise_token; dp(noise_token); */ +int eof_token = 0; dp(eof_token); + +extern int active_color; dp(active_color); +extern int active_bar_color; dp(active_bar_color); +extern int inactive_color; dp(inactive_color); +extern int inactive_bar_color; dp(inactive_bar_color); +extern int backdrop_color; dp(backdrop_color); +extern int backdrop_bar_color; dp(backdrop_bar_color); + + +int id_token(int); + +static int name_token(char *name){ + sss(name); + free(name); + ids(tkn_dict); + return id_token(fis()); +} + +void init_params(void) { + int n; + map_param_number = init_array(N_PARAMS,sizeof(param_number_map)); + + init_param_val(off, 0); + init_param_val(on, 1); + +/* + + N.B. The following list should be in alphabetical order. Make sure that + when you enter a new parameter, you enter it in the right place! + +*/ + init_param(allow_macros, global, implicit); + init_param(auto_init, global, implicit); + init_param(auto_resynch, global, implicit); + + init_param(backtrack, global, implicit); + init_param(bottom_margin, global, int_value); + init_param_co(bright_background, global, implicit); + + init_param(case_sensitive, global, implicit); + init_param(compile_command, global, string_value); + init_param(context_type, global, text_value); + init_param(coverage_file_name, global, string_value); + + init_param(declare_pcb, global,implicit); + init_dict_param(default_input_type, global, cast_dict); + init_param(default_reductions, global, implicit); + init_dict_param(default_token_type, global, cast_dict); + init_param(diagnose_errors, global, implicit); + + init_param(edit_command, global, string_value); + init_param(enum_constant_name, global, string_value); + init_token_id_param(eof_token, global); + init_param(error_frame, global, implicit); + init_token_id_param(error_token, global); + init_param(error_trace, global, implicit); + init_param(escape_backslashes, global, implicit); + init_param(event_driven, global, implicit); + + init_param(far_tables, global, implicit); + + init_token_id_param(grammar_token, global); + + init_param(header_file_name, global, string_value); + + init_param(input_values, global, implicit); + + init_param(line_length, global, int_value); + init_param(line_numbers, global, implicit); + init_param(line_numbers_path, global, string_value); + init_param(lines_and_columns, global, implicit); + + init_param(main_program, global, implicit); + init_param(max_conflicts, global, int_value); + + init_param(near_functions, global, implicit); + init_param(nest_comments, global, implicit); + + init_param(old_style, global, implicit); + + init_param(page_length, global, int_value); + init_param(parser_file_name, global, string_value); + init_param(parser_name, global, text_value); + init_dict_param(parser_stack_alignment, global, cast_dict); + init_param(parser_stack_size, global, int_value); + init_param(pointer_input, global, implicit); + init_param(pointer_type, global, text_value); + init_param(print_file_name, global, string_value); + + init_param(quick_reference, global, implicit); + + init_param(reduction_choices, global, implicit); + init_param(rule_coverage, global, implicit); + + init_param(tab_spacing, global, int_value); + init_param(test_file_binary, global, implicit); + init_param(test_file_mask, global, string_value); + init_param(test_range, global, implicit); + init_param(token_names, global, implicit); + init_param(top_margin, global, int_value); + init_param(traditional_engine, global, implicit); + init_param_co(video_mode, global, int_value); + + + + init_param_co(active_bar_color, global, color_value); + init_param_co(active_color, global, color_value); + init_param_co(backdrop_bar_color, global, color_value); + init_param_co(backdrop_color, global, color_value); + init_param_co(inactive_bar_color, global, color_value); + init_param_co(inactive_color, global, color_value); + + + n = param_dict->nsx; + assert(n < N_PARAMS); + map_param_number = set_array_size(map_param_number, n); +} +#line - "cf-old.c" + +#ifndef CONVERT_CASE +#define CONVERT_CASE(c) (c) +#endif +#ifndef TAB_SPACING +#define TAB_SPACING 8 +#endif +int cf-old_value(void) { + int returnValue; + returnValue = (*(int *) &(PCB).vs[(PCB).ssx]); + return returnValue; +} + +static void near ag_rp_1(void) { +#line - "cf-old.syn" + cf_gp4(1); +#line - "cf-old.c" +} + +static void near ag_rp_2(void) { +#line - "cf-old.syn" + cf_gp4(0); +#line - "cf-old.c" +} + +static void near ag_rp_3(void) { +#line - "cf-old.syn" + cf_gp2(); +#line - "cf-old.c" +} + +static void near ag_rp_4(void) { +#line - "cf-old.syn" + cf_gp3(); +#line - "cf-old.c" +} + +static void near ag_rp_5(int n) { +#line - "cf-old.syn" + cf_gp5(n); +#line - "cf-old.c" +} + +static void near ag_rp_6(unsigned long n) { +#line - "cf-old.syn" + trial_copy_code = n; +#line - "cf-old.c" +} + +static unsigned long near ag_rp_7(int d) { +#line - "cf-old.syn" + return d-'0'; +#line - "cf-old.c" +} + +static unsigned long near ag_rp_8(unsigned long n, int d) { +#line - "cf-old.syn" + return 10*n + d-'0'; +#line - "cf-old.c" +} + +static void near ag_rp_9(void) { +#line - "cf-old.syn" + concat_string(); +#line - "cf-old.c" +} + +static void near ag_rp_10(void) { +#line - "cf-old.syn" + concat_string(); +#line - "cf-old.c" +} + +static int near ag_rp_11(void) { +#line - "cf-old.syn" + return scs('('),0; +#line - "cf-old.c" +} + +static void near ag_rp_12(void) { +#line - "cf-old.syn" + concat_string(), acs(')'); +#line - "cf-old.c" +} + +static void near ag_rp_13(void) { +#line - "cf-old.syn" + concat_string(); +#line - "cf-old.c" +} + +static void near ag_rp_14(void) { +#line - "cf-old.syn" + sss(" *"); +#line - "cf-old.c" +} + +static void near ag_rp_15(void) { +#line - "cf-old.syn" + concat_string(); +#line - "cf-old.c" +} + +static void near ag_rp_16(int a) { +#line - "cf-old.syn" + scs(a); +#line - "cf-old.c" +} + +static void near ag_rp_17(int a) { +#line - "cf-old.syn" + acs(a); +#line - "cf-old.c" +} + +static void near ag_rp_18(int a) { +#line - "cf-old.syn" + acs(' '), acs(a); +#line - "cf-old.c" +} + +static int near ag_rp_19(int d) { +#line - "cf-old.syn" + return d - '0'; +#line - "cf-old.c" +} + +static int near ag_rp_20(int n, int d) { +#line - "cf-old.syn" + return 10*n + d - '0'; +#line - "cf-old.c" +} + +static int near ag_rp_21(void) { +#line - "cf-old.syn" + return 0; +#line - "cf-old.c" +} + +static int near ag_rp_22(int n, int d) { +#line - "cf-old.syn" + return 8*n + d - '0'; +#line - "cf-old.c" +} + +static int near ag_rp_23(void) { +#line - "cf-old.syn" + return 0; +#line - "cf-old.c" +} + +static int near ag_rp_24(void) { +#line - "cf-old.syn" + return 0; +#line - "cf-old.c" +} + +static int near ag_rp_25(int n, int d) { +#line - "cf-old.syn" + return 16*n + d - '0'; +#line - "cf-old.c" +} + +static int near ag_rp_26(int n, int d) { +#line - "cf-old.syn" + return 16*n + (d&7) + 9; +#line - "cf-old.c" +} + +static int near ag_rp_27(int s, int n) { +#line - "cf-old.syn" + return s*n; +#line - "cf-old.c" +} + +static int near ag_rp_28(void) { +#line - "cf-old.syn" + return 1; +#line - "cf-old.c" +} + +static int near ag_rp_29(void) { +#line - "cf-old.syn" + return -1; +#line - "cf-old.c" +} + +static void near ag_rp_30(void) { +#line - "cf-old.syn" + ics(); +#line - "cf-old.c" +} + +static int near ag_rp_31(void) { +#line - "cf-old.syn" + return '\a'; +#line - "cf-old.c" +} + +static int near ag_rp_32(void) { +#line - "cf-old.syn" + return '\b'; +#line - "cf-old.c" +} + +static int near ag_rp_33(void) { +#line - "cf-old.syn" + return '\f'; +#line - "cf-old.c" +} + +static int near ag_rp_34(void) { +#line - "cf-old.syn" + return '\n'; +#line - "cf-old.c" +} + +static int near ag_rp_35(void) { +#line - "cf-old.syn" + return '\r'; +#line - "cf-old.c" +} + +static int near ag_rp_36(void) { +#line - "cf-old.syn" + return '\t'; +#line - "cf-old.c" +} + +static int near ag_rp_37(void) { +#line - "cf-old.syn" + return '\v'; +#line - "cf-old.c" +} + +static int near ag_rp_38(void) { +#line - "cf-old.syn" + return '\\'; +#line - "cf-old.c" +} + +static int near ag_rp_39(void) { +#line - "cf-old.syn" + return '\?'; +#line - "cf-old.c" +} + +static int near ag_rp_40(void) { +#line - "cf-old.syn" + return '\''; +#line - "cf-old.c" +} + +static int near ag_rp_41(void) { +#line - "cf-old.syn" + return '"'; +#line - "cf-old.c" +} + +static int near ag_rp_42(int n) { +#line - "cf-old.syn" + return n==0?cf_error("Null character in string"),0 : n; +#line - "cf-old.c" +} + +static int near ag_rp_43(int n) { +#line - "cf-old.syn" + return n&7; +#line - "cf-old.c" +} + +static int near ag_rp_44(int n, int d) { +#line - "cf-old.syn" + return n*8 + (d&7); +#line - "cf-old.c" +} + +static int near ag_rp_45(int n, int d) { +#line - "cf-old.syn" + return n*8 + (d&7); +#line - "cf-old.c" +} + +static int near ag_rp_46(int n) { +#line - "cf-old.syn" + return n==0?cf_error("Null character in string"),0 : n; +#line - "cf-old.c" +} + +static int near ag_rp_47(int n) { +#line - "cf-old.syn" + return n; +#line - "cf-old.c" +} + +static void near ag_rp_48(int c) { +#line - "cf-old.syn" + acs(c); +#line - "cf-old.c" +} + +static void near ag_rp_49(int c) { +#line - "cf-old.syn" + acs(c); +#line - "cf-old.c" +} + +static void near ag_rp_50(int c) { +#line - "cf-old.syn" + acs(c); +#line - "cf-old.c" +} + +static void near ag_rp_51(int c) { +#line - "cf-old.syn" + acs(c); +#line - "cf-old.c" +} + +static void near ag_rp_52(int c) { +#line - "cf-old.syn" + acs(c); +#line - "cf-old.c" +} + +static void near ag_rp_53(int n) { +#line - "cf-old.syn" + acs(n); +#line - "cf-old.c" +} + +static void near ag_rp_54(int n) { +#line - "cf-old.syn" + acs(n); +#line - "cf-old.c" +} + +static void near ag_rp_55(int n) { +#line - "cf-old.syn" + acs(n); +#line - "cf-old.c" +} + +static void near ag_rp_56(int n) { +#line - "cf-old.syn" + acs(n); +#line - "cf-old.c" +} + +static void near ag_rp_57(void) { +#line - "cf-old.syn" +if (nest_comments) PCB.reduction_token = cf_c_comment_text_token; +#line - "cf-old.c" +} + + +#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 cf-old_vs_type const ag_null_value NULL_VALUE_INITIALIZER; + +static const unsigned char ag_rpx[] = { + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 1, 2, 3, 4, 5, 6, 7, 8, 0, 9, 0, 0, 10, 11, 12, + 0, 13, 14, 0, 15, 16, 17, 18, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 19, 20, 21, 22, + 23, 24, 25, 26, 0, 0, 0, 27, 0, 0, 28, 29, 0, 0, 0, 0, 30, 0, + 0, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 0, 0, + 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 0, 0, 0, 57 +}; + +static const unsigned char ag_key_itt[] = { + 0 +}; + +static const unsigned short ag_key_pt[] = { +0 +}; + +static const unsigned char ag_key_ch[] = { + 0, 42, 47,255, 47,116,255, 42, 47,255, 47,116,255, 42, 47,255, 47,255, + 47,255, 47,255,116,255, 42, 47,255, 88,120,255, 47, 48,255, 47, 99,255, + 88,120,255, 48,255, 88,120,255, 47, 48,255, 34, 39, 63, 92, 97, 98,102, + 110,114,116,118,120,255, 92,255, 47, 99,255 +}; + +static const unsigned char ag_key_act[] = { + 0,0,0,4,2,3,4,3,3,4,3,3,4,0,0,4,2,4,3,4,3,4,3,4,0,0,4,0,0,4,2,2,4,3,3, + 4,0,0,4,2,4,0,0,4,3,2,4,0,0,0,0,0,0,0,0,0,0,0,0,4,2,4,3,3,4 +}; + +static const unsigned char ag_key_parm[] = { + 0,102, 54, 0, 0, 29, 0,101,102, 0, 54, 29, 0,102, 54, 0, 0, 0, + 102, 0, 54, 0, 29, 0,102, 54, 0, 65, 64, 0, 0, 0, 0,102, 30, 0, + 65, 64, 0, 0, 0, 65, 64, 0,102, 0, 0, 89, 88, 87, 86, 79, 80, 81, + 82, 83, 84, 85, 97, 0, 0, 0,102, 31, 0 +}; + +static const unsigned char ag_key_jmp[] = { + 0, 0, 0, 0, 1, 0, 0, 5, 7, 0, 9, 11, 0, 0, 0, 0, 13, 0, + 16, 0, 18, 0, 20, 0, 0, 0, 0, 0, 0, 0, 24, 27, 0, 25, 27, 0, + 0, 0, 0, 36, 0, 0, 0, 0, 31, 41, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 47, 0, 33, 35, 0 +}; + +static const unsigned char ag_key_index[] = { + 4, 7, 4, 10, 0, 16, 16, 0, 0, 18, 0, 20, 4, 22, 20, 0, 0, 0, + 0, 30, 16, 0, 33, 30, 39, 0, 0, 4, 44, 18, 30, 30, 39, 60, 20, 0, + 44, 62, 16, 16, 16, 16, 0, 60, 60, 39, 60, 60, 60, 16, 16, 20, 0, 20, + 18, 60, 16, 0, 0, 16, 0, 20 +}; + +static const unsigned char ag_key_ends[] = { +114,105,97,108,0, 47,0, 42,0, 47,0, 114,105,97,108,0, 42,0, +47,0, 114,105,97,108,0, 42,0, 111,112,121,0, 42,0, 42,0, +111,100,101,0, +}; + +#define AG_TCV(x) ag_tcv[(x)] + +static const unsigned char ag_tcv[] = { + 24,107,107,107,107,107,107,107,107, 44, 51, 53, 53, 49,107,107,107,107, + 107,107,107,107,107,107,107,107, 24,107,107,107,107,107, 44,107, 72,107, + 107,107,107,107, 13, 15, 40, 9,107, 7,107,107, 61,104,104,104,104,104, + 104,104,105,105,107,107,107, 3,107,107,107, 66, 66, 66, 66, 66, 66,106, + 106,106,106,106,106,106,106,106,106,106,106,106,106,106,106,106,106,106, + 106,107, 92,107,107,106,107, 66, 66, 66, 66, 66, 66,106,106,106,106,106, + 106,106,106,106,106,106,106,106,106,106,106,106,106,106,106,107,107,107, + 11,107,107,107,107,107,107,107,107,107,107,107,107,107,107,107,107,107, + 107,107,107,107,107,107,107,107,107,107,107,107,107,107,107,107,107,107, + 107,107,107,107,107,107,107,107,107,107,107,107,107,107,107,107,107,107, + 107,107,107,107,107,107,107,107,107,107,107,107,107,107,107,107,107,107, + 107,107,107,107,107,107,107,107,107,107,107,107,107,107,107,107,107,107, + 107,107,107,107,107,107,107,107,107,107,107,107,107,107,107,107,107,107, + 107,107,107,107,107,107,107,107,107,107,107,107,107,107,107,107,107,107, + 107,107,107,107 +}; + +#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 + + +#ifndef INPUT_CODE +#define INPUT_CODE(T) (T) +#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; + +static void near ag_get_key_word(int ag_k) { + int ag_save = (int) ((PCB).la_ptr - (PCB).pointer); + const unsigned char *ag_p; + int ag_ch; + while (1) { + switch (ag_key_act[ag_k]) { + case ag_cf_end_key: { + const unsigned char *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 + CONVERT_CASE(*(PCB).la_ptr)]) goto ag_fail; + (PCB).token_number = (cf-old_token_type) ag_key_pt[ag_k1 + 1]; + return; + } + } while (CONVERT_CASE(*(PCB).la_ptr++) == ag_ch); + goto ag_fail; + } + case ag_end_key: { + const unsigned char *sp = ag_key_ends + ag_key_jmp[ag_k]; + do { + if ((ag_ch = *sp++) == 0) { + (PCB).token_number = (cf-old_token_type) ag_key_parm[ag_k]; + return; + } + } while (CONVERT_CASE(*(PCB).la_ptr++) == ag_ch); + } + case ag_no_match_key: +ag_fail: + (PCB).la_ptr = (PCB).pointer + ag_save; + 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 + CONVERT_CASE(*(PCB).la_ptr)]) break; + ag_save = (int) ((PCB).la_ptr - (PCB).pointer); + (PCB).token_number = (cf-old_token_type) ag_key_pt[ag_k1+1]; + break; + } + case ag_set_key: + ag_save = (int) ((PCB).la_ptr - (PCB).pointer); + (PCB).token_number = (cf-old_token_type) ag_key_parm[ag_k]; + case ag_jmp_key: + ag_k = ag_key_jmp[ag_k]; + break; + case ag_accept_key: + (PCB).token_number = (cf-old_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 + CONVERT_CASE(*(PCB).la_ptr)]) + (PCB).la_ptr = (PCB).pointer + ag_save; + else (PCB).token_number = (cf-old_token_type) ag_key_pt[ag_k1+1]; + return; + } + } + ag_ch = CONVERT_CASE(*(PCB).la_ptr++); + ag_p = &ag_key_ch[ag_k]; + if (ag_ch <= 255) while (*ag_p < ag_ch) ag_p++; + if (ag_ch > 255 || *ag_p != ag_ch) { + (PCB).la_ptr = (PCB).pointer + ag_save; + return; + } + ag_k = (int) (ag_p - ag_key_ch); + } +} + + +#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 near ag_track(void) { + int ag_k = (int) ((PCB).la_ptr - (PCB).pointer); + while (ag_k--) { + switch (*(PCB).pointer++) { + 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++; + } + } +} + + +static void near 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]; + (PCB).cs[ag_k] = (PCB).cs[(PCB).ssx]; +} + +static void near 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).cs[(PCB).ssx] = (PCB).cs[ag_k]; + } + (PCB).token_number = (cf-old_token_type) (PCB).drt; + (PCB).ssx = (PCB).dssx; + (PCB).sn = (PCB).dsn; + (PCB).drt = -1; +} + + + +static const int ag_rtt[] = { + 45,100, 0 +}; + +static const unsigned char ag_tstt[] = { +106,102,66,54,51,49,44,29,24,11,0,1,16,17,18,45,100, +107,106,105,104,102,101,92,72,66,61,53,51,49,44,40,15,13,11,9,7,3,0,45,100, +102,44,0,16,45,100, +106,66,54,51,49,29,24,11,0,10,19,20,21,22,23,25,41,47,50, +107,106,105,104,92,72,66,61,53,51,49,44,40,15,13,11,9,7,3,0,56,57, +106,102,66,54,51,49,44,0,4,5,16,17,45,46,47,48,50,100, +106,105,104,102,66,61,54,51,49,44,40,24,15,13,3,0,16,17,18,45,100, +51,0, +51,49,0,50, +102,44,0,16,17,45,100, +106,66,0,25,41, +3,0,2, +106,102,66,54,53,51,49,44,29,24,11,0,16,45,47,50,52,100, +106,66,29,11,0,10,19,25,41, +54,51,49,24,0,20,47,50, +24,0, +107,106,105,104,92,72,66,61,53,44,40,15,13,11,9,7,3,0, +51,0, +51,49,0,48,50, +106,105,104,102,72,66,65,64,61,54,51,49,44,40,13,9,7,0,16,45,46,47,48,50, + 100, +106,105,104,102,66,61,44,0,16,45,100, +51,0, +102,44,30,0,16,45,100, +106,105,104,102,72,66,65,64,61,54,51,49,44,9,7,0,4,5,16,17,45,46,47,48,50, + 100, +106,105,104,72,66,65,64,61,9,7,0,6,8,25,26,27,28,41,68,69,70, +51,49,0,50, +51,0, +106,102,66,54,53,51,49,44,29,24,11,0,16,45,47,50,52,100, +102,44,0,16,17,45,100, +102,44,0,16,17,45,100, +105,104,102,65,64,61,54,51,49,44,0,4,5,16,17,45,46,47,48,50,100, +105,104,102,65,64,61,54,51,49,44,0,4,5,16,17,45,46,47,48,50,100, +105,104,65,64,61,0,58,60,63,67, +107,106,105,104,97,92,89,88,87,86,85,84,83,82,81,80,79,66,61,53,44,40,15,13, + 11,9,7,3,0,71,73,74,75,76,78,90,91,93,94,95,96, +40,13,0,12,34,35,36,37,38,39, +51,0, +102,44,0,16,45,100, +102,44,31,0,16,45,100, +105,104,66,61,0, +104,61,0, +105,104,61,0, +102,54,51,49,44,24,0,16,17,18,45,100, +104,61,0, +104,61,0, +104,61,0, +65,64,0,63, +105,66,0, +105,104,66,61,0, +107,106,97,92,89,88,87,86,85,84,83,82,81,80,79,72,53,44,40,15,13,11,9,7,3,0, + 76,78,90,91,93,94,95,96, +102,54,51,49,44,40,13,0,4,5,16,17,45,46,47,48,50,100, +106,102,66,54,51,49,44,40,24,15,13,0,16,17,18,45,100, +106,66,0,25,41, +40,13,0,12,34,35,36,37,38,39, +40,13,0,12,36,37,38,39, +102,44,3,0,16,17,18,45,100, +105,104,66,61,0, +102,54,51,49,44,24,0,16,17,18,45,100, +15,0,14, +3,0,2, +102,54,51,49,44,24,15,0,16,17,18,45,100, +105,104,61,0,32, +105,104,61,0, + +}; + + +static unsigned const char ag_astt[649] = { + 8,1,8,8,8,8,1,8,5,8,7,0,1,1,1,1,1,3,3,3,3,1,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3, + 3,7,2,1,1,9,5,3,3,1,2,2,1,8,1,1,8,1,7,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, + 1,5,5,1,1,1,1,1,1,1,1,7,1,3,5,1,5,1,8,1,1,7,3,3,1,1,1,3,1,3,1,1,10,10,10,1, + 10,10,5,5,5,1,5,5,5,5,5,7,1,1,3,1,1,3,7,8,1,7,1,1,1,7,1,1,1,1,2,2,7,2,1,1, + 4,1,5,1,5,1,9,8,1,9,5,5,5,7,3,3,1,1,3,1,2,2,1,1,5,1,3,1,1,1,8,1,5,7,1,1,1, + 3,7,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,5,1,7,8,1,7,3,1,5,5,5,1,5,5,5,5,5,1, + 8,1,9,5,5,5,5,7,3,3,3,1,3,1,1,2,2,2,1,2,2,9,5,3,3,1,3,7,1,9,1,7,3,3,1,5,5, + 5,1,5,5,5,5,5,1,8,1,1,5,5,7,3,3,1,1,1,3,1,3,1,1,2,5,5,2,2,5,5,5,1,1,7,2,2, + 1,2,2,2,1,1,2,1,8,1,7,1,3,7,5,1,5,1,9,8,1,9,5,5,5,7,3,3,1,1,3,1,1,1,5,1,1, + 1,1,1,1,7,1,1,1,1,5,5,1,5,5,5,1,8,1,1,7,3,3,1,1,1,3,1,3,1,1,5,5,1,5,5,5,1, + 8,1,1,7,3,3,1,1,1,3,1,3,1,1,2,2,2,2,2,7,1,1,1,1,2,2,2,2,1,1,2,2,2,2,2,2,2, + 2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,7,1,1,1,1,2,2,2,1,1,2,2,2,1,1,5,2,2,1,2,1,1, + 1,3,7,1,9,5,3,3,1,1,9,1,7,3,3,1,10,10,10,10,5,10,10,5,10,10,10,5,1,5,5,5,1, + 5,7,1,1,2,1,1,2,2,7,2,2,5,2,2,5,2,2,7,1,2,2,5,10,10,10,10,5,2,2,1,1,2,2,2, + 2,2,2,2,2,2,2,2,1,2,2,2,2,2,2,2,2,2,7,2,2,2,1,1,2,2,2,1,1,8,1,1,5,5,7,3,3, + 1,1,1,3,1,3,1,1,5,1,5,5,5,5,1,5,5,5,5,7,1,1,2,1,1,2,2,5,2,1,1,1,7,2,1,1,1, + 1,1,1,1,1,5,2,2,1,2,1,1,1,8,7,1,1,1,1,1,10,10,10,10,4,1,5,5,5,1,5,7,1,1,3, + 1,1,1,7,2,1,7,1,1,5,5,5,1,5,5,7,1,1,3,1,1,2,2,2,7,1,10,10,10,4 +}; + + +static const unsigned char ag_pstt[] = { +3,1,3,3,3,3,2,3,10,3,0,0,2,2,3,2,1, +121,121,121,121,1,119,121,121,121,121,121,121,121,121,121,121,121,121,121, + 121,121,1,122,1, +1,9,11,9,9,1, +41,41,4,7,7,9,15,5,3,10,14,12,14,13,15,11,6,8,7, +16,16,16,16,16,16,16,16,16,65,65,16,16,16,16,16,16,16,16,4,16,67, +1,1,1,4,17,17,19,5,6,6,19,19,19,6,18,6,17,1, +42,42,42,1,42,42,10,10,10,20,10,10,10,10,10,6,20,20,44,20,1, +60,7, +21,21,8,21, +1,22,9,22,22,22,1, +41,41,10,22,6, +23,21,24, +16,1,16,4,62,26,26,61,16,16,16,12,61,61,25,26,61,1, +41,41,9,5,19,10,14,11,6, +4,7,7,18,14,27,8,7, +20,15, +64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,66, +28,17, +17,17,18,50,17, +47,47,47,1,47,47,47,47,47,4,17,17,9,47,47,47,47,19,9,9,48,18,48,17,1, +43,43,43,1,43,43,9,11,9,9,1, +59,21, +1,9,29,22,9,9,1, +1,1,1,1,1,1,1,1,1,4,17,17,19,1,1,23,3,3,19,19,19,3,18,3,17,1, +41,80,80,88,41,80,80,80,30,31,24,83,82,34,23,24,25,6,32,82,33, +35,35,25,35, +57,26, +15,1,15,4,62,26,26,61,15,15,15,27,61,61,25,26,61,1, +1,36,54,36,36,36,1, +1,37,29,37,37,37,1, +1,1,1,1,1,1,4,17,17,19,30,5,5,19,19,19,5,18,5,17,1, +1,1,1,1,1,1,4,17,17,19,31,4,4,19,19,19,4,18,4,17,1, +68,68,73,72,70,32,40,39,38,41, +110,110,111,111,45,42,101,100,99,98,97,96,95,94,93,92,91,111,111,110,110, + 110,110,110,110,110,110,110,33,48,47,46,48,110,110,102,44,43,115,108, + 117, +50,49,29,34,30,53,30,52,53,51, +58,35, +1,9,55,9,9,1, +1,9,54,37,9,9,1, +74,74,75,74,78, +71,71,77, +69,69,69,76, +1,10,10,10,2,10,41,2,2,79,2,1, +103,103,42, +105,105,107, +104,104,106, +73,72,45,55, +114,114,86, +113,113,113,113,85, +112,112,45,42,101,100,99,98,97,96,95,94,93,92,91,56,112,112,112,112,112,112, + 112,112,112,48,112,112,102,44,43,116,108,118, +1,4,17,17,19,1,1,49,7,7,19,19,19,7,18,7,17,1, +10,1,10,10,10,10,2,10,10,10,10,50,2,2,38,2,1, +41,41,36,37,6, +50,49,52,34,57,53,57,52,53,51, +50,49,31,34,33,52,40,51, +1,2,58,54,2,2,58,2,1, +74,74,75,74,109, +1,10,10,10,2,10,56,2,2,84,2,1, +59,57,35, +23,58,60, +1,10,10,10,2,10,10,59,2,2,12,2,1, +27,27,27,60,61, +28,28,28,26, + +}; + + +static const unsigned short ag_sbt[] = { + 0, 17, 41, 47, 66, 88, 106, 127, 129, 133, 140, 145, 148, 166, + 175, 183, 185, 203, 205, 210, 235, 246, 248, 255, 281, 302, 306, 308, + 326, 333, 340, 361, 382, 392, 433, 443, 445, 451, 458, 463, 466, 470, + 482, 485, 488, 491, 495, 498, 503, 537, 555, 572, 577, 587, 595, 604, + 609, 621, 624, 627, 640, 645, 649 +}; + + +static const unsigned short ag_sbe[] = { + 10, 38, 43, 55, 85, 95, 121, 128, 131, 135, 142, 146, 159, 170, + 179, 184, 202, 204, 207, 227, 242, 247, 251, 270, 291, 304, 307, 319, + 328, 335, 350, 371, 387, 420, 435, 444, 447, 454, 462, 465, 469, 476, + 484, 487, 490, 493, 497, 502, 528, 544, 566, 574, 579, 589, 598, 608, + 615, 622, 625, 634, 643, 648, 649 +}; + + +static const unsigned char ag_fl[] = { + 1,0,1,2,2,2,2,2,1,2,0,1,2,1,2,2,1,0,1,1,3,1,2,3,3,3,8,1,2,1,2,1,1,2,1, + 3,1,2,2,1,2,1,2,3,2,1,1,1,2,1,2,1,0,1,2,3,1,2,3,3,2,2,2,1,2,0,1,2,1,2, + 1,2,1,1,2,2,1,1,1,3,0,1,1,1,4,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,2,2, + 2,1,1,1,2,1,1,2,2,2,1,2,1,2,2,1,2,2 +}; + +static const unsigned char ag_ptt[] = { + 0, 5, 5, 2, 6, 8, 10, 12, 17, 17, 18, 18, 14, 21, 21, 22, 22, 23, + 23, 23, 1, 19, 19, 19, 19, 19, 19, 32, 32, 26, 26, 34, 34, 34, 37, 36, + 38, 38, 39, 35, 35, 41, 41, 41, 25, 16, 16, 4, 4, 4, 46, 46, 50, 50, + 48, 48, 52, 52, 52, 20, 20, 20, 20, 56, 56, 57, 57, 47, 58, 58, 60, 60, + 63, 63, 63, 63, 67, 67, 67, 28, 69, 69, 68, 68, 27, 71, 71, 71, 70, 76, + 76, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 91, 93, 90, 95, 95, + 94, 96, 73, 73, 73, 73, 73, 74, 74, 75, 75, 45,100,100, 45 +}; + +static const unsigned char *ag_valid(int ag_k) { + const unsigned char *ag_tp = &ag_tstt[ag_sbt[(PCB).sn+1]]; + while (*--ag_tp != (unsigned char) ag_k) if (*ag_tp == 0) return NULL; + return ag_tp; +} + +int cf-old_change_reduction(cf-old_token_type ag_k) { + if (!ag_valid(ag_k)) return 0; + (PCB).reduction_token = ag_k; + return 1; +} + +static void near ag_default(const int *ag_tp) { + (PCB).ag_dsn = (PCB).sn; + (PCB).ag_dtl = ag_tp; + while (!ag_valid((cf-old_token_type) *ag_tp)) ag_tp++; + (PCB).reduction_token = (cf-old_token_type) *ag_tp; +} + + + +static void near ag_ra(void) +{ + switch(ag_rpx[(PCB).ag_ap]) { + case 1: ag_rp_1(); break; + case 2: ag_rp_2(); break; + case 3: ag_rp_3(); break; + case 4: ag_rp_4(); break; + case 5: ag_rp_5(V(2,(int *))); break; + case 6: ag_rp_6(V(7,(unsigned long *))); break; + case 7: V(0,(unsigned long *)) = ag_rp_7(V(0,(int *))); break; + case 8: V(0,(unsigned long *)) = ag_rp_8(V(0,(unsigned long *)), V(1,(int *))); break; + case 9: ag_rp_9(); break; + case 10: ag_rp_10(); break; + case 11: V(0,(int *)) = ag_rp_11(); break; + case 12: ag_rp_12(); break; + case 13: ag_rp_13(); break; + case 14: ag_rp_14(); break; + case 15: ag_rp_15(); break; + case 16: ag_rp_16(V(0,(int *))); break; + case 17: ag_rp_17(V(1,(int *))); break; + case 18: ag_rp_18(V(2,(int *))); break; + case 19: V(0,(int *)) = ag_rp_19(V(0,(int *))); break; + case 20: V(0,(int *)) = ag_rp_20(V(0,(int *)), V(1,(int *))); break; + case 21: V(0,(int *)) = ag_rp_21(); break; + case 22: V(0,(int *)) = ag_rp_22(V(0,(int *)), V(1,(int *))); break; + case 23: V(0,(int *)) = ag_rp_23(); break; + case 24: V(0,(int *)) = ag_rp_24(); break; + case 25: V(0,(int *)) = ag_rp_25(V(0,(int *)), V(1,(int *))); break; + case 26: V(0,(int *)) = ag_rp_26(V(0,(int *)), V(1,(int *))); break; + case 27: V(0,(int *)) = ag_rp_27(V(0,(int *)), V(1,(int *))); break; + case 28: V(0,(int *)) = ag_rp_28(); break; + case 29: V(0,(int *)) = ag_rp_29(); break; + case 30: ag_rp_30(); break; + case 31: V(0,(int *)) = ag_rp_31(); break; + case 32: V(0,(int *)) = ag_rp_32(); break; + case 33: V(0,(int *)) = ag_rp_33(); break; + case 34: V(0,(int *)) = ag_rp_34(); break; + case 35: V(0,(int *)) = ag_rp_35(); break; + case 36: V(0,(int *)) = ag_rp_36(); break; + case 37: V(0,(int *)) = ag_rp_37(); break; + case 38: V(0,(int *)) = ag_rp_38(); break; + case 39: V(0,(int *)) = ag_rp_39(); break; + case 40: V(0,(int *)) = ag_rp_40(); break; + case 41: V(0,(int *)) = ag_rp_41(); break; + case 42: V(0,(int *)) = ag_rp_42(V(0,(int *))); break; + case 43: V(0,(int *)) = ag_rp_43(V(1,(int *))); break; + case 44: V(0,(int *)) = ag_rp_44(V(0,(int *)), V(1,(int *))); break; + case 45: V(0,(int *)) = ag_rp_45(V(0,(int *)), V(1,(int *))); break; + case 46: V(0,(int *)) = ag_rp_46(V(0,(int *))); break; + case 47: V(0,(int *)) = ag_rp_47(V(1,(int *))); break; + case 48: ag_rp_48(V(0,(int *))); break; + case 49: ag_rp_49(V(0,(int *))); break; + case 50: ag_rp_50(V(1,(int *))); break; + case 51: ag_rp_51(V(1,(int *))); break; + case 52: ag_rp_52(V(1,(int *))); break; + case 53: ag_rp_53(V(0,(int *))); break; + case 54: ag_rp_54(V(1,(int *))); break; + case 55: ag_rp_55(V(0,(int *))); break; + case 56: ag_rp_56(V(1,(int *))); break; + case 57: ag_default(&ag_rtt[0]); ag_rp_57(); break; + } + (PCB).la_ptr = (PCB).pointer; +} + + +static const unsigned char ag_ctn[] = { + 0,0, 45,1, 0,0, 0,0, 47,1, 10,1, 25,1, 20,1, 20,1, 19,1, 19,1, 19,1, + 20,1, 22,1, 22,1, 0,0, 0,0, 0,0, 46,1, 0,0, 0,0, 20,2, 0,0, 2,1, + 19,2, 52,1, 52,1, 20,1, 0,0, 19,3, 8,1, 6,1, 28,1, 27,1, 26,1, 52,2, + 0,0, 0,0, 63,1, 60,1, 58,1, 28,2, 76,1, 76,1, 76,1, 0,0, 71,1, 71,1, + 71,1, 36,1, 39,1, 0,0, 36,1, 34,1, 19,5, 63,1, 27,3, 36,2, 19,6, 0,0, + 19,7, 32,1 +}; + +#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 near 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(INPUT_CODE((*(PCB).pointer))) && INPUT_CODE((*(PCB).pointer)) != '\\') { + char buf[20]; + sprintf(buf, "\'%c\'", (char) INPUT_CODE((*(PCB).pointer))); + sprintf((PCB).ag_msg, UNEXPECTED_FORMAT, buf); + } + else sprintf((PCB).ag_msg, UNEXPECTED_FORMAT, UNNAMED_TOKEN); + (PCB).error_message = (PCB).ag_msg; + + +{ + int ag_sx, ag_t; + + ag_sx = (PCB).ssx; + (PCB).ss[ag_sx] = (PCB).sn; + do { + while (ag_sx && ag_ctn[2*(ag_snd = (PCB).ss[ag_sx])] == 0) ag_sx--; + if (ag_sx) { + ag_t = ag_ctn[2*ag_snd]; + ag_sx -= ag_ctn[2*ag_snd +1]; + ag_snd = (PCB).ss[ag_sx]; + } + else { + ag_snd = 0; + ag_t = ag_ptt[0]; + } + } while (ag_sx && *TOKEN_NAMES[ag_t]==0); + if (*TOKEN_NAMES[ag_t] == 0) ag_t = 0; + (PCB).error_frame_ssx = ag_sx; + (PCB).error_frame_token = (cf-old_token_type) ag_t; +} + + +} +static int near ag_action_1_r_proc(void); +static int near ag_action_2_r_proc(void); +static int near ag_action_3_r_proc(void); +static int near ag_action_4_r_proc(void); +static int near ag_action_1_s_proc(void); +static int near ag_action_3_s_proc(void); +static int near ag_action_1_proc(void); +static int near ag_action_2_proc(void); +static int near ag_action_3_proc(void); +static int near ag_action_4_proc(void); +static int near ag_action_5_proc(void); +static int near ag_action_6_proc(void); +static int near ag_action_7_proc(void); +static int near ag_action_8_proc(void); +static int near ag_action_9_proc(void); +static int near ag_action_10_proc(void); +static int near ag_action_11_proc(void); +static int near ag_action_8_proc(void); + + +static int (near *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 (near *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 (near *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 near ag_rns(int ag_t, int *ag_sx, int ag_snd) { + while (1) { + int ag_act, ag_k = ag_sbt[ag_snd], ag_lim = ag_sbt[ag_snd+1]; + int ag_p; + + while (ag_k < ag_lim && ag_tstt[ag_k] != ag_t) ag_k++; + if (ag_k == ag_lim) break; + ag_act = ag_astt[ag_k]; + ag_p = ag_pstt[ag_k]; + if (ag_act == ag_action_2) return ag_p; + if (ag_act == ag_action_10 || ag_act == ag_action_11) { + (*ag_sx)--; + return ag_snd; + } + if (ag_act != ag_action_3 && + ag_act != ag_action_4) break; + *ag_sx -= (ag_fl[ag_p] - 1); + ag_snd = (PCB).ss[*ag_sx]; + ag_t = ag_ptt[ag_p]; + } + return 0; +} + +static int near ag_jns(int ag_t) { + int ag_k; + + ag_k = ag_sbt[(PCB).sn]; + while (ag_tstt[ag_k] != ag_t && ag_tstt[ag_k]) ag_k++; + while (1) { + int ag_p = ag_pstt[ag_k]; + int ag_sd; + + switch (ag_astt[ag_k]) { + case ag_action_2: + GET_CONTEXT; + (PCB).ss[(PCB).ssx] = (PCB).sn; + return ag_p; + case ag_action_10: + case ag_action_11: + return (PCB).ss[(PCB).ssx--]; + case ag_action_9: + GET_CONTEXT; + (PCB).ss[(PCB).ssx] = (PCB).sn; + (PCB).ssx++; + (PCB).sn = ag_p; + ag_k = ag_sbt[(PCB).sn]; + while (ag_tstt[ag_k] != ag_t && ag_tstt[ag_k]) ag_k++; + continue; + case ag_action_3: + case ag_action_4: + ag_sd = ag_fl[ag_p] - 1; + if (ag_sd) (PCB).sn = (PCB).ss[(PCB).ssx -= ag_sd]; + else GET_CONTEXT; + (PCB).ss[(PCB).ssx] = (PCB).sn; + ag_t = ag_ptt[ag_p]; + ag_k = ag_sbt[(PCB).sn+1]; + while (ag_tstt[--ag_k] != ag_t); + continue; + case ag_action_5: + case ag_action_6: + if (ag_fl[ag_p]) break; + (PCB).sn = ag_rns(ag_ptt[ag_p],&(PCB).ssx, (PCB).sn); + (PCB).ss[++(PCB).ssx] = (PCB).sn; + ag_k = ag_sbt[(PCB).sn]; + while (ag_tstt[ag_k] != ag_t && ag_tstt[ag_k]) ag_k++; + continue; + } + break; + } + return 0; +} + + +static int near ag_atx(int ag_t, int *ag_sx, int ag_snd) { + int ag_k, ag_f; + int ag_save_btsx = (PCB).btsx; + int ag_flag = 1; + + while (1) { + int ag_a; + + (PCB).bts[128 - ++(PCB).btsx] = *ag_sx; + (PCB).ss[128 - (PCB).btsx] = (PCB).ss[*ag_sx]; + (PCB).ss[*ag_sx] = ag_snd; + ag_k = ag_sbt[ag_snd]; + while (ag_tstt[ag_k] != ag_t && ag_tstt[ag_k]) ag_k++; + ag_a = ag_astt[ag_k]; + if (ag_a == ag_action_2 || + ag_a == ag_action_3 || + ag_a == ag_action_10 || + ag_a == ag_action_11 || + ag_a == ag_action_1 || + ag_a == ag_action_4) break; + if ((ag_a == ag_action_5 || + ag_a == ag_action_6) && + (ag_k = ag_fl[ag_f = ag_pstt[ag_k]]) == 0) { + ag_snd = ag_rns(ag_ptt[ag_f],ag_sx, (PCB).ss[*ag_sx]); + (*ag_sx)++; + continue; + } + if (ag_a == ag_action_9) { + ag_snd = ag_pstt[ag_k]; + (*ag_sx)++; + continue; + } + ag_flag = 0; + break; + } + while ((PCB).btsx > ag_save_btsx) { + *ag_sx = (PCB).bts[128 - (PCB).btsx]; + (PCB).ss[*ag_sx] = (PCB).ss[128 - (PCB).btsx--]; + } + return ag_flag; +} + + +static int near ag_tst_tkn(void) { + int ag_rk, ag_sx, ag_snd = (PCB).sn; + + (PCB).token_number = (cf-old_token_type) AG_TCV(INPUT_CODE(*(PCB).la_ptr)); + (PCB).la_ptr++; + if (ag_key_index[(PCB).sn]) { + unsigned ag_k = ag_key_index[(PCB).sn]; + int ag_ch = CONVERT_CASE(INPUT_CODE(*(PCB).pointer)); + 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); + } + } + for (ag_rk = 0; ag_rk < (PCB).ag_lrss; ag_rk += 2) { + ag_sx = (PCB).ag_rss[ag_rk]; + if (ag_sx > (PCB).ssx || ag_sx > (PCB).ag_min_depth) continue; + (PCB).sn = (PCB).ag_rss[ag_rk + 1]; + if (ag_atx((PCB).token_number, &ag_sx, (PCB).sn)) break; + } + (PCB).sn = ag_snd; + return ag_rk; +} + +static void near ag_set_error_procs(void); + +static void near ag_auto_resynch(void) { + int ag_sx, ag_rk; + int ag_rk1, ag_rk2, ag_tk1; + (PCB).ss[(PCB).ssx] = (PCB).sn; + if ((PCB).ag_error_depth && (PCB).ag_min_depth >= (PCB).ag_error_depth) { + (PCB).ssx = (PCB).ag_error_depth; + (PCB).sn = (PCB).ss[(PCB).ssx]; + } + else { + ag_diagnose(); + SYNTAX_ERROR; + if ((PCB).exit_flag != AG_RUNNING_CODE) return; + (PCB).ag_error_depth = (PCB).ag_min_depth = 0; + (PCB).ag_lrss = 0; + (PCB).ss[ag_sx = (PCB).ssx] = (PCB).sn; + (PCB).ag_min_depth = (PCB).ag_rss[(PCB).ag_lrss++] = ag_sx; + (PCB).ag_rss[(PCB).ag_lrss++] = (PCB).sn; + while (ag_sx && (PCB).ag_lrss < 2*128) { + int ag_t = 0, ag_x, ag_s, ag_sxs = ag_sx; + + while (ag_sx && (ag_t = ag_ctn[2*(PCB).sn]) == 0) (PCB).sn = (PCB).ss[--ag_sx]; + if (ag_t) (PCB).sn = (PCB).ss[ag_sx -= ag_ctn[2*(PCB).sn +1]]; + else { + if (ag_sx == 0) (PCB).sn = 0; + ag_t = ag_ptt[0]; + } + if ((ag_s = ag_rns(ag_t, &ag_sx, (PCB).sn)) == 0) break; + for (ag_x = 0; ag_x < (PCB).ag_lrss; ag_x += 2) + if ((PCB).ag_rss[ag_x] == ag_sx + 1 && (PCB).ag_rss[ag_x+1] == ag_s) break; + if (ag_x == (PCB).ag_lrss) { + (PCB).ag_rss[(PCB).ag_lrss++] = ++ag_sx; + (PCB).ag_rss[(PCB).ag_lrss++] = (PCB).sn = ag_s; + } + else if (ag_sx >= ag_sxs) ag_sx--; + } + ag_set_error_procs(); + } + (PCB).la_ptr = (PCB).pointer; + if ((PCB).ssx > (PCB).ag_min_depth) (PCB).ag_min_depth = (PCB).ssx; + while (1) { + ag_rk1 = ag_tst_tkn(); + if ((PCB).token_number == 24) + {(PCB).exit_flag = AG_SYNTAX_ERROR_CODE; return;} + if (ag_rk1 < (PCB).ag_lrss) break; + {(PCB).la_ptr = (PCB).pointer + 1; ag_track();} + } + ag_tk1 = (PCB).token_number; + ag_track(); + ag_rk2 = ag_tst_tkn(); + if (ag_rk2 < ag_rk1) {ag_rk = ag_rk2; ag_track();} + else {ag_rk = ag_rk1; (PCB).token_number = (cf-old_token_type) ag_tk1; (PCB).la_ptr = (PCB).pointer;} + (PCB).ag_min_depth = (PCB).ssx = (PCB).ag_rss[ag_rk++]; + (PCB).sn = (PCB).ss[(PCB).ssx] = (PCB).ag_rss[ag_rk]; + (PCB).sn = ag_jns((PCB).token_number); + if ((PCB).ag_error_depth == 0 || (PCB).ag_error_depth > (PCB).ssx) + (PCB).ag_error_depth = (PCB).ssx; + if (++(PCB).ssx >= 128) { + (PCB).exit_flag = AG_STACK_ERROR_CODE; + PARSER_STACK_OVERFLOW; + return; + } + GET_CONTEXT; + (PCB).ss[(PCB).ssx] = (PCB).sn; + (PCB).ag_tmp_depth = (PCB).ag_min_depth; + (PCB).la_ptr = (PCB).pointer; + return; +} + + +static int near ag_action_10_proc(void) { + int ag_t = (PCB).token_number; + (PCB).btsx = 0, (PCB).drt = -1; + do { + ag_track(); + (PCB).token_number = (cf-old_token_type) AG_TCV(INPUT_CODE(*(PCB).la_ptr)); + (PCB).la_ptr++; + if (ag_key_index[(PCB).sn]) { + unsigned ag_k = ag_key_index[(PCB).sn]; + int ag_ch = CONVERT_CASE(INPUT_CODE(*(PCB).pointer)); + 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 == (cf-old_token_type) ag_t); + (PCB).la_ptr = (PCB).pointer; + return 1; +} + +static int near ag_action_11_proc(void) { + int ag_t = (PCB).token_number; + + (PCB).btsx = 0, (PCB).drt = -1; + do { + (*(int *) &(PCB).vs[(PCB).ssx]) = *(PCB).pointer; + (PCB).ssx--; + ag_track(); + ag_ra(); + if ((PCB).exit_flag != AG_RUNNING_CODE) return 0; + (PCB).ssx++; + (PCB).token_number = (cf-old_token_type) AG_TCV(INPUT_CODE(*(PCB).la_ptr)); + (PCB).la_ptr++; + if (ag_key_index[(PCB).sn]) { + unsigned ag_k = ag_key_index[(PCB).sn]; + int ag_ch = CONVERT_CASE(INPUT_CODE(*(PCB).pointer)); + 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 == (cf-old_token_type) ag_t); + (PCB).la_ptr = (PCB).pointer; + return 1; +} + +static int near 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 = (cf-old_token_type) ag_ptt[(PCB).ag_ap]; + ag_ra(); + return (PCB).exit_flag == AG_RUNNING_CODE; +} + +static int near 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 = (cf-old_token_type) ag_ptt[(PCB).ag_ap]; + ag_ra(); + return (PCB).exit_flag == AG_RUNNING_CODE; +} + +static int near 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 = (cf-old_token_type) ag_ptt[(PCB).ag_ap]; + return 1; +} + +static int near 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; + } + (*(int *) &(PCB).vs[(PCB).ssx]) = *(PCB).pointer; + GET_CONTEXT; + (PCB).ss[(PCB).ssx] = (PCB).sn; + (PCB).ssx++; + (PCB).sn = (PCB).ag_ap; + ag_track(); + return 0; +} + +static int near 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; + GET_CONTEXT; + (PCB).ss[(PCB).ssx] = (PCB).sn; + (PCB).ssx++; + (PCB).sn = (PCB).ag_ap; + (PCB).la_ptr = (PCB).pointer; + return (PCB).exit_flag == AG_RUNNING_CODE; +} + +static int near ag_action_2_r_proc(void) { + (PCB).ssx++; + (PCB).sn = (PCB).ag_ap; + return 0; +} + +static int near ag_action_7_proc(void) { + --(PCB).ssx; + (PCB).la_ptr = (PCB).pointer; + (PCB).exit_flag = AG_SUCCESS_CODE; + return 0; +} + +static int near ag_action_1_proc(void) { + ag_track(); + (PCB).exit_flag = AG_SUCCESS_CODE; + return 0; +} + +static int near ag_action_1_r_proc(void) { + (PCB).exit_flag = AG_SUCCESS_CODE; + return 0; +} + +static int near ag_action_1_s_proc(void) { + (PCB).exit_flag = AG_SUCCESS_CODE; + return 0; +} + +static int near ag_action_4_proc(void) { + int ag_sd = ag_fl[(PCB).ag_ap] - 1; + (PCB).reduction_token = (cf-old_token_type) ag_ptt[(PCB).ag_ap]; + (PCB).btsx = 0, (PCB).drt = -1; + (*(int *) &(PCB).vs[(PCB).ssx]) = *(PCB).pointer; + if (ag_sd) (PCB).sn = (PCB).ss[(PCB).ssx -= ag_sd]; + else GET_CONTEXT; + (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); + if (ag_tstt[ag_t1] != (PCB).reduction_token) { + (PCB).exit_flag = AG_REDUCTION_ERROR_CODE; + REDUCTION_TOKEN_ERROR; break;} + (PCB).ag_ap = ag_pstt[ag_t1]; + if ((*(PCB).s_procs[ag_astt[ag_t1]])() == 0) break; + } + return 0; +} + +static int near ag_action_3_proc(void) { + int ag_sd = ag_fl[(PCB).ag_ap] - 1; + (PCB).btsx = 0, (PCB).drt = -1; + (*(int *) &(PCB).vs[(PCB).ssx]) = *(PCB).pointer; + if (ag_sd) (PCB).sn = (PCB).ss[(PCB).ssx -= ag_sd]; + else GET_CONTEXT; + (PCB).ss[(PCB).ssx] = (PCB).sn; + ag_track(); + (PCB).reduction_token = (cf-old_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); + if (ag_tstt[ag_t1] != (PCB).reduction_token) { + (PCB).exit_flag = AG_REDUCTION_ERROR_CODE; + REDUCTION_TOKEN_ERROR; break;} + (PCB).ag_ap = ag_pstt[ag_t1]; + if ((*(PCB).s_procs[ag_astt[ag_t1]])() == 0) break; + } + return 0; +} + +static int near ag_action_8_proc(void) { + ag_undo(); + (PCB).la_ptr = (PCB).pointer; + ag_auto_resynch(); + return (PCB).exit_flag == AG_RUNNING_CODE; +} + +static int near 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 { + GET_CONTEXT; + (PCB).ss[(PCB).ssx] = (PCB).sn; + } + (PCB).la_ptr = (PCB).pointer; + (PCB).reduction_token = (cf-old_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); + if (ag_tstt[ag_t1] != (PCB).reduction_token) { + (PCB).exit_flag = AG_REDUCTION_ERROR_CODE; + REDUCTION_TOKEN_ERROR; break;} + (PCB).ag_ap = ag_pstt[ag_t1]; + if ((*(PCB).r_procs[ag_astt[ag_t1]])() == 0) break; + } + return (PCB).exit_flag == AG_RUNNING_CODE; +} + +static int near ag_action_6_proc(void) { + int ag_sd = ag_fl[(PCB).ag_ap]; + (PCB).reduction_token = (cf-old_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; + GET_CONTEXT; + (PCB).ss[(PCB).ssx] = (PCB).sn; + } + (PCB).la_ptr = (PCB).pointer; + 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); + if (ag_tstt[ag_t1] != (PCB).reduction_token) { + (PCB).exit_flag = AG_REDUCTION_ERROR_CODE; + REDUCTION_TOKEN_ERROR; break;} + (PCB).ag_ap = ag_pstt[ag_t1]; + if ((*(PCB).r_procs[ag_astt[ag_t1]])() == 0) break; + } + return (PCB).exit_flag == AG_RUNNING_CODE; +} + + +static void near ag_check_depth(int ag_fl) { + int ag_sx = (PCB).ssx - ag_fl; + if ((PCB).ag_error_depth && ag_sx < (PCB).ag_tmp_depth) (PCB).ag_tmp_depth = ag_sx; +} + +static int near ag_action_3_er_proc(void) { + ag_check_depth(ag_fl[(PCB).ag_ap] - 1); + return ag_action_4_r_proc(); +} + +static int near ag_action_2_e_proc(void) { + ag_action_2_proc(); + (PCB).ag_min_depth = (PCB).ag_tmp_depth; + return 0; +} + +static int near ag_action_4_e_proc(void) { + ag_check_depth(ag_fl[(PCB).ag_ap] - 1); + (PCB).ag_min_depth = (PCB).ag_tmp_depth; + return ag_action_4_proc(); +} + +static int near ag_action_6_e_proc(void) { + ag_check_depth(ag_fl[(PCB).ag_ap]); + return ag_action_6_proc(); +} + +static int near ag_action_11_e_proc(void) { + return ag_action_10_proc(); +} + +static int (near *ag_r_procs_error[])(void) = { + ag_action_1_r_proc, + ag_action_2_r_proc, + ag_action_3_er_proc, + ag_action_3_er_proc +}; + +static int (near *ag_s_procs_error[])(void) = { + ag_action_1_s_proc, + ag_action_2_r_proc, + ag_action_3_er_proc, + ag_action_3_er_proc +}; + +static int (near *ag_gt_procs_error[])(void) = { + ag_action_1_proc, + ag_action_2_e_proc, + ag_action_4_e_proc, + ag_action_4_e_proc, + ag_action_6_e_proc, + ag_action_6_e_proc, + ag_action_7_proc, + ag_action_8_proc, + ag_action_9_proc, + ag_action_10_proc, + ag_action_11_e_proc, + ag_action_8_proc +}; + +static void near ag_set_error_procs(void) { + (PCB).gt_procs = ag_gt_procs_error; + (PCB).r_procs = ag_r_procs_error; + (PCB).s_procs = ag_s_procs_error; +} + + +void init_cf-old(void) { + (PCB).la_ptr = (PCB).pointer; + (PCB).gt_procs = ag_gt_procs_scan; + (PCB).r_procs = ag_r_procs_scan; + (PCB).s_procs = ag_s_procs_scan; + (PCB).ag_error_depth = (PCB).ag_min_depth = (PCB).ag_tmp_depth = 0; + (PCB).ag_resynch_active = 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 cf-old(void) { + init_cf-old(); + (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; + (PCB).token_number = (cf-old_token_type) AG_TCV(INPUT_CODE(*(PCB).la_ptr)); + (PCB).la_ptr++; + if (ag_key_index[(PCB).sn]) { + unsigned ag_k = ag_key_index[(PCB).sn]; + int ag_ch = CONVERT_CASE(INPUT_CODE(*(PCB).pointer)); + 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]; + (*(PCB).gt_procs[ag_astt[ag_t1]])(); + } +} + +