view tests/agcl/oldagsrc/good/scr4d.c @ 23:cac4c76600eb

Update lint ok file for recent change.
author David A. Holland
date Mon, 13 Jun 2022 00:17:10 -0400
parents 13d2b8934445
children
line wrap: on
line source

/*
   AnaGram Syntax Analyzer. Copyright (c) Jerome T. Holland, 1989, 1990, 1991.
   All Rights Reserved.
*/

#include HEADERS
#include PF

#include STDLIB
#include DATA
#include ASSERT
#include MYALLOC
#include ARRAYS
#include SP
#include SCREEN
#include STK
#include SCR4D
#include SETJMP
#include STDARG
#include STDIO
#include WIN
/* #include DIRECT */
#include DEMO

dc          *activate_window(dc *);
void         bury_top_image(void);
int          chdir_s1(char*);
dc          *check_selection(dc *);
dc          *clear_mode(dc *);
int          display_line_number(int);
extern dc   *edit_window;
void         force_screen_real(void);
void         hide_cursor(void);
dc          *prt(dc*);
extern dc   *quick_ref_display;
void         remove_ghost(dc *);
dc          *open_windows(dc *);
dc          *resize_window_mode(dc *);
void         set_work_dir(void);
void         update_screen(dc *);
dc          *window_move(dc *);
int          wkb(void);
void         xeq_qa(void);

extern long current_date, expiration_date;


scr_pcb_type scr_pcb;
#define PCB scr_pcb

#define GET_INPUT PCB.input_code = wkb()
#define PARSE_STACK_OVERFLOW myabort();
#define SYNTAX_ERROR


extern rect mode_area;
extern rect position_area;
extern cint current_cursor;

extern dc *active_dc;
extern dc *cmnd_map_display;
extern dc *file_pick_display;
extern dc *help_index;
extern dc *pick_list_display;
extern dc *quick_ref_display;
extern dc *window_menu_display;

extern int n_windows;
extern char *string_base;

extern char *current_mode_string;

void sbeep(void);


/*
 * 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 SCR4D_H
#include "scr4d.h"
#endif

#ifndef SCR4D_H
#error Mismatched header file
#endif

#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) scr_change_reduction(scr_##x##_token)
int scr_change_reduction(scr_token_type);


#line - "scr4d.syn"
#define F1                  315
#define F2                  316
#define F3                  317
#define F4                  318
#define F5                  319
#define F6                  320
#define F7                  321
#define F8                  322
#define F9                  323
#define F10                 324
#define ALT_F1              360
#define ALT_F2              361
#define ALT_F3              362
#define ALT_F4              363
#define ALT_F5              364
#define ALT_F6              365
#define ALT_F7              366
#define ALT_F8              367
#define ALT_F9              368
#define ALT_F10             369

#define move_code  F2
#define reduce ALT_F2
#define left   331
#define right  333

#line - "scr4d.c"
#line - "scr4d.syn"
#ifdef DEMO_FLAG
void restrict_usage(void);

dc *check_expiration(void) {
		long *ex = &expiration_date + 47;
		long *cd = &current_date + 252;
    if (ex[-47] < cd[-252]) restrict_usage();
    return NULL;
 }
#else
dc *check_expiration(void) {return NULL;}
#endif

#line - "scr4d.c"
#line - "scr4d.syn"
void set_mode(char *);

dc *replace_window(dc *d, dc *new);
dc *pop_up_window(dc *d);

#line - "scr4d.c"
#line - "scr4d.syn"
static int end_line_number_mode(int n){
  flash_str_fill(mode_area.pos,current_mode_string,0,mode_area.size.x);
  return n;
}
#line - "scr4d.c"
#line - "scr4d.syn"
static dc *reset_position_window(dc *d) {
  flash_str_fill(mode_area.pos,current_mode_string,0,mode_area.size.x);
  current_cursor.x = -1;
  return d;
}

static int line_number_1(void) {
  flash_str_fill(mode_area.pos,"Line Number",0,mode_area.size.x);
  return 0;
}

static int line_number_2(int n, int d) {
  return display_line_number(10*n+d-48);
}
static int line_number_3(int n) {
  return display_line_number(n/10);
}

dc *find_help(char *);
dc *pop_up_window(dc *);

static dc *key_assign(dc *dm, char *title) {
  dc *d = find_help(title);
  if (d == NULL) return beep(dm);
  return pop_up_window(d);
}
#line - "scr4d.c"
#line - "scr4d.syn"
dc *pop_up_aux_win_menu(dc *);
dc *pop_up_aux_cmnd_menu(dc *);

dc *first_clone(dc *);

static dc *cycle_clone(dc *d) {
  dc *c;
  if (d->no_clone) return beep(d);
  c = first_clone(d);
  if (c != NULL) return pop_up_window(c);
  return beep(d);
}
#line - "scr4d.c"
#line - "scr4d.syn"
extern char *search_key;
char *old_string;
int search_key_index;

char *build_string(void);
extern int search_flag;

static dc *save_search_key(dc *d) {
  if (search_key != NULL) free(search_key);
  search_flag--;
  search_key = build_string();
  close_window(d);
  hide_cursor();
  activate_window(map_window_plane[--nplanes].d);
  return active_dc;
}

extern char work_dir_name[];

void set_work_dir(void);

static dc *chdir_s2(dc *d) {
  tss();
  if (chdir_s1(string_base)) return beep(d);
  rcs();
  search_flag--;
  CHANGE_REDUCTION(new_directory);
  set_work_dir();
/*  getcwd(work_dir_name, MAXPATH); */
  set_work_dir();
  close_window(d);
  hide_cursor();
  activate_window(map_window_plane[--nplanes].d);
  return active_dc;
}

