view tests/agcl/contrib/good/parse.c @ 6:607e3be6bad8

Adjust to the moving target called the C++ standard. Apparently nowadays it's not allowed to define an explicit copy constructor but not an assignment operator. Consequently, defining the explicit copy constructor in terms of the implicit/automatic assignment operator for general convenience no longer works. Add assignment operators. Caution: not tested with the IBM compiler, but there's no particular reason it shouldn't work.
author David A. Holland
date Mon, 30 May 2022 23:46:22 -0400
parents 13d2b8934445
children
line wrap: on
line source

/*
 * AnaGram, A System for Syntax Directed Programming
 * Copyright 1993-1994 Steve Holland. All rights reserved.
 * See the file COPYING for license and usage terms.
 */
/* Embedded C code */
#include <exec/lists.h>
#include <intuition/classes.h>
#include <proto/intuition.h>
#include "OOLib.h"
#include "Expr.h"
#include "PushString.h"
#include "ClassManager.h"
#include "Driver/VariableClass.h"
#include "Number.h"
#include "Util.h"

struct List ExprList;

#define SYNTAX_ERROR fprintf(stderr,"%s, line %d, column %d\n",  (PCB).error_message, (PCB).line, (PCB).column)
#define PARSER_STACK_OVERFLOW {fprintf(stderr,   "\nParser stack overflow, line %d, column %d\n",   (PCB).line, (PCB).column);}
#define REDUCTION_TOKEN_ERROR {fprintf(stderr,    "\nReduction token error, line %d, column %d\n",    (PCB).line, (PCB).column);}

Object *VariableProto=NULL; /* remember to initialize this */

void Prepare_parse(void)
{
  VariableProto=NewObject(FindOOClass("numberclass"),NULL,NM_ID,VARIABLECLASS_ID,TAG_END);
  if (!VariableProto) Warning(183,"Unable to create prototype variable object");
  if (!ExprList.lh_Head) NewList(&ExprList);
}

void End_parse(void)
{
  if (VariableProto) DisposeObject(VariableProto);
  VariableProto=NULL;
}


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

#ifndef PARSE_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])



parse_pcb_type parse_pcb;
#define PCB parse_pcb

#ifndef CONVERT_CASE

static const char agCaseTable[31] = {
  0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
  0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
  0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,    0,
  0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20
};

static int agConvertCase(int c) {
  if (c >= 'a' && c <= 'z') return c ^= 0x20;
  if (c >= 0xe0 && c < 0xff) c ^= agCaseTable[c-0xe0];
  return c;
}

#define CONVERT_CASE(c) agConvertCase(c)

#endif


#ifndef TAB_SPACING
#define TAB_SPACING 8
#endif

static void ag_rp_1(void) {
#line - "parse.syn"
  PCB.exit_flag=AG_SUCCESS_CODE;
#line - "parse.c"
}

static void ag_rp_2(void) {
#line - "parse.syn"
                     Object *Result;
                     struct ExprNode *Node;
                     char *String=NULL;
                     Result=EvalExpr(&ExprList);
                     if (Result) {
                       GetAttr(NM_NumberString,Result,(ULONG *)&String);
                       if (String) printf("%s\n",String);
                       DisposeObject(Result);
                     }

                     while (Node=(struct ExprNode *)RemHead(&ExprList)) {
                       if (Node->Op != OP_FUNC && Node->Data) DisposeObject(Node->Data);
                       Free(Node);
                     }
                  
#line - "parse.c"
}

static void ag_rp_3(int a) {
#line - "parse.syn"
ReverseTopExprStack(&ExprList,a);Push(&ExprList,OP_GROUP,a,NULL);
#line - "parse.c"
}

static void ag_rp_4(void) {
#line - "parse.syn"
struct Locale *Locale;DoMethod(VariableProto,VCM_NEWLOCALE,&Locale);
#line - "parse.c"
}

static struct LocaleNode * ag_rp_5(void) {
#line - "parse.syn"
struct LocaleNode *Locale;DoMethod(VariableProto,VCM_TAKELOCALE,NULL,&Locale);return Locale;
#line - "parse.c"
}

static void ag_rp_6(struct String * Str) {
#line - "parse.syn"
                               if (Str && GetString(Str)) {
                                 NewObject(FindOOClass("numberclass"),NULL,
                                   NM_ID,VARIABLECLASS_ID,
                                   VA_Create,TRUE,
                                   NM_NumberString,GetString(Str),
                                   VA_NoObject,TRUE,
                                   TAG_END);
                                 DeleteString(Str);
                               }
                               else ParsePanic(PP_MEM);
                             
#line - "parse.c"
}

static void ag_rp_7(struct String * Str, Object * Num) {
#line - "parse.syn"
                               Object *Const;
                               if (Str && GetString(Str)) {
                                 Const=NewObject(FindOOClass("numberclass"),NULL,
                                   NM_ID,VARIABLECLASS_ID,
                                   NM_NumberString,GetString(Str),
                                   VA_Constant,TRUE,
                                   VA_Create,TRUE,
                                   TAG_END);
                                 DeleteString(Str);
                                 if (Const && Num) DoMethod(Const,VCM_ASSIGNFORCE,Num);
                                 if (Const) DisposeObject(Const);
                               }
                               else ParsePanic(PP_MEM);
                               if (Num) DisposeObject(Num);
                             
#line - "parse.c"
}

static void ag_rp_8(struct String * Str) {
#line - "parse.syn"
                               if (Str && GetString(Str)) {
                                 NewObject(FindOOClass("numberclass"),NULL,
                                   NM_ID,VARIABLECLASS_ID,
                                   VA_Create,TRUE,
                                   NM_NumberString,GetString(Str),
                                   VA_NoObject,TRUE,
                                   TAG_END);
                                 DeleteString(Str);
                               }
                               else ParsePanic(PP_MEM);
                             
#line - "parse.c"
}

static void ag_rp_9(struct String * Str) {
#line - "parse.syn"
                               if (Str && GetString(Str)) {
                                 NewObject(FindOOClass("numberclass"),NULL,
                                   NM_ID,VARIABLECLASS_ID,
                                   NM_NumberString,GetString(Str),
                                   VA_ByReference,TRUE,
                                   VA_Create,TRUE,
                                   VA_NoObject,TRUE,
                                   TAG_END);
                                 DeleteString(Str);
                               }
                               else ParsePanic(PP_MEM);
                             
#line - "parse.c"
}

