view tests/agcl/oldagsrc/good/asilbug1.cpp @ 0:13d2b8934445

Import AnaGram (near-)release tree into Mercurial.
author David A. Holland
date Sat, 22 Dec 2007 17:52:45 -0500
parents
children
line wrap: on
line source

/*
 VM.SYN

 Virtual Machine Compiler
 Copyright (c) 1997 Parsifal Software, All Rights Reserved.

 The expression syntax is borrowed from C but with the
 addition of the FORTRAN exponentiation operator (**).

 The cast, increment, and decrement operators are not
 implemented, nor are operations that are defined only
 for integers:
   Bitwise logical operators:   &, |, ^, ~, &=, |=, ^=
   Remainder operators:         %, %=
   Shift operators:             <<, >>, >>=, <<=

 The supported operations are:
   Assignment operators:        =, +=, -=, *=, /=
   Conditional expressions:     ? :
   Logical operators:           !, &&, ||
   Comparison operators:        ==, !=, <, <=, >, >=
   Binary arithmetic operators: +, -, *, /
   Exponentiation:              **
   Unary arithmetic operators:  +, -
   Parentheses
   Function calls

 All arithmetic is double precision floating point.

 Statements may include expression statements, blocks, if/else statements
 or while statements, following the rules of C.

 The statement syntax has been written to avoid the conventional
 if/else ambiguity.

 There are no declarations. All variables are presumed to be double.

 Input strings may contain any number of statements. White space may be
 used freely, including both C and C++ style comments.

 vmCompile makes the following external calls:
   void pushChar(int character);
     Push the specified character onto a character stack.

   int locateVariable(int nameLength);
     Pop the last nameLength characters from the character stack
     and, treating them as the name of a variable, return an
     index into the variable array.

 Overrides for macros defined by AnaGram, such as SYNTAX_ERROR
 are included in VMDEFS.H

 VM.SYN is compiled with the AnaGram parser generator
 yielding VM.H and VM.CPP.

 To build VM, compile VM.CPP and VMDEMO.CPP and link them
 with your C++ compiler.

 For information about AnaGram, visit http://www.parsifalsoft.com.
*/

#include <math.h>
#include "vmdefs.h"                  // defines external interface

static VirtualMachine *vm;


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

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



asil_pcb_type asil_pcb;
#define PCB asil_pcb
#define CHANGE_REDUCTION(x) asil_change_reduction(asil_##x##_token)
int asil_change_reduction(asil_token_type);


#line - "asilbug1.syn"
 // begin embedded C


int compileStatements(VirtualMachine *v, char *text) {
  vm = v;
  resetCharStack();
  vmCompile_pcb.pointer = (unsigned char *) text;
  vmCompile();
  return vmCompile_pcb.exit_flag != AG_SUCCESS_CODE;
}
#line - "asilbug1.cpp"

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

#define ag_rp_1(x) (x)

#define ag_rp_2(x) (x)

static double ag_rp_3(double x) {
#line - "asilbug1.syn"
if (x) CHANGE_REDUCTION(true_if_clause);
#line - "asilbug1.cpp"
}

#define ag_rp_4(k, x) (vm->code(STORE, k), x)

#define ag_rp_5(k, x) (vm->code(ADDM,k), x)

#define ag_rp_6(k, x) (vm->code(SUBM,k), x)

#define ag_rp_7(k, x) (vm->code(MULM,k), x)

#define ag_rp_8(k, x) (vm->code(DIVM,k), x)

#define ag_rp_9(c, x, y) (vm->codeIfElse(c,x,y))

#define ag_rp_10(x, y) (vm->insertCode(OR, vm->wx - y, y), x)

#define ag_rp_11(x, y) (vm->insertCode(AND, vm->wx - y, y), x)

#define ag_rp_12(x, y) (vm->code(EQ), x)

#define ag_rp_13(x, y) (vm->code(NE), x)

#define ag_rp_14(x, y) (vm->code(LT), x)

#define ag_rp_15(x, y) (vm->code(LE), x)

#define ag_rp_16(x, y) (vm->code(GT), x)

#define ag_rp_17(x, y) (vm->code(GE), x)

#define ag_rp_18(x, y) (vm->code(ADD), x)

#define ag_rp_19(x, y) (vm->code(SUB), x)

#define ag_rp_20(x, y) (vm->code(MUL), x)

#define ag_rp_21(x, y) (vm->code(DIV), x)

#define ag_rp_22(x, y) (vm->code(POW), x)

#define ag_rp_23(x) (vm->code(PUSHI, x))

#define ag_rp_24(k) (vm->code(PUSH, k))

#define ag_rp_25(x) (vm->code(LOG), x)

#define ag_rp_26(x) (vm->code(EXP), x)

#define ag_rp_28(x) (vm->code(NEG), x)

#define ag_rp_29(x) (x)

#define ag_rp_30(x) (vm->code(NOT), x)

#define ag_rp_31(x, e) (x*pow(10,e))

#define ag_rp_32(x, e) (x*pow(10,-e))

#define ag_rp_33(i, f) (i+f)

#define ag_rp_34(f) (f)

#define ag_rp_35(d) (d-'0')

#define ag_rp_36(x, d) (10*x + d-'0')

#define ag_rp_37(d) ((d-'0')/10.)

#define ag_rp_38(d, f) ((d-'0' + f)/10.)

#define ag_rp_39(d) (d-'0')

#define ag_rp_40(x, d) (10*x + d-'0')

#define ag_rp_41(k) (locateVariable(k))

#define ag_rp_42(c) (pushChar(c), 1)

#define ag_rp_43(k, c) (pushChar(c), k+1)


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

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

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

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

static const unsigned char ag_key_ch[] = {
    0, 42, 47,255, 47,101,105,108,119,255, 42,255, 42, 61,255, 42, 47, 61,
  255,108,120,255, 33, 38, 42, 43, 45, 47, 60, 61, 62,101,105,108,119,124,
  255,101,105,108,119,255, 42, 47,255, 33, 38, 42, 47, 60, 61, 62,124,255,
   42, 47,255, 47,101,108,255, 42, 47,255, 47,255,101,108,255, 33, 38, 42,
   60, 61, 62,124,255, 33, 38, 60, 61, 62,124,255, 33, 38, 61,124,255, 42,
   61,255, 42, 47, 61,255, 33, 38, 42, 43, 45, 47, 60, 61, 62,124,255, 38,
  124,255,124,255, 42, 47,255,108,120,255, 47,101,105,108,119,255, 42, 61,
  255, 33, 38, 42, 43, 45, 47, 60, 61, 62,124,255,105,119,255,108,120,255,
  101,105,108,119,255, 42, 47,255, 33, 38, 42, 47, 60, 61, 62,101,105,108,
  119,124,255, 42, 47,255, 47,105,119,255
};

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

static const unsigned char ag_key_parm[] = {
    0, 68, 73,  0,  0,129,105,128,102,  0, 72,  0,126,110,  0, 68, 73,111,
    0,104,129,  0,117,115,  0,108,109,  0,119,116,121,  0,105,128,102,114,
    0,129,105,128,102,  0, 68, 73,  0,117,115,126,  0,119,116,121,114,  0,
   68, 73,  0,  0,129,128,  0, 68, 73,  0,  0,  0,129,128,  0,117,115,126,
  119,116,121,114,  0,117,115,119,116,121,114,  0,117,115,116,114,  0,126,
  110,  0, 68, 73,111,  0,117,115,  0,108,109,  0,119,116,121,114,  0,115,
  114,  0,114,  0, 68, 73,  0,104,129,  0,  0,  0,105,128,102,  0,126,110,
    0,117,115,  0,108,109,111,119,116,121,114,  0,105,102,  0,104,129,  0,
    0,105,128,102,  0, 68, 73,  0,117,115,126,  0,119,116,121,129,105,128,
  102,114,  0, 68, 73,  0,  0,105,102,  0
};

