view tests/agcl/examples/good/ct.cpp @ 10:5b21f127e957

silence random gcc warning
author David A. Holland
date Mon, 30 May 2022 23:58:14 -0400
parents 13d2b8934445
children
line wrap: on
line source

/*
 * AnaGram, a System for Syntax Directed Programming
 * C Macro preprocessor
 * Token Classifier Module
 *
 * Copyright 1993-2000 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.
 */

#include "mpp.h"


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

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



ct_pcb_type ct_pcb;
#define PCB ct_pcb

token_id ct_value(void);


#line - "ct.syn"
                                      // Embedded C

#define SYNTAX_ERROR                   // no diagnostic needed

static char *input_string;

/*

id_name() adds the string on the local string_accumulator to the token
dictionary and checks to see if the handle corresponds to a reserved
word. Otherwise the string is classified simply as a NAME

*/

static token_id id_name(void) {
  unsigned handle = td << input_string;
  token_id id;
  if (handle <= n_reserved_words) id = reserved_words[handle].id;
  else id = NAME;
  return id;
}

/*

classify_token() is an interface function for the grammar. It sets up
the pointer in the parser control block to point to the input string,
calls the parser, and returns the token_id determined by the parser if
there was no error, and returns "UNRECOGNIZED" if there was an error.

*/

token_id classify_token(char *string) {
  input_string = string;
  PCB.pointer = (unsigned char *) string;
  ct();
  return PCB.exit_flag == AG_SUCCESS_CODE ? ct_value() : UNRECOGNIZED;
}

#line - "ct.cpp"

#ifndef CONVERT_CASE
#define CONVERT_CASE(c) (c)
#endif
#ifndef TAB_SPACING
#define TAB_SPACING 8
#endif
token_id ct_value(void) {
  token_id returnValue;
  returnValue = (*(token_id *) &(PCB).vs[(PCB).ssx]);
  return returnValue;
}

static token_id ag_rp_1(void) {
#line - "ct.syn"
  return id_name();
#line - "ct.cpp"
}

static token_id ag_rp_2(void) {
#line - "ct.syn"
  return STRINGliteral;
#line - "ct.cpp"
}

static token_id ag_rp_3(void) {
#line - "ct.syn"
  return CHARACTERconstant;
#line - "ct.cpp"
}

static token_id ag_rp_4(int p) {
#line - "ct.syn"
  return (token_id) p;
#line - "ct.cpp"
}

static token_id ag_rp_5(void) {
#line - "ct.syn"
  return ANDAND;
#line - "ct.cpp"
}

static token_id ag_rp_6(void) {
#line - "ct.syn"
  return ANDassign;
#line - "ct.cpp"
}

static token_id ag_rp_7(void) {
#line - "ct.syn"
  return ARROW;
#line - "ct.cpp"
}

static token_id ag_rp_8(void) {
#line - "ct.syn"
  return CONCAT;
#line - "ct.cpp"
}

static token_id ag_rp_9(void) {
#line - "ct.syn"
  return DECR;
#line - "ct.cpp"
}

static token_id ag_rp_10(void) {
#line - "ct.syn"
  return DIVassign;
#line - "ct.cpp"
}

static token_id ag_rp_11(void) {
#line - "ct.syn"
  return ELLIPSIS;
#line - "ct.cpp"
}

static token_id ag_rp_12(void) {
#line - "ct.syn"
  return EQ;
#line - "ct.cpp"
}

static token_id ag_rp_13(void) {
#line - "ct.syn"
  return ERassign;
#line - "ct.cpp"
}

static token_id ag_rp_14(void) {
#line - "ct.syn"
  return GE;
#line - "ct.cpp"
}

static token_id ag_rp_15(void) {
#line - "ct.syn"
  return ICR;
#line - "ct.cpp"
}

static token_id ag_rp_16(void) {
#line - "ct.syn"
  return LE;
#line - "ct.cpp"
}

static token_id ag_rp_17(void) {
#line - "ct.syn"
  return LS;
#line - "ct.cpp"
}