static void ag_rp_10(struct String * Str, Object * Num) {
#line - "parse.syn"
                               Object *Const;
                               if (Str && GetString(Str)) {
                                 Const=NewObject(FindOOClass("numberclass"),NULL,
                                   NM_ID,VARIABLECLASS_ID,
                                   NM_NumberString,GetString(Str),
                                   VA_Constant,TRUE,
                                   VA_Create,TRUE,
                                   TAG_END);
                                 if (Const && Num) DoMethod(Const,VCM_ASSIGNFORCE,Num);
                                 if (Const) DisposeObject(Const);
                                 DeleteString(Str);
                                 
                               }
                               else ParsePanic(PP_MEM);
                               if (Num) DisposeObject(Num);
                             
#line - "parse.c"
}

static void ag_rp_11(void) {
#line - "parse.syn"
ReverseTopExprStack(&ExprList,2);Push(&ExprList,OP_FUNC,2,FUNC_GT);
#line - "parse.c"
}

static void ag_rp_12(void) {
#line - "parse.syn"
ReverseTopExprStack(&ExprList,2);Push(&ExprList,OP_FUNC,2,FUNC_LT);
#line - "parse.c"
}

static void ag_rp_13(void) {
#line - "parse.syn"
ReverseTopExprStack(&ExprList,2);Push(&ExprList,OP_FUNC,2,FUNC_COMP);
#line - "parse.c"
}

static void ag_rp_14(void) {
#line - "parse.syn"
ReverseTopExprStack(&ExprList,2);Push(&ExprList,OP_FUNC,2,FUNC_GTEQ);
#line - "parse.c"
}

static void ag_rp_15(void) {
#line - "parse.syn"
ReverseTopExprStack(&ExprList,2);Push(&ExprList,OP_FUNC,2,FUNC_LTEQ);
#line - "parse.c"
}

static int ag_rp_16(void) {
#line - "parse.syn"
  return 1;
#line - "parse.c"
}

static int ag_rp_17(void) {
#line - "parse.syn"
  return 1;
#line - "parse.c"
}

static int ag_rp_18(int n) {
#line - "parse.syn"
  return n+1;
#line - "parse.c"
}

static void ag_rp_19(Object * s) {
#line - "parse.syn"
Push(&ExprList,OP_ASSIGN,0,s);
#line - "parse.c"
}

static void ag_rp_20(struct String * f, unsigned n) {
#line - "parse.syn"
ReverseTopExprStack(&ExprList,n);Push(&ExprList,OP_FUNC,n,GetString(f));DeleteString(f);
#line - "parse.c"
}

static void ag_rp_21(void) {
#line - "parse.syn"
ReverseTopExprStack(&ExprList,2);Push(&ExprList,OP_FUNC,2,FUNC_ADD);
#line - "parse.c"
}

static void ag_rp_22(void) {
#line - "parse.syn"
ReverseTopExprStack(&ExprList,2);Push(&ExprList,OP_FUNC,2,FUNC_SUB);
#line - "parse.c"
}

static unsigned ag_rp_23(void) {
#line - "parse.syn"
  return 0;
#line - "parse.c"
}

static unsigned ag_rp_24(void) {
#line - "parse.syn"
return 1;
#line - "parse.c"
}

static unsigned ag_rp_25(unsigned a) {
#line - "parse.syn"
  return a+1;
#line - "parse.c"
}

static void ag_rp_26(void) {
#line - "parse.syn"
ReverseTopExprStack(&ExprList,2);Push(&ExprList,OP_FUNC,2,FUNC_MUL);
#line - "parse.c"
}

static void ag_rp_27(void) {
#line - "parse.syn"
ReverseTopExprStack(&ExprList,2);Push(&ExprList,OP_FUNC,2,FUNC_DIV);
#line - "parse.c"
}

static void ag_rp_28(void) {
#line - "parse.syn"
  Push(&ExprList,OP_FUNC,1,FUNC_OPPOSITE);
#line - "parse.c"
}

static void ag_rp_29(void) {
#line - "parse.syn"
ReverseTopExprStack(&ExprList,2);Push(&ExprList,OP_FUNC,2,FUNC_POW);
#line - "parse.c"
}

static void ag_rp_30(Object * Vari) {
#line - "parse.syn"
  Push(&ExprList,OP_VAR,1,Vari);
#line - "parse.c"
}

static Object * ag_rp_31(struct String * Str) {
#line - "parse.syn"
                               Object *Result;
                               if (Str && GetString(Str)) {
                                 DiscardBlanks(Str);
                                 Result=NewObject(FindOOClass("numberclass"),NULL,
                                   NM_NumberString,GetString(Str),
                                   TAG_END);
                                 DeleteString(Str);
                                 if (Result) return Result;
                               }
                               ParsePanic(PP_MEM);
                               return NULL;
                             
#line - "parse.c"
}

static struct String * ag_rp_32(struct String * s) {
#line - "parse.syn"
  return s;
#line - "parse.c"
}

static struct String * ag_rp_33(int c) {
#line - "parse.syn"
struct String *String;String=CreateString();StringInsChar(String,strlen(GetString(String)),c);return String;
#line - "parse.c"
}

static struct String * ag_rp_34(struct String * String, int c) {
#line - "parse.syn"
  return StringInsChar(String,strlen(GetString(String)),c);
#line - "parse.c"
}