static const unsigned char ag_key_jmp[] = {
    0,  0,  0,  0,  1,  0,  3,  5,  8,  0, 13,  0,  0,  0,  0,  0,  0,  0,
    0, 29, 32,  0, 15, 17, 12, 19, 21, 15, 23, 25, 27, 19, 34, 36, 39, 44,
    0, 46, 49, 51, 54,  0,  0,  0,  0, 59, 61, 63, 42, 65, 67, 69, 71,  0,
    0,  0,  0, 54, 73, 76,  0,  0,  0,  0, 61,  0, 79, 82,  0, 85, 87, 89,
   91, 93, 95, 97,  0, 99,101,103,105,107,109,  0,111,113,115,117,  0,  0,
    0,  0,  0,  0,  0,  0,119,121, 89,123,125, 92,127,129,131,133,  0,135,
  137,  0,139,  0,  0,  0,  0,141,144,  0,112,115,146,148,151,  0,  0,  0,
    0,156,158,124,160,162,164,166,168,170,172,  0,174,176,  0,181,184,  0,
  141,186,188,191,  0,  0,  0,  0,196,198,200,149,202,204,206,208,211,213,
  216,221,  0,  0,  0,  0,165,223,225,  0
};

static const unsigned char ag_key_index[] = {
    4,  0, 10, 22, 37,  0,  0, 10, 10,  0, 45, 45, 57, 57, 57, 57, 64, 64,
   45, 66, 66, 66, 66,  0,  0, 69, 77, 77, 77, 84, 96,107, 64, 64, 96,110,
    0,  0,  4,118,127,138, 37,  0,  0, 37,  0, 37,  0, 45, 45,  0,  0, 66,
   66, 57, 66, 57, 66, 57, 66, 66, 66, 57, 66, 57, 66, 57, 66, 57, 66, 57,
   66, 57, 66, 57, 66, 57, 66, 57, 66, 66,  0,138, 57, 66, 57, 66, 57, 66,
   57, 66, 57, 66, 64, 64, 57, 64, 64, 64,  0,  0,  0,  0,  0,144,144,  0,
    0, 37,118,  0,  0,152,  0,  0, 77, 77, 77, 77, 77, 77, 77, 77, 84,107,
    0,  0,  0,  0,  0,138,138,  4, 37,138,168,138,  4, 37,138, 45, 45, 66,
  144,138
};

static const unsigned char ag_key_ends[] = {
120,112,0, 102,0, 111,103,0, 104,105,108,101,0, 47,0, 61,0, 
38,0, 61,0, 61,0, 61,0, 61,0, 61,0, 115,101,0, 112,0, 102,0, 
111,103,0, 104,105,108,101,0, 124,0, 120,112,0, 102,0, 111,103,0, 
104,105,108,101,0, 61,0, 38,0, 42,0, 61,0, 61,0, 61,0, 124,0, 
120,112,0, 111,103,0, 120,112,0, 111,103,0, 61,0, 38,0, 42,0, 
61,0, 61,0, 61,0, 124,0, 61,0, 38,0, 61,0, 61,0, 61,0, 124,0, 
61,0, 38,0, 61,0, 124,0, 61,0, 38,0, 61,0, 61,0, 61,0, 61,0, 
61,0, 124,0, 38,0, 124,0, 124,0, 115,101,0, 112,0, 102,0, 
111,103,0, 104,105,108,101,0, 61,0, 38,0, 61,0, 61,0, 61,0, 
61,0, 61,0, 61,0, 124,0, 102,0, 104,105,108,101,0, 115,101,0, 
112,0, 102,0, 111,103,0, 104,105,108,101,0, 61,0, 38,0, 42,0, 
61,0, 61,0, 61,0, 120,112,0, 102,0, 111,103,0, 104,105,108,101,0, 
124,0, 102,0, 104,105,108,101,0, 
};

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

static const unsigned char ag_tcv[] = {
    7, 93, 93, 93, 93, 93, 93, 93, 93, 92, 77, 92, 92, 92, 93, 93, 93, 93,
   93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 92,130,131,131,
  131,131,131,131, 97, 96,124,122,131,123,132,125,133,133,133,133,133,133,
  133,133,133,133,112,100,118,106,120,113,131,134,134,134,134,135,134,134,
  134,134,134,134,134,134,134,134,134,134,134,134,134,134,134,134,134,134,
  134,131,131,131,131,134,131,134,134,134,134,135,134,134,134,134,134,134,
  134,134,134,134,134,134,134,134,134,134,134,134,134,134,134, 99,131, 98,
  131, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93,
   93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93,
   93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93,
   93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93,
   93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93,
   93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93,
   93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93,
   93, 93, 93, 93
};

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

#ifndef FIRST_LINE
#define FIRST_LINE 1
#endif

#ifndef FIRST_COLUMN
#define FIRST_COLUMN 1
#endif

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

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


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

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

static void ag_get_key_word(int ag_k) {
  int ag_save = (int) ((PCB).la_ptr - (PCB).pointer);
  const  unsigned char *ag_p;
  int ag_ch;
  while (1) {
    switch (ag_key_act[ag_k]) {
    case ag_cf_end_key: {
      const  unsigned char *sp = ag_key_ends + ag_key_jmp[ag_k];
      do {
        if ((ag_ch = *sp++) == 0) {
          int ag_k1 = ag_key_parm[ag_k];
          int ag_k2 = ag_key_pt[ag_k1];
          if (ag_key_itt[ag_k2 + CONVERT_CASE(*(PCB).la_ptr)]) goto ag_fail;
          (PCB).token_number = (asil_token_type) ag_key_pt[ag_k1 + 1];
          return;
        }
      } while (CONVERT_CASE(*(PCB).la_ptr++) == ag_ch);
      goto ag_fail;
    }
    case ag_end_key: {
      const  unsigned char *sp = ag_key_ends + ag_key_jmp[ag_k];
      do {
        if ((ag_ch = *sp++) == 0) {
          (PCB).token_number = (asil_token_type) ag_key_parm[ag_k];
          return;
        }
      } while (CONVERT_CASE(*(PCB).la_ptr++) == ag_ch);
    }
    case ag_no_match_key:
ag_fail:
      (PCB).la_ptr = (PCB).pointer + ag_save;
      return;
    case ag_cf_set_key: {
      int ag_k1 = ag_key_parm[ag_k];
      int ag_k2 = ag_key_pt[ag_k1];
      ag_k = ag_key_jmp[ag_k];
      if (ag_key_itt[ag_k2 + CONVERT_CASE(*(PCB).la_ptr)]) break;
      ag_save = (int) ((PCB).la_ptr - (PCB).pointer);
      (PCB).token_number = (asil_token_type) ag_key_pt[ag_k1+1];
      break;
    }
    case ag_set_key:
      ag_save = (int) ((PCB).la_ptr - (PCB).pointer);
      (PCB).token_number = (asil_token_type) ag_key_parm[ag_k];
    case ag_jmp_key:
      ag_k = ag_key_jmp[ag_k];
      break;
    case ag_accept_key:
      (PCB).token_number = (asil_token_type) ag_key_parm[ag_k];
      return;
    case ag_cf_accept_key: {
      int ag_k1 = ag_key_parm[ag_k];
      int ag_k2 = ag_key_pt[ag_k1];
      if (ag_key_itt[ag_k2 + CONVERT_CASE(*(PCB).la_ptr)])
        (PCB).la_ptr = (PCB).pointer + ag_save;
      else (PCB).token_number = (asil_token_type) ag_key_pt[ag_k1+1];
      return;
    }
    }
    ag_ch = CONVERT_CASE(*(PCB).la_ptr++);
    ag_p = &ag_key_ch[ag_k];
    if (ag_ch <= 255) while (*ag_p < ag_ch) ag_p++;
    if (ag_ch > 255 || *ag_p != ag_ch) {
      (PCB).la_ptr = (PCB).pointer + ag_save;
      return;
    }
    ag_k = (int) (ag_p - ag_key_ch);
  }
}


#ifndef AG_NEWLINE
#define AG_NEWLINE 10
#endif

#ifndef AG_RETURN
#define AG_RETURN 13
#endif

#ifndef AG_FORMFEED
#define AG_FORMFEED 12
#endif

#ifndef AG_TABCHAR
#define AG_TABCHAR 9
#endif