static token_id ag_rp_18(void) {
#line - "ct.syn"
  return LSassign;
#line - "ct.cpp"
}

static token_id ag_rp_19(void) {
#line - "ct.syn"
  return MODassign;
#line - "ct.cpp"
}

static token_id ag_rp_20(void) {
#line - "ct.syn"
  return MINUSassign;
#line - "ct.cpp"
}

static token_id ag_rp_21(void) {
#line - "ct.syn"
  return MULTassign;
#line - "ct.cpp"
}

static token_id ag_rp_22(void) {
#line - "ct.syn"
  return NE;
#line - "ct.cpp"
}

static token_id ag_rp_23(void) {
#line - "ct.syn"
  return ORassign;
#line - "ct.cpp"
}

static token_id ag_rp_24(void) {
#line - "ct.syn"
  return OROR;
#line - "ct.cpp"
}

static token_id ag_rp_25(void) {
#line - "ct.syn"
  return PLUSassign;
#line - "ct.cpp"
}

static token_id ag_rp_26(void) {
#line - "ct.syn"
  return RS;
#line - "ct.cpp"
}

static token_id ag_rp_27(void) {
#line - "ct.syn"
  return RSassign;
#line - "ct.cpp"
}

static token_id ag_rp_28(void) {
#line - "ct.syn"
  return FLOATconstant;
#line - "ct.cpp"
}

static token_id ag_rp_29(void) {
#line - "ct.syn"
  return OCTconstant;
#line - "ct.cpp"
}

static token_id ag_rp_30(void) {
#line - "ct.syn"
  return DECconstant;
#line - "ct.cpp"
}

static token_id ag_rp_31(void) {
#line - "ct.syn"
  return HEXconstant;
#line - "ct.cpp"
}


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

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

#define AG_TCV(x) ag_tcv[(x)]

static const unsigned char ag_tcv[] = {
    3, 61, 61, 61, 61, 61, 61, 61, 61, 61, 55, 61, 61, 61, 61, 61, 61, 61,
   61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 23, 51, 15,
   61, 21, 11, 57, 61, 61, 22, 19, 61, 13, 17, 16, 43, 62, 62, 62, 62, 62,
   62, 62, 36, 36, 61, 61, 20, 12, 14, 61, 61, 63, 63, 63, 63, 37, 28, 64,
   64, 64, 64, 64, 29, 64, 64, 64, 64, 64, 64, 64, 64, 49, 64, 64, 46, 64,
   64, 61, 53, 61, 18, 64, 61, 63, 63, 63, 63, 37, 28, 64, 64, 64, 64, 64,
   29, 64, 64, 64, 64, 64, 64, 64, 64, 49, 64, 64, 46, 64, 64, 61, 24, 61,
   61, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65,
   65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65,
   65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65,
   65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65,
   65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65,
   65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65,
   65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65,
   65, 65, 65, 65
};

#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


#ifndef INPUT_CODE
#define INPUT_CODE(T) (T)
#endif


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

static void ag_undo(void) {
  if ((PCB).drt == -1) return;
  while ((PCB).btsx) {
    int ag_k = 128 - (PCB).btsx;
    (PCB).sn = (PCB).bts[(PCB).btsx--];
    (PCB).ssx = (PCB).bts[ag_k];
    (PCB).vs[(PCB).ssx] = (PCB).vs[ag_k];
    (PCB).ss[(PCB).ssx] = (PCB).ss[ag_k];
  }
  (PCB).token_number = (ct_token_type) (PCB).drt;
  (PCB).ssx = (PCB).dssx;
  (PCB).sn = (PCB).dsn;
  (PCB).drt = -1;
}