static struct String * ag_rp_35(struct String * String, int c) {
#line - "parse.syn"
  return StringInsChar(String,strlen(GetString(String)),c);
#line - "parse.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 parse_vs_type const ag_null_value NULL_VALUE_INITIALIZER;

static const unsigned char ag_rpx[] = {
    0,  0,  0,  0,  0,  0,  0,  0,  1,  2,  3,  4,  5,  0,  0,  0,  6,  7,
    8,  9, 10,  0, 11, 12, 13, 14, 15, 16, 17, 18,  0, 19, 20,  0, 21, 22,
   23, 24, 25,  0, 26, 27,  0, 28, 29,  0, 30,  0, 31, 32, 33, 34, 35
};

static const unsigned char ag_key_itt[] = {
 0
};

static const unsigned short ag_key_pt[] = {
0
};

static const unsigned char ag_key_ch[] = {
    0, 47, 68, 80, 81, 86,255, 47, 61, 67, 68, 80, 81, 86,255, 68, 80, 81,
   86,255, 42,255, 47, 67, 86,255, 47,255, 47, 61,255, 61,255, 47, 67,255,
   67,255, 47, 61, 67, 86,255, 67, 86,255
};

static const unsigned char ag_key_act[] = {
  0,3,3,3,3,3,4,3,3,3,3,3,3,3,4,3,3,3,3,4,3,4,3,3,3,4,3,4,3,3,4,3,4,3,3,
  4,3,4,3,3,3,3,4,3,3,4
};

static const unsigned char ag_key_parm[] = {
    0, 46, 59, 60, 62, 61,  0, 46, 68, 65, 59, 60, 62, 61,  0, 59, 60, 62,
   61,  0, 49,  0, 46, 65, 61,  0, 46,  0, 46, 68,  0, 68,  0, 46, 65,  0,
   65,  0, 46, 68, 65, 61,  0, 65, 61,  0
};

static const unsigned char ag_key_jmp[] = {
    0,  0,  2,  8, 13, 17,  0, 20, 22, 24, 29, 35, 40, 44,  0, 47, 53, 58,
   62,  0, 65,  0, 67, 69, 74,  0, 77,  0, 79, 81,  0, 83,  0, 85, 87,  0,
   92,  0, 97, 99,101,106,  0,109,114,  0
};

static const unsigned char ag_key_index[] = {
    1,  0,  7, 15, 20, 22, 26,  0, 28,  0, 28, 31, 31, 31, 31, 31, 26, 33,
   26, 26, 31, 36,  0,  0,  0, 15, 31,  0, 31, 26,  0,  0, 26,  0, 26,  0,
   26,  0,  0, 26,  0, 26,  0, 26,  0, 26,  0, 26,  0,  0,  1, 26,  0, 38,
    0,  0, 31, 31, 31,  0,  0,  0, 43, 22,  0,  0, 43,  0,  0,  0,  0, 43,
    0, 43,  0,  0,  0
};

static const unsigned char ag_key_ends[] = {
42,0, 69,70,73,78,69,0, 82,73,78,84,0, 85,73,84,0, 65,82,0, 
42,0, 61,0, 79,78,83,84,0, 69,70,73,78,69,0, 82,73,78,84,0, 
85,73,84,0, 65,82,0, 69,70,73,78,69,0, 82,73,78,84,0, 85,73,84,0, 
65,82,0, 47,0, 42,0, 79,78,83,84,0, 65,82,0, 42,0, 42,0, 61,0, 
61,0, 42,0, 79,78,83,84,0, 79,78,83,84,0, 42,0, 61,0, 
79,78,83,84,0, 65,82,0, 79,78,83,84,0, 65,82,0, 
};
#define AG_TCV(x) (((int)(x) >= 0 && (int)(x) <= 308) ? ag_tcv[(x)] : 0)

static const unsigned char ag_tcv[] = {
   54, 50, 50, 50, 50, 50, 50, 50, 50, 44, 51, 50, 50, 51, 50, 50, 50, 50,
   50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 44, 50, 50, 50,
   50, 50, 50, 50, 57, 56, 71, 69, 63, 70, 50, 72, 50, 50, 50, 50, 50, 50,
   50, 50, 50, 50, 50, 55, 67, 64, 66, 50, 50, 50, 50, 50, 50, 50, 50, 50,
   50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50,
   50, 50, 50, 50, 73, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50,
   50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50,
   50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50,
   50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50,
   50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50,
   50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50,
   50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50,
   50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50,
   50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50,
   50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50,
   50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50,
   50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50,
   50, 50, 50
};

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

#ifndef FIRST_LINE
#define FIRST_LINE 1
#endif

#ifndef FIRST_COLUMN
#define FIRST_COLUMN 1
#endif

#ifndef PARSER_STACK_OVERFLOW
#define PARSER_STACK_OVERFLOW {fprintf(stderr, \
   "\nParser stack overflow, line %d, column %d\n",\
   (PCB).line, (PCB).column);}
#endif

#ifndef REDUCTION_TOKEN_ERROR
#define REDUCTION_TOKEN_ERROR {fprintf(stderr, \
    "\nReduction token error, line %d, column %d\n", \
    (PCB).line, (PCB).column);}
#endif


typedef enum
  {ag_accept_key, ag_set_key, ag_jmp_key, ag_end_key, ag_no_match_key,
   ag_cf_accept_key, ag_cf_set_key, ag_cf_end_key} key_words;

#ifndef GET_INPUT
#define GET_INPUT ((PCB).input_code = getchar())
#endif


static int ag_look_ahead(void) {
  if ((PCB).rx < (PCB).fx) {
    return CONVERT_CASE((PCB).lab[(PCB).rx++]);
  }
  GET_INPUT;
  (PCB).fx++;
  return CONVERT_CASE((PCB).lab[(PCB).rx++] = (PCB).input_code);
}

static void ag_get_key_word(int ag_k) {
  int save_index = (PCB).rx;
  const  unsigned char *sp;
  int ag_ch;
  while (1) {
    switch (ag_key_act[ag_k]) {
    case ag_cf_end_key:
      sp = ag_key_ends + ag_key_jmp[ag_k];
      do {
        if ((ag_ch = *sp++) == 0) {
          int ag_k1 = ag_key_parm[ag_k];
          int ag_k2 = ag_key_pt[ag_k1];
          if (ag_key_itt[ag_k2 + ag_look_ahead()]) goto ag_fail;
          (PCB).rx--;
          (PCB).token_number = (parse_token_type) ag_key_pt[ag_k1 + 1];
          return;
        }
      } while (ag_look_ahead() == ag_ch);
      goto ag_fail;
    case ag_end_key:
      sp = ag_key_ends + ag_key_jmp[ag_k];
      do {
        if ((ag_ch = *sp++) == 0) {
          (PCB).token_number = (parse_token_type) ag_key_parm[ag_k];
          return;
        }
      } while (ag_look_ahead() == ag_ch);
    case ag_no_match_key:
ag_fail:
      (PCB).rx = save_index;
      return;
    case ag_cf_set_key: {
      int ag_k1 = ag_key_parm[ag_k];
      int ag_k2 = ag_key_pt[ag_k1];
      ag_k = ag_key_jmp[ag_k];
      if (ag_key_itt[ag_k2 + (ag_ch = ag_look_ahead())]) break;
      save_index = --(PCB).rx;
      (PCB).token_number = (parse_token_type) ag_key_pt[ag_k1+1];
      break;
    }
    case ag_set_key:
      save_index = (PCB).rx;
      (PCB).token_number = (parse_token_type) ag_key_parm[ag_k];
    case ag_jmp_key:
      ag_k = ag_key_jmp[ag_k];
      ag_ch = ag_look_ahead();
      break;
    case ag_accept_key:
      (PCB).token_number =  (parse_token_type) ag_key_parm[ag_k];
      return;
    case ag_cf_accept_key: {
      int ag_k1 = ag_key_parm[ag_k];
      int ag_k2 = ag_key_pt[ag_k1];
      if (ag_key_itt[ag_k2 + ag_look_ahead()]) (PCB).rx = save_index;
      else {
        (PCB).rx--;
        (PCB).token_number =  (parse_token_type) ag_key_pt[ag_k1+1];
      }
      return;
    }
    default:
      /* not reachable; here to suppress compiler warnings */
      goto ag_fail;
    }
    if (ag_ch <= 255) while (ag_key_ch[ag_k] < ag_ch) ag_k++;
    if (ag_ch > 255 || ag_key_ch[ag_k] != ag_ch) {
      (PCB).rx = save_index;
      return;
    }
  }
}