static void ag_track(void) {
  int ag_k = (int) ((PCB).la_ptr - (PCB).pointer);
  while (ag_k--) {
    switch (*(PCB).pointer++) {
    case AG_NEWLINE:
      (PCB).column = 1, (PCB).line++;
    case AG_RETURN:
    case AG_FORMFEED:
      break;
    case AG_TABCHAR:
      (PCB).column += (TAB_SPACING) - ((PCB).column - 1) % (TAB_SPACING);
      break;
    default:
      (PCB).column++;
    }
  }
}


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



static const int ag_rtt[] = {
   32, 31,  0
};

static const unsigned char ag_tstt[] = {
135,134,133,132,130,129,128,123,122,105,102,100,99,97,92,77,73,68,7,0,1,94,
  95,
135,134,133,132,131,130,125,124,123,122,120,118,113,112,106,100,99,98,97,96,
  93,92,77,0,75,76,
135,134,133,132,131,130,125,124,123,122,120,118,113,112,106,100,99,98,97,96,
  93,92,77,72,0,70,71,
92,77,73,68,0,1,
135,134,133,132,130,129,128,123,122,105,102,100,99,97,7,0,2,3,4,5,6,12,15,
  17,18,19,23,24,25,28,30,31,32,34,35,41,44,46,48,51,56,57,58,59,62,64,65,
  66,78,82,87,107,127,
135,134,133,132,131,130,125,124,123,122,120,118,113,112,106,100,99,98,97,96,
  93,92,0,
77,0,
135,134,133,132,131,130,125,124,123,122,120,118,113,112,106,100,99,98,97,96,
  93,92,77,0,
72,0,
133,0,84,
135,133,132,126,125,124,123,122,121,120,119,118,117,116,115,114,113,112,100,
  96,92,77,73,68,0,85,
135,0,
135,134,133,132,131,130,129,128,125,124,123,122,120,118,113,112,106,100,99,
  98,97,96,92,77,73,68,0,1,94,95,
135,134,133,132,131,130,129,128,125,124,123,122,120,118,113,112,106,100,99,
  98,97,96,92,77,73,68,0,1,94,95,
135,134,133,132,131,130,129,128,125,124,123,122,120,118,113,112,106,100,99,
  98,97,96,92,77,73,68,0,1,94,95,
135,134,133,132,131,130,129,128,125,124,123,122,120,118,113,112,106,97,96,
  92,77,73,68,0,1,94,95,
97,92,77,73,68,0,1,94,95,
97,92,77,73,68,0,1,94,95,
126,125,124,123,122,121,120,119,118,117,116,115,114,113,112,100,96,92,77,73,
  68,0,1,94,95,
135,134,133,132,130,129,128,123,122,97,0,2,3,12,57,58,62,64,65,66,78,82,87,
  107,127,
135,134,133,132,130,129,128,123,122,97,0,2,3,12,57,58,62,64,65,66,78,82,87,
  107,127,
135,134,133,132,130,129,128,123,122,97,0,2,3,12,57,58,62,64,65,66,78,82,87,
  107,127,
135,134,133,132,130,129,128,123,122,97,0,2,3,12,23,35,41,44,46,48,51,56,57,
  58,59,62,64,65,66,78,82,87,107,127,
97,0,12,
97,0,12,
126,0,63,
125,124,0,60,61,
123,122,0,57,58,
121,120,119,118,0,52,53,54,55,
117,116,0,49,50,
135,134,133,0,
115,0,47,
97,92,77,73,68,0,1,94,95,
97,92,77,73,68,0,1,94,95,
126,125,124,123,122,121,120,119,118,117,116,115,114,113,112,111,110,109,108,
  106,100,96,92,77,73,68,0,1,94,95,
114,113,0,42,45,
97,0,12,
97,0,10,12,
135,134,133,132,131,130,129,128,125,124,123,122,120,118,113,112,106,105,102,
  100,99,98,97,92,77,73,68,0,1,94,95,
135,134,133,132,130,129,128,123,122,105,104,103,102,101,100,99,98,97,92,77,
  73,68,7,0,1,94,95,
111,110,109,108,106,0,36,37,38,39,40,
135,134,133,132,131,130,125,124,123,122,120,118,113,112,106,105,102,100,99,
  97,0,8,10,11,12,13,15,20,21,22,28,34,36,42,43,52,54,57,58,60,61,66,79,
  83,86,90,91,
135,134,133,132,130,129,128,123,122,105,102,100,99,97,0,2,3,12,15,17,18,19,
  23,24,25,28,30,31,32,34,35,41,44,46,48,51,56,57,58,59,62,64,65,66,78,82,
  87,107,127,
103,101,0,26,
103,101,0,26,
135,134,133,132,130,129,128,123,122,105,102,100,99,98,97,0,2,3,5,12,15,16,
  17,18,19,23,24,25,28,30,31,32,34,35,41,44,46,48,51,56,57,58,59,62,64,65,
  66,78,82,87,107,127,
100,0,24,
135,134,133,132,130,129,128,123,122,105,102,100,99,97,0,2,3,12,15,17,18,19,
  23,24,25,28,30,31,32,34,35,41,44,46,48,51,56,57,58,59,62,64,65,66,78,82,
  87,107,127,
7,0,
133,0,84,
133,0,84,
133,123,122,0,80,
96,0,14,
135,134,133,132,130,129,128,123,122,97,0,2,3,12,23,35,41,44,46,48,51,56,57,
  58,59,62,64,65,66,78,82,87,107,127,
135,134,133,132,130,129,128,123,122,97,0,2,3,12,23,35,41,44,46,48,51,56,57,
  58,59,62,64,65,66,78,82,87,107,127,
135,134,133,132,130,129,128,123,122,97,92,77,73,68,0,1,94,95,
135,134,133,132,130,129,128,123,122,97,0,2,3,12,57,58,59,62,64,65,66,78,82,
  87,107,127,
135,134,133,132,131,130,129,128,125,124,123,122,120,118,113,112,106,100,99,
  98,97,96,92,77,73,68,0,1,94,95,
135,134,133,132,130,129,128,123,122,97,0,2,3,12,57,58,59,62,64,65,66,78,82,
  87,107,127,
135,134,133,132,131,130,129,128,125,124,123,122,120,118,113,112,106,100,99,
  98,97,96,92,77,73,68,0,1,94,95,
135,134,133,132,130,129,128,123,122,97,0,2,3,12,57,58,59,62,64,65,66,78,82,
  87,107,127,
135,134,133,132,130,129,128,123,122,97,0,2,3,12,56,57,58,59,62,64,65,66,78,
  82,87,107,127,
135,134,133,132,130,129,128,123,122,97,0,2,3,12,56,57,58,59,62,64,65,66,78,
  82,87,107,127,
135,134,133,132,130,129,128,123,122,97,92,77,73,68,0,1,94,95,
135,134,133,132,130,129,128,123,122,97,0,2,3,12,51,56,57,58,59,62,64,65,66,
  78,82,87,107,127,
135,134,133,132,131,130,129,128,125,124,123,122,120,118,113,112,106,100,99,
  98,97,96,92,77,73,68,0,1,94,95,
135,134,133,132,130,129,128,123,122,97,0,2,3,12,51,56,57,58,59,62,64,65,66,
  78,82,87,107,127,
135,134,133,132,130,129,128,123,122,97,92,77,73,68,0,1,94,95,
135,134,133,132,130,129,128,123,122,97,0,2,3,12,51,56,57,58,59,62,64,65,66,
  78,82,87,107,127,
135,134,133,132,131,130,129,128,125,124,123,122,120,118,113,112,106,100,99,
  98,97,96,92,77,73,68,0,1,94,95,
135,134,133,132,130,129,128,123,122,97,0,2,3,12,51,56,57,58,59,62,64,65,66,
  78,82,87,107,127,
135,134,133,132,130,129,128,123,122,97,92,77,73,68,0,1,94,95,
135,134,133,132,130,129,128,123,122,97,0,2,3,12,48,51,56,57,58,59,62,64,65,
  66,78,82,87,107,127,
135,134,133,132,130,129,128,123,122,97,92,77,73,68,0,1,94,95,
135,134,133,132,130,129,128,123,122,97,0,2,3,12,48,51,56,57,58,59,62,64,65,
  66,78,82,87,107,127,
135,134,133,132,130,129,128,123,122,97,92,77,73,68,0,1,94,95,
135,134,133,132,130,129,128,123,122,97,0,2,3,12,46,48,51,56,57,58,59,62,64,
  65,66,78,82,87,107,127,
135,134,133,132,130,129,128,123,122,97,92,77,73,68,0,1,94,95,
135,134,133,132,130,129,128,123,122,97,0,2,3,12,44,46,48,51,56,57,58,59,62,
  64,65,66,78,82,87,107,127,
135,134,133,132,131,130,129,128,125,124,123,122,120,118,113,112,106,100,99,
  98,97,96,92,77,73,68,0,1,94,95,
135,134,133,132,130,129,128,123,122,97,0,2,3,12,23,35,41,44,46,48,51,56,57,
  58,59,62,64,65,66,78,82,87,107,127,
135,134,133,132,130,129,128,123,122,97,0,2,3,12,23,35,41,44,46,48,51,56,57,
  58,59,62,64,65,66,78,82,87,107,127,
135,134,133,132,131,130,125,124,123,122,120,118,113,112,106,97,96,0,8,10,12,
  13,36,42,43,52,54,57,58,60,61,66,79,83,86,90,91,
135,134,133,132,131,130,125,124,123,122,120,118,113,112,106,105,102,100,99,
  97,0,8,10,11,12,13,15,21,22,28,34,36,42,43,52,54,57,58,60,61,66,79,83,
  86,90,91,
135,134,133,132,130,129,128,123,122,97,92,77,73,68,0,1,94,95,
135,134,133,132,130,129,128,123,122,97,0,2,3,12,23,35,41,44,46,48,51,56,57,
  58,59,62,64,65,66,78,82,87,107,127,
135,134,133,132,130,129,128,123,122,97,92,77,73,68,0,1,94,95,
135,134,133,132,130,129,128,123,122,97,0,2,3,12,23,35,41,44,46,48,51,56,57,
  58,59,62,64,65,66,78,82,87,107,127,
135,134,133,132,130,129,128,123,122,97,92,77,73,68,0,1,94,95,
135,134,133,132,130,129,128,123,122,97,0,2,3,12,23,35,41,44,46,48,51,56,57,
  58,59,62,64,65,66,78,82,87,107,127,
135,134,133,132,130,129,128,123,122,97,92,77,73,68,0,1,94,95,
135,134,133,132,130,129,128,123,122,97,0,2,3,12,23,35,41,44,46,48,51,56,57,
  58,59,62,64,65,66,78,82,87,107,127,
135,134,133,132,131,130,129,128,125,124,123,122,120,118,113,112,106,100,99,
  98,97,96,92,77,73,68,0,1,94,95,
135,134,133,132,130,129,128,123,122,97,0,2,3,12,23,35,41,44,46,48,51,56,57,
  58,59,62,64,65,66,78,82,87,107,127,
135,134,133,132,131,130,125,124,123,122,120,118,113,112,106,100,99,98,97,96,
  92,77,73,68,0,1,94,95,
135,134,133,132,131,130,125,124,123,122,120,118,113,112,106,100,99,98,97,96,
  92,77,73,68,0,1,94,95,
135,134,133,132,131,130,129,128,125,124,123,122,120,118,113,112,106,100,99,
  98,97,96,92,77,73,68,0,1,94,95,
135,134,133,132,131,130,125,124,123,122,120,118,113,112,106,100,99,98,97,96,
  92,77,73,68,0,1,94,95,
135,134,133,132,131,130,125,124,123,122,120,118,113,112,106,100,99,98,97,96,
  92,77,73,68,0,1,94,95,
135,134,133,132,131,130,125,124,123,122,120,118,113,112,106,100,99,98,97,96,
  92,77,73,68,0,1,94,95,
135,134,133,132,131,130,125,124,123,122,120,118,113,112,106,99,98,97,0,8,10,
  11,12,13,15,36,42,43,52,54,57,58,60,61,66,79,83,86,90,91,
135,134,133,132,131,130,125,124,123,122,120,118,113,112,106,99,97,0,10,11,
  12,15,36,42,43,52,54,57,58,60,61,66,79,83,86,90,91,
97,0,10,12,
97,0,10,12,
100,0,24,
104,0,33,
104,0,33,
103,101,0,27,29,
103,101,0,27,29,
135,134,133,132,130,129,128,123,122,105,102,100,99,98,97,0,2,3,12,15,16,17,
  18,19,23,24,25,28,30,31,32,34,35,41,44,46,48,51,56,57,58,59,62,64,65,66,
  78,82,87,107,127,
135,134,133,132,131,130,129,128,125,124,123,122,120,118,113,112,106,105,104,
  103,102,101,100,99,98,97,96,92,77,73,68,7,0,1,94,95,
133,0,81,
133,0,81,
135,134,133,132,131,130,129,128,126,125,124,123,122,121,120,119,118,117,116,
  115,114,113,112,106,105,102,100,99,98,97,96,92,77,73,68,0,1,94,95,
96,0,14,
96,0,14,
125,124,0,60,61,
125,124,0,60,61,
123,122,0,57,58,
123,122,0,57,58,
123,122,0,57,58,
123,122,0,57,58,
121,120,119,118,0,52,53,54,55,
121,120,119,118,0,52,53,54,55,
117,116,0,49,50,
115,0,47,
112,0,43,
96,0,14,
96,0,14,
98,0,16,
98,0,16,
135,134,133,132,131,130,125,124,123,122,120,118,113,112,106,105,102,100,99,
  97,0,8,10,11,12,13,15,20,21,22,28,34,36,42,43,52,54,57,58,60,61,66,79,
  83,86,90,91,
135,134,133,132,131,130,125,124,123,122,120,118,113,112,106,105,102,100,99,
  97,0,8,10,11,12,13,15,21,22,28,34,36,42,43,52,54,57,58,60,61,66,79,83,
  86,90,91,
135,134,133,132,131,130,129,128,125,124,123,122,120,118,113,112,106,105,102,
  100,99,97,92,77,73,68,0,1,94,95,
135,134,133,132,130,129,128,123,122,105,102,100,99,97,0,2,3,12,15,17,18,19,
  23,24,25,28,30,31,32,34,35,41,44,46,48,51,56,57,58,59,62,64,65,66,78,82,
  87,107,127,
135,134,133,132,131,130,125,124,123,122,120,118,113,112,106,105,102,100,99,
  97,0,8,10,11,12,13,15,20,21,22,28,34,36,42,43,52,54,57,58,60,61,66,79,
  83,86,90,91,
135,134,133,132,131,130,125,124,123,122,120,118,113,112,106,105,102,100,99,
  97,92,77,73,68,0,1,94,95,
135,134,133,132,131,130,125,124,123,122,120,118,113,112,106,105,102,100,99,
  97,0,8,10,11,12,13,15,20,21,22,28,34,36,42,43,52,54,57,58,60,61,66,79,
  83,86,90,91,
135,134,133,132,130,129,128,123,122,105,102,100,99,97,92,77,73,68,0,1,94,95,
135,134,133,132,130,129,128,123,122,105,102,100,99,97,0,2,3,12,15,17,18,19,
  23,24,25,28,30,31,32,34,35,41,44,46,48,51,56,57,58,59,62,64,65,66,78,82,
  87,107,127,
135,134,133,132,131,130,125,124,123,122,120,118,113,112,106,105,102,100,99,
  97,0,8,10,11,12,13,15,20,21,22,28,34,36,42,43,52,54,57,58,60,61,66,79,
  83,86,90,91,
133,0,
133,0,
135,134,133,132,130,129,128,123,122,97,0,2,3,12,35,41,44,46,48,51,56,57,58,
  59,62,64,65,66,78,82,87,107,127,
104,0,33,
135,134,133,132,131,130,125,124,123,122,120,118,113,112,106,105,102,100,99,
  97,0,8,10,11,12,13,15,20,21,22,28,34,36,42,43,52,54,57,58,60,61,66,79,
  83,86,90,91,

};