static dc *quit_search(dc *d) {
  close_window(d);
  rcs();
  search_flag--;
  hide_cursor();
  activate_window(map_window_plane[--nplanes].d);
  ok_ptr(active_dc->des);
  active_dc->des->c_loc_doc.x = 0;
  return active_dc;
}
#line - "scr4d.c"
#line - "scr4d.syn"
void search_key_line(void)   {
  tss();
  sss(string_base);
}

static dc *search_key_right(dc *d) {
  if( tis() <= d->des->c_loc_doc.x) {
    int c;
    if (search_key == NULL) return d;
    c = old_string[search_key_index];
    if (c == 0) return d;
    acs(c);
    search_key_index++;
    ok_ptr(d->des);
    d->des->refresh++;
  }
  fiddle_window(d,right);
  return d;
}
static dc *search_key_end(dc *d) {
  ok_ptr(d->des);

  if( tis() <= d->des->c_loc_doc.x) {
    int c = old_string[search_key_index];
    while (c) {
      acs(c);
      c = old_string[++search_key_index];
    }
  d->des->refresh++;
  }
  d->des->c_loc_doc.x = tis();
  bound_cursor_hor(d->des);
  return d;
}

static dc *insert_text(dc *d, int c) {
  wd *w;

  w = d->des;
  ok_ptr(w);
  its(c, w->c_loc_doc.x);
  fiddle_window(d,right);
  w->refresh++;
  return d;
}
static dc *delete_char(dc *d) {
  ok_ptr(d->des);
  dcs(d->des->c_loc_doc.x);
  d->des->refresh++;
  return d;
}

static dc *backspace_char(dc *d) {
  wd *w;

  w = d->des;
  if (w->c_loc_doc.x == 0) return d;
  fiddle_window(d,left);
  delete_char(d);
  return d;
}

#line - "scr4d.c"
#line - "scr4d.syn"
static dc *show_mode(dc *d, int t) {
  char *ms = "";

  ok_ptr(d);
  switch (t) {
  case move_code:
/*
    if (d->move == NULL) {
      PCB.reduction_token = scr_window_token;
      beep(d);
      break;
    }
*/
    ms = "Move Window";
    break;
  case reduce:
/*
    if (d->resize == NULL) {
      beep(d);
      PCB.reduction_token = scr_window_token;
      break;
    }
*/
    ms = "Resize Window";
    break;
  }
  flash_str_fill(mode_area.pos,ms,0,mode_area.size.x);
  return d;
}

#line - "scr4d.c"
#line - "scr4d.syn"
cint ci();
cint aci();
cint sci();
cint ulci();

extern int start_keys[];
extern dc *error_display;

void log_error(void);

void pop_up_code_segment(char *, char *);

dc *resize_window_mode(dc *d) {
  set_mode("Resize Window");
  CHANGE_REDUCTION(resize_window);
  return d;
}

dc *window_move(dc *d) {
  set_mode("Move Window");
  CHANGE_REDUCTION(move_window);
  return d;
}

static dc *naughty(void) {
  force_screen_real();
  pop_up_code_segment("birb", "");
  wkb();
  return NULL;
}

void deactivate_window(dc *);

static dc *activate_cmnd_menu(void) {
  dc *new;
  force_screen_real();
  if (active_dc != NULL) {
    if (active_dc != quick_ref_display) return active_dc;
    deactivate_window(active_dc);
  }
  new = activate_window(cmnd_map_display);
  if (nerrors) new = pop_up_window(error_display);
  return new;
}


extern dc *search_key_window;


static dc *edit_search(void) {
  cint loc;
  cint corner;
  dc *d;
  rect w;

  d = active_dc;
  loc = aci(d->act->c_loc_scr, ci(1,1));
  deactivate_window(d);
  w = place_rect(display_area, search_key_window->des->b_size,22);
  corner = w.pos;
  search_key_window->des->b_loc_scr = ulci(loc,corner);
  search_key_window->des->b_size = w.size;
  activate_window(search_key_window);
  return active_dc;
}

static dc *init_search_window(void) {
  ics();
  search_flag++;
  ok_ptr(search_key_window->des);
  search_key_window->des->c_loc_doc.x = 0;
  search_key_index = 0;
  old_string = search_key;

  return edit_search();
}