#ifndef AG_NEWLINE
#define AG_NEWLINE 10
#endif

#ifndef AG_RETURN
#define AG_RETURN 13
#endif

#ifndef AG_FORMFEED
#define AG_FORMFEED 12
#endif

#ifndef AG_TABCHAR
#define AG_TABCHAR 9
#endif

static void ag_track(void) {
  int ag_k = 0;
  while (ag_k < (PCB).rx) {
    int ag_ch = (PCB).lab[ag_k++];
    switch (ag_ch) {
    case AG_NEWLINE:
      (PCB).column = 1, (PCB).line++;
    case AG_RETURN:
    case AG_FORMFEED:
      break;
    case AG_TABCHAR:
      (PCB).column += (TAB_SPACING) - ((PCB).column - 1) % (TAB_SPACING);
      break;
    default:
      (PCB).column++;
    }
  }
  ag_k = 0;
  while ((PCB).rx < (PCB).fx) (PCB).lab[ag_k++] = (PCB).lab[(PCB).rx++];
  (PCB).fx = ag_k;
  (PCB).rx = 0;
}


static void ag_prot(void) {
  int ag_k;
  ag_k = 1000 - ++(PCB).btsx;
  if (ag_k <= (PCB).ssx) {
    (PCB).exit_flag = AG_STACK_ERROR_CODE;
    PARSER_STACK_OVERFLOW;
    return;
  }
  (PCB).bts[(PCB).btsx] = (PCB).sn;
  (PCB).bts[ag_k] = (PCB).ssx;
  (PCB).vs[ag_k] = (PCB).vs[(PCB).ssx];
  (PCB).ss[ag_k] = (PCB).ss[(PCB).ssx];
}