static unsigned const char ag_astt[2991] = {
  8,8,8,8,8,8,8,8,8,8,8,8,8,8,1,1,1,1,8,7,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
  1,1,1,1,1,1,1,1,8,7,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,8,7,
  1,1,9,9,1,1,5,3,2,2,2,1,1,1,1,1,1,1,1,1,1,1,8,7,2,1,0,1,1,1,1,2,2,2,1,2,1,
  1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,9,9,9,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19,11,
  10,30,34,18,
84,84,84,84,84,84,84,84,84,84,84,84,84,84,84,84,84,84,84,84,84,84,86,
87,6,
79,79,79,79,79,79,79,79,79,79,79,79,79,79,79,79,79,79,79,79,79,79,79,81,
82,8,
49,9,97,
94,99,50,94,94,94,94,94,94,94,94,94,94,94,94,94,94,94,94,94,94,94,94,94,10,
  96,
51,88,
176,176,176,176,176,176,176,176,176,176,176,176,176,176,176,176,176,176,176,
  176,176,176,3,3,1,2,12,3,3,212,
176,176,176,176,176,176,176,176,176,176,176,176,176,176,176,176,176,176,176,
  176,176,176,3,3,1,2,13,3,3,204,
176,176,176,176,176,176,176,176,176,176,176,176,176,176,176,176,176,176,176,
  176,176,176,3,3,1,2,14,3,3,205,
176,176,176,176,176,176,176,176,176,176,176,176,176,176,176,176,176,176,176,
  3,3,1,2,15,3,3,179,
176,3,3,1,2,16,3,3,211,
176,3,3,1,2,17,3,3,210,
176,176,176,176,176,176,176,176,176,176,176,176,176,176,176,176,176,3,3,1,2,
  18,3,3,209,
105,105,98,9,12,16,17,14,13,15,19,69,70,22,20,21,76,24,23,19,11,10,30,34,18,
105,105,98,9,12,16,17,14,13,15,20,69,70,22,20,21,75,24,23,19,11,10,30,34,18,
105,105,98,9,12,16,17,14,13,15,21,69,70,22,20,21,74,24,23,19,11,10,30,34,18,
105,105,98,9,12,16,17,14,13,15,22,69,40,22,52,52,35,31,29,28,27,26,20,21,26,
  25,24,23,19,11,10,30,34,18,
15,23,53,
15,24,54,
55,67,56,
57,59,61,60,58,
14,13,56,62,61,
63,65,67,69,53,70,68,66,64,
71,73,51,74,72,
106,106,106,104,
75,49,76,
176,3,3,1,2,32,3,3,187,
176,3,3,1,2,33,3,3,184,
176,176,176,176,176,176,176,176,176,176,176,176,176,176,176,176,176,176,176,
  176,176,176,3,3,1,2,34,3,3,189,
77,79,47,80,78,
15,36,81,
15,37,83,82,
176,176,176,176,176,176,176,176,176,176,176,176,176,176,176,176,176,176,176,
  176,176,176,176,3,3,1,2,38,3,3,181,
176,176,176,176,176,176,176,176,176,176,176,176,176,176,176,176,176,176,3,3,
  1,2,176,39,3,3,182,
84,86,88,90,92,70,93,91,89,87,85,
94,95,97,98,99,12,57,59,14,13,65,69,79,96,92,32,33,104,38,15,41,101,101,105,
  82,104,100,33,105,33,103,102,101,101,101,101,101,101,101,101,101,101,
  101,101,101,101,101,
105,105,98,9,12,16,17,14,13,32,33,39,38,15,42,69,40,22,45,32,106,32,46,106,
  44,37,43,42,41,36,46,35,31,29,28,27,26,20,21,26,25,24,23,19,11,10,30,34,
  18,
107,107,43,107,
108,108,44,108,
105,105,98,9,12,16,17,14,13,32,33,39,38,110,15,45,69,40,109,22,45,22,16,16,
  16,46,16,44,37,43,42,41,36,46,35,31,29,28,27,26,20,21,26,25,24,23,19,11,
  10,30,34,18,
39,46,20,
105,105,98,9,12,16,17,14,13,32,33,39,38,15,2,69,40,22,45,17,17,17,46,17,44,
  37,43,42,41,36,46,35,31,29,28,27,26,20,21,26,25,24,23,19,11,10,30,34,18,
3,48,
49,100,101,
49,95,93,
112,111,112,51,112,
113,52,73,
105,105,98,9,12,16,17,14,13,15,53,69,40,22,114,114,35,31,29,28,27,26,20,21,
  26,25,24,23,19,11,10,30,34,18,
105,105,98,9,12,16,17,14,13,15,54,69,40,22,115,115,35,31,29,28,27,26,20,21,
  26,25,24,23,19,11,10,30,34,18,
176,176,176,176,176,176,176,176,176,176,3,3,1,2,55,3,3,208,
105,105,98,9,12,16,17,14,13,15,56,69,70,22,20,21,68,25,24,23,19,11,10,30,34,
  18,
176,176,176,176,176,176,176,176,176,176,176,176,176,176,176,176,176,176,176,
  176,176,176,3,3,1,2,57,3,3,207,
105,105,98,9,12,16,17,14,13,15,58,69,70,22,20,21,66,25,24,23,19,11,10,30,34,
  18,
176,176,176,176,176,176,176,176,176,176,176,176,176,176,176,176,176,176,176,
  176,176,176,3,3,1,2,59,3,3,206,
105,105,98,9,12,16,17,14,13,15,60,69,70,22,20,21,65,25,24,23,19,11,10,30,34,
  18,
105,105,98,9,12,16,17,14,13,15,61,69,70,22,116,20,21,116,25,24,23,19,11,10,
  30,34,18,
105,105,98,9,12,16,17,14,13,15,62,69,70,22,117,20,21,117,25,24,23,19,11,10,
  30,34,18,
176,176,176,176,176,176,176,176,176,176,3,3,1,2,63,3,3,203,
105,105,98,9,12,16,17,14,13,15,64,69,70,22,118,26,20,21,26,25,24,23,19,11,
  10,30,34,18,
176,176,176,176,176,176,176,176,176,176,176,176,176,176,176,176,176,176,176,
  176,176,176,3,3,1,2,65,3,3,202,
105,105,98,9,12,16,17,14,13,15,66,69,70,22,119,26,20,21,26,25,24,23,19,11,
  10,30,34,18,
176,176,176,176,176,176,176,176,176,176,3,3,1,2,67,3,3,201,
105,105,98,9,12,16,17,14,13,15,68,69,70,22,120,26,20,21,26,25,24,23,19,11,
  10,30,34,18,
176,176,176,176,176,176,176,176,176,176,176,176,176,176,176,176,176,176,176,
  176,176,176,3,3,1,2,69,3,3,200,
105,105,98,9,12,16,17,14,13,15,70,69,70,22,121,26,20,21,26,25,24,23,19,11,
  10,30,34,18,
176,176,176,176,176,176,176,176,176,176,3,3,1,2,71,3,3,199,
105,105,98,9,12,16,17,14,13,15,72,69,70,22,122,27,26,20,21,26,25,24,23,19,
  11,10,30,34,18,
176,176,176,176,176,176,176,176,176,176,3,3,1,2,73,3,3,198,
105,105,98,9,12,16,17,14,13,15,74,69,70,22,123,27,26,20,21,26,25,24,23,19,
  11,10,30,34,18,
176,176,176,176,176,176,176,176,176,176,3,3,1,2,75,3,3,197,
105,105,98,9,12,16,17,14,13,15,76,69,70,22,124,28,27,26,20,21,26,25,24,23,
  19,11,10,30,34,18,
176,176,176,176,176,176,176,176,176,176,3,3,1,2,77,3,3,196,
105,105,98,9,12,16,17,14,13,15,78,69,70,22,125,29,28,27,26,20,21,26,25,24,
  23,19,11,10,30,34,18,
176,176,176,176,176,176,176,176,176,176,176,176,176,176,176,176,176,176,176,
  176,176,176,3,3,1,2,79,3,3,195,
105,105,98,9,12,16,17,14,13,15,80,69,40,22,126,126,35,31,29,28,27,26,20,21,
  26,25,24,23,19,11,10,30,34,18,
105,105,98,9,12,16,17,14,13,15,81,69,40,22,127,127,35,31,29,28,27,26,20,21,
  26,25,24,23,19,11,10,30,34,18,
94,95,97,98,99,12,57,59,14,13,65,69,79,96,92,15,128,82,101,101,82,128,101,
  101,101,101,101,101,101,101,101,101,101,101,101,101,101,
94,95,97,98,99,12,57,59,14,13,65,69,79,96,92,32,33,104,38,15,83,101,101,25,
  82,104,100,25,36,103,102,101,101,101,101,101,101,101,101,101,101,101,
  101,101,101,101,
176,176,176,176,176,176,176,176,176,176,3,3,1,2,84,3,3,193,
105,105,98,9,12,16,17,14,13,15,85,69,40,22,46,46,35,31,29,28,27,26,20,21,26,
  25,24,23,19,11,10,30,34,18,
176,176,176,176,176,176,176,176,176,176,3,3,1,2,86,3,3,192,
105,105,98,9,12,16,17,14,13,15,87,69,40,22,45,45,35,31,29,28,27,26,20,21,26,
  25,24,23,19,11,10,30,34,18,
176,176,176,176,176,176,176,176,176,176,3,3,1,2,88,3,3,191,
105,105,98,9,12,16,17,14,13,15,89,69,40,22,44,44,35,31,29,28,27,26,20,21,26,
  25,24,23,19,11,10,30,34,18,
176,176,176,176,176,176,176,176,176,176,3,3,1,2,90,3,3,190,
105,105,98,9,12,16,17,14,13,15,91,69,40,22,43,43,35,31,29,28,27,26,20,21,26,
  25,24,23,19,11,10,30,34,18,
176,176,176,176,176,176,176,176,176,176,176,176,176,176,176,176,176,176,176,
  176,176,176,3,3,1,2,92,3,3,188,
105,105,98,9,12,16,17,14,13,15,93,69,40,22,42,42,35,31,29,28,27,26,20,21,26,
  25,24,23,19,11,10,30,34,18,
176,176,176,176,176,176,176,176,176,176,176,176,176,176,176,176,176,176,176,
  176,3,3,1,2,94,3,3,217,
176,176,176,176,176,176,176,176,176,176,176,176,176,176,176,176,176,176,176,
  176,3,3,1,2,95,3,3,216,
176,176,176,176,176,176,176,176,176,176,176,176,176,176,176,176,176,176,176,
  176,176,176,3,3,1,2,96,3,3,194,
176,176,176,176,176,176,176,176,176,176,176,176,176,176,176,176,176,176,176,
  176,3,3,1,2,97,3,3,215,
176,176,176,176,176,176,176,176,176,176,176,176,176,176,176,176,176,176,176,
  176,3,3,1,2,98,3,3,214,
176,176,176,176,176,176,176,176,176,176,176,176,176,176,176,176,176,176,176,
  176,3,3,1,2,99,3,3,213,
94,95,97,98,99,12,57,59,14,13,65,69,79,96,92,38,130,15,100,101,101,129,82,
  130,100,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,
94,95,97,98,99,12,57,59,14,13,65,69,79,96,92,38,15,10,7,8,82,100,6,6,6,6,6,
  6,6,6,6,6,6,6,6,6,6,
15,102,131,82,
15,103,132,82,
39,104,28,
133,18,134,
133,14,135,
138,136,107,137,139,
138,136,108,140,139,
105,105,98,9,12,16,17,14,13,32,33,39,38,110,15,109,69,40,22,45,23,17,17,17,
  46,17,44,37,43,42,41,36,46,35,31,29,28,27,26,20,21,26,25,24,23,19,11,10,
  30,34,18,
176,176,176,176,176,176,176,176,176,176,176,176,176,176,176,176,176,176,176,
  176,176,176,176,176,176,176,176,3,3,1,2,176,110,3,3,180,
102,111,141,
102,112,142,
176,176,176,176,176,176,176,176,176,176,176,176,176,176,176,176,176,176,176,
  176,176,176,176,176,176,176,176,176,176,176,176,3,3,1,2,113,3,3,178,
113,114,72,
113,115,71,
57,59,63,60,58,
57,59,62,60,58,
14,13,60,62,61,
14,13,59,62,61,
14,13,58,62,61,
14,13,57,62,61,
63,65,67,69,55,70,68,66,64,
63,65,67,69,54,70,68,66,64,
71,73,52,74,72,
75,50,76,
96,126,143,
113,127,40,
113,128,11,
110,129,13,
110,130,12,
94,95,97,98,99,12,57,59,14,13,65,69,79,96,92,32,33,104,38,15,131,101,101,
  144,82,104,100,37,144,37,103,102,101,101,101,101,101,101,101,101,101,
  101,101,101,101,101,101,
94,95,97,98,99,12,57,59,14,13,65,69,79,96,92,32,33,104,38,15,132,101,101,30,
  82,104,100,30,39,103,102,101,101,101,101,101,101,101,101,101,101,101,
  101,101,101,101,
176,176,176,176,176,176,176,176,176,176,176,176,176,176,176,176,176,176,176,
  176,176,176,3,3,1,2,133,3,3,186,
105,105,98,9,12,16,17,14,13,32,33,39,38,15,134,69,40,22,45,35,35,35,46,35,
  44,37,43,42,41,36,46,35,31,29,28,27,26,20,21,26,25,24,23,19,11,10,30,34,
  18,
94,95,97,98,99,12,57,59,14,13,65,69,79,96,92,32,33,104,38,15,135,101,101,34,
  82,104,100,34,34,34,103,102,101,101,101,101,101,101,101,101,101,101,101,
  101,101,101,101,
176,176,176,176,176,176,176,176,176,176,176,176,176,176,176,176,176,176,176,
  176,3,3,1,2,136,3,3,183,
94,95,97,98,99,12,57,59,14,13,65,69,79,96,92,32,33,104,38,15,137,101,101,31,
  82,104,100,31,31,31,103,102,101,101,101,101,101,101,101,101,101,101,101,
  101,101,101,101,
176,176,176,176,176,176,176,176,176,176,176,176,176,176,3,3,1,2,138,3,3,185,
105,105,98,9,12,16,17,14,13,32,33,39,38,15,139,69,40,22,45,27,27,27,46,27,
  44,37,43,42,41,36,46,35,31,29,28,27,26,20,21,26,25,24,23,19,11,10,30,34,
  18,
94,95,97,98,99,12,57,59,14,13,65,69,79,96,92,32,33,104,38,15,140,101,101,24,
  82,104,100,24,24,24,103,102,101,101,101,101,101,101,101,101,101,101,101,
  101,101,101,101,
103,92,
103,91,
105,105,98,9,12,16,17,14,13,15,143,69,70,22,48,35,31,29,28,27,26,20,21,26,
  25,24,23,19,11,10,30,34,18,
133,18,145,
94,95,97,98,99,12,57,59,14,13,65,69,79,96,92,32,33,104,38,15,145,101,101,38,
  82,104,100,38,38,38,103,102,101,101,101,101,101,101,101,101,101,101,101,
  101,101,101,101,

};


