diff tests/agcl/examples/good/fc5.c @ 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/examples/good/fc5.c	Sat Dec 22 17:52:45 2007 -0500
@@ -0,0 +1,1099 @@
+
+/*
+ * 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 FC5_H
+#include "fc5.h"
+#endif
+
+#ifndef FC5_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])
+
+
+
+fc5_pcb_type fc5_pcb;
+#define PCB fc5_pcb
+
+/*  Line -, fc5.syn */
+                                                 /* Embedded C */
+
+#include <stdlib.h>
+#include <stdio.h>
+
+const double zero = 273.16;
+
+int main(void) {
+  init_fc5();                                     /* Initialize parser */
+  while (fc5_pcb.exit_flag == AG_RUNNING_CODE) {  /* Until done */
+    fc5_pcb.input_code = getchar();               /* Hand char to parser */
+    fc5();                                        /* Process character */
+  }
+  return (fc5_pcb.exit_flag - AG_SUCCESS_CODE);   /* Return error level */
+}
+
+
+#ifndef CONVERT_CASE
+#define CONVERT_CASE(c) (c)
+#endif
+#ifndef TAB_SPACING
+#define TAB_SPACING 8
+#endif
+
+static void ag_rp_1(double c) {
+/* Line -, fc5.syn */
+                                       /* P2 */
+                     double f = 9*c/5 + 32;
+                     printf("%.6g\370F = %.6g\370C = %.6g\370K\n",f,c,c+zero);
+                   
+}
+
+static void ag_rp_2(double f) {
+/* Line -, fc5.syn */
+                                       /* P3 */
+                     double c = 5*(f-32)/9;
+                     printf("%.6g\370F = %.6g\370C = %.6g\370K\n",f,c,c+zero);
+                   
+}
+
+static void ag_rp_3(double k) {
+/* Line -, fc5.syn */
+                         /* P3a */
+                     double c = k - zero;
+                     double f = 9*c/5 + 32;
+                     printf("%.6g\370F = %.6g\370C = %.6g\370K\n", f, c, k);
+                   
+}
+
+#define ag_rp_4(n) (-n)
+
+#define ag_rp_5(n) (n)
+
+#define ag_rp_6(i, f) (i+f)
+
+#define ag_rp_7(f) (f)
+
+#define ag_rp_8(d) (d-'0')
+
+#define ag_rp_9(n, d) (10*n+d-'0')
+
+#define ag_rp_10(d) ((d-'0')/10.)
+
+#define ag_rp_11(d, f) ((d-'0' + f)/10.)
+
+
+#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 fc5_vs_type const ag_null_value NULL_VALUE_INITIALIZER;
+
+static const unsigned char ag_rpx[] = {
+    0,  0,  0,  0,  0,  0,  0,  0,  0,  1,  2,  0,  0,  3,  0,  4,  5,  0,
+    0,  0,  6,  7,  8,  9, 10, 11
+};
+
+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,255, 42,255, 47,255, 47,255
+};
+
+static const unsigned char ag_key_act[] = {
+  0,0,0,4,2,4,3,4,3,4,3,4
+};
+
+static const unsigned char ag_key_parm[] = {
+    0, 25, 30,  0,  0,  0, 29,  0, 30,  0, 25,  0
+};
+
+static const unsigned char ag_key_jmp[] = {
+    0,  0,  0,  0,  1,  0,  0,  0,  2,  0,  4,  0
+};
+
+static const unsigned char ag_key_index[] = {
+    4,  6,  4,  4,  4,  8,  6,  6,  6,  4, 10, 10,  0,  0,  8,  0,  0,  8,
+    8,  8,  8,  0,  6,  4,  0,  0, 10,  0, 10, 10,  0,  0,  4,  8,  4,  8,
+    0,  0,  4,  8,  8, 10, 10, 10, 10, 10,  0,  4,  8,  8,  8,  0,  0,  0,
+    4,  8, 10, 10,  8,  0,  0
+};
+
+static const unsigned char ag_key_ends[] = {
+47,0, 47,0, 42,0, 
+};
+#define AG_TCV(x) (((int)(x) >= -1 && (int)(x) <= 255) ? ag_tcv[(x) + 1] : 0)
+
+static const unsigned char ag_tcv[] = {
+   10, 36, 36, 36, 36, 36, 36, 36, 36, 36, 24, 35, 36, 36, 36, 36, 36, 36,
+   36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 24, 36, 36,
+   36, 36, 36, 36, 36, 36, 36, 36, 42, 36, 45, 20, 36, 23, 23, 23, 23, 23,
+   23, 23, 23, 23, 23, 36, 36, 36, 36, 36, 36, 36, 36, 36, 40, 36, 36, 41,
+   36, 36, 36, 36, 43, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36,
+   36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 40, 36, 36, 41, 36, 36, 36, 36,
+   43, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36,
+   36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36,
+   36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36,
+   36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36,
+   36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36,
+   36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36,
+   36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36,
+   36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36,
+   36, 36, 36, 36, 36
+};
+
+#ifndef SYNTAX_ERROR
+#define SYNTAX_ERROR fprintf(stderr,"%s, line %d, column %d\n", \
+  (PCB).error_message, (PCB).line, (PCB).column)
+#endif
+
+#ifndef FIRST_LINE
+#define FIRST_LINE 1
+#endif
+
+#ifndef FIRST_COLUMN
+#define FIRST_COLUMN 1
+#endif
+
+#ifndef PARSER_STACK_OVERFLOW
+#define PARSER_STACK_OVERFLOW {fprintf(stderr, \
+   "\nParser stack overflow, line %d, column %d\n",\
+   (PCB).line, (PCB).column);}
+#endif
+
+#ifndef REDUCTION_TOKEN_ERROR
+#define REDUCTION_TOKEN_ERROR {fprintf(stderr, \
+    "\nReduction token error, line %d, column %d\n", \
+    (PCB).line, (PCB).column);}
+#endif
+
+
+typedef enum
+  {ag_accept_key, ag_set_key, ag_jmp_key, ag_end_key, ag_no_match_key,
+   ag_cf_accept_key, ag_cf_set_key, ag_cf_end_key} key_words;
+
+
+#ifndef AG_NEWLINE
+#define AG_NEWLINE 10
+#endif
+
+#ifndef AG_RETURN
+#define AG_RETURN 13
+#endif
+
+#ifndef AG_FORMFEED
+#define AG_FORMFEED 12
+#endif
+
+#ifndef AG_TABCHAR
+#define AG_TABCHAR 9
+#endif
+
+static void ag_track(void) {
+  int ag_k = 0;
+  while (ag_k < (PCB).rx) {
+    int ag_ch = (PCB).lab[ag_k++];
+    switch (ag_ch) {
+    case AG_NEWLINE:
+      (PCB).column = 1, (PCB).line++;
+    case AG_RETURN:
+    case AG_FORMFEED:
+      break;
+    case AG_TABCHAR:
+      (PCB).column += (TAB_SPACING) - ((PCB).column - 1) % (TAB_SPACING);
+      break;
+    default:
+      (PCB).column++;
+    }
+  }
+  ag_k = 0;
+  while ((PCB).rx < (PCB).fx) (PCB).lab[ag_k++] = (PCB).lab[(PCB).rx++];
+  (PCB).fx = ag_k;
+  (PCB).rx = 0;
+}
+
+
+static void ag_prot(void) {
+  int ag_k;
+  ag_k = 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 = (fc5_token_type) (PCB).drt;
+  (PCB).ssx = (PCB).dssx;
+  (PCB).sn = (PCB).dsn;
+  (PCB).drt = -1;
+}
+
+
+static const unsigned char ag_tstt[] = {
+45,42,35,30,25,24,23,20,10,0,1,37,38,
+45,43,42,41,40,36,35,29,24,23,20,0,27,28,
+45,43,42,41,40,35,30,25,24,23,20,10,0,
+45,43,42,41,40,35,30,25,24,23,20,10,0,
+45,43,42,41,40,35,30,25,24,23,20,10,0,1,
+45,42,35,30,23,20,17,10,0,4,5,6,7,8,9,11,14,15,18,
+45,43,42,41,40,36,35,29,24,23,20,0,
+45,43,42,41,40,36,35,29,24,23,20,0,
+29,0,
+45,43,42,41,40,35,30,25,24,23,20,10,0,
+25,24,23,20,0,1,37,38,
+25,24,23,20,0,1,37,38,
+23,20,0,
+23,20,0,2,19,44,
+35,30,0,
+23,20,0,2,19,44,
+41,40,0,12,13,
+35,30,0,
+35,30,0,3,34,39,
+45,42,35,30,23,20,10,0,
+45,42,35,30,23,20,17,10,0,5,6,7,11,14,15,18,
+10,0,
+45,43,42,41,40,36,35,29,24,23,20,0,
+45,43,42,41,40,35,30,25,24,23,20,10,0,
+23,20,0,
+23,20,0,
+43,41,40,25,24,23,20,0,
+23,0,22,
+43,41,40,25,24,23,20,0,21,
+43,41,40,25,24,0,1,37,38,
+41,40,0,
+43,41,40,0,16,
+35,30,25,24,0,1,37,38,
+35,30,0,
+35,30,25,24,0,1,37,38,
+35,30,0,
+45,43,42,41,40,36,35,24,23,20,0,32,33,
+35,0,
+45,42,35,30,25,24,23,20,10,0,1,37,38,
+45,42,35,30,23,20,10,0,
+45,42,35,30,23,20,10,0,
+43,41,40,25,24,23,0,22,
+43,41,40,25,24,0,
+43,41,40,25,24,23,20,0,
+43,41,40,25,24,23,0,22,
+43,41,40,25,24,0,
+43,41,40,0,
+35,30,25,24,0,1,37,38,
+35,30,0,
+35,30,0,
+35,30,0,
+45,43,42,41,40,36,35,24,23,20,0,
+45,43,42,41,40,36,35,24,23,20,0,
+35,0,
+45,42,35,30,25,24,23,20,10,0,
+45,42,35,30,23,20,10,0,
+43,41,40,25,24,0,
+43,41,40,25,24,0,
+35,30,0,
+45,43,42,41,40,36,35,24,23,20,0,
+  0
+};
+
+
+static unsigned const char ag_astt[459] = {
+  5,5,5,5,1,1,5,5,5,7,1,1,1,1,1,1,1,1,1,1,5,1,1,1,7,1,1,5,5,5,5,5,5,5,5,5,5,
+  5,5,7,5,5,5,5,5,5,5,5,5,5,5,5,7,5,5,5,5,5,5,5,1,1,5,5,5,7,1,1,1,5,5,5,5,1,
+  5,7,0,1,1,1,1,1,1,1,1,1,5,5,5,5,5,5,5,5,5,5,5,7,1,1,1,1,1,1,1,5,1,1,1,7,1,
+  7,5,5,5,5,5,5,5,5,5,5,5,5,7,1,1,5,5,7,1,1,1,1,1,5,5,7,1,1,1,5,5,7,1,1,7,1,
+  1,1,5,5,7,1,1,7,1,1,1,1,1,7,1,1,5,5,7,5,1,7,1,1,1,5,5,5,5,5,5,5,7,1,1,5,5,
+  5,5,1,5,7,1,1,1,1,1,1,1,3,7,5,5,5,5,5,5,5,5,5,5,5,7,5,5,5,5,5,5,5,5,5,5,5,
+  5,7,5,5,7,5,5,7,4,4,4,4,4,4,4,7,1,7,1,5,5,5,5,5,1,1,7,1,5,5,5,1,1,7,1,1,1,
+  4,4,7,1,4,4,7,1,5,5,1,1,7,1,1,1,4,4,7,5,5,1,1,7,1,1,1,4,4,7,1,1,1,1,1,1,5,
+  1,1,1,7,1,1,1,7,5,5,5,5,1,1,5,5,5,7,1,1,1,5,5,5,5,5,5,5,7,5,5,5,5,5,5,5,7,
+  4,4,4,4,4,1,7,1,4,4,4,4,4,7,4,4,4,4,4,4,4,7,5,5,5,5,5,1,7,1,5,5,5,5,5,7,5,
+  5,5,7,5,5,1,1,7,1,1,1,4,4,7,5,5,7,5,5,7,5,5,5,5,5,5,5,5,5,5,7,1,1,1,1,1,1,
+  5,1,1,1,7,5,7,5,5,5,5,5,5,5,5,5,7,5,5,5,5,5,5,5,7,4,4,4,4,4,7,4,4,4,4,4,7,
+  5,5,7,5,5,5,5,5,5,5,5,5,5,7,11
+};
+
+
+static const unsigned char ag_pstt[] = {
+60,60,60,60,1,2,60,60,60,0,3,4,5,
+6,6,6,6,6,6,6,29,6,6,6,1,7,8,
+26,26,26,26,26,26,26,26,26,26,26,26,2,
+58,58,58,58,58,58,58,58,58,58,58,58,3,
+61,61,61,61,61,61,61,1,2,61,61,61,4,9,
+11,10,1,1,11,11,14,6,5,0,17,18,19,20,21,16,12,15,13,
+27,27,27,27,27,27,27,27,27,27,27,6,
+22,22,22,22,22,22,22,30,22,22,22,7,
+23,8,
+59,59,59,59,59,59,59,59,59,59,59,59,9,
+1,2,60,60,10,3,4,24,
+1,2,60,60,11,3,4,25,
+12,12,12,
+26,27,13,30,28,29,
+14,14,14,
+26,27,15,31,28,29,
+32,34,16,35,33,
+2,2,17,
+36,36,18,39,37,38,
+4,4,4,4,4,4,4,19,
+11,10,1,1,11,11,14,7,20,17,18,40,16,12,15,13,
+8,21,
+28,28,28,28,28,28,28,28,28,28,28,22,
+31,31,31,31,31,31,31,31,31,31,31,31,23,
+65,65,24,
+68,68,25,
+22,22,22,22,22,22,22,26,
+41,27,42,
+17,17,17,17,17,43,44,28,45,
+60,60,60,1,2,29,3,4,46,
+15,15,30,
+47,16,16,31,48,
+60,60,1,2,32,3,4,49,
+10,10,33,
+60,60,1,2,34,3,4,50,
+9,9,35,
+51,51,51,51,51,51,34,51,51,51,36,52,53,
+54,37,
+60,60,60,60,1,2,60,60,60,38,3,4,55,
+3,3,3,3,3,3,3,39,
+5,5,5,5,5,5,5,40,
+24,24,24,24,24,41,41,56,
+21,21,21,21,21,42,
+23,23,23,23,23,23,23,43,
+18,18,18,18,18,41,44,57,
+19,19,19,19,19,45,
+67,67,67,46,
+60,60,1,2,47,3,4,58,
+13,13,48,
+64,64,49,
+63,63,50,
+32,32,32,32,32,32,32,32,32,32,51,
+59,59,59,59,59,59,35,59,59,59,52,
+37,53,
+38,38,38,38,38,38,38,38,38,54,
+62,62,62,62,62,62,62,55,
+25,25,25,25,25,56,
+20,20,20,20,20,57,
+66,66,58,
+33,33,33,33,33,33,33,33,33,33,59,
+  0
+};
+
+
+static const unsigned short ag_sbt[] = {
+     0,  13,  27,  40,  53,  67,  86,  98, 110, 112, 125, 133, 141, 144,
+   150, 153, 159, 164, 167, 173, 181, 197, 199, 211, 224, 227, 230, 238,
+   241, 250, 259, 262, 267, 275, 278, 286, 289, 302, 304, 317, 325, 333,
+   341, 347, 355, 363, 369, 373, 381, 384, 387, 390, 401, 412, 414, 424,
+   432, 438, 444, 447, 458
+};
+
+
+static const unsigned short ag_sbe[] = {
+     9,  24,  39,  52,  65,  75,  97, 109, 111, 124, 129, 137, 143, 146,
+   152, 155, 161, 166, 169, 180, 189, 198, 210, 223, 226, 229, 237, 239,
+   248, 255, 261, 265, 271, 277, 282, 288, 299, 303, 313, 324, 332, 339,
+   346, 354, 361, 368, 372, 377, 383, 386, 389, 400, 411, 413, 423, 431,
+   437, 443, 446, 457, 458
+};
+
+
+static const unsigned char ag_fl[] = {
+  2,0,1,2,1,2,0,1,2,2,2,0,1,3,1,2,2,0,1,2,3,2,1,2,1,2,1,1,2,0,1,3,1,2,0,
+  1,0,2,2,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
+};
+
+static const unsigned char ag_ptt[] = {
+    0,  6,  6,  7,  8,  8,  9,  9,  4,  5,  5, 15, 15,  5,  5, 11, 11, 21,
+   21, 44, 44, 44, 19, 19, 22, 22,  1, 27, 27, 28, 28,  1, 32, 32, 33, 33,
+   34, 34, 39, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 31, 31, 31, 31, 31,
+   31, 31, 31, 31, 37, 37, 38, 38,  3, 12, 13, 14, 16,  2, 18
+};
+
+
+static void ag_ra(void)
+{
+  switch(ag_rpx[(PCB).ag_ap]) {
+    case 1: ag_rp_1(V(0,(double *))); break;
+    case 2: ag_rp_2(V(0,(double *))); break;
+    case 3: ag_rp_3(V(1,(double *))); break;
+    case 4: V(0,(double *)) = ag_rp_4(V(1,(double *))); break;
+    case 5: V(0,(double *)) = ag_rp_5(V(1,(double *))); break;
+    case 6: V(0,(double *)) = ag_rp_6(V(0,(double *)), V(2,(double *))); break;
+    case 7: V(0,(double *)) = ag_rp_7(V(1,(double *))); break;
+    case 8: V(0,(double *)) = ag_rp_8(V(0,(int *))); break;
+    case 9: V(0,(double *)) = ag_rp_9(V(0,(double *)), V(1,(int *))); break;
+    case 10: V(0,(double *)) = ag_rp_10(V(0,(int *))); break;
+    case 11: V(0,(double *)) = ag_rp_11(V(0,(int *)), V(1,(double *))); break;
+  }
+}
+
+#define TOKEN_NAMES fc5_token_names
+const char *const fc5_token_names[46] = {
+  "grammar",
+  "white space",
+  "unsigned number",
+  "end of line",
+  "grammar",
+  "temperature",
+  "",
+  "",
+  "",
+  "",
+  "eof",
+  "number",
+  "",
+  "",
+  "'+'",
+  "",
+  "",
+  "error",
+  "'-'",
+  "integer",
+  "'.'",
+  "",
+  "fraction",
+  "",
+  "",
+  "\"/*\"",
+  "",
+  "",
+  "",
+  "\"*/\"",
+  "\"//\"",
+  "",
+  "",
+  "",
+  "",
+  "'\\n'",
+  "",
+  "",
+  "",
+  "end of line",
+  "",
+  "",
+  "'+'",
+  "",
+  "unsigned number",
+  "'-'",
+
+};
+
+#ifndef MISSING_FORMAT
+#define MISSING_FORMAT "Missing %s"
+#endif
+#ifndef UNEXPECTED_FORMAT
+#define UNEXPECTED_FORMAT "Unexpected %s"
+#endif
+#ifndef UNNAMED_TOKEN
+#define UNNAMED_TOKEN "input"
+#endif
+
+
+static void ag_diagnose(void) {
+  int ag_snd = (PCB).sn;
+  int ag_k = ag_sbt[ag_snd];
+
+  if (*TOKEN_NAMES[ag_tstt[ag_k]] && ag_astt[ag_k + 1] == ag_action_8) {
+    sprintf((PCB).ag_msg, MISSING_FORMAT, TOKEN_NAMES[ag_tstt[ag_k]]);
+  }
+  else if (ag_astt[ag_sbe[(PCB).sn]] == ag_action_8
+          && (ag_k = (int) ag_sbe[(PCB).sn] + 1) == (int) ag_sbt[(PCB).sn+1] - 1
+          && *TOKEN_NAMES[ag_tstt[ag_k]]) {
+    sprintf((PCB).ag_msg, MISSING_FORMAT, TOKEN_NAMES[ag_tstt[ag_k]]);
+  }
+  else if ((PCB).token_number && *TOKEN_NAMES[(PCB).token_number]) {
+    sprintf((PCB).ag_msg, UNEXPECTED_FORMAT, TOKEN_NAMES[(PCB).token_number]);
+  }
+  else if (isprint((*(PCB).lab)) && (*(PCB).lab) != '\\') {
+    char buf[20];
+    sprintf(buf, "\'%c\'", (char) (*(PCB).lab));
+    sprintf((PCB).ag_msg, UNEXPECTED_FORMAT, buf);
+  }
+  else sprintf((PCB).ag_msg, UNEXPECTED_FORMAT, UNNAMED_TOKEN);
+  (PCB).error_message = (PCB).ag_msg;
+
+
+}
+static int ag_action_1_r_proc(void);
+static int ag_action_2_r_proc(void);
+static int ag_action_3_r_proc(void);
+static int ag_action_4_r_proc(void);
+static int ag_action_1_s_proc(void);
+static int ag_action_3_s_proc(void);
+static int ag_action_1_proc(void);
+static int ag_action_2_proc(void);
+static int ag_action_3_proc(void);
+static int ag_action_4_proc(void);
+static int ag_action_5_proc(void);
+static int ag_action_6_proc(void);
+static int ag_action_7_proc(void);
+static int ag_action_8_proc(void);
+static int ag_action_9_proc(void);
+static int ag_action_10_proc(void);
+static int ag_action_11_proc(void);
+static int ag_action_12_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_12_proc
+};
+
+
+static int ag_action_1_er_proc(void);
+static int ag_action_2_er_proc(void);
+static int ag_action_3_er_proc(void);
+static int ag_action_4_er_proc(void);
+
+static int (*const  ag_er_procs_scan[])(void) = {
+  ag_action_1_er_proc,
+  ag_action_2_er_proc,
+  ag_action_3_er_proc,
+  ag_action_4_er_proc
+};
+
+
+static void ag_error_resynch(void) {
+  int ag_k;
+  int ag_ssx = (PCB).ssx;
+
+  ag_diagnose();
+  SYNTAX_ERROR;
+  if ((PCB).exit_flag != AG_RUNNING_CODE) return;
+  while (1) {
+    ag_k = ag_sbt[(PCB).sn];
+    while (ag_tstt[ag_k] != 17 && ag_tstt[ag_k]) ag_k++;
+    if (ag_tstt[ag_k] || (PCB).ssx == 0) break;
+    (PCB).sn = (PCB).ss[--(PCB).ssx];
+  }
+  if (ag_tstt[ag_k] == 0) {
+    (PCB).sn = (PCB).ss[(PCB).ssx = ag_ssx];
+    (PCB).exit_flag = AG_SYNTAX_ERROR_CODE;
+    return;
+  }
+  ag_k = ag_sbt[(PCB).sn];
+  while (ag_tstt[ag_k] != 17 && ag_tstt[ag_k]) ag_k++;
+  (PCB).ag_ap = ag_pstt[ag_k];
+  (ag_er_procs_scan[ag_astt[ag_k]])();
+  (PCB).ss[(PCB).ssx++] = (PCB).sn;
+  (PCB).sn = 60;
+  return;
+}
+
+static int ag_action_12_proc(void) {
+  int ag_t, ag_k = ag_sbt[(PCB).ss[(PCB).ssx-1]];
+
+  while (ag_tstt[ag_k] != (unsigned char) (PCB).token_number && ag_tstt[ag_k]) ag_k++;
+  ag_t = ag_tstt[ag_k];
+  if (ag_t && ag_astt[ag_k] != ag_action_10){
+    (PCB).sn = (PCB).ss[--(PCB).ssx];
+    (PCB).rx = 0;
+    return 1;
+  }
+  if ((PCB).token_number == 10)
+     {(PCB).exit_flag = AG_SYNTAX_ERROR_CODE; return 0;}
+  ag_track();
+  return 0;
+}
+
+
+static int ag_action_10_proc(void) {
+  (PCB).btsx = 0, (PCB).drt = -1;
+  ag_track();
+  return 0;
+}
+
+static int ag_action_11_proc(void) {
+  (PCB).btsx = 0, (PCB).drt = -1;
+  (*(int *) &(PCB).vs[(PCB).ssx]) = *(PCB).lab;
+  (PCB).ssx--;
+  ag_ra();
+  (PCB).ssx++;
+  ag_track();
+  return 0;
+}
+
+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 = (fc5_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 = (fc5_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 = (fc5_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).lab;
+  (PCB).ss[(PCB).ssx] = (PCB).sn;
+  (PCB).ssx++;
+  (PCB).sn = (PCB).ag_ap;
+  ag_track();
+  return 0;
+}
+
+static int ag_action_9_proc(void) {
+  if ((PCB).drt == -1) {
+    (PCB).drt=(PCB).token_number;
+    (PCB).dssx=(PCB).ssx;
+    (PCB).dsn=(PCB).sn;
+  }
+  ag_prot();
+  (PCB).ss[(PCB).ssx] = (PCB).sn;
+  (PCB).ssx++;
+  (PCB).sn = (PCB).ag_ap;
+  (PCB).rx = 0;
+  return (PCB).exit_flag == AG_RUNNING_CODE;
+}
+
+static int ag_action_2_r_proc(void) {
+  (PCB).ssx++;
+  (PCB).sn = (PCB).ag_ap;
+  return 0;
+}
+
+static int ag_action_7_proc(void) {
+  --(PCB).ssx;
+  (PCB).exit_flag = AG_SUCCESS_CODE;
+  (PCB).rx = 0;
+  return 0;
+}
+
+static int ag_action_1_proc(void) {
+  (PCB).exit_flag = AG_SUCCESS_CODE;
+  ag_track();
+  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 = (fc5_token_type) ag_ptt[(PCB).ag_ap];
+  (PCB).btsx = 0, (PCB).drt = -1;
+  (*(int *) &(PCB).vs[(PCB).ssx]) = *(PCB).lab;
+  if (ag_sd) (PCB).sn = (PCB).ss[(PCB).ssx -= ag_sd];
+  else (PCB).ss[(PCB).ssx] = (PCB).sn;
+  ag_track();
+  while ((PCB).exit_flag == AG_RUNNING_CODE) {
+    unsigned ag_t1 = ag_sbe[(PCB).sn] + 1;
+    unsigned ag_t2 = ag_sbt[(PCB).sn+1] - 1;
+    do {
+      unsigned ag_tx = (ag_t1 + ag_t2)/2;
+      if (ag_tstt[ag_tx] < (unsigned char)(PCB).reduction_token) ag_t1 = ag_tx + 1;
+      else ag_t2 = ag_tx;
+    } while (ag_t1 < ag_t2);
+    (PCB).ag_ap = ag_pstt[ag_t1];
+    if ((ag_s_procs_scan[ag_astt[ag_t1]])() == 0) break;
+  }
+  return 0;
+}
+
+static int ag_action_3_proc(void) {
+  int ag_sd = ag_fl[(PCB).ag_ap] - 1;
+  (PCB).btsx = 0, (PCB).drt = -1;
+  (*(int *) &(PCB).vs[(PCB).ssx]) = *(PCB).lab;
+  if (ag_sd) (PCB).sn = (PCB).ss[(PCB).ssx -= ag_sd];
+  else (PCB).ss[(PCB).ssx] = (PCB).sn;
+  ag_track();
+  (PCB).reduction_token = (fc5_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) {
+  int ag_k = ag_sbt[(PCB).sn];
+  while (ag_tstt[ag_k] != 17 && ag_tstt[ag_k]) ag_k++;
+  if (ag_tstt[ag_k] == 0) ag_undo();
+  (PCB).rx = 0;
+  ag_error_resynch();
+  return (PCB).exit_flag == AG_RUNNING_CODE;
+}
+
+static int ag_action_5_proc(void) {
+  int ag_sd = ag_fl[(PCB).ag_ap];
+  (PCB).btsx = 0, (PCB).drt = -1;
+  if (ag_sd) (PCB).sn = (PCB).ss[(PCB).ssx -= ag_sd];
+  else {
+    (PCB).ss[(PCB).ssx] = (PCB).sn;
+  }
+  (PCB).rx = 0;
+  (PCB).reduction_token = (fc5_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 = (fc5_token_type) ag_ptt[(PCB).ag_ap];
+  if ((PCB).drt == -1) {
+    (PCB).drt=(PCB).token_number;
+    (PCB).dssx=(PCB).ssx;
+    (PCB).dsn=(PCB).sn;
+  }
+  if (ag_sd) {
+    (PCB).sn = (PCB).ss[(PCB).ssx -= ag_sd];
+  }
+  else {
+    ag_prot();
+    (PCB).vs[(PCB).ssx] = ag_null_value;
+    (PCB).ss[(PCB).ssx] = (PCB).sn;
+  }
+  (PCB).rx = 0;
+  while ((PCB).exit_flag == AG_RUNNING_CODE) {
+    unsigned ag_t1 = ag_sbe[(PCB).sn] + 1;
+    unsigned ag_t2 = ag_sbt[(PCB).sn+1] - 1;
+    do {
+      unsigned ag_tx = (ag_t1 + ag_t2)/2;
+      if (ag_tstt[ag_tx] < (unsigned char)(PCB).reduction_token) ag_t1 = ag_tx + 1;
+      else ag_t2 = ag_tx;
+    } while (ag_t1 < ag_t2);
+    (PCB).ag_ap = ag_pstt[ag_t1];
+    if ((ag_r_procs_scan[ag_astt[ag_t1]])() == 0) break;
+  }
+  return (PCB).exit_flag == AG_RUNNING_CODE;
+}
+
+
+static int ag_action_2_er_proc(void) {
+  (PCB).btsx = 0, (PCB).drt = -1;
+  (*(int *) &(PCB).vs[(PCB).ssx]) = *(PCB).lab;
+  (PCB).ssx++;
+  (PCB).sn = (PCB).ag_ap;
+  return 0;
+}
+
+static int ag_action_1_er_proc(void) {
+  (PCB).btsx = 0, (PCB).drt = -1;
+  (PCB).exit_flag = AG_SUCCESS_CODE;
+  return 0;
+}
+
+static int ag_action_4_er_proc(void) {
+  int ag_sd = ag_fl[(PCB).ag_ap] - 1;
+  (PCB).btsx = 0, (PCB).drt = -1;
+  (PCB).reduction_token = (fc5_token_type) ag_ptt[(PCB).ag_ap];
+  if (ag_sd) (PCB).sn = (PCB).ss[(PCB).ssx -= ag_sd];
+  else (PCB).ss[(PCB).ssx] = (PCB).sn;
+  while ((PCB).exit_flag == AG_RUNNING_CODE) {
+    unsigned ag_t1 = ag_sbe[(PCB).sn] + 1;
+    unsigned ag_t2 = ag_sbt[(PCB).sn+1] - 1;
+    do {
+      unsigned ag_tx = (ag_t1 + ag_t2)/2;
+      if (ag_tstt[ag_tx] < (unsigned char)(PCB).reduction_token) ag_t1 = ag_tx + 1;
+      else ag_t2 = ag_tx;
+    } while (ag_t1 < ag_t2);
+    (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_er_proc(void) {
+  int ag_sd = ag_fl[(PCB).ag_ap] - 1;
+  (PCB).btsx = 0, (PCB).drt = -1;
+  if (ag_sd) (PCB).sn = (PCB).ss[(PCB).ssx -= ag_sd];
+  else (PCB).ss[(PCB).ssx] = (PCB).sn;
+  (PCB).reduction_token = (fc5_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;
+}
+
+
+void init_fc5(void) {
+  unsigned ag_t1;
+  ag_t1 = 0;
+  (PCB).rx = (PCB).fx = 0;
+  (PCB).ss[0] = (PCB).sn = (PCB).ssx = 0;
+  (PCB).exit_flag = AG_RUNNING_CODE;
+  (PCB).key_sp = NULL;
+  (PCB).key_state = 0;
+  (PCB).line = FIRST_LINE;
+  (PCB).column = FIRST_COLUMN;
+  (PCB).btsx = 0, (PCB).drt = -1;
+  while (ag_tstt[ag_t1] == 0) {
+    (PCB).ag_ap = ag_pstt[ag_t1];
+    (ag_gt_procs_scan[ag_astt[ag_t1]])();
+    ag_t1 = ag_sbt[(PCB).sn];
+  }
+}
+
+void fc5(void) {
+  (PCB).lab[(PCB).fx++] = (PCB).input_code;
+  while ((PCB).exit_flag == AG_RUNNING_CODE) {
+    while (1) {
+      const  unsigned char *ag_p;
+      int ag_ch;
+      if ((PCB).rx >= (PCB).fx) return;
+      ag_ch = CONVERT_CASE((PCB).lab[(PCB).rx++]);
+      if ((PCB).key_sp) {
+        if (ag_ch != *(PCB).key_sp++) {
+          (PCB).rx = (PCB).save_index;
+          (PCB).key_sp = NULL;
+          (PCB).key_state = 0;
+          break;
+        } else if (*(PCB).key_sp) continue;
+        if (ag_key_act[(PCB).key_state] == ag_cf_end_key) {
+          int ag_k1;
+          int ag_k2;
+          if ((PCB).rx >= (PCB).fx) {
+            (PCB).rx--;
+            (PCB).key_sp--;
+            return;
+          }
+          (PCB).key_sp = NULL;
+          ag_k1 = ag_key_parm[(PCB).key_state];
+          ag_k2 = ag_key_pt[ag_k1];
+          if (ag_key_itt[ag_k2 + CONVERT_CASE((PCB).lab[(PCB).rx])])
+            (PCB).rx = (PCB).save_index;
+          else {
+            (PCB).token_number =  (fc5_token_type) ag_key_pt[ag_k1+1];
+            (PCB).key_state = 0;
+          }
+          break;
+        }
+        else {
+          (PCB).token_number = (fc5_token_type) ag_key_parm[(PCB).key_state];
+          (PCB).key_state = 0;
+          (PCB).key_sp = NULL;
+        }
+        break;
+      }
+      if ((PCB).key_state == 0) {
+        (PCB).token_number = (fc5_token_type) AG_TCV(ag_ch);
+        if (((PCB).key_state = ag_key_index[(PCB).sn]) == 0) break;
+        (PCB).save_index = 1;
+      }
+      ag_p = &ag_key_ch[(PCB).key_state];
+      if (ag_ch <= 255) while (*ag_p < ag_ch) ag_p++;
+      if (*ag_p == ag_ch) {
+        (PCB).key_state = (int)(ag_p - ag_key_ch);
+        switch (ag_key_act[(PCB).key_state]) {
+        case ag_cf_set_key: {
+          int ag_k1;
+          int ag_k2;
+          if ((PCB).rx >= (PCB).fx) {
+            (PCB).rx--;
+            return;
+          }
+          ag_k1 = ag_key_parm[(PCB).key_state];
+          ag_k2 = ag_key_pt[ag_k1];
+          (PCB).key_state = ag_key_jmp[(PCB).key_state];
+          if (ag_key_itt[ag_k2 + CONVERT_CASE((PCB).lab[(PCB).rx])]) continue;
+          (PCB).save_index = (PCB).rx;
+          (PCB).token_number = (fc5_token_type) ag_key_pt[ag_k1+1];
+          continue;
+        }
+        case ag_set_key:
+          (PCB).save_index = (PCB).rx;
+          (PCB).token_number = (fc5_token_type) ag_key_parm[(PCB).key_state];
+        case ag_jmp_key:
+          (PCB).key_state = ag_key_jmp[(PCB).key_state];
+          continue;
+        case ag_cf_end_key:
+        case ag_end_key:
+          (PCB).key_sp = ag_key_ends + ag_key_jmp[(PCB).key_state];
+          continue;
+        case ag_accept_key:
+          (PCB).token_number = (fc5_token_type) ag_key_parm[(PCB).key_state];
+          (PCB).key_state = 0;
+          break;
+        case ag_cf_accept_key: {
+          int ag_k1;
+          int ag_k2;
+          if ((PCB).rx >= (PCB).fx) {
+            (PCB).rx--;
+            return;
+          }
+          ag_k1 = ag_key_parm[(PCB).key_state];
+          ag_k2 = ag_key_pt[ag_k1];
+          if (ag_key_itt[ag_k2 + CONVERT_CASE((PCB).lab[(PCB).rx])])
+            (PCB).rx = (PCB).save_index;
+          else {
+            (PCB).token_number = (fc5_token_type) ag_key_pt[ag_k1+1];
+            (PCB).key_state = 0;
+          }
+          break;
+        }
+        }
+        break;
+      } else {
+        (PCB).rx = (PCB).save_index;
+        (PCB).key_state = 0;
+        break;
+      }
+    }
+
+    {
+      unsigned ag_t1 = ag_sbt[(PCB).sn];
+      unsigned ag_t2 = ag_sbe[(PCB).sn] - 1;
+      do {
+        unsigned ag_tx = (ag_t1 + ag_t2)/2;
+        if (ag_tstt[ag_tx] > (unsigned char)(PCB).token_number)
+          ag_t1 = ag_tx + 1;
+        else ag_t2 = ag_tx;
+      } while (ag_t1 < ag_t2);
+      if (ag_tstt[ag_t1] != (PCB).token_number)  ag_t1 = ag_sbe[(PCB).sn];
+      (PCB).ag_ap = ag_pstt[ag_t1];
+      (ag_gt_procs_scan[ag_astt[ag_t1]])();
+    }
+  }
+}
+
+