static void ag_undo(void) {
  if ((PCB).drt == -1) return;
  while ((PCB).btsx) {
    int ag_k = 1000 - (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 = (parse_token_type) (PCB).drt;
  (PCB).ssx = (PCB).dssx;
  (PCB).sn = (PCB).dsn;
  (PCB).drt = -1;
}


static const unsigned char ag_tstt[] = {
73,70,62,61,60,59,57,51,50,46,44,0,1,52,53,
73,72,71,70,69,67,66,64,63,57,56,55,51,50,44,0,48,
51,46,44,0,1,
73,70,62,61,60,59,57,50,0,2,3,4,5,6,8,10,11,15,16,18,19,27,28,32,33,35,37,
  38,40,58,
73,72,71,70,69,67,66,64,63,57,56,55,51,50,49,44,0,
73,70,65,63,61,57,56,51,50,46,44,0,1,52,53,
73,70,57,51,50,46,44,0,1,52,53,
73,70,57,50,0,2,3,11,14,19,20,27,28,32,33,35,37,38,40,58,
73,50,44,0,
73,70,57,50,0,2,3,11,27,33,37,38,40,58,
73,72,71,70,69,68,67,66,64,63,57,56,55,51,50,46,44,0,1,52,53,
73,0,42,
57,0,11,
72,71,0,39,41,
64,0,26,
70,69,0,36,37,
55,51,46,44,0,1,52,53,
73,65,51,50,46,44,0,1,52,53,
73,51,50,46,44,0,1,52,53,
73,51,50,46,44,0,1,52,53,
68,67,66,0,29,30,31,
73,65,50,0,2,3,17,25,58,
73,50,0,2,3,58,
73,50,0,2,3,58,
55,0,9,
73,70,62,61,60,59,57,54,50,0,2,3,5,7,8,10,11,15,16,18,19,27,28,32,33,35,37,
  38,40,58,
68,67,66,55,0,9,29,30,31,
56,0,13,
73,0,42,
73,57,51,50,46,44,0,1,52,53,
73,57,50,0,2,3,11,27,33,40,58,
73,70,57,56,50,0,2,3,11,14,19,20,27,28,32,33,34,35,37,38,40,58,
73,57,51,50,46,44,0,1,52,53,
73,57,50,0,2,3,11,27,33,40,58,
73,57,51,50,46,44,0,1,52,53,
73,57,50,0,2,3,11,27,33,40,58,
73,70,57,51,50,46,44,0,1,52,53,
73,70,57,50,0,2,3,11,27,32,33,35,37,38,40,58,
73,70,57,50,0,2,3,11,27,33,35,37,38,40,58,
73,70,57,51,50,46,44,0,1,52,53,
73,70,57,50,0,2,3,11,27,33,35,37,38,40,58,
73,70,57,51,50,46,44,0,1,52,53,
73,70,57,50,0,2,3,11,27,28,32,33,35,37,38,40,58,
73,70,64,57,51,50,46,44,0,1,52,53,
73,70,64,57,50,0,2,3,11,26,27,28,32,33,35,37,38,40,58,
73,70,64,57,51,50,46,44,0,1,52,53,
73,70,64,57,50,0,2,3,11,26,27,28,32,33,35,37,38,40,58,
73,51,50,46,44,0,1,52,53,
73,50,0,2,3,58,
57,0,11,
73,70,63,62,61,60,59,57,56,54,51,50,46,44,0,1,52,53,
51,46,44,0,1,52,53,
73,70,57,50,0,2,3,11,19,20,27,28,32,33,35,37,38,40,58,
73,72,71,70,69,68,67,66,65,63,61,57,56,55,51,50,46,44,0,1,52,53,
63,0,24,
56,0,13,
70,69,0,36,37,
72,71,0,39,41,
72,71,0,39,41,
73,70,57,50,0,2,3,11,27,28,32,33,35,37,38,40,58,
73,70,57,50,0,2,3,11,27,28,32,33,35,37,38,40,58,
64,0,26,
73,65,63,61,56,50,0,12,21,
73,70,65,61,57,56,51,50,46,44,0,1,52,53,
73,70,57,56,50,0,2,3,11,14,19,20,27,28,32,33,34,35,37,38,40,58,
73,50,0,2,3,27,58,
73,65,63,61,57,56,50,0,2,3,16,22,23,25,58,
56,0,13,
73,50,0,2,3,58,
73,50,0,2,3,58,
63,0,24,
73,65,63,61,57,50,0,12,21,
73,50,0,2,3,27,58,
73,65,61,50,0,2,3,16,23,25,58,
57,0,11,
73,70,57,50,0,2,3,11,14,19,20,27,28,32,33,35,37,38,40,58,
56,0,13,

};


static unsigned const char ag_astt[823] = {
  8,8,8,8,8,8,8,1,8,1,1,7,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,7,1,9,1,9,5,3,
  2,1,1,1,1,1,1,2,7,1,1,0,1,1,1,1,1,1,1,2,1,1,1,1,1,1,1,1,1,1,9,9,9,9,9,9,9,
  9,9,9,9,9,9,9,3,9,7,5,5,5,5,5,5,5,1,5,1,1,7,1,1,3,5,5,5,1,5,1,1,7,1,1,3,2,
  1,1,2,7,1,1,1,1,1,2,1,1,1,1,1,1,1,1,1,10,10,10,4,2,1,1,2,7,1,1,1,2,1,1,1,1,
  1,5,5,5,5,5,5,5,5,5,5,5,5,5,1,5,1,1,7,1,1,3,1,5,1,1,4,1,1,1,5,1,1,1,4,1,1,
  1,5,1,1,5,1,1,1,7,1,1,3,5,5,1,5,1,1,7,1,1,3,5,1,5,1,1,7,1,1,3,5,1,5,1,1,7,
  1,1,3,1,1,1,4,1,1,1,2,1,2,7,2,1,3,1,1,2,2,7,3,1,1,2,2,7,1,1,1,1,7,3,2,1,1,
  1,1,1,1,1,2,7,1,1,3,3,1,1,1,1,1,2,1,1,1,1,1,1,1,1,1,1,1,1,1,1,4,1,1,1,1,1,
  7,3,1,4,1,5,5,1,5,1,1,7,1,1,3,2,1,2,7,1,1,1,2,2,2,1,2,1,1,4,2,7,1,1,1,1,1,
  2,1,1,1,1,1,1,1,1,1,1,5,5,1,5,1,1,7,1,1,3,2,1,2,7,1,1,1,2,2,2,1,5,5,1,5,1,
  1,7,1,1,3,2,1,2,7,1,1,1,2,2,2,1,5,5,5,1,5,1,1,7,1,1,3,2,1,1,2,7,1,1,1,2,1,
  1,1,1,1,1,1,2,1,1,2,7,1,1,1,2,1,1,1,1,1,1,5,5,5,1,5,1,1,7,1,1,3,2,1,1,2,7,
  1,1,1,2,1,1,1,1,1,1,5,5,5,1,5,1,1,7,1,1,3,2,1,1,2,7,1,1,1,1,2,1,1,1,1,1,1,
  1,5,5,5,5,1,5,1,1,7,1,1,3,2,1,1,1,2,7,1,1,1,1,1,2,1,1,1,1,1,1,1,5,5,5,5,1,
  5,1,1,7,1,1,3,2,1,1,1,2,7,1,1,1,1,1,2,1,1,1,1,1,1,1,5,1,5,1,1,7,1,1,3,2,2,
  7,1,1,1,1,7,1,5,5,5,5,5,5,5,5,5,5,1,5,1,1,7,1,1,3,1,1,1,5,1,1,3,2,1,1,2,4,
  1,1,1,1,2,1,1,1,1,1,1,1,1,1,5,5,5,5,5,5,5,5,5,5,5,5,5,5,1,5,1,1,7,1,1,3,1,
  4,1,1,7,2,1,1,4,1,1,1,1,4,1,1,1,1,4,1,1,2,1,1,2,7,1,1,1,1,2,1,1,1,1,1,1,1,
  2,1,1,2,7,1,1,1,1,2,1,1,1,1,1,1,1,1,7,1,4,4,4,4,4,4,7,1,1,5,5,5,5,5,5,1,5,
  1,1,7,1,1,3,2,1,1,4,2,7,1,1,1,1,1,2,1,1,1,1,2,1,1,1,1,1,2,2,7,2,1,2,1,2,1,
  8,1,5,5,2,7,2,1,1,1,1,1,1,1,7,1,2,2,7,1,1,1,2,2,7,2,1,1,1,4,1,4,4,4,4,4,4,
  7,1,1,2,2,7,2,1,2,1,2,1,1,2,7,2,1,1,3,1,1,1,7,1,2,1,1,2,7,1,1,1,1,1,2,1,1,
  1,1,1,1,1,1,1,1,7,3
};


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

};


static const unsigned short ag_sbt[] = {
     0,  15,  32,  37,  67,  84,  99, 110, 130, 134, 148, 169, 172, 175,
   180, 183, 188, 196, 206, 215, 224, 231, 240, 246, 252, 255, 285, 294,
   297, 300, 310, 321, 343, 353, 364, 374, 385, 396, 412, 427, 438, 453,
   464, 481, 493, 512, 524, 543, 552, 558, 561, 579, 586, 605, 627, 630,
   633, 638, 643, 648, 665, 682, 685, 694, 708, 730, 737, 752, 755, 761,
   767, 770, 779, 786, 797, 800, 820, 823
};


static const unsigned short ag_sbe[] = {
    11,  30,  35,  45,  83,  95, 106, 114, 133, 138, 165, 170, 173, 177,
   181, 185, 192, 202, 211, 220, 227, 234, 242, 248, 253, 264, 289, 295,
   298, 306, 313, 326, 349, 356, 370, 377, 392, 400, 416, 434, 442, 460,
   468, 489, 498, 520, 529, 548, 554, 559, 575, 582, 590, 623, 628, 631,
   635, 640, 645, 652, 669, 683, 691, 704, 713, 732, 744, 753, 757, 763,
   768, 776, 781, 790, 798, 804, 821, 823
};


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

static const unsigned char ag_ptt[] = {
    0,  6,  6,  4,  5,  8,  8,  8,  8,  8, 14, 21, 12, 22, 22, 22, 17, 17,
   23, 23, 23, 19, 19, 19, 19, 19, 19, 20, 20, 20, 28, 28, 33, 32, 32, 32,
   34, 34, 34, 35, 35, 35, 38, 38, 38, 40, 40, 40, 27, 58,  3,  3,  3,  1,
   48, 48,  1, 43, 43, 45, 45, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47,
   47, 47, 47, 47, 52, 52, 53, 53,  7,  9, 13, 11,  2, 10, 15, 16, 18, 24,
   26, 25, 29, 30, 31, 36, 37, 39, 41, 42
};


static void 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(V(0,(int *))); break;
    case 4: ag_rp_4(); break;
    case 5: V(0,(struct LocaleNode * *)) = ag_rp_5(); break;
    case 6: ag_rp_6(V(0,(struct String * *))); break;
    case 7: ag_rp_7(V(1,(struct String * *)), V(3,(Object * *))); break;
    case 8: ag_rp_8(V(0,(struct String * *))); break;
    case 9: ag_rp_9(V(1,(struct String * *))); break;
    case 10: ag_rp_10(V(1,(struct String * *)), V(2,(Object * *))); break;
    case 11: 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: V(0,(int *)) = ag_rp_16(); break;
    case 17: V(0,(int *)) = ag_rp_17(); break;
    case 18: V(0,(int *)) = ag_rp_18(V(2,(int *))); break;
    case 19: ag_rp_19(V(0,(Object * *))); break;
    case 20: ag_rp_20(V(0,(struct String * *)), V(2,(unsigned *))); break;
    case 21: ag_rp_21(); break;
    case 22: ag_rp_22(); break;
    case 23: V(0,(unsigned *)) = ag_rp_23(); break;
    case 24: V(0,(unsigned *)) = ag_rp_24(); break;
    case 25: V(0,(unsigned *)) = ag_rp_25(V(2,(unsigned *))); break;
    case 26: ag_rp_26(); break;
    case 27: ag_rp_27(); break;
    case 28: ag_rp_28(); break;
    case 29: ag_rp_29(); break;
    case 30: ag_rp_30(V(0,(Object * *))); break;
    case 31: V(0,(Object * *)) = ag_rp_31(V(0,(struct String * *))); break;
    case 32: V(0,(struct String * *)) = ag_rp_32(V(0,(struct String * *))); break;
    case 33: V(0,(struct String * *)) = ag_rp_33(V(0,(int *))); break;
    case 34: V(0,(struct String * *)) = ag_rp_34(V(0,(struct String * *)), V(1,(int *))); break;
    case 35: V(0,(struct String * *)) = ag_rp_35(V(0,(struct String * *)), V(1,(int *))); break;
  }
}