static const unsigned short ag_sbt[] = {
     0,  23,  49,  76,  82, 135, 158, 160, 184, 186, 189, 215, 217, 247,
   277, 307, 334, 343, 352, 377, 402, 427, 452, 486, 489, 492, 495, 500,
   505, 514, 519, 523, 526, 535, 544, 574, 579, 582, 586, 617, 644, 655,
   702, 751, 755, 759, 811, 814, 863, 865, 868, 871, 876, 879, 913, 947,
   965, 991,1021,1047,1077,1103,1130,1157,1175,1203,1233,1261,1279,1307,
  1337,1365,1383,1412,1430,1459,1477,1507,1525,1556,1586,1620,1654,1691,
  1737,1755,1789,1807,1841,1859,1893,1911,1945,1975,2009,2037,2065,2095,
  2123,2151,2179,2219,2256,2260,2264,2267,2270,2273,2278,2283,2334,2370,
  2373,2376,2415,2418,2421,2426,2431,2436,2441,2446,2451,2460,2469,2474,
  2477,2480,2483,2486,2489,2492,2539,2585,2615,2664,2711,2739,2786,2808,
  2857,2904,2906,2908,2941,2944,2991
};


static const unsigned short ag_sbe[] = {
    19,  46,  73,  80,  97, 157, 159, 183, 185, 187, 213, 216, 243, 273,
   303, 330, 339, 348, 373, 387, 412, 437, 462, 487, 490, 493, 497, 502,
   509, 516, 522, 524, 531, 540, 570, 576, 580, 583, 613, 640, 649, 675,
   716, 753, 757, 774, 812, 828, 864, 866, 869, 874, 877, 889, 923, 961,
   975,1017,1031,1073,1087,1113,1140,1171,1185,1229,1243,1275,1289,1333,
  1347,1379,1393,1426,1440,1473,1487,1521,1535,1582,1596,1630,1671,1711,
  1751,1765,1803,1817,1855,1869,1907,1921,1971,1985,2033,2061,2091,2119,
  2147,2175,2197,2236,2257,2261,2265,2268,2271,2275,2280,2298,2366,2371,
  2374,2411,2416,2419,2423,2428,2433,2438,2443,2448,2455,2464,2471,2475,
  2478,2481,2484,2487,2490,2512,2559,2611,2629,2684,2735,2759,2804,2822,
  2877,2905,2907,2918,2942,2964,2991
};


