diff tests/agcl/oldagsrc/good/rcalcx.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 diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/agcl/oldagsrc/good/rcalcx.cpp	Sat Dec 22 17:52:45 2007 -0500
@@ -0,0 +1,1208 @@
+/*
+AnaGram, a System for Syntax Directed Parsing
+RCALC.SYN: A Roman Numeral Calculator Example
+
+Copyright (c) MCMXCIII, MCMXCVI, Parsifal Software.
+All Rights Reserved.
+*/
+/*
+ * 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 RCALCX_H
+#include "rcalcx.h"
+#endif
+
+#ifndef RCALCX_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])
+
+
+#ifndef PCB_TYPE
+#define PCB_TYPE rcalcx_pcb_type
+#endif
+
+
+#define PCB (*pcb_pointer)
+#define PCB_DECL PCB_TYPE *pcb_pointer
+#define PCB_POINTER pcb_pointer
+
+/*  Line -, rcalcx.syn */
+                               /* Embedded C */
+#include <stdio.h>
+
+#define PCB_TYPE Parser
+
+class Parser : public rcalcx_pcb_type {
+  int semantic_error;
+public:
+  Parser() {}
+  void parse(char *);
+  void syntax_error();
+  int divide_error(int cn);
+  void print_roman(long k);
+};
+
+
+void Parser::parse(char *text) {
+  pointer = (unsigned char *) text;
+  semantic_error = 0;
+  rcalcx(this);
+}
+
+/* Macro Definitions */
+
+#define GET_CONTEXT CONTEXT = PCB.column
+#define SYNTAX_ERROR PCB.syntax_error()
+
+/*
+
+syntax_error() positions a '^' character under the input line at the
+point where the syntax error was discovered and then writes the error
+message.
+
+*/
+
+void Parser::syntax_error() {
+  int k = column;
+  while (k-- > 0) putchar(' ');
+  printf("^? %s\n","ERRARE HUMANUM EST\n");
+}
+
+
+/*
+
+divide_error() is called when an attempt is made to divide by zero. The
+entire divisor is marked with '^' characters. "semantic_error" is set
+in order to disable printing of a result.
+
+*/
+
+int Parser::divide_error(int cn) {
+  int k = column - cn;
+  while (cn--) putchar(' ');
+  while (k--) putchar('^');
+  puts(" DIVISOR NIHIL EST");
+  semantic_error = 1;
+  return 0;
+}
+
+
+/*
+
+print_roman() prints a signed integer in upper case Roman numerals.
+
+*/
+
+void Parser::print_roman(long k) {
+  if (semantic_error) {
+    semantic_error = 0;
+    return;
+  }
+  printf("  = ");
+  if (k == 0)      {printf("NIHIL\n"); return;}
+
+  if (k < 0)        putchar('-'), k=-k;
+
+  while (k >= 1000) putchar('M'), k-=1000;
+
+  if (k >= 900)     printf("CM"), k-=900;
+  if (k >= 500)     putchar('D'), k-=500;
+  if (k >= 400)     printf("CD"), k-=400;
+
+  while (k >= 100)  putchar('C'), k-=100;
+
+  if (k >= 90)      printf("XC"), k-=90;
+  if (k >= 50)      putchar('L'), k-=50;
+  if (k >= 40)      printf("XL"), k-=40;
+
+  while (k >= 10)   putchar('X'), k-=10;
+
+  if (k >= 9)       printf("IX"), k -= 9;
+  if (k >= 5)       putchar('V'), k-=5;
+  if (k >= 4)       printf("IV"), k-=4;
+
+  while (k >= 1)    putchar('I'), k--;
+
+  putchar('\n');
+}
+
+
+/* Main Program -- reads a line from stdin and calls parser */
+
+int main(void) {
+  char line[82];
+  while (1) {
+    Parser pcb;
+    printf("#");
+    if (gets(line) == NULL) break;
+    pcb.parse(line);
+  }
+  return 0;
+}
+
+
+#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(PCB_DECL, long x) {
+/* Line -, rcalcx.syn */
+  PCB.print_roman(x);
+}
+
+static long ag_rp_2(PCB_DECL, long x, long y) {
+/* Line -, rcalcx.syn */
+  return x+y;
+}
+
+static long ag_rp_3(PCB_DECL, long x, long y) {
+/* Line -, rcalcx.syn */
+  return x-y;
+}
+
+static long ag_rp_4(PCB_DECL, long x, long y) {
+/* Line -, rcalcx.syn */
+  return x*y;
+}
+
+static long ag_rp_5(PCB_DECL, long x, long y) {
+/* Line -, rcalcx.syn */
+  return y ? x/y : PCB.divide_error(RULE_CONTEXT[2]);
+}
+
+static long ag_rp_6(PCB_DECL) {
+/* Line -, rcalcx.syn */
+  return 0;
+}
+
+static long ag_rp_7(PCB_DECL, long x) {
+/* Line -, rcalcx.syn */
+  return x;
+}
+
+static long ag_rp_8(PCB_DECL, long x) {
+/* Line -, rcalcx.syn */
+  return -x;
+}
+
+static long ag_rp_9(PCB_DECL, long x, long y) {
+/* Line -, rcalcx.syn */
+  return x+y;
+}
+
+static long ag_rp_10(PCB_DECL) {
+/* Line -, rcalcx.syn */
+  return 1000;
+}
+
+static long ag_rp_11(PCB_DECL, long x) {
+/* Line -, rcalcx.syn */
+  return x+1000;
+}
+
+static long ag_rp_12(PCB_DECL, long x, long y) {
+/* Line -, rcalcx.syn */
+  return x+y;
+}
+
+static long ag_rp_13(PCB_DECL) {
+/* Line -, rcalcx.syn */
+  return 900;
+}
+
+static long ag_rp_14(PCB_DECL) {
+/* Line -, rcalcx.syn */
+  return 400;
+}
+
+static long ag_rp_15(PCB_DECL) {
+/* Line -, rcalcx.syn */
+  return 100;
+}
+
+static long ag_rp_16(PCB_DECL) {
+/* Line -, rcalcx.syn */
+  return 500;
+}
+
+static long ag_rp_17(PCB_DECL, long x) {
+/* Line -, rcalcx.syn */
+  return x+100;
+}
+
+static long ag_rp_18(PCB_DECL, long x, long y) {
+/* Line -, rcalcx.syn */
+  return x+y;
+}
+
+static long ag_rp_19(PCB_DECL) {
+/* Line -, rcalcx.syn */
+  return 990;
+}
+
+static long ag_rp_20(PCB_DECL) {
+/* Line -, rcalcx.syn */
+  return 490;
+}
+
+static long ag_rp_21(PCB_DECL) {
+/* Line -, rcalcx.syn */
+  return 90;
+}
+
+static long ag_rp_22(PCB_DECL) {
+/* Line -, rcalcx.syn */
+  return 40;
+}
+
+static long ag_rp_23(PCB_DECL) {
+/* Line -, rcalcx.syn */
+  return 10;
+}
+
+static long ag_rp_24(PCB_DECL) {
+/* Line -, rcalcx.syn */
+  return 50;
+}
+
+static long ag_rp_25(PCB_DECL, long x) {
+/* Line -, rcalcx.syn */
+  return x+10;
+}
+
+static long ag_rp_26(PCB_DECL) {
+/* Line -, rcalcx.syn */
+  return 999;
+}
+
+static long ag_rp_27(PCB_DECL) {
+/* Line -, rcalcx.syn */
+  return 499;
+}
+
+static long ag_rp_28(PCB_DECL) {
+/* Line -, rcalcx.syn */
+  return 99;
+}
+
+static long ag_rp_29(PCB_DECL) {
+/* Line -, rcalcx.syn */
+  return 49;
+}
+
+static long ag_rp_30(PCB_DECL) {
+/* Line -, rcalcx.syn */
+  return 9;
+}
+
+static long ag_rp_31(PCB_DECL) {
+/* Line -, rcalcx.syn */
+  return 4;
+}
+
+static long ag_rp_32(PCB_DECL) {
+/* Line -, rcalcx.syn */
+  return 1;
+}
+
+static long ag_rp_33(PCB_DECL) {
+/* Line -, rcalcx.syn */
+  return 5;
+}
+
+static long ag_rp_34(PCB_DECL, long x) {
+/* Line -, rcalcx.syn */
+  return x+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 rcalcx_vs_type const ag_null_value NULL_VALUE_INITIALIZER;
+
+static const unsigned char ag_rpx[] = {
+    0,  1,  0,  2,  3,  0,  4,  5,  0,  6,  7,  8,  9,  0,  0, 10, 11, 12,
+    0,  0, 13, 14,  0, 15, 16, 17, 18,  0,  0, 19, 20, 21, 22,  0, 23, 24,
+   25, 26, 27, 28, 29, 30, 31,  0, 32, 33, 34
+};
+
+static const unsigned char ag_key_itt[] = {
+ 0
+};
+
+static const unsigned short ag_key_pt[] = {
+0
+};
+
+static const unsigned char ag_key_ch[] = {
+    0, 78,255
+};
+
+static const unsigned char ag_key_act[] = {
+  0,3,4
+};
+
+static const unsigned char ag_key_parm[] = {
+    0, 38,  0
+};
+
+static const unsigned char ag_key_jmp[] = {
+    0,  0,  0
+};
+
+static const unsigned char ag_key_index[] = {
+    1,  1,  1,  0,  0,  0,  0,  0,  0,  0,  0,  0,  1,  1,  0,  0,  1,  1,
+    0,  0,  0,  1,  1,  1,  1,  1,  1,  1,  0,  0,  0
+};
+
+static const unsigned char ag_key_ends[] = {
+73,72,73,76,0, 
+};
+
+#define AG_TCV(x) ag_tcv[(x)]
+
+static const unsigned char ag_tcv[] = {
+    5,  0,  0,  0,  0,  0,  0,  0,  0,  1,  0,  0,  0,  0,  0,  0,  0,  0,
+    0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  1,  0,  0,  0,
+    0,  0,  0,  0, 40, 39, 35, 33,  0, 34,  0, 36,  0,  0,  0,  0,  0,  0,
+    0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0, 20, 21,  0,  0,  0,
+    0, 28,  0,  0, 26, 17,  0,  0,  0,  0,  0,  0,  0,  0, 29,  0, 25,  0,
+    0,  0,  0,  0,  0,  0,  0,  0,  0, 20, 21,  0,  0,  0,  0, 28,  0,  0,
+   26, 17,  0,  0,  0,  0,  0,  0,  0,  0, 29,  0, 25,  0,  0,  0,  0,  0,
+    0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,
+    0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,
+    0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,
+    0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,
+    0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,
+    0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,
+    0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,
+    0,  0,  0,  0
+};
+
+#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(PCB_DECL, 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 = (rcalcx_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 = (rcalcx_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 = (rcalcx_token_type) ag_key_pt[ag_k1+1];
+      break;
+    }
+    case ag_set_key:
+      ag_save = (int) ((PCB).la_ptr - (PCB).pointer);
+      (PCB).token_number = (rcalcx_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 = (rcalcx_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 = (rcalcx_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(PCB_DECL) {
+  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(PCB_DECL) {
+  int ag_k;
+  ag_k = 128 - ++(PCB).btsx;
+  if (ag_k <= (PCB).ssx) {
+    (PCB).exit_flag = AG_STACK_ERROR_CODE;
+    PARSER_STACK_OVERFLOW;
+    return;
+  }
+  (PCB).bts[(PCB).btsx] = (PCB).sn;
+  (PCB).bts[ag_k] = (PCB).ssx;
+  (PCB).vs[ag_k] = (PCB).vs[(PCB).ssx];
+  (PCB).ss[ag_k] = (PCB).ss[(PCB).ssx];
+  (PCB).cs[ag_k] = (PCB).cs[(PCB).ssx];
+}
+
+static void ag_undo(PCB_DECL) {
+  if ((PCB).drt == -1) return;
+  while ((PCB).btsx) {
+    int ag_k = 128 - (PCB).btsx;
+    (PCB).sn = (PCB).bts[(PCB).btsx--];
+    (PCB).ssx = (PCB).bts[ag_k];
+    (PCB).vs[(PCB).ssx] = (PCB).vs[ag_k];
+    (PCB).ss[(PCB).ssx] = (PCB).ss[ag_k];
+    (PCB).cs[(PCB).ssx] = (PCB).cs[ag_k];
+  }
+  (PCB).token_number = (rcalcx_token_type) (PCB).drt;
+  (PCB).ssx = (PCB).dssx;
+  (PCB).sn = (PCB).dsn;
+  (PCB).drt = -1;
+}
+
+
+static const unsigned char ag_tstt[] = {
+40,38,34,29,28,26,25,21,20,17,1,0,31,32,
+1,0,
+40,38,34,29,28,26,25,21,20,17,0,2,3,4,6,8,9,12,13,15,16,18,19,22,23,24,27,
+  30,37,
+28,0,
+29,26,25,21,20,17,0,
+25,0,
+26,21,20,17,0,
+29,28,0,24,30,
+20,0,
+21,17,0,
+29,28,26,25,0,19,23,24,27,30,
+29,28,26,25,21,20,17,0,16,18,19,22,23,24,27,30,
+40,38,34,29,28,26,25,21,20,17,1,0,31,32,
+40,38,34,29,28,26,25,21,20,17,1,0,31,32,
+39,36,35,34,33,5,1,0,31,32,
+39,36,35,34,33,5,1,0,31,32,
+40,38,34,29,28,26,25,21,20,17,0,2,8,9,12,13,15,16,18,19,22,23,24,27,30,37,
+40,38,34,29,28,26,25,21,20,17,0,2,4,6,8,9,12,13,15,16,18,19,22,23,24,27,30,
+  37,
+36,35,0,10,11,
+34,33,5,0,7,8,
+39,34,33,0,7,8,14,
+40,38,34,29,28,26,25,21,20,17,1,0,31,32,
+40,38,34,29,28,26,25,21,20,17,0,2,8,9,12,13,15,16,18,19,22,23,24,27,30,37,
+40,38,34,29,28,26,25,21,20,17,1,0,31,32,
+40,38,34,29,28,26,25,21,20,17,0,2,8,9,12,13,15,16,18,19,22,23,24,27,30,37,
+40,38,34,29,28,26,25,21,20,17,0,2,6,8,9,12,13,15,16,18,19,22,23,24,27,30,37,
+40,38,34,29,28,26,25,21,20,17,1,0,31,32,
+40,38,34,29,28,26,25,21,20,17,0,2,6,8,9,12,13,15,16,18,19,22,23,24,27,30,37,
+39,36,35,34,33,5,1,0,31,32,
+36,35,0,10,11,
+36,35,0,10,11,
+
+};
+
+
+static unsigned const char ag_astt[385] = {
+  8,8,8,8,8,8,8,8,8,8,1,7,1,1,9,5,1,1,1,2,1,2,1,2,1,2,7,1,0,1,1,1,1,2,1,1,1,
+  1,1,1,1,1,1,1,1,10,5,2,2,2,2,2,2,4,10,5,2,2,2,2,4,2,1,5,2,1,10,5,2,2,4,2,1,
+  2,1,5,2,1,2,1,1,2,1,2,1,2,1,10,5,2,1,2,1,1,2,1,1,5,5,5,5,5,5,5,5,5,5,1,7,1,
+  3,5,5,5,5,5,5,5,5,5,5,1,7,1,3,5,5,5,5,5,5,1,7,1,3,5,5,5,5,5,5,1,7,1,3,1,1,
+  1,2,1,2,1,2,1,2,7,2,1,2,2,1,1,1,1,1,1,1,1,1,1,1,1,1,1,2,1,2,1,2,1,2,7,1,1,
+  1,1,1,2,1,1,1,1,1,1,1,1,1,1,1,1,1,5,1,1,1,1,2,7,1,1,1,1,1,7,1,1,2,5,5,5,5,
+  5,5,5,5,5,5,1,7,1,3,1,1,1,2,1,2,1,2,1,2,7,2,1,2,2,1,1,1,1,1,1,1,1,1,1,1,5,
+  5,5,5,5,5,5,5,5,5,1,7,1,3,1,1,1,2,1,2,1,2,1,2,7,2,1,2,2,1,1,1,1,1,1,1,1,1,
+  1,1,1,1,1,2,1,2,1,2,1,2,7,1,1,1,1,2,1,1,1,1,1,1,1,1,1,1,1,5,5,5,5,5,5,5,5,
+  5,5,1,7,1,3,1,1,1,2,1,2,1,2,1,2,7,1,1,1,1,2,1,1,1,1,1,1,1,1,1,1,1,5,5,5,5,
+  5,5,1,7,1,3,1,1,4,1,1,1,1,4,1,1
+};
+
+
+static const unsigned char ag_pstt[] = {
+2,2,2,2,2,2,2,2,2,2,1,0,1,2,
+48,50,
+13,14,12,45,4,35,6,24,9,15,2,18,0,19,18,16,18,9,17,11,15,10,15,8,7,15,5,3,
+  15,
+46,43,
+42,40,41,38,39,37,44,
+36,33,
+32,30,31,29,34,
+45,4,27,26,3,
+25,22,
+21,20,23,
+45,4,35,6,18,17,7,17,5,3,
+45,4,35,6,24,9,16,13,12,10,12,8,7,12,5,3,
+49,49,49,49,49,49,49,49,49,49,1,12,1,52,
+49,49,49,49,49,49,49,49,49,49,1,13,1,58,
+49,49,49,49,49,49,1,14,1,56,
+49,49,49,49,49,49,1,15,1,55,
+13,14,12,45,4,35,6,24,9,15,16,11,16,11,9,17,11,15,10,15,8,7,15,5,3,15,
+13,14,12,45,4,35,6,24,9,15,17,18,20,18,16,18,9,17,11,15,10,15,8,7,15,5,3,15,
+21,23,2,24,22,
+12,26,1,19,27,25,
+28,12,26,20,27,25,10,
+49,49,49,49,49,49,49,49,49,49,1,21,1,54,
+13,14,12,45,4,35,6,24,9,15,22,7,16,7,9,17,11,15,10,15,8,7,15,5,3,15,
+49,49,49,49,49,49,49,49,49,49,1,23,1,53,
+13,14,12,45,4,35,6,24,9,15,24,6,16,6,9,17,11,15,10,15,8,7,15,5,3,15,
+13,14,12,45,4,35,6,24,9,15,25,29,29,16,29,9,17,11,15,10,15,8,7,15,5,3,15,
+49,49,49,49,49,49,49,49,49,49,1,26,1,51,
+13,14,12,45,4,35,6,24,9,15,27,30,30,16,30,9,17,11,15,10,15,8,7,15,5,3,15,
+49,49,49,49,49,49,1,28,1,57,
+21,23,4,24,22,
+21,23,3,24,22,
+
+};
+
+
+static const unsigned short ag_sbt[] = {
+     0,  14,  16,  45,  47,  54,  56,  61,  66,  68,  71,  81,  97, 111,
+   125, 135, 145, 171, 199, 204, 210, 217, 231, 257, 271, 297, 324, 338,
+   365, 375, 380, 385
+};
+
+
+static const unsigned short ag_sbe[] = {
+    11,  15,  26,  46,  53,  55,  60,  63,  67,  70,  75,  88, 108, 122,
+   132, 142, 155, 181, 201, 207, 213, 228, 241, 268, 281, 307, 335, 348,
+   372, 377, 382, 385
+};
+
+
+static const unsigned char ag_fl[] = {
+  2,2,1,3,3,1,3,3,1,1,3,2,2,1,1,1,2,2,1,1,2,2,1,1,1,2,2,1,1,2,2,2,2,1,1,
+  1,2,2,2,2,2,2,2,1,1,1,2,1,2,0,1,2,2,2,2,2,2,2,2
+};
+
+static const unsigned char ag_ptt[] = {
+    0,  3,  4,  4,  4,  6,  6,  6,  9,  9,  9,  9, 37, 37, 37, 15, 15, 16,
+   16, 16, 18, 18, 18, 22, 22, 22, 19, 19, 19, 23, 23, 23, 23, 23, 27, 27,
+   27, 24, 24, 24, 24, 24, 24, 24, 30, 30, 30, 31, 31, 32, 32,  7,  8, 10,
+   11,  2, 12, 14, 13
+};
+
+
+static void ag_ra(PCB_DECL)
+{
+  switch(ag_rpx[(PCB).ag_ap]) {
+    case 1: ag_rp_1(PCB_POINTER, V(0,(long *))); break;
+    case 2: V(0,(long *)) = ag_rp_2(PCB_POINTER, V(0,(long *)), V(2,(long *))); break;
+    case 3: V(0,(long *)) = ag_rp_3(PCB_POINTER, V(0,(long *)), V(2,(long *))); break;
+    case 4: V(0,(long *)) = ag_rp_4(PCB_POINTER, V(0,(long *)), V(2,(long *))); break;
+    case 5: V(0,(long *)) = ag_rp_5(PCB_POINTER, V(0,(long *)), V(2,(long *))); break;
+    case 6: V(0,(long *)) = ag_rp_6(PCB_POINTER); break;
+    case 7: V(0,(long *)) = ag_rp_7(PCB_POINTER, V(1,(long *))); break;
+    case 8: V(0,(long *)) = ag_rp_8(PCB_POINTER, V(1,(long *))); break;
+    case 9: V(0,(long *)) = ag_rp_9(PCB_POINTER, V(0,(long *)), V(1,(long *))); break;
+    case 10: V(0,(long *)) = ag_rp_10(PCB_POINTER); break;
+    case 11: V(0,(long *)) = ag_rp_11(PCB_POINTER, V(0,(long *))); break;
+    case 12: V(0,(long *)) = ag_rp_12(PCB_POINTER, V(0,(long *)), V(1,(long *))); break;
+    case 13: V(0,(long *)) = ag_rp_13(PCB_POINTER); break;
+    case 14: V(0,(long *)) = ag_rp_14(PCB_POINTER); break;
+    case 15: V(0,(long *)) = ag_rp_15(PCB_POINTER); break;
+    case 16: V(0,(long *)) = ag_rp_16(PCB_POINTER); break;
+    case 17: V(0,(long *)) = ag_rp_17(PCB_POINTER, V(0,(long *))); break;
+    case 18: V(0,(long *)) = ag_rp_18(PCB_POINTER, V(0,(long *)), V(1,(long *))); break;
+    case 19: V(0,(long *)) = ag_rp_19(PCB_POINTER); break;
+    case 20: V(0,(long *)) = ag_rp_20(PCB_POINTER); break;
+    case 21: V(0,(long *)) = ag_rp_21(PCB_POINTER); break;
+    case 22: V(0,(long *)) = ag_rp_22(PCB_POINTER); break;
+    case 23: V(0,(long *)) = ag_rp_23(PCB_POINTER); break;
+    case 24: V(0,(long *)) = ag_rp_24(PCB_POINTER); break;
+    case 25: V(0,(long *)) = ag_rp_25(PCB_POINTER, V(0,(long *))); break;
+    case 26: V(0,(long *)) = ag_rp_26(PCB_POINTER); break;
+    case 27: V(0,(long *)) = ag_rp_27(PCB_POINTER); break;
+    case 28: V(0,(long *)) = ag_rp_28(PCB_POINTER); break;
+    case 29: V(0,(long *)) = ag_rp_29(PCB_POINTER); break;
+    case 30: V(0,(long *)) = ag_rp_30(PCB_POINTER); break;
+    case 31: V(0,(long *)) = ag_rp_31(PCB_POINTER); break;
+    case 32: V(0,(long *)) = ag_rp_32(PCB_POINTER); break;
+    case 33: V(0,(long *)) = ag_rp_33(PCB_POINTER); break;
+    case 34: V(0,(long *)) = ag_rp_34(PCB_POINTER, V(0,(long *))); break;
+  }
+  (PCB).la_ptr = (PCB).pointer;
+}
+
+#define TOKEN_NAMES rcalcx_token_names
+const char *const rcalcx_token_names[41] = {
+  "calculation",
+  "ws",
+  "roman numeral",
+  "calculation",
+  "expression",
+  "eof",
+  "term",
+  "'+'",
+  "'-'",
+  "factor",
+  "'*'",
+  "'/'",
+  "\"NIHIL\"",
+  "'('",
+  "')'",
+  "thousands",
+  "hundreds",
+  "m",
+  "hundreds field",
+  "tens",
+  "c",
+  "d",
+  "count hundreds",
+  "tens field",
+  "units",
+  "x",
+  "l",
+  "count tens",
+  "i",
+  "v",
+  "count units",
+  "",
+  "",
+  "'+'",
+  "'-'",
+  "'*'",
+  "'/'",
+  "roman numeral",
+  "\"NIHIL\"",
+  "')'",
+  "'('",
+
+};
+
+#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(PCB_DECL) {
+  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(PCB_DECL);
+static int ag_action_2_r_proc(PCB_DECL);
+static int ag_action_3_r_proc(PCB_DECL);
+static int ag_action_4_r_proc(PCB_DECL);
+static int ag_action_1_s_proc(PCB_DECL);
+static int ag_action_3_s_proc(PCB_DECL);
+static int ag_action_1_proc(PCB_DECL);
+static int ag_action_2_proc(PCB_DECL);
+static int ag_action_3_proc(PCB_DECL);
+static int ag_action_4_proc(PCB_DECL);
+static int ag_action_5_proc(PCB_DECL);
+static int ag_action_6_proc(PCB_DECL);
+static int ag_action_7_proc(PCB_DECL);
+static int ag_action_8_proc(PCB_DECL);
+static int ag_action_9_proc(PCB_DECL);
+static int ag_action_10_proc(PCB_DECL);
+static int ag_action_11_proc(PCB_DECL);
+static int ag_action_8_proc(PCB_DECL);
+
+
+static int (*const  ag_r_procs_scan[])(PCB_DECL) = {
+  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[])(PCB_DECL) = {
+  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[])(PCB_DECL) = {
+  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(PCB_DECL) {
+  int ag_t = (PCB).token_number;
+  (PCB).btsx = 0, (PCB).drt = -1;
+  do {
+    ag_track(PCB_POINTER);
+    (PCB).token_number = (rcalcx_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((PCB_TYPE *)PCB_POINTER, ag_k);
+      }
+    }
+  } while ((PCB).token_number == (rcalcx_token_type) ag_t);
+  (PCB).la_ptr =  (PCB).pointer;
+  return 1;
+}
+
+static int ag_action_11_proc(PCB_DECL) {
+  int ag_t = (PCB).token_number;
+
+  (PCB).btsx = 0, (PCB).drt = -1;
+  do {
+    (*(int *) &(PCB).vs[(PCB).ssx]) = *(PCB).pointer;
+    (PCB).ssx--;
+    ag_track(PCB_POINTER);
+    ag_ra(PCB_POINTER);
+    if ((PCB).exit_flag != AG_RUNNING_CODE) return 0;
+    (PCB).ssx++;
+    (PCB).token_number = (rcalcx_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((PCB_TYPE *)PCB_POINTER, ag_k);
+      }
+    }
+  }
+  while ((PCB).token_number == (rcalcx_token_type) ag_t);
+  (PCB).la_ptr =  (PCB).pointer;
+  return 1;
+}
+
+static int ag_action_3_r_proc(PCB_DECL) {
+  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 = (rcalcx_token_type) ag_ptt[(PCB).ag_ap];
+  ag_ra(PCB_POINTER);
+  return (PCB).exit_flag == AG_RUNNING_CODE;
+}
+
+static int ag_action_3_s_proc(PCB_DECL) {
+  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 = (rcalcx_token_type) ag_ptt[(PCB).ag_ap];
+  ag_ra(PCB_POINTER);
+  return (PCB).exit_flag == AG_RUNNING_CODE;
+}
+
+static int ag_action_4_r_proc(PCB_DECL) {
+  int ag_sd = ag_fl[(PCB).ag_ap] - 1;
+  if (ag_sd) (PCB).sn = (PCB).ss[(PCB).ssx -= ag_sd];
+  (PCB).reduction_token = (rcalcx_token_type) ag_ptt[(PCB).ag_ap];
+  return 1;
+}
+
+static int ag_action_2_proc(PCB_DECL) {
+  (PCB).btsx = 0, (PCB).drt = -1;
+  if ((PCB).ssx >= 128) {
+    (PCB).exit_flag = AG_STACK_ERROR_CODE;
+    PARSER_STACK_OVERFLOW;
+  }
+  (*(int *) &(PCB).vs[(PCB).ssx]) = *(PCB).pointer;
+  GET_CONTEXT;
+  (PCB).ss[(PCB).ssx] = (PCB).sn;
+  (PCB).ssx++;
+  (PCB).sn = (PCB).ag_ap;
+  ag_track(PCB_POINTER);
+  return 0;
+}
+
+static int ag_action_9_proc(PCB_DECL) {
+  if ((PCB).drt == -1) {
+    (PCB).drt=(PCB).token_number;
+    (PCB).dssx=(PCB).ssx;
+    (PCB).dsn=(PCB).sn;
+  }
+  ag_prot(PCB_POINTER);
+  (PCB).vs[(PCB).ssx] = ag_null_value;
+  GET_CONTEXT;
+  (PCB).ss[(PCB).ssx] = (PCB).sn;
+  (PCB).ssx++;
+  (PCB).sn = (PCB).ag_ap;
+  (PCB).la_ptr =  (PCB).pointer;
+  return (PCB).exit_flag == AG_RUNNING_CODE;
+}
+
+static int ag_action_2_r_proc(PCB_DECL) {
+  (PCB).ssx++;
+  (PCB).sn = (PCB).ag_ap;
+  return 0;
+}
+
+static int ag_action_7_proc(PCB_DECL) {
+  --(PCB).ssx;
+  (PCB).la_ptr =  (PCB).pointer;
+  (PCB).exit_flag = AG_SUCCESS_CODE;
+  return 0;
+}
+
+static int ag_action_1_proc(PCB_DECL) {
+  ag_track(PCB_POINTER);
+  (PCB).exit_flag = AG_SUCCESS_CODE;
+  return 0;
+}
+
+static int ag_action_1_r_proc(PCB_DECL) {
+  (PCB).exit_flag = AG_SUCCESS_CODE;
+  return 0;
+}
+
+static int ag_action_1_s_proc(PCB_DECL) {
+  (PCB).exit_flag = AG_SUCCESS_CODE;
+  return 0;
+}
+
+static int ag_action_4_proc(PCB_DECL) {
+  int ag_sd = ag_fl[(PCB).ag_ap] - 1;
+  (PCB).reduction_token = (rcalcx_token_type) ag_ptt[(PCB).ag_ap];
+  (PCB).btsx = 0, (PCB).drt = -1;
+  (*(int *) &(PCB).vs[(PCB).ssx]) = *(PCB).pointer;
+  if (ag_sd) (PCB).sn = (PCB).ss[(PCB).ssx -= ag_sd];
+  else GET_CONTEXT;
+  (PCB).ss[(PCB).ssx] = (PCB).sn;
+  ag_track(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_s_procs_scan[ag_astt[ag_t1]])(PCB_POINTER) == 0) break;
+  }
+  return 0;
+}
+
+static int ag_action_3_proc(PCB_DECL) {
+  int ag_sd = ag_fl[(PCB).ag_ap] - 1;
+  (PCB).btsx = 0, (PCB).drt = -1;
+  (*(int *) &(PCB).vs[(PCB).ssx]) = *(PCB).pointer;
+  if (ag_sd) (PCB).sn = (PCB).ss[(PCB).ssx -= ag_sd];
+  else GET_CONTEXT;
+  (PCB).ss[(PCB).ssx] = (PCB).sn;
+  ag_track(PCB_POINTER);
+  (PCB).reduction_token = (rcalcx_token_type) ag_ptt[(PCB).ag_ap];
+  ag_ra(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_s_procs_scan[ag_astt[ag_t1]])(PCB_POINTER) == 0) break;
+  }
+  return 0;
+}
+
+static int ag_action_8_proc(PCB_DECL) {
+  ag_undo(PCB_POINTER);
+  (PCB).la_ptr =  (PCB).pointer;
+  (PCB).exit_flag = AG_SYNTAX_ERROR_CODE;
+  ag_diagnose(PCB_POINTER);
+  SYNTAX_ERROR;
+  {(PCB).la_ptr = (PCB).pointer + 1; ag_track(PCB_POINTER);}
+  return (PCB).exit_flag == AG_RUNNING_CODE;
+}
+
+static int ag_action_5_proc(PCB_DECL) {
+  int ag_sd = ag_fl[(PCB).ag_ap];
+  (PCB).btsx = 0, (PCB).drt = -1;
+  if (ag_sd) (PCB).sn = (PCB).ss[(PCB).ssx -= ag_sd];
+  else {
+    GET_CONTEXT;
+    (PCB).ss[(PCB).ssx] = (PCB).sn;
+  }
+  (PCB).la_ptr =  (PCB).pointer;
+  (PCB).reduction_token = (rcalcx_token_type) ag_ptt[(PCB).ag_ap];
+  ag_ra(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]])(PCB_POINTER) == 0) break;
+  }
+  return (PCB).exit_flag == AG_RUNNING_CODE;
+}
+
+static int ag_action_6_proc(PCB_DECL) {
+  int ag_sd = ag_fl[(PCB).ag_ap];
+  (PCB).reduction_token = (rcalcx_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_POINTER);
+    (PCB).vs[(PCB).ssx] = ag_null_value;
+    GET_CONTEXT;
+    (PCB).ss[(PCB).ssx] = (PCB).sn;
+  }
+  (PCB).la_ptr =  (PCB).pointer;
+  while ((PCB).exit_flag == AG_RUNNING_CODE) {
+    unsigned ag_t1 = ag_sbe[(PCB).sn] + 1;
+    unsigned ag_t2 = ag_sbt[(PCB).sn+1] - 1;
+    do {
+      unsigned ag_tx = (ag_t1 + ag_t2)/2;
+      if (ag_tstt[ag_tx] < (unsigned char)(PCB).reduction_token) ag_t1 = ag_tx + 1;
+      else ag_t2 = ag_tx;
+    } while (ag_t1 < ag_t2);
+    (PCB).ag_ap = ag_pstt[ag_t1];
+    if ((ag_r_procs_scan[ag_astt[ag_t1]])(PCB_POINTER) == 0) break;
+  }
+  return (PCB).exit_flag == AG_RUNNING_CODE;
+}
+
+
+void init_rcalcx(rcalcx_pcb_type *PCB_POINTER) {
+  (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 rcalcx(rcalcx_pcb_type *PCB_POINTER) {
+  init_rcalcx(PCB_POINTER);
+  (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 = (rcalcx_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((PCB_TYPE *)PCB_POINTER, 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]])((PCB_TYPE *)PCB_POINTER);
+  }
+}
+
+