#define TOKEN_NAMES parse_token_names
const char *const parse_token_names[74] = {
  "LineParse",
  "WhiteSpace",
  "VariNumStr",
  "StringBody",
  "LineParse",
  "Terminated Line",
  "",
  "",
  "Line",
  "';'",
  "\"DEFINE\"",
  "'('",
  "VariableList",
  "')'",
  "Group",
  "\"PRINT\"",
  "\"VAR\"",
  "VariableDecl",
  "\"QUIT\"",
  "Comparison",
  "Comparisons",
  "",
  "VariableListWork",
  "VariListMemb",
  "','",
  "\"CONST\"",
  "'='",
  "VariNum",
  "Assignment",
  "'>'",
  "'<'",
  "\"==\"",
  "Expression",
  "FunctionCall",
  "ArgumentList",
  "Product",
  "'+'",
  "'-'",
  "PowerFactor",
  "'*'",
  "Factor",
  "'/'",
  "'^'",
  "ALNUM",
  "WS",
  "WSDISREGARD",
  "\"/*\"",
  "ANYTHING",
  "",
  "\"*/\"",
  "",
  "",
  "",
  "",
  "",
  "';'",
  "')'",
  "'('",
  "VariNumStr",
  "\"DEFINE\"",
  "\"PRINT\"",
  "\"VAR\"",
  "\"QUIT\"",
  "','",
  "'='",
  "\"CONST\"",
  "'>'",
  "'<'",
  "\"==\"",
  "'+'",
  "'-'",
  "'*'",
  "'/'",
  "'^'",

};

#ifndef MISSING_FORMAT
#define MISSING_FORMAT "Missing %s"
#endif
#ifndef UNEXPECTED_FORMAT
#define UNEXPECTED_FORMAT "Unexpected %s"
#endif
#ifndef UNNAMED_TOKEN
#define UNNAMED_TOKEN "input"
#endif


static void ag_diagnose(void) {
  int ag_snd = (PCB).sn;
  int ag_k = ag_sbt[ag_snd];

  if (*TOKEN_NAMES[ag_tstt[ag_k]] && ag_astt[ag_k + 1] == ag_action_8) {
    sprintf((PCB).ag_msg, MISSING_FORMAT, TOKEN_NAMES[ag_tstt[ag_k]]);
  }
  else if (ag_astt[ag_sbe[(PCB).sn]] == ag_action_8
          && (ag_k = (int) ag_sbe[(PCB).sn] + 1) == (int) ag_sbt[(PCB).sn+1] - 1
          && *TOKEN_NAMES[ag_tstt[ag_k]]) {
    sprintf((PCB).ag_msg, MISSING_FORMAT, TOKEN_NAMES[ag_tstt[ag_k]]);
  }
  else if ((PCB).token_number && *TOKEN_NAMES[(PCB).token_number]) {
    sprintf((PCB).ag_msg, UNEXPECTED_FORMAT, TOKEN_NAMES[(PCB).token_number]);
  }
  else if (isprint((*(PCB).lab)) && (*(PCB).lab) != '\\') {
    char buf[20];
    sprintf(buf, "\'%c\'", (char) (*(PCB).lab));
    sprintf((PCB).ag_msg, UNEXPECTED_FORMAT, buf);
  }
  else sprintf((PCB).ag_msg, UNEXPECTED_FORMAT, UNNAMED_TOKEN);
  (PCB).error_message = (PCB).ag_msg;


}
static int ag_action_1_r_proc(void);
static int ag_action_2_r_proc(void);
static int ag_action_3_r_proc(void);
static int ag_action_4_r_proc(void);
static int ag_action_1_s_proc(void);
static int ag_action_3_s_proc(void);
static int ag_action_1_proc(void);
static int ag_action_2_proc(void);
static int ag_action_3_proc(void);
static int ag_action_4_proc(void);
static int ag_action_5_proc(void);
static int ag_action_6_proc(void);
static int ag_action_7_proc(void);
static int ag_action_8_proc(void);
static int ag_action_9_proc(void);
static int ag_action_10_proc(void);
static int ag_action_11_proc(void);
static int ag_action_8_proc(void);


static int (*const  ag_r_procs_scan[])(void) = {
  ag_action_1_r_proc,
  ag_action_2_r_proc,
  ag_action_3_r_proc,
  ag_action_4_r_proc
};

static int (*const  ag_s_procs_scan[])(void) = {
  ag_action_1_s_proc,
  ag_action_2_r_proc,
  ag_action_3_s_proc,
  ag_action_4_r_proc
};

static int (*const  ag_gt_procs_scan[])(void) = {
  ag_action_1_proc,
  ag_action_2_proc,
  ag_action_3_proc,
  ag_action_4_proc,
  ag_action_5_proc,
  ag_action_6_proc,
  ag_action_7_proc,
  ag_action_8_proc,
  ag_action_9_proc,
  ag_action_10_proc,
  ag_action_11_proc,
  ag_action_8_proc
};