static const unsigned char ag_fl[] = {
  2,0,1,2,1,1,2,2,2,0,1,3,3,3,1,1,1,2,1,1,2,1,2,3,4,3,0,3,2,1,3,4,2,2,4,
  4,3,3,5,3,4,1,3,3,3,3,3,1,5,1,3,1,3,1,3,3,1,3,3,3,3,1,3,3,1,3,3,1,3,1,
  1,4,4,3,2,2,2,1,1,2,0,1,3,1,2,0,1,3,1,0,1,4,4,3,0,1,2,2,1,2,1,2,1,2,1,
  1,2,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
  1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,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,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,  8,  8,  8,  8,  8, 13, 13, 10, 11, 11, 17, 17,  5,  5,
   20, 20, 18, 18, 18, 18, 18, 25, 26, 26, 21, 21, 21, 19, 19, 19, 19, 19,
   30, 22, 22, 22, 32, 23, 23, 23, 23, 23, 23, 35, 35, 41, 41, 44, 44, 46,
   46, 46, 48, 48, 48, 48, 48, 51, 51, 51, 56, 56, 56, 59, 59, 62, 62, 62,
   62, 62, 62, 62, 62,  1, 70, 70, 71, 71,  1, 75, 75, 76, 76,  1,127, 80,
   80,127,127, 78, 85, 85, 78, 78, 82, 82, 84, 84, 81, 81,107, 87, 87,  9,
    9,  9,  9,  9,  9,  9,  9,  9,  9,  9,  9,  9,  9,  9, 67, 67, 69, 69,
   69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69,
   69, 69, 69, 74, 74, 74, 74, 74, 74, 74, 74, 74, 74, 74, 74, 74, 74, 74,
   74, 74, 74, 74, 74, 74, 74, 88, 88, 89, 89, 89, 94, 94, 95, 95, 14, 12,
   16, 15, 24, 27, 28, 29, 33, 34, 36,  3, 37, 38, 39, 40, 43, 42, 45, 47,
   49, 50, 52, 53, 54, 55, 57, 58, 60, 61, 63,  2, 64, 65, 66, 90, 83, 86,
   91, 79
};

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 asil_change_reduction(asil_token_type ag_k) {
  if (!ag_valid(ag_k)) return 0;
  (PCB).reduction_token = ag_k;
  return 1;
}