static const unsigned char ag_tstt[] = {
64,63,62,61,57,55,53,51,49,46,43,37,36,29,28,24,23,22,21,20,19,18,17,16,15,
  14,13,12,11,0,1,2,4,5,6,7,8,9,25,27,30,32,33,34,39,40,41,45,50,56,
46,0,
62,43,37,36,17,0,31,
62,43,37,36,0,31,
63,62,43,37,36,28,0,
62,43,37,36,17,0,31,
62,43,36,17,0,
24,12,0,
12,0,
12,0,
12,0,
20,12,0,
19,12,0,
14,12,0,
12,0,
12,0,
62,43,36,17,0,
12,0,
15,0,
14,13,12,0,
12,11,0,
65,64,63,62,61,57,53,51,49,46,43,37,36,29,28,24,23,22,21,20,19,18,17,16,15,
  14,13,12,11,0,
65,64,63,62,61,57,53,51,49,46,43,37,36,29,28,24,23,22,21,20,19,18,17,16,15,
  14,13,12,11,0,
49,29,0,42,
49,29,0,42,
49,29,0,42,
29,28,3,0,26,
64,63,62,49,46,43,37,36,29,28,0,
3,0,
63,62,43,37,36,28,0,
62,43,36,19,13,0,38,
62,43,36,0,
62,43,36,0,
62,43,36,0,
12,0,
12,0,
17,0,
65,64,63,62,61,57,55,53,51,49,46,43,37,36,29,28,24,23,22,21,20,19,18,17,16,
  15,14,13,12,11,0,
65,64,63,62,61,57,55,53,51,49,46,43,37,36,29,28,24,23,22,21,20,19,18,17,16,
  15,14,13,12,11,0,
62,43,36,0,
62,43,36,0,

};


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


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

};


static const unsigned short ag_sbt[] = {
     0,  50,  52,  59,  65,  72,  79,  84,  87,  89,  91,  93,  96,  99,
   102, 104, 106, 111, 113, 115, 119, 122, 152, 182, 186, 190, 194, 199,
   210, 212, 219, 226, 230, 234, 238, 240, 242, 244, 275, 306, 310, 314
};


static const unsigned short ag_sbe[] = {
    29,  51,  57,  63,  71,  77,  83,  86,  88,  90,  92,  95,  98, 101,
   103, 105, 110, 112, 114, 118, 121, 151, 181, 184, 188, 192, 197, 209,
   211, 218, 224, 229, 233, 237, 239, 241, 243, 274, 305, 309, 313, 314
};


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

static const unsigned char ag_ptt[] = {
    0,  1,  2,  2,  2,  2,  2,  2,  2,  9,  9,  9,  9,  9,  9,  9,  9,  9,
    9,  9,  9,  9,  9,  9,  9,  9,  9,  9,  9,  9,  9,  9,  5, 25, 26, 26,
   26, 27, 27, 27, 27, 30, 30, 30, 30, 30, 32, 32, 31, 38, 38, 31, 31,  6,
    6,  6, 39, 39, 34, 34, 41, 41, 45, 45, 40, 40, 33, 33, 42, 42,  7, 50,
   50, 50, 50,  8, 56, 56, 56, 56,  4,  4
};