int do_key(int x) {
  PCB.input_code = x;
  scr();
  if (PCB.exit_flag == AG_SYNTAX_ERROR_CODE) {
    sbeep();
    PCB.exit_flag = AG_RUNNING_CODE;
  }
  return (PCB.exit_flag == AG_RUNNING_CODE);
}

#line - "scr4d.c"

#ifndef CONVERT_CASE
#define CONVERT_CASE(c) (c)
#endif
#ifndef TAB_SPACING
#define TAB_SPACING 8
#endif

#define ag_rp_1() (naughty())

#define ag_rp_2() (check_expiration())

#define ag_rp_3() (activate_cmnd_menu())

#define ag_rp_4() (pop_up_window(cmnd_map_display))

#define ag_rp_5() (pop_up_window(window_menu_display))

#define ag_rp_6() (pop_up_window(quick_ref_display))

#define ag_rp_7(w) (rcs(), search_flag--, quit_window(w))

#define ag_rp_8(w) (check_expiration(),w)

#define ag_rp_9(w) (check_expiration(),w)

#define ag_rp_10(d) ((*d->enter)(d))

#define ag_rp_11(n) (end_line_number_mode(n))

#define ag_rp_12(n) (end_line_number_mode(n))

#define ag_rp_13(n) (end_line_number_mode(n))

#define ag_rp_14() (line_number_1())

#define ag_rp_15(n, d) (line_number_2(n,d))

#define ag_rp_16(n) (line_number_3(n))

#define ag_rp_17(n) (line_number_3(n))

#define ag_rp_18(w) (quit_window(w))

#define ag_rp_19(w) (help_window(w))

#define ag_rp_20() (pop_up_window(help_index))

#define ag_rp_21(w) (key_assign(w,"Function Keys"))

#define ag_rp_22(w) (key_assign(w,"Cursor Keys"))

#define ag_rp_23(w) (prt(w))

#define ag_rp_24(w, k) (cursor(w,k))

#define ag_rp_25(w, k) (control(w,k))

#define ag_rp_26(w) (search_forward(w))

#define ag_rp_27(w) (search_reverse(w))

#define ag_rp_28(w, c) (alpha_access(w,c))

#define ag_rp_29(w, n) (reposition_cursor(w,n))

#define ag_rp_30(w, n) (backup_cursor(w,n))

#define ag_rp_31(w, n) (advance_cursor(w,n))

#define ag_rp_32(w) (reset_position_window(w))

#define ag_rp_33(w) (clone_window(w))

#define ag_rp_34(w) (cycle_clone(w))

#define ag_rp_35(w) (pop_up_aux_win_menu(w))

#define ag_rp_36(w) (pop_up_aux_cmnd_menu(w))

#define ag_rp_37(w) (open_windows(w))

#define ag_rp_38(w) (previous_window(w))

#define ag_rp_39(w) (bottom_window(w))

#define ag_rp_40(w) (bury_window(w))

#define ag_rp_41(sk) (save_search_key(sk))

#define ag_rp_42(sk) (save_search_key(sk))

#define ag_rp_43(sk) (save_search_key(sk))

#define ag_rp_44(sk) (save_search_key(sk))

#define ag_rp_45(sk) (quit_search(sk))

#define ag_rp_46() (init_search_window())

#define ag_rp_47(sk, k) (fiddle_window(sk,k))

#define ag_rp_48(sk) (search_key_right(sk))

#define ag_rp_49(sk, c) (insert_text(sk,c))

#define ag_rp_50(sk) (backspace_char(sk))

#define ag_rp_51(sk) (delete_char(sk))

#define ag_rp_52(sk, k) (fiddle_window(sk,k))

#define ag_rp_53(sk) (search_key_end(sk))

#define ag_rp_54(sk, k) (fiddle_window(sk,k))

#define ag_rp_55(sk, k) (fiddle_window(sk,k))

#define ag_rp_56(d) (d)

#define ag_rp_57(d) (chdir_s2(d))

#define ag_rp_58() (edit_window)

#define ag_rp_59(sk, k) (fiddle_window(sk,k))

#define ag_rp_60(sk) (search_key_right(sk))

#define ag_rp_61(sk, k) (fiddle_window(sk,k))

#define ag_rp_62(sk) (search_key_end(sk))

#define ag_rp_63(sk, c) (insert_text(sk,c))

#define ag_rp_64(sk) (backspace_char(sk))

#define ag_rp_65(sk) (delete_char(sk))

#define ag_rp_66(sk, k) (fiddle_window(sk,k))

#define ag_rp_67(sk, k) (fiddle_window(sk,k))

#define ag_rp_68(sk) (clear_mode(sk))

#define ag_rp_69(sk) (clear_mode(sk))

#define ag_rp_70(sk) (clear_mode(sk))

#define ag_rp_71(sk, k) (show_mode(sk,k))

#define ag_rp_72(sk, k) (move(sk,k))

#define ag_rp_73(sk, k) (show_mode(sk,k))

#define ag_rp_74(sk, k) (resize(sk,k))