static void ag_default(const  int *ag_tp) {
  (PCB).ag_dsn = (PCB).sn;
  (PCB).ag_dtl = ag_tp;
  while (!ag_valid((asil_token_type) *ag_tp)) ag_tp++;
  (PCB).reduction_token = (asil_token_type) *ag_tp;
}



static void ag_ra(void)
{
  switch(ag_rpx[(PCB).ag_ap]) {
    case 1: V(0,(double *)) = ag_rp_1(V(0,(double *))); break;
    case 2: V(0,(double *)) = ag_rp_2(V(0,(double *))); break;
    case 3: ag_default(&ag_rtt[0]); V(0,(double *)) = ag_rp_3(V(2,(double *))); break;
    case 4: V(0,(double *)) = ag_rp_4(V(0,(int *)), V(2,(double *))); break;
    case 5: V(0,(double *)) = ag_rp_5(V(0,(int *)), V(2,(double *))); break;
    case 6: V(0,(double *)) = ag_rp_6(V(0,(int *)), V(2,(double *))); break;
    case 7: V(0,(double *)) = ag_rp_7(V(0,(int *)), V(2,(double *))); break;
    case 8: V(0,(double *)) = ag_rp_8(V(0,(int *)), V(2,(double *))); break;
    case 9: V(0,(double *)) = ag_rp_9(V(0,(double *)), V(2,(double *)), V(4,(double *))); break;
    case 10: V(0,(double *)) = ag_rp_10(V(0,(double *)), V(2,(double *))); break;
    case 11: V(0,(double *)) = ag_rp_11(V(0,(double *)), V(2,(double *))); break;
    case 12: V(0,(double *)) = ag_rp_12(V(0,(double *)), V(2,(double *))); break;
    case 13: V(0,(double *)) = ag_rp_13(V(0,(double *)), V(2,(double *))); break;
    case 14: V(0,(double *)) = ag_rp_14(V(0,(double *)), V(2,(double *))); break;
    case 15: V(0,(double *)) = ag_rp_15(V(0,(double *)), V(2,(double *))); break;
    case 16: V(0,(double *)) = ag_rp_16(V(0,(double *)), V(2,(double *))); break;
    case 17: V(0,(double *)) = ag_rp_17(V(0,(double *)), V(2,(double *))); break;
    case 18: V(0,(double *)) = ag_rp_18(V(0,(double *)), V(2,(double *))); break;
    case 19: V(0,(double *)) = ag_rp_19(V(0,(double *)), V(2,(double *))); break;
    case 20: V(0,(double *)) = ag_rp_20(V(0,(double *)), V(2,(double *))); break;
    case 21: V(0,(double *)) = ag_rp_21(V(0,(double *)), V(2,(double *))); break;
    case 22: V(0,(double *)) = ag_rp_22(V(0,(double *)), V(2,(double *))); break;
    case 23: V(0,(double *)) = ag_rp_23(V(0,(double *))); break;
    case 24: V(0,(double *)) = ag_rp_24(V(0,(int *))); break;
    case 25: V(0,(double *)) = ag_rp_25(V(2,(double *))); break;
    case 26: V(0,(double *)) = ag_rp_26(V(2,(double *))); break;
    case 27: V(0,(double *)) = ag_rp_2(V(1,(double *))); break;
    case 28: V(0,(double *)) = ag_rp_28(V(1,(double *))); break;
    case 29: V(0,(double *)) = ag_rp_29(V(1,(double *))); break;
    case 30: V(0,(double *)) = ag_rp_30(V(1,(double *))); break;
    case 31: V(0,(double *)) = ag_rp_31(V(0,(double *)), V(3,(int *))); break;
    case 32: V(0,(double *)) = ag_rp_32(V(0,(double *)), V(3,(int *))); break;
    case 33: V(0,(double *)) = ag_rp_33(V(0,(double *)), V(2,(double *))); break;
    case 34: V(0,(double *)) = ag_rp_34(V(1,(double *))); break;
    case 35: V(0,(double *)) = ag_rp_35(V(0,(int *))); break;
    case 36: V(0,(double *)) = ag_rp_36(V(0,(double *)), V(1,(int *))); break;
    case 37: V(0,(double *)) = ag_rp_37(V(0,(int *))); break;
    case 38: V(0,(double *)) = ag_rp_38(V(0,(int *)), V(1,(double *))); break;
    case 39: V(0,(int *)) = ag_rp_39(V(0,(int *))); break;
    case 40: V(0,(int *)) = ag_rp_40(V(0,(int *)), V(1,(int *))); break;
    case 41: V(0,(int *)) = ag_rp_41(V(0,(int *))); break;
    case 42: V(0,(int *)) = ag_rp_42(V(0,(int *))); break;
    case 43: V(0,(int *)) = ag_rp_43(V(0,(int *)), V(1,(int *))); break;
  }
  (PCB).la_ptr = (PCB).pointer;
}