static int ag_action_10_proc(void) {
  int ag_t = (PCB).token_number;
  (PCB).btsx = 0, (PCB).drt = -1;
  do {
    ag_track();
    if ((PCB).rx < (PCB).fx) {
      (PCB).input_code = (PCB).lab[(PCB).rx++];
      (PCB).token_number = (parse_token_type) AG_TCV((PCB).input_code);}
    else {
      GET_INPUT;
      (PCB).lab[(PCB).fx++] = (PCB).input_code;
      (PCB).token_number = (parse_token_type) AG_TCV((PCB).input_code);
      (PCB).rx++;
    }
    if (ag_key_index[(PCB).sn]) {
      unsigned ag_k = ag_key_index[(PCB).sn];
      int ag_ch = CONVERT_CASE((PCB).input_code);
      if (ag_ch < 255) {
        while (ag_key_ch[ag_k] < ag_ch) ag_k++;
        if (ag_key_ch[ag_k] == ag_ch) ag_get_key_word(ag_k);
      }
    }
  } while ((PCB).token_number == (parse_token_type) ag_t);
  (PCB).rx = 0;
  return 1;
}

static int ag_action_11_proc(void) {
  int ag_t = (PCB).token_number;

  (PCB).btsx = 0, (PCB).drt = -1;
  do {
    (*(int *) &(PCB).vs[(PCB).ssx]) = *(PCB).lab;
    (PCB).ssx--;
    ag_track();
    ag_ra();
    if ((PCB).exit_flag != AG_RUNNING_CODE) return 0;
    (PCB).ssx++;
    if ((PCB).rx < (PCB).fx) {
      (PCB).input_code = (PCB).lab[(PCB).rx++];
      (PCB).token_number = (parse_token_type) AG_TCV((PCB).input_code);}
    else {
      GET_INPUT;
      (PCB).lab[(PCB).fx++] = (PCB).input_code;
      (PCB).token_number = (parse_token_type) AG_TCV((PCB).input_code);
      (PCB).rx++;
    }
    if (ag_key_index[(PCB).sn]) {
      unsigned ag_k = ag_key_index[(PCB).sn];
      int ag_ch = CONVERT_CASE((PCB).input_code);
      if (ag_ch < 255) {
        while (ag_key_ch[ag_k] < ag_ch) ag_k++;
        if (ag_key_ch[ag_k] == ag_ch) ag_get_key_word(ag_k);
      }
    }
  }
  while ((PCB).token_number == (parse_token_type) ag_t);
  (PCB).rx = 0;
  return 1;
}

static int ag_action_3_r_proc(void) {
  int ag_sd = ag_fl[(PCB).ag_ap] - 1;
  if (ag_sd) (PCB).sn = (PCB).ss[(PCB).ssx -= ag_sd];
  (PCB).btsx = 0, (PCB).drt = -1;
  (PCB).reduction_token = (parse_token_type) ag_ptt[(PCB).ag_ap];
  ag_ra();
  return (PCB).exit_flag == AG_RUNNING_CODE;
}

static int ag_action_3_s_proc(void) {
  int ag_sd = ag_fl[(PCB).ag_ap] - 1;
  if (ag_sd) (PCB).sn = (PCB).ss[(PCB).ssx -= ag_sd];
  (PCB).btsx = 0, (PCB).drt = -1;
  (PCB).reduction_token = (parse_token_type) ag_ptt[(PCB).ag_ap];
  ag_ra();
  return (PCB).exit_flag == AG_RUNNING_CODE;
}

static int ag_action_4_r_proc(void) {
  int ag_sd = ag_fl[(PCB).ag_ap] - 1;
  if (ag_sd) (PCB).sn = (PCB).ss[(PCB).ssx -= ag_sd];
  (PCB).reduction_token = (parse_token_type) ag_ptt[(PCB).ag_ap];
  return 1;
}

static int ag_action_2_proc(void) {
  (PCB).btsx = 0, (PCB).drt = -1;
  if ((PCB).ssx >= 1000) {
    (PCB).exit_flag = AG_STACK_ERROR_CODE;
    PARSER_STACK_OVERFLOW;
  }
  (*(int *) &(PCB).vs[(PCB).ssx]) = *(PCB).lab;
  (PCB).ss[(PCB).ssx] = (PCB).sn;
  (PCB).ssx++;
  (PCB).sn = (PCB).ag_ap;
  ag_track();
  return 0;
}

static int ag_action_9_proc(void) {
  if ((PCB).drt == -1) {
    (PCB).drt=(PCB).token_number;
    (PCB).dssx=(PCB).ssx;
    (PCB).dsn=(PCB).sn;
  }
  ag_prot();
  (PCB).vs[(PCB).ssx] = ag_null_value;
  (PCB).ss[(PCB).ssx] = (PCB).sn;
  (PCB).ssx++;
  (PCB).sn = (PCB).ag_ap;
  (PCB).rx = 0;
  return (PCB).exit_flag == AG_RUNNING_CODE;
}

static int ag_action_2_r_proc(void) {
  (PCB).ssx++;
  (PCB).sn = (PCB).ag_ap;
  return 0;
}

static int ag_action_7_proc(void) {
  --(PCB).ssx;
  (PCB).rx = 0;
  (PCB).exit_flag = AG_SUCCESS_CODE;
  return 0;
}

static int ag_action_1_proc(void) {
  ag_track();
  (PCB).exit_flag = AG_SUCCESS_CODE;
  return 0;
}

static int ag_action_1_r_proc(void) {
  (PCB).exit_flag = AG_SUCCESS_CODE;
  return 0;
}

static int ag_action_1_s_proc(void) {
  (PCB).exit_flag = AG_SUCCESS_CODE;
  return 0;
}

static int ag_action_4_proc(void) {
  int ag_sd = ag_fl[(PCB).ag_ap] - 1;
  (PCB).reduction_token = (parse_token_type) ag_ptt[(PCB).ag_ap];
  (PCB).btsx = 0, (PCB).drt = -1;
  (*(int *) &(PCB).vs[(PCB).ssx]) = *(PCB).lab;
  if (ag_sd) (PCB).sn = (PCB).ss[(PCB).ssx -= ag_sd];
  else (PCB).ss[(PCB).ssx] = (PCB).sn;
  ag_track();
  while ((PCB).exit_flag == AG_RUNNING_CODE) {
    unsigned ag_t1 = ag_sbe[(PCB).sn] + 1;
    unsigned ag_t2 = ag_sbt[(PCB).sn+1] - 1;
    do {
      unsigned ag_tx = (ag_t1 + ag_t2)/2;
      if (ag_tstt[ag_tx] < (unsigned char)(PCB).reduction_token) ag_t1 = ag_tx + 1;
      else ag_t2 = ag_tx;
    } while (ag_t1 < ag_t2);
    (PCB).ag_ap = ag_pstt[ag_t1];
    if ((ag_s_procs_scan[ag_astt[ag_t1]])() == 0) break;
  }
  return 0;
}