#define ag_rp_75(sk, k) (show_mode(sk,k))

#define ag_rp_76(sk, k) (move(sk,k))

#define ag_rp_77(sk, k) (show_mode(sk,k))

#define ag_rp_78(sk, k) (resize(sk,k))

#define ag_rp_79(w, k) (show_mode(w,k))

#define ag_rp_80(w, k) (move(w,k))

#define ag_rp_81(w, k) (show_mode(w,k))

#define ag_rp_82(w, k) (resize(w,k))


#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 scr_vs_type const ag_null_value NULL_VALUE_INITIALIZER;

static const unsigned char ag_rpx[] = {
    0,  0,  0,  0,  1,  0,  0,  0,  2,  0,  0,  0,  0,  3,  4,  5,  6,  7,
    8,  9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24,  0,
    0,  0,  0, 25, 26, 27, 28,  0, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38,
   39, 40,  0, 41, 42,  0, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54,
   55,  0, 56, 57, 58, 59, 60, 61, 62,  0, 63, 64, 65, 66, 67,  0,  0, 68,
    0,  0, 69,  0,  0, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82
};
#define AG_TCV(x) (((int)(x) >= 0 && (int)(x) <= 388) ? ag_tcv[(x)] : 0)

static const unsigned char ag_tcv[] = {
    0,  0,  0,  0,  0,  0,  0,  0, 29,  0,  0,  0,  0, 21,  0,  0,  0,  0,
    0,  0,  0,  0,  0, 86,  0,  0, 87, 19,  0,  0,  0,  0, 90, 90, 90, 90,
   90, 90, 90, 90, 90, 90, 90, 89, 90, 88, 90, 90, 28, 28, 28, 28, 28, 28,
   28, 28, 28, 28, 90, 90, 90, 90, 90, 18, 90, 90, 90, 90, 90, 90, 90, 90,
   90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90,
   90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90,
   90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90,
   90, 90,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,
    0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,
    0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,
    0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,
    0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,
    0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,
    0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,
    0,  0,  0,  0,  0, 67,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,
    0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0, 35,  0,  0,  0,  0,  0, 58,
    0,  0,  0,  0,  0,  0, 27,  0,  0,  0,  0,  0,  0,  6,  0,  0,  0,  0,
    0,  0,  0,  0,  0,  0,  0,  0,  0, 31, 77, 56, 53, 52, 51, 45, 50, 17,
   11,  0,  0, 62, 57, 80,  0, 59,  0, 60,  0, 63, 55, 81,  0, 30, 33,  0,
    0,  0,  0,  0,  0,  0,  0,  0, 34,  0,  0,  0,  0,  0,  0,  0,  0,  0,
   32, 79,  0,  0,  0,  0, 46, 49, 47, 48,  0, 64, 65, 83, 85, 82,  0,  0,
    0,  0,  0,  0,  0,  0,  0,  0,  0,  0, 84
};

#ifndef SYNTAX_ERROR
#define SYNTAX_ERROR fprintf(stderr,"%s\n", (PCB).error_message)
#endif

#ifndef PARSER_STACK_OVERFLOW
#define PARSER_STACK_OVERFLOW {fprintf(stderr, \
  "\nParser stack overflow\n");}
#endif

#ifndef REDUCTION_TOKEN_ERROR
#define REDUCTION_TOKEN_ERROR {fprintf(stderr, \
  "\nReduction token error\n");}
#endif


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];
}

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).token_number = (scr_token_type) (PCB).drt;
  (PCB).ssx = (PCB).dssx;
  (PCB).sn = (PCB).dsn;
  (PCB).drt = -1;
}



static const int ag_rtt[] = {
   16,  7,  4,  0, 14, 66,  0
};