static void ag_ra(void)
{
  switch(ag_rpx[(PCB).ag_ap]) {
    case 1: V(0,(token_id *)) = ag_rp_1(); break;
    case 2: V(0,(token_id *)) = ag_rp_2(); break;
    case 3: V(0,(token_id *)) = ag_rp_3(); break;
    case 4: V(0,(token_id *)) = ag_rp_4(V(0,(int *))); break;
    case 5: V(0,(token_id *)) = ag_rp_5(); break;
    case 6: V(0,(token_id *)) = ag_rp_6(); break;
    case 7: V(0,(token_id *)) = ag_rp_7(); break;
    case 8: V(0,(token_id *)) = ag_rp_8(); break;
    case 9: V(0,(token_id *)) = ag_rp_9(); break;
    case 10: V(0,(token_id *)) = ag_rp_10(); break;
    case 11: V(0,(token_id *)) = ag_rp_11(); break;
    case 12: V(0,(token_id *)) = ag_rp_12(); break;
    case 13: V(0,(token_id *)) = ag_rp_13(); break;
    case 14: V(0,(token_id *)) = ag_rp_14(); break;
    case 15: V(0,(token_id *)) = ag_rp_15(); break;
    case 16: V(0,(token_id *)) = ag_rp_16(); break;
    case 17: V(0,(token_id *)) = ag_rp_17(); break;
    case 18: V(0,(token_id *)) = ag_rp_18(); break;
    case 19: V(0,(token_id *)) = ag_rp_19(); break;
    case 20: V(0,(token_id *)) = ag_rp_20(); break;
    case 21: V(0,(token_id *)) = ag_rp_21(); break;
    case 22: V(0,(token_id *)) = ag_rp_22(); break;
    case 23: V(0,(token_id *)) = ag_rp_23(); break;
    case 24: V(0,(token_id *)) = ag_rp_24(); break;
    case 25: V(0,(token_id *)) = ag_rp_25(); break;
    case 26: V(0,(token_id *)) = ag_rp_26(); break;
    case 27: V(0,(token_id *)) = ag_rp_27(); break;
    case 28: V(0,(token_id *)) = ag_rp_28(); break;
    case 29: V(0,(token_id *)) = ag_rp_29(); break;
    case 30: V(0,(token_id *)) = ag_rp_30(); break;
    case 31: V(0,(token_id *)) = ag_rp_31(); break;
  }
  (PCB).la_ptr = (PCB).pointer;
}

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 {
    (PCB).pointer = (PCB).la_ptr;
    (PCB).token_number = (ct_token_type) AG_TCV(INPUT_CODE(*(PCB).la_ptr));
    (PCB).la_ptr++;
  } while ((PCB).token_number == (ct_token_type) ag_t);
  (PCB).la_ptr = (PCB).pointer;
  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).pointer;
    (PCB).ssx--;
    (PCB).pointer = (PCB).la_ptr;
    ag_ra();
    if ((PCB).exit_flag != AG_RUNNING_CODE) return 0;
    (PCB).ssx++;
    (PCB).token_number = (ct_token_type) AG_TCV(INPUT_CODE(*(PCB).la_ptr));
    (PCB).la_ptr++;
  }
  while ((PCB).token_number == (ct_token_type) ag_t);
  (PCB).la_ptr = (PCB).pointer;
  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 = (ct_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 = (ct_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 = (ct_token_type) ag_ptt[(PCB).ag_ap];
  return 1;
}

static int ag_action_2_proc(void) {
  (PCB).btsx = 0, (PCB).drt = -1;
  if ((PCB).ssx >= 128) {
    (PCB).exit_flag = AG_STACK_ERROR_CODE;
    PARSER_STACK_OVERFLOW;
  }
  (*(int *) &(PCB).vs[(PCB).ssx]) = *(PCB).pointer;
  (PCB).ss[(PCB).ssx] = (PCB).sn;
  (PCB).ssx++;
  (PCB).sn = (PCB).ag_ap;
  (PCB).pointer = (PCB).la_ptr;
  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).la_ptr = (PCB).pointer;
  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).la_ptr = (PCB).pointer;
  (PCB).exit_flag = AG_SUCCESS_CODE;
  return 0;
}

static int ag_action_1_proc(void) {
  (PCB).pointer = (PCB).la_ptr;
  (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 = (ct_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 (PCB).ss[(PCB).ssx] = (PCB).sn;
  (PCB).pointer = (PCB).la_ptr;
  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).pointer;
  if (ag_sd) (PCB).sn = (PCB).ss[(PCB).ssx -= ag_sd];
  else (PCB).ss[(PCB).ssx] = (PCB).sn;
  (PCB).pointer = (PCB).la_ptr;
  (PCB).reduction_token = (ct_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).la_ptr = (PCB).pointer;
  (PCB).exit_flag = AG_SYNTAX_ERROR_CODE;
  SYNTAX_ERROR;
  (PCB).la_ptr = ++(PCB).pointer;
  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).la_ptr = (PCB).pointer;
  (PCB).reduction_token = (ct_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 = (ct_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).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);
    (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_ct(void) {
  (PCB).la_ptr = (PCB).pointer;
  (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;
}

void ct(void) {
  init_ct();
  (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 = (ct_token_type) AG_TCV(INPUT_CODE(*(PCB).la_ptr));
      (PCB).la_ptr++;
      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]])();
  }
}