#define TOKEN_NAMES asil_token_names
const char *const asil_token_names[136] = {
  "input string",
  "white space",
  "real",
  "name",
  "input string",
  "statements",
  "",
  "eof",
  "statement text",
  "statement char",
  "balanced parens",
  "balanced braces",
  "'('",
  "",
  "')'",
  "'{'",
  "'}'",
  "statement",
  "unconditional statement",
  "conditional statement",
  "skip statement",
  "skip unconditional statement",
  "skip conditional statement",
  "expression",
  "';'",
  "gather unconditional while",
  "while loop",
  "false condition",
  "\"while\"",
  "true condition",
  "gather conditional while",
  "true if clause",
  "false if clause",
  "\"else\"",
  "\"if\"",
  "conditional expression",
  "'='",
  "\"+=\"",
  "\"-=\"",
  "\"*=\"",
  "\"/=\"",
  "logical or expression",
  "'\\?'",
  "':'",
  "logical and expression",
  "\"||\"",
  "equality expression",
  "\"&&\"",
  "relational expression",
  "\"==\"",
  "\"!=\"",
  "additive expression",
  "'<'",
  "\"<=\"",
  "'>'",
  "\">=\"",
  "multiplicative expression",
  "'+'",
  "'-'",
  "factor",
  "'*'",
  "'/'",
  "primary",
  "\"**\"",
  "\"log\"",
  "\"exp\"",
  "'!'",
  "blank",
  "\"/*\"",
  "",
  "",
  "",
  "\"*/\"",
  "\"//\"",
  "",
  "",
  "",
  "'\\n'",
  "simple real",
  "",
  "",
  "exponent",
  "integer part",
  "'.'",
  "fraction part",
  "",
  "digit",
  "name string",
  "letter",
  "",
  "",
  "",
  "",
  "",
  "",
  "",
  "')'",
  "'('",
  "'}'",
  "'{'",
  "';'",
  "false condition",
  "\"while\"",
  "true condition",
  "\"else\"",
  "\"if\"",
  "'='",
  "name",
  "\"+=\"",
  "\"-=\"",
  "\"*=\"",
  "\"/=\"",
  "':'",
  "'\\?'",
  "\"||\"",
  "\"&&\"",
  "\"==\"",
  "\"!=\"",
  "'<'",
  "\"<=\"",
  "'>'",
  "\">=\"",
  "'+'",
  "'-'",
  "'*'",
  "'/'",
  "\"**\"",
  "real",
  "\"log\"",
  "\"exp\"",
  "'!'",
  "",
  "'.'",
  "digit",
  "",
  "",

};

#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(INPUT_CODE((*(PCB).pointer))) && INPUT_CODE((*(PCB).pointer)) != '\\') {
    char buf[20];
    sprintf(buf, "\'%c\'", (char) INPUT_CODE((*(PCB).pointer)));
    sprintf((PCB).ag_msg, UNEXPECTED_FORMAT, buf);
  }
  else sprintf((PCB).ag_msg, UNEXPECTED_FORMAT, UNNAMED_TOKEN);
  (PCB).error_message = (PCB).ag_msg;


}
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();
    (PCB).token_number = (asil_token_type) AG_TCV(INPUT_CODE(*(PCB).la_ptr));
    (PCB).la_ptr++;
    if (ag_key_index[(PCB).sn]) {
      unsigned ag_k = ag_key_index[(PCB).sn];
      int ag_ch = CONVERT_CASE(INPUT_CODE(*(PCB).pointer));
      if (ag_ch <= 255) {
        while (ag_key_ch[ag_k] < ag_ch) ag_k++;
        if (ag_key_ch[ag_k] == ag_ch) ag_get_key_word(ag_k);
      }
    }
  } while ((PCB).token_number == (asil_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--;
    ag_track();
    ag_ra();
    if ((PCB).exit_flag != AG_RUNNING_CODE) return 0;
    (PCB).ssx++;
    (PCB).token_number = (asil_token_type) AG_TCV(INPUT_CODE(*(PCB).la_ptr));
    (PCB).la_ptr++;
    if (ag_key_index[(PCB).sn]) {
      unsigned ag_k = ag_key_index[(PCB).sn];
      int ag_ch = CONVERT_CASE(INPUT_CODE(*(PCB).pointer));
      if (ag_ch <= 255) {
        while (ag_key_ch[ag_k] < ag_ch) ag_k++;
        if (ag_key_ch[ag_k] == ag_ch) ag_get_key_word(ag_k);
      }
    }
  }
  while ((PCB).token_number == (asil_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 = (asil_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 = (asil_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 = (asil_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;
  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).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) {
  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 = (asil_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;
  ag_track();
  while ((PCB).exit_flag == AG_RUNNING_CODE) {
    unsigned ag_t1 = ag_sbe[(PCB).sn] + 1;
    unsigned ag_t2 = ag_sbt[(PCB).sn+1] - 1;
    do {
      unsigned ag_tx = (ag_t1 + ag_t2)/2;
      if (ag_tstt[ag_tx] < (unsigned char)(PCB).reduction_token) ag_t1 = ag_tx + 1;
      else ag_t2 = ag_tx;
    } while (ag_t1 < ag_t2);
    if (ag_tstt[ag_t1] != (PCB).reduction_token) {
      (PCB).exit_flag = AG_REDUCTION_ERROR_CODE; 
      REDUCTION_TOKEN_ERROR; break;}
      (PCB).ag_ap = ag_pstt[ag_t1];
    if ((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;
  ag_track();
  (PCB).reduction_token = (asil_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 ag_action_8_proc(void) {
  ag_undo();
  (PCB).la_ptr =  (PCB).pointer;
  (PCB).exit_flag = AG_SYNTAX_ERROR_CODE;
  ag_diagnose();
  SYNTAX_ERROR;
  {(PCB).la_ptr = (PCB).pointer + 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).la_ptr =  (PCB).pointer;
  (PCB).reduction_token = (asil_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 ag_action_6_proc(void) {
  int ag_sd = ag_fl[(PCB).ag_ap];
  (PCB).reduction_token = (asil_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);
    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_asil(void) {
  (PCB).la_ptr = (PCB).pointer;
  (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 asil(void) {
  init_asil();
  (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 = (asil_token_type) AG_TCV(INPUT_CODE(*(PCB).la_ptr));
      (PCB).la_ptr++;
      if (ag_key_index[(PCB).sn]) {
        unsigned ag_k = ag_key_index[(PCB).sn];
        int ag_ch = CONVERT_CASE(INPUT_CODE(*(PCB).pointer));
        if (ag_ch <= 255) {
          while (ag_key_ch[ag_k] < ag_ch) ag_k++;
          if (ag_key_ch[ag_k] == ag_ch) ag_get_key_word(ag_k);
        }
      }
      do {
        unsigned ag_tx = (ag_t1 + ag_t2)/2;
        if (ag_tstt[ag_tx] > (unsigned char)(PCB).token_number)
          ag_t1 = ag_tx + 1;
        else ag_t2 = ag_tx;
      } while (ag_t1 < ag_t2);
      if (ag_tstt[ag_t1] != (unsigned char)(PCB).token_number)
        ag_t1 = ag_sbe[(PCB).sn];
    }
    (PCB).ag_ap = ag_pstt[ag_t1];
    (ag_gt_procs_scan[ag_astt[ag_t1]])();
  }
}