static const unsigned char ag_tstt[] = {
58,27,11,6,0,1,2,3,4,7,8,9,10,12,13,16,20,37,38,39,71,72,73,74,75,76,
90,89,88,81,80,79,77,65,64,63,62,60,59,57,56,55,53,30,29,28,21,19,18,6,0,78,
90,89,88,81,80,79,77,65,64,63,62,60,59,57,56,55,53,30,29,28,21,19,18,6,0,78,
90,89,88,87,86,85,84,83,82,81,80,79,77,65,64,63,62,60,59,58,57,56,55,53,52,
  51,50,49,48,47,46,45,35,34,33,32,31,28,27,21,19,18,17,11,6,0,78,
90,89,88,87,86,85,84,83,82,81,80,79,77,65,64,63,62,60,59,58,57,56,55,53,52,
  51,50,49,48,47,46,45,35,34,33,32,31,28,27,21,19,18,17,11,6,0,78,
90,89,88,79,77,65,64,56,53,30,29,28,21,19,18,6,0,
90,89,88,79,77,65,64,63,62,60,59,30,29,28,18,6,0,
30,29,28,6,0,
90,89,88,79,77,65,64,30,29,28,18,6,0,
90,89,88,87,86,85,84,83,82,79,77,65,64,58,56,53,52,51,50,49,48,47,46,45,35,
  34,33,32,31,28,27,21,19,18,17,11,6,0,40,
90,89,88,87,86,85,84,83,82,81,80,79,77,65,64,63,62,60,59,58,57,56,55,53,52,
  51,50,49,48,47,46,45,35,34,33,32,31,28,27,21,19,18,17,11,6,0,36,40,78,
67,0,5,14,15,66,68,69,70,
90,89,88,79,77,58,56,53,52,51,50,49,48,47,46,45,35,34,33,32,31,28,27,21,18,
  17,11,6,0,3,8,9,12,13,22,23,25,41,42,44,71,72,73,
90,89,88,81,80,79,77,65,64,63,62,60,59,57,55,30,29,28,19,18,6,0,78,
90,89,88,81,80,79,77,65,64,63,62,60,59,57,55,30,29,28,19,18,6,0,78,
90,89,88,79,77,65,64,30,29,28,19,18,6,0,
90,89,88,79,77,65,64,63,62,60,59,30,29,28,21,19,18,6,0,
90,89,88,79,77,65,64,30,29,28,18,6,0,
90,89,88,79,77,65,64,63,62,60,59,57,56,55,53,30,29,28,21,19,18,6,0,
89,88,57,55,30,29,28,21,19,6,0,
90,89,88,79,77,65,64,56,53,30,29,28,21,18,6,0,
  0
};


static unsigned const char ag_astt[507] = {
  2,2,2,2,7,0,1,2,1,0,1,1,2,1,1,1,1,1,1,1,1,1,2,1,1,2,5,5,5,10,10,5,5,5,5,10,
  10,10,10,10,5,10,5,5,5,5,5,5,5,5,7,2,5,5,5,10,10,5,5,5,5,10,10,10,10,10,5,
  10,5,5,5,5,5,5,5,5,7,2,5,5,5,5,5,5,5,5,5,10,10,5,5,5,5,10,10,10,10,5,10,5,
  10,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,7,2,5,5,5,5,5,5,5,5,5,10,10,
  5,5,5,5,10,10,10,10,5,10,5,10,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,
  7,2,5,5,5,5,5,5,5,5,5,5,5,5,5,3,5,5,7,5,5,5,5,5,5,5,10,10,10,10,5,5,5,5,5,
  7,10,10,10,3,7,2,2,2,2,2,2,2,2,2,2,2,3,7,4,4,4,2,2,2,2,2,2,4,4,2,2,4,4,4,4,
  4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,3,4,4,4,4,7,2,4,4,4,10,10,10,10,10,10,10,10,
  4,4,10,10,10,10,10,10,4,10,4,10,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,10,4,4,4,
  4,7,2,2,2,2,7,1,1,1,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,2,2,
  2,2,2,2,3,7,3,1,1,1,1,2,2,2,2,2,3,1,1,2,5,5,5,10,10,5,5,5,5,10,10,10,10,10,
  10,5,5,5,5,5,5,7,2,5,5,5,10,10,5,5,5,5,10,10,10,10,10,10,5,5,5,5,5,5,7,2,5,
  5,5,5,5,5,5,5,5,5,3,5,5,7,5,5,5,5,5,5,5,10,10,10,10,5,5,5,2,2,5,5,7,2,2,2,
  2,2,2,2,2,2,2,2,3,7,5,5,5,5,5,5,5,10,10,10,10,2,5,2,5,5,5,5,5,2,5,5,7,2,2,
  2,2,10,10,10,2,2,3,7,2,2,2,2,2,2,2,2,2,2,2,2,2,2,3,7,11
};


static const unsigned char ag_pstt[] = {
63,24,8,4,0,0,12,4,11,0,8,7,13,6,5,10,9,10,10,10,2,1,92,4,3,95,
91,91,91,97,97,91,91,91,91,97,97,97,97,97,91,97,91,91,91,91,91,91,91,91,1,
  97,
90,90,90,99,99,90,90,90,90,99,99,99,99,99,90,99,90,90,90,90,90,90,90,90,2,
  99,
94,94,94,94,94,94,94,94,94,105,105,94,94,94,94,105,105,105,105,94,105,94,
  105,94,94,94,94,94,94,94,94,94,94,94,94,94,94,94,94,94,94,94,94,94,94,3,
  105,
93,93,93,93,93,93,93,93,93,107,107,93,93,93,93,107,107,107,107,93,107,93,
  107,93,93,93,93,93,93,93,93,93,93,93,93,93,93,93,93,93,93,93,93,93,93,4,
  107,
10,10,10,10,10,10,10,10,10,10,10,10,10,73,10,10,5,
9,9,9,9,9,9,9,70,69,65,64,9,9,9,9,9,6,
27,26,25,7,7,
66,66,66,98,96,72,71,68,67,66,66,6,8,
19,19,19,39,39,39,39,39,39,19,19,39,39,19,19,19,19,19,19,19,19,19,19,19,19,
  19,19,19,19,19,19,19,38,19,19,19,19,9,39,
18,18,18,34,34,34,34,34,34,34,34,18,18,34,34,34,34,34,34,18,34,18,34,18,18,
  18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,28,18,18,18,18,10,34,34,34,
76,11,17,16,15,74,14,13,89,
42,42,42,106,104,63,41,40,55,54,53,52,51,50,49,48,33,32,31,30,29,42,24,20,
  16,15,14,1,12,1,20,19,18,5,44,45,46,40,41,43,2,1,92,
88,88,88,101,101,88,88,88,88,101,101,101,101,101,101,88,88,88,88,88,88,13,
  101,
87,87,87,103,103,87,87,87,87,103,103,103,103,103,103,87,87,87,87,87,87,14,
  103,
12,12,12,12,12,12,12,12,12,12,81,12,12,15,
11,11,11,11,11,11,11,80,79,78,77,11,11,11,75,17,11,11,16,
82,82,82,102,100,86,85,84,83,82,82,2,17,
9,9,9,9,9,9,9,70,69,65,64,61,9,58,9,9,9,9,9,62,9,9,18,
23,22,22,23,27,26,25,21,47,7,19,
66,66,66,98,96,72,71,60,57,68,67,66,57,66,6,20,
  0
};