static int ag_action_3_proc(void) {
  int ag_sd = ag_fl[(PCB).ag_ap] - 1;
  (PCB).btsx = 0, (PCB).drt = -1;
  (*(int *) &(PCB).vs[(PCB).ssx]) = *(PCB).lab;
  if (ag_sd) (PCB).sn = (PCB).ss[(PCB).ssx -= ag_sd];
  else (PCB).ss[(PCB).ssx] = (PCB).sn;
  ag_track();
  (PCB).reduction_token = (parse_token_type) ag_ptt[(PCB).ag_ap];
  ag_ra();
  while ((PCB).exit_flag == AG_RUNNING_CODE) {
    unsigned ag_t1 = ag_sbe[(PCB).sn] + 1;
    unsigned ag_t2 = ag_sbt[(PCB).sn+1] - 1;
    do {
      unsigned ag_tx = (ag_t1 + ag_t2)/2;
      if (ag_tstt[ag_tx] < (unsigned char)(PCB).reduction_token) ag_t1 = ag_tx + 1;
      else ag_t2 = ag_tx;
    } while (ag_t1 < ag_t2);
    (PCB).ag_ap = ag_pstt[ag_t1];
    if ((ag_s_procs_scan[ag_astt[ag_t1]])() == 0) break;
  }
  return 0;
}

static int ag_action_8_proc(void) {
  ag_undo();
  (PCB).rx = 0;
  (PCB).exit_flag = AG_SYNTAX_ERROR_CODE;
  ag_diagnose();
  SYNTAX_ERROR;
  {(PCB).rx = 1; ag_track();}
  return (PCB).exit_flag == AG_RUNNING_CODE;
}

static int ag_action_5_proc(void) {
  int ag_sd = ag_fl[(PCB).ag_ap];
  (PCB).btsx = 0, (PCB).drt = -1;
  if (ag_sd) (PCB).sn = (PCB).ss[(PCB).ssx -= ag_sd];
  else {
    (PCB).ss[(PCB).ssx] = (PCB).sn;
  }
  (PCB).rx = 0;
  (PCB).reduction_token = (parse_token_type) ag_ptt[(PCB).ag_ap];
  ag_ra();
  while ((PCB).exit_flag == AG_RUNNING_CODE) {
    unsigned ag_t1 = ag_sbe[(PCB).sn] + 1;
    unsigned ag_t2 = ag_sbt[(PCB).sn+1] - 1;
    do {
      unsigned ag_tx = (ag_t1 + ag_t2)/2;
      if (ag_tstt[ag_tx] < (unsigned char)(PCB).reduction_token) ag_t1 = ag_tx + 1;
      else ag_t2 = ag_tx;
    } while (ag_t1 < ag_t2);
    (PCB).ag_ap = ag_pstt[ag_t1];
    if ((ag_r_procs_scan[ag_astt[ag_t1]])() == 0) break;
  }
  return (PCB).exit_flag == AG_RUNNING_CODE;
}

static int ag_action_6_proc(void) {
  int ag_sd = ag_fl[(PCB).ag_ap];
  (PCB).reduction_token = (parse_token_type) ag_ptt[(PCB).ag_ap];
  if ((PCB).drt == -1) {
    (PCB).drt=(PCB).token_number;
    (PCB).dssx=(PCB).ssx;
    (PCB).dsn=(PCB).sn;
  }
  if (ag_sd) {
    (PCB).sn = (PCB).ss[(PCB).ssx -= ag_sd];
  }
  else {
    ag_prot();
    (PCB).vs[(PCB).ssx] = ag_null_value;
    (PCB).ss[(PCB).ssx] = (PCB).sn;
  }
  (PCB).rx = 0;
  while ((PCB).exit_flag == AG_RUNNING_CODE) {
    unsigned ag_t1 = ag_sbe[(PCB).sn] + 1;
    unsigned ag_t2 = ag_sbt[(PCB).sn+1] - 1;
    do {
      unsigned ag_tx = (ag_t1 + ag_t2)/2;
      if (ag_tstt[ag_tx] < (unsigned char)(PCB).reduction_token) ag_t1 = ag_tx + 1;
      else ag_t2 = ag_tx;
    } while (ag_t1 < ag_t2);
    (PCB).ag_ap = ag_pstt[ag_t1];
    if ((ag_r_procs_scan[ag_astt[ag_t1]])() == 0) break;
  }
  return (PCB).exit_flag == AG_RUNNING_CODE;
}


void init_parse(void) {
  (PCB).rx = (PCB).fx = 0;
  (PCB).ss[0] = (PCB).sn = (PCB).ssx = 0;
  (PCB).exit_flag = AG_RUNNING_CODE;
  (PCB).line = FIRST_LINE;
  (PCB).column = FIRST_COLUMN;
  (PCB).btsx = 0, (PCB).drt = -1;
}

void parse(void) {
  init_parse();
  (PCB).exit_flag = AG_RUNNING_CODE;
  while ((PCB).exit_flag == AG_RUNNING_CODE) {
    unsigned ag_t1 = ag_sbt[(PCB).sn];
    if (ag_tstt[ag_t1]) {
      unsigned ag_t2 = ag_sbe[(PCB).sn] - 1;
      if ((PCB).rx < (PCB).fx) {
        (PCB).input_code = (PCB).lab[(PCB).rx++];
        (PCB).token_number = (parse_token_type) AG_TCV((PCB).input_code);}
      else {
        GET_INPUT;
        (PCB).lab[(PCB).fx++] = (PCB).input_code;
        (PCB).token_number = (parse_token_type) AG_TCV((PCB).input_code);
        (PCB).rx++;
      }
      if (ag_key_index[(PCB).sn]) {
        unsigned ag_k = ag_key_index[(PCB).sn];
        int ag_ch = CONVERT_CASE((PCB).input_code);
        if (ag_ch < 255) {
          while (ag_key_ch[ag_k] < ag_ch) ag_k++;
          if (ag_key_ch[ag_k] == ag_ch) ag_get_key_word(ag_k);
        }
      }
      do {
        unsigned ag_tx = (ag_t1 + ag_t2)/2;
        if (ag_tstt[ag_tx] > (unsigned char)(PCB).token_number)
          ag_t1 = ag_tx + 1;
        else ag_t2 = ag_tx;
      } while (ag_t1 < ag_t2);
      if (ag_tstt[ag_t1] != (unsigned char)(PCB).token_number)
        ag_t1 = ag_sbe[(PCB).sn];
    }
    (PCB).ag_ap = ag_pstt[ag_t1];
    (ag_gt_procs_scan[ag_astt[ag_t1]])();
  }
}