static const unsigned short ag_sbt[] = {
     0,  26,  52,  78, 125, 172, 189, 206, 211, 224, 263, 312, 321, 364,
   387, 410, 424, 443, 456, 479, 490, 506
};


static const unsigned short ag_sbe[] = {
     4,  50,  76, 123, 170, 188, 205, 210, 223, 261, 308, 313, 349, 385,
   408, 423, 442, 455, 478, 489, 505, 506
};


static const unsigned char ag_fl[] = {
  1,2,3,1,1,1,2,2,1,1,1,1,1,1,2,2,2,3,1,1,2,2,2,2,1,2,2,2,2,2,2,2,2,2,2,
  1,1,1,2,2,2,2,2,2,2,2,2,3,2,2,2,2,2,2,2,2,1,2,2,1,2,2,2,1,2,2,2,2,2,2,
  2,2,2,2,2,2,1,2,2,2,2,2,2,2,2,2,2,1,1,1,1,1,1,1,1,1,2,2,2,2,2,2,2,2,2,
  2,2,2,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1
};

static const unsigned char ag_ptt[] = {
    0,  1,  1,  1,  1,  3,  3,  3, 10,  8,  8,  5,  5, 16, 16, 16, 16, 16,
    2,  2, 16, 22, 23, 25,  9,  9,  9,  9, 16, 16, 16, 16, 16, 16, 16, 16,
   16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 37,
   38, 39, 41, 41, 41, 42, 42, 42, 44, 12, 12, 12, 12, 12, 12, 12, 12, 12,
   12, 12, 16, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 70, 70, 15,
   73, 73, 13, 76, 76, 20, 72, 72, 71, 71, 69, 69, 68, 68, 75, 75, 74, 74,
   78, 78, 78, 78, 78, 78, 78, 78, 36, 36, 40, 40, 40, 40, 40, 40, 40, 40
};

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 scr_change_reduction(scr_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((scr_token_type) *ag_tp)) ag_tp++;
  (PCB).reduction_token = (scr_token_type) *ag_tp;
}



static void near ag_ra(void)
{
  switch(ag_rpx[(PCB).ag_ap]) {
    case 1: ag_rp_1(); break;
    case 2: V(0,(dc * *)) = ag_rp_2(); break;
    case 3: V(0,(dc * *)) = ag_rp_3(); break;
    case 4: V(0,(dc * *)) = ag_rp_4(); break;
    case 5: V(0,(dc * *)) = ag_rp_5(); break;
    case 6: V(0,(dc * *)) = ag_rp_6(); break;
    case 7: V(0,(dc * *)) = ag_rp_7(V(1,(dc * *))); break;
    case 8: V(0,(dc * *)) = ag_rp_8(V(0,(dc * *))); break;
    case 9: V(0,(dc * *)) = ag_rp_9(V(0,(dc * *))); break;
    case 10: ag_default(&ag_rtt[0]); V(0,(dc * *)) = ag_rp_10(V(0,(dc * *))); break;
    case 11: V(0,(int *)) = ag_rp_11(V(0,(int *))); break;
    case 12: V(0,(int *)) = ag_rp_12(V(0,(int *))); break;
    case 13: V(0,(int *)) = ag_rp_13(V(0,(int *))); break;
    case 14: V(0,(int *)) = ag_rp_14(); break;
    case 15: V(0,(int *)) = ag_rp_15(V(0,(int *)), V(1,(int *))); break;
    case 16: V(0,(int *)) = ag_rp_16(V(0,(int *))); break;
    case 17: V(0,(int *)) = ag_rp_17(V(0,(int *))); break;
    case 18: V(0,(dc * *)) = ag_rp_18(V(0,(dc * *))); break;
    case 19: V(0,(dc * *)) = ag_rp_19(V(0,(dc * *))); break;
    case 20: V(0,(dc * *)) = ag_rp_20(); break;
    case 21: V(0,(dc * *)) = ag_rp_21(V(0,(dc * *))); break;
    case 22: V(0,(dc * *)) = ag_rp_22(V(0,(dc * *))); break;
    case 23: V(0,(dc * *)) = ag_rp_23(V(0,(dc * *))); break;
    case 24: V(0,(dc * *)) = ag_rp_24(V(0,(dc * *)), V(1,(int *))); break;
    case 25: V(0,(dc * *)) = ag_rp_25(V(0,(dc * *)), V(1,(int *))); break;
    case 26: V(0,(dc * *)) = ag_rp_26(V(0,(dc * *))); break;
    case 27: V(0,(dc * *)) = ag_rp_27(V(0,(dc * *))); break;
    case 28: V(0,(dc * *)) = ag_rp_28(V(0,(dc * *)), V(1,(int *))); break;
    case 29: V(0,(dc * *)) = ag_rp_29(V(0,(dc * *)), V(1,(int *))); break;
    case 30: V(0,(dc * *)) = ag_rp_30(V(0,(dc * *)), V(1,(int *))); break;
    case 31: V(0,(dc * *)) = ag_rp_31(V(0,(dc * *)), V(1,(int *))); break;
    case 32: V(0,(dc * *)) = ag_rp_32(V(0,(dc * *))); break;
    case 33: V(0,(dc * *)) = ag_rp_33(V(0,(dc * *))); break;
    case 34: V(0,(dc * *)) = ag_rp_34(V(0,(dc * *))); break;
    case 35: V(0,(dc * *)) = ag_rp_35(V(0,(dc * *))); break;
    case 36: V(0,(dc * *)) = ag_rp_36(V(0,(dc * *))); break;
    case 37: V(0,(dc * *)) = ag_rp_37(V(0,(dc * *))); break;
    case 38: V(0,(dc * *)) = ag_rp_38(V(0,(dc * *))); break;
    case 39: V(0,(dc * *)) = ag_rp_39(V(0,(dc * *))); break;
    case 40: V(0,(dc * *)) = ag_rp_40(V(0,(dc * *))); break;
    case 41: V(0,(dc * *)) = ag_rp_41(V(0,(dc * *))); break;
    case 42: V(0,(dc * *)) = ag_rp_42(V(0,(dc * *))); break;
    case 43: V(0,(dc * *)) = ag_rp_43(V(0,(dc * *))); break;
    case 44: V(0,(dc * *)) = ag_rp_44(V(0,(dc * *))); break;
    case 45: V(0,(dc * *)) = ag_rp_45(V(0,(dc * *))); break;
    case 46: V(0,(dc * *)) = ag_rp_46(); break;
    case 47: V(0,(dc * *)) = ag_rp_47(V(0,(dc * *)), V(1,(int *))); break;
    case 48: V(0,(dc * *)) = ag_rp_48(V(0,(dc * *))); break;
    case 49: V(0,(dc * *)) = ag_rp_49(V(0,(dc * *)), V(1,(int *))); break;
    case 50: V(0,(dc * *)) = ag_rp_50(V(0,(dc * *))); break;
    case 51: V(0,(dc * *)) = ag_rp_51(V(0,(dc * *))); break;
    case 52: V(0,(dc * *)) = ag_rp_52(V(0,(dc * *)), V(1,(int *))); break;
    case 53: V(0,(dc * *)) = ag_rp_53(V(0,(dc * *))); break;
    case 54: V(0,(dc * *)) = ag_rp_54(V(0,(dc * *)), V(1,(int *))); break;
    case 55: V(0,(dc * *)) = ag_rp_55(V(0,(dc * *)), V(1,(int *))); break;
    case 56: V(0,(dc * *)) = ag_rp_56(V(1,(dc * *))); break;
    case 57: ag_default(&ag_rtt[4]); V(0,(dc * *)) = ag_rp_57(V(0,(dc * *))); break;
    case 58: V(0,(dc * *)) = ag_rp_58(); break;
    case 59: V(0,(dc * *)) = ag_rp_59(V(0,(dc * *)), V(1,(int *))); break;
    case 60: V(0,(dc * *)) = ag_rp_60(V(0,(dc * *))); break;
    case 61: V(0,(dc * *)) = ag_rp_61(V(0,(dc * *)), V(1,(int *))); break;
    case 62: V(0,(dc * *)) = ag_rp_62(V(0,(dc * *))); break;
    case 63: V(0,(dc * *)) = ag_rp_63(V(0,(dc * *)), V(1,(int *))); break;
    case 64: V(0,(dc * *)) = ag_rp_64(V(0,(dc * *))); break;
    case 65: V(0,(dc * *)) = ag_rp_65(V(0,(dc * *))); break;
    case 66: V(0,(dc * *)) = ag_rp_66(V(0,(dc * *)), V(1,(int *))); break;
    case 67: V(0,(dc * *)) = ag_rp_67(V(0,(dc * *)), V(1,(int *))); break;
    case 68: V(0,(dc * *)) = ag_rp_68(V(0,(dc * *))); break;
    case 69: V(0,(dc * *)) = ag_rp_69(V(0,(dc * *))); break;
    case 70: V(0,(dc * *)) = ag_rp_70(V(0,(dc * *))); break;
    case 71: V(0,(dc * *)) = ag_rp_71(V(0,(dc * *)), V(1,(int *))); break;
    case 72: V(0,(dc * *)) = ag_rp_72(V(0,(dc * *)), V(1,(int *))); break;
    case 73: V(0,(dc * *)) = ag_rp_73(V(0,(dc * *)), V(1,(int *))); break;
    case 74: V(0,(dc * *)) = ag_rp_74(V(0,(dc * *)), V(1,(int *))); break;
    case 75: V(0,(dc * *)) = ag_rp_75(V(0,(dc * *)), V(1,(int *))); break;
    case 76: V(0,(dc * *)) = ag_rp_76(V(0,(dc * *)), V(1,(int *))); break;
    case 77: V(0,(dc * *)) = ag_rp_77(V(0,(dc * *)), V(1,(int *))); break;
    case 78: V(0,(dc * *)) = ag_rp_78(V(0,(dc * *)), V(1,(int *))); break;
    case 79: V(0,(dc * *)) = ag_rp_79(V(0,(dc * *)), V(1,(int *))); break;
    case 80: V(0,(dc * *)) = ag_rp_80(V(0,(dc * *)), V(1,(int *))); break;
    case 81: V(0,(dc * *)) = ag_rp_81(V(0,(dc * *)), V(1,(int *))); break;
    case 82: V(0,(dc * *)) = ag_rp_82(V(0,(dc * *)), V(1,(int *))); break;
  }
}

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_action_10_proc(void) {
  (PCB).btsx = 0, (PCB).drt = -1;
  return 0;
}

static int near ag_action_11_proc(void) {
  (PCB).btsx = 0, (PCB).drt = -1;
  (*(int *) &(PCB).vs[(PCB).ssx]) = (PCB).input_code;
  (PCB).ssx--;
  ag_ra();
  (PCB).ssx++;
  return 0;
}

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 = (scr_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 = (scr_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 = (scr_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).input_code;
  (PCB).ss[(PCB).ssx] = (PCB).sn;
  (PCB).ssx++;
  (PCB).sn = (PCB).ag_ap;
  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).ss[(PCB).ssx] = (PCB).sn;
  (PCB).ssx++;
  (PCB).sn = (PCB).ag_ap;
  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).exit_flag = AG_SUCCESS_CODE;
  return 0;
}

static int near ag_action_1_proc(void) {
  (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 = (scr_token_type) ag_ptt[(PCB).ag_ap];
  (PCB).btsx = 0, (PCB).drt = -1;
  (*(int *) &(PCB).vs[(PCB).ssx]) = (PCB).input_code;
  if (ag_sd) (PCB).sn = (PCB).ss[(PCB).ssx -= ag_sd];
  else (PCB).ss[(PCB).ssx] = (PCB).sn;
  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 ((ag_s_procs_scan[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).input_code;
  if (ag_sd) (PCB).sn = (PCB).ss[(PCB).ssx -= ag_sd];
  else (PCB).ss[(PCB).ssx] = (PCB).sn;
  (PCB).reduction_token = (scr_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 ((ag_s_procs_scan[ag_astt[ag_t1]])() == 0) break;
  }
  return 0;
}

static int near ag_action_8_proc(void) {
  ag_undo();
  (PCB).exit_flag = AG_SYNTAX_ERROR_CODE;
  SYNTAX_ERROR;
  
  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 {
    (PCB).ss[(PCB).ssx] = (PCB).sn;
  }
  (PCB).reduction_token = (scr_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 ((ag_r_procs_scan[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 = (scr_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;
  }
  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 ((ag_r_procs_scan[ag_astt[ag_t1]])() == 0) break;
  }
  return (PCB).exit_flag == AG_RUNNING_CODE;
}


void init_scr(void) {
  unsigned ag_t1;
  ag_t1 = 0;
  (PCB).error_message = "Syntax Error";
  (PCB).ss[0] = (PCB).sn = (PCB).ssx = 0;
  (PCB).exit_flag = AG_RUNNING_CODE;
  (PCB).btsx = 0, (PCB).drt = -1;
  while (ag_tstt[ag_t1] == 0) {
    (PCB).ag_ap = ag_pstt[ag_t1];
    (ag_gt_procs_scan[ag_astt[ag_t1]])();
    ag_t1 = ag_sbt[(PCB).sn];
  }
}

void scr(void) {
  (PCB).token_number = (scr_token_type) AG_TCV((PCB).input_code);
  while (1) {
    unsigned ag_t1 = ag_sbt[(PCB).sn];
    unsigned ag_t2 = ag_sbe[(PCB).sn] - 1;
    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];
    if ((ag_gt_procs_scan[ag_astt[ag_t1]])() == 0) break;
  }
}