diff tests/agcl/parsifal/good/rfc822a.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/parsifal/good/rfc822a.c	Sat Dec 22 17:52:45 2007 -0500
@@ -0,0 +1,1359 @@
+#define GET_CONTEXT CONTEXT = PCB.pointer
+
+/*
+ * 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 RFC822A_H
+#include "rfc822a.h"
+#endif
+
+#ifndef RFC822A_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])
+
+
+
+rfc822a_pcb_type rfc822a_pcb;
+#define PCB rfc822a_pcb
+
+/*  Line -, rfc822a.syn */
+	/**************************************************************
+	* Input function to the parsing engine.
+	*
+	* It takse a pointer to a string and a ponter to a Request Object
+	* that will be populated
+	***************************************************************/
+/*INT rfc822_parser(char *buffer, CRfc822Req  *Request)
+	{
+		PCB.pointer = (unsigned char *)buffer;
+		pRequest = Request;
+		rfc822parse();
+		return PCB.exit_flag;
+
+	}*/
+
+#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
+
+
+#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 int const ag_null_value NULL_VALUE_INITIALIZER;
+
+static const unsigned char ag_rpx[] = {
+    0
+};
+
+static const unsigned char ag_key_itt[] = {
+ 0
+};
+
+static const unsigned short ag_key_pt[] = {
+0
+};
+
+static const unsigned char ag_key_ch[] = {
+    0, 66, 84,255, 45,255, 84,255, 78,255, 69,255, 67, 83, 84,255, 69,255,
+   66, 67, 68, 70, 77, 82, 84,255, 70,255, 66, 84,255, 45,255, 84,255, 78,
+  255, 69,255, 67, 83, 84,255, 69,255, 13, 66, 67, 68, 70, 77, 82, 84,255,
+   82,255, 65, 85,255, 72, 85,255, 70, 77, 83, 84, 87,255, 66, 84,255, 45,
+  255, 84,255, 78,255, 69,255, 67, 83, 84,255, 69,255, 13, 66, 67, 68, 70,
+   77, 80, 82, 84,255, 80,255, 83,255, 66, 70, 83, 84,255, 45,255, 84,255,
+   78,255, 69,255, 67, 80, 83, 84,255, 69,255, 13, 66, 67, 68, 70, 77, 82,
+   84,255, 66, 70, 83, 84,255, 45,255, 84,255, 78,255, 69,255, 67, 83, 84,
+  255, 69,255, 13, 66, 67, 68, 70, 77, 82, 84,255, 82,255, 13,255, 70, 82,
+  255, 66, 82, 84,255, 45,255, 84,255, 78,255, 69,255, 67, 83, 84,255, 69,
+  255, 13, 66, 67, 68, 70, 77, 82, 84,255, 79, 82,255, 66, 70, 73, 86, 87,
+  255, 67, 89,255, 79, 82,255, 66, 70, 82, 83, 84,255, 45,255, 84,255, 78,
+  255, 69,255, 67, 80, 83, 84,255, 69,255, 13, 66, 67, 68, 70, 73, 77, 80,
+   82, 84, 86, 87,255, 80, 85,255, 76, 78,255, 65, 85,255, 82, 89,255, 65,
+  255, 65, 68, 70, 74, 77, 78, 79, 83,255, 66, 82, 84,255, 45,255, 84,255,
+   78,255, 69,255, 67, 83, 84,255, 69,255, 13, 66, 67, 68, 70, 77, 80, 82,
+   84,255, 68, 83,255, 68, 83,255, 68, 83,255, 68, 83,255, 67, 69, 71, 77,
+   80, 85,255
+};
+
+static const unsigned char ag_key_act[] = {
+  0,3,3,4,2,4,2,4,2,4,2,4,3,2,3,4,2,4,3,3,3,3,3,2,3,4,3,4,3,3,4,2,4,2,4,
+  2,4,2,4,3,2,3,4,2,4,3,3,3,3,3,3,2,3,4,3,4,3,3,4,3,3,4,3,3,2,2,3,4,3,3,
+  4,2,4,2,4,2,4,2,4,3,2,3,4,2,4,3,3,3,3,3,3,3,2,3,4,3,4,3,4,3,3,3,3,4,2,
+  4,2,4,2,4,2,4,3,3,2,3,4,2,4,3,3,3,3,3,3,2,3,4,3,3,3,3,4,2,4,2,4,2,4,2,
+  4,3,2,3,4,2,4,3,3,3,3,3,3,2,3,4,3,4,3,4,3,3,4,3,3,3,4,2,4,2,4,2,4,2,4,
+  3,2,3,4,2,4,3,3,3,3,3,3,2,3,4,3,3,4,3,2,3,3,3,4,3,0,4,3,3,4,3,3,3,3,3,
+  4,2,4,2,4,2,4,2,4,3,3,2,3,4,2,4,3,2,3,3,2,3,3,3,2,3,3,3,4,3,3,4,0,0,4,
+  3,2,4,0,0,4,2,4,2,3,3,2,2,3,3,3,4,3,3,3,4,2,4,2,4,2,4,2,4,3,2,3,4,2,4,
+  3,3,3,3,3,3,3,2,3,4,3,3,4,3,3,4,3,3,4,3,3,4,2,2,3,2,2,3,4
+};
+
+static const unsigned char ag_key_parm[] = {
+    0, 63, 58,  0,  0,  0,  0,  0,  0,  0,  0,  0, 60,  0,156,  0,  0,  0,
+   61, 59,117, 18,116,  0, 56,  0, 18,  0, 63, 58,  0,  0,  0,  0,  0,  0,
+    0,  0,  0, 60,  0,156,  0,  0,  0, 30, 61, 59,117, 18,116,  0, 56,  0,
+  132,  0, 51, 52,  0, 49, 47,  0, 50, 46,  0,  0, 48,  0, 63, 58,  0,  0,
+    0,  0,  0,  0,  0,  0,  0, 60,  0,156,  0,  0,  0, 30, 61, 59,117, 18,
+  116, 89,  0, 56,  0, 89,  0, 21,  0, 63,153,152, 58,  0,  0,  0,  0,  0,
+    0,  0,  0,  0, 60,119,  0,156,  0,  0,  0, 30, 61, 59,117, 18,116,  0,
+   56,  0, 63,153,152, 58,  0,  0,  0,  0,  0,  0,  0,  0,  0, 60,  0,156,
+    0,  0,  0, 30, 61, 59,117, 18,116,  0, 56,  0,154,  0, 30,  0, 18,132,
+    0, 63,150, 58,  0,  0,  0,  0,  0,  0,  0,  0,  0, 60,  0,156,  0,  0,
+    0, 30, 61, 59,117, 18,116,  0, 56,  0,146, 18,  0,138,  0,144,140,142,
+    0, 61,138,  0,146, 18,  0, 63,153,150,152, 58,  0,  0,  0,  0,  0,  0,
+    0,  0,  0, 60,119,  0,156,  0,  0,  0, 30,  0, 59,117,  0,144,116, 89,
+    0, 56,140,142,  0,103,107,  0,106,105,  0,100,  0,  0,102,104,  0,  0,
+    0,  0,111,101,  0,  0,110,109,108,  0, 63,150, 58,  0,  0,  0,  0,  0,
+    0,  0,  0,  0, 60,  0,156,  0,  0,  0, 30, 61, 59,117, 18,116, 89,  0,
+   56,  0,173,172,  0,171,170,  0,175,174,  0,177,176,  0,  0,  0,169,  0,
+    0,168,  0
+};
+
+static const unsigned short ag_key_jmp[] = {
+    0, 30, 33,  0,  1,  0,  4,  0,  6,  0,  8,  0, 23, 10, 35,  0, 12,  0,
+    0,  3,  5,  9, 13, 16, 44,  0, 46,  0, 82, 85,  0, 28,  0, 31,  0, 33,
+    0, 35,  0, 75, 37, 87,  0, 39,  0, 50, 52, 55, 57, 61, 65, 43, 96,  0,
+   98,  0,112,114,  0,116,118,  0,106,109, 56, 59,120,  0,161,164,  0, 68,
+    0, 71,  0, 73,  0, 75,  0,154, 77,166,  0, 79,  0,123,125,128,130,134,
+  138,148, 83,175,  0,177,  0,183,  0,227,230,234,240,  0, 99,  0,104,  0,
+  106,  0,108,  0,214,221,110,242,  0,112,  0,189,191,194,196,200,204,117,
+  251,  0,285,288,292,298,  0,128,  0,133,  0,135,  0,137,  0,278,139,300,
+    0,141,  0,253,255,258,260,264,268,145,309,  0,311,  0,322,  0,324,328,
+    0,368,371,379,  0,163,  0,167,  0,169,  0,171,  0,361,173,381,  0,175,
+    0,336,338,341,343,347,351,179,390,  0,394,396,  0,392,190,399,401,404,
+    0,410,  0,  0,418,420,  0,454,457,461,469,475,  0,205,  0,211,  0,213,
+    0,215,  0,441,448,217,477,  0,219,  0,408,199,412,414,202,423,425,435,
+  224,486,488,491,  0,495,497,  0,  0,  0,  0,505,242,  0,  0,  0,  0,248,
+    0,239,499,502,245,251,507,510,513,  0,554,557,565,  0,262,  0,266,  0,
+  268,  0,270,  0,547,272,567,  0,274,  0,516,518,521,523,527,531,541,278,
+  576,  0,578,580,  0,582,584,  0,589,591,  0,593,595,  0,290,293,586,296,
+  299,597,  0
+};
+
+static const unsigned short ag_key_index[] = {
+   18,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0, 26, 45, 45,  0, 54,  0, 62,
+   85, 85, 95, 95, 95, 95, 97,  0,119,147,156,158,158,  0,  0,160,  0,  0,
+    0,158,  0,  0,  0,  0, 45, 45, 45, 45,  0, 95,  0,  0,  0,181,  0,  0,
+    0,  0,193,  0,  0,  0,  0,  0,158,  0,158,  0,  0,  0,  0, 95, 95, 95,
+    0, 95, 95, 95,  0, 62,158,158,226,  0,  0,  0,  0,  0,  0,  0,193,253,
+    0,  0,  0,  0, 95,  0,147,280, 95,158,  0,  0,  0, 62,  0,  0,302, 95,
+   26, 45,  0,  0,  0,  0,  0, 95,  0, 95,  0,  0
+};
+
+static const unsigned char ag_key_ends[] = {
+67,67,0, 67,0, 65,84,69,0, 82,79,77,0, 
+69,83,83,65,71,69,45,73,68,0, 69,78,84,45,67,67,0, 67,67,0, 79,0, 
+85,82,78,45,80,65,84,72,0, 79,0, 82,79,77,0, 10,0, 67,67,0, 
+67,0, 65,84,69,0, 82,79,77,0, 69,83,83,65,71,69,45,73,68,0, 
+69,78,84,45,67,67,0, 67,67,0, 79,0, 85,82,78,45,80,65,84,72,0, 
+79,0, 69,67,69,73,86,69,68,0, 82,73,0, 79,78,0, 84,0, 78,0, 
+85,0, 69,0, 69,68,0, 10,0, 67,67,0, 67,0, 65,84,69,0, 
+82,79,77,0, 69,83,83,65,71,69,45,73,68,0, 72,82,65,83,69,0, 
+69,78,84,45,67,67,0, 67,67,0, 79,0, 85,82,78,45,80,65,84,72,0, 
+79,0, 72,82,65,83,69,0, 69,78,68,69,82,0, 10,0, 67,67,0, 67,0, 
+65,84,69,0, 82,79,77,0, 69,83,83,65,71,69,45,73,68,0, 
+69,78,84,45,67,67,0, 76,89,45,84,79,0, 67,67,0, 82,79,77,0, 
+69,78,68,69,82,0, 79,0, 85,82,78,45,80,65,84,72,0, 79,0, 10,0, 
+67,67,0, 67,0, 65,84,69,0, 82,79,77,0, 
+69,83,83,65,71,69,45,73,68,0, 69,78,84,45,67,67,0, 67,67,0, 
+82,79,77,0, 69,78,68,69,82,0, 79,0, 85,82,78,45,80,65,84,72,0, 
+79,0, 69,83,69,78,84,45,68,65,84,69,0, 10,0, 82,79,77,0, 
+69,67,69,73,86,69,68,0, 10,0, 67,67,0, 67,0, 65,84,69,0, 
+82,79,77,0, 69,83,83,65,71,69,45,73,68,0, 69,78,84,45,67,67,0, 
+67,67,0, 69,80,76,89,45,84,79,0, 79,0, 85,82,78,45,80,65,84,72,0, 
+79,0, 89,0, 82,0, 79,77,0, 68,0, 73,65,0, 73,84,72,0, 10,0, 
+67,0, 67,0, 65,84,69,0, 82,0, 79,77,0, 68,0, 
+69,83,83,65,71,69,45,73,68,0, 72,82,65,83,69,0, 
+69,78,84,45,67,67,0, 76,89,45,84,79,0, 67,67,0, 82,79,77,0, 
+69,80,76,89,45,84,79,0, 69,78,68,69,82,0, 79,0, 
+85,82,78,45,80,65,84,72,0, 79,0, 73,65,0, 73,84,72,0, 82,0, 
+71,0, 69,67,0, 69,66,0, 78,0, 79,86,0, 67,84,0, 69,80,0, 10,0, 
+67,67,0, 67,0, 65,84,69,0, 82,79,77,0, 
+69,83,83,65,71,69,45,73,68,0, 72,82,65,83,69,0, 
+69,78,84,45,67,67,0, 67,67,0, 69,80,76,89,45,84,79,0, 79,0, 
+85,82,78,45,80,65,84,72,0, 79,0, 84,0, 84,0, 84,0, 84,0, 
+77,84,0, 84,0, 84,0, 84,0, 84,0, 84,0, 
+};
+
+#define AG_TCV(x) ag_tcv[(x)]
+
+static const unsigned char ag_tcv[] = {
+  182,182,182,182,182,182,182,182,182,183,182,182,182,184,182,182,182,182,
+  182,182,182,182,182,182,182,182,182,182,182,182,182,182, 22,181,180,181,
+  181,181,181,181, 20, 24,181,181, 43,181, 66,181, 37, 37, 37, 37, 37, 37,
+   37, 37, 37, 37, 19, 90,113,181,114,181, 14,178,178,178,178,178,178,178,
+  178,178,178,178,178,178,178,178,178,178,178,178,178,178,178,178,178,178,
+  178, 68,125, 71,181,181,181,178,178,178,178,178,178,178,178,178,178,178,
+  178,178,178,178,178,178,178,178,178,178,178,178,178,178,178,181,181,181,
+  181,182,  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(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 = (rfc822a_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 = (rfc822a_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 = (rfc822a_token_type) ag_key_pt[ag_k1+1];
+      break;
+    }
+    case ag_set_key:
+      ag_save = (int) ((PCB).la_ptr - (PCB).pointer);
+      (PCB).token_number = (rfc822a_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 = (rfc822a_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 = (rfc822a_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];
+  (PCB).cs[ag_k] = (PCB).cs[(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).cs[(PCB).ssx] = (PCB).cs[ag_k];
+  }
+  (PCB).token_number = (rfc822a_token_type) (PCB).drt;
+  (PCB).ssx = (PCB).dssx;
+  (PCB).sn = (PCB).dsn;
+  (PCB).drt = -1;
+}
+
+
+static const unsigned char ag_tstt[] = {
+156,117,116,63,61,60,59,58,56,20,18,0,1,38,39,55,79,80,81,82,115,155,161,
+  162,
+19,0,
+22,0,
+19,0,
+19,0,
+19,0,
+19,0,
+19,0,
+19,0,
+19,0,
+19,0,
+20,18,0,17,118,
+22,0,
+156,117,116,63,61,60,59,58,56,30,20,18,0,2,38,39,55,80,81,82,98,99,115,155,
+  161,162,
+113,0,95,
+132,0,131,167,
+113,0,112,
+52,51,50,49,48,47,46,37,0,41,42,44,
+181,180,178,156,117,116,89,63,61,60,59,58,56,37,30,20,18,0,3,4,9,10,11,12,
+  13,62,126,
+181,180,178,156,117,116,89,63,61,60,59,58,56,37,30,20,18,0,3,4,9,10,11,12,
+  13,62,126,
+181,180,178,89,37,0,3,4,9,10,11,12,13,57,126,
+181,180,178,89,37,0,3,4,9,10,11,12,13,57,126,
+181,180,178,89,37,0,3,4,9,10,11,12,13,57,126,
+181,180,178,89,37,0,3,4,9,10,11,12,13,57,126,
+21,0,
+19,0,
+156,153,152,119,117,116,63,61,60,59,58,56,30,20,18,0,120,
+156,153,152,117,116,63,61,60,59,58,56,30,20,18,0,148,149,163,
+154,0,40,
+184,183,182,181,180,178,125,114,113,90,71,68,66,43,37,30,24,22,20,19,14,0,
+  96,97,164,
+30,0,2,98,
+181,180,178,37,14,0,157,158,159,160,
+19,0,
+132,0,131,
+181,180,178,37,0,3,4,12,13,126,
+43,0,
+37,0,8,33,34,
+183,182,181,180,178,125,114,113,90,71,68,66,43,37,30,24,22,20,19,14,0,2,5,6,
+  7,29,32,123,128,129,130,
+181,178,37,0,
+22,0,
+14,0,
+22,19,0,
+22,0,
+22,0,
+22,0,
+22,0,
+19,0,
+181,180,178,89,37,0,3,4,10,12,13,126,
+19,0,
+19,0,
+19,0,
+156,150,117,116,63,61,60,59,58,56,30,20,18,0,151,
+19,0,
+181,178,68,37,0,3,15,64,65,67,73,
+19,14,0,159,
+181,180,178,37,0,3,4,12,13,126,
+146,144,142,140,138,18,0,133,134,136,
+114,0,
+37,0,
+22,0,
+37,0,45,91,
+183,22,0,
+183,30,22,0,2,5,6,
+184,183,182,181,180,178,125,114,113,90,71,68,66,43,37,24,22,20,19,14,0,86,
+183,182,181,178,125,114,113,90,71,68,66,43,37,30,24,22,20,19,14,0,2,5,6,7,
+  29,32,123,128,
+180,0,
+66,0,93,94,
+181,178,68,37,0,3,15,64,65,67,73,
+113,0,95,
+181,180,178,89,37,0,3,4,10,12,13,23,126,
+181,180,178,89,37,0,3,4,9,10,11,12,13,126,
+181,180,178,89,37,0,3,4,10,12,13,126,
+22,0,
+181,180,178,89,37,0,3,4,9,10,11,12,13,57,126,
+181,180,178,89,37,0,3,4,10,12,13,23,126,
+181,180,178,89,37,0,3,4,10,12,13,126,
+19,0,
+52,51,50,49,48,47,46,37,0,41,42,44,
+183,182,181,180,178,125,114,113,90,66,43,37,30,24,22,20,19,14,0,2,5,6,7,29,
+  32,69,70,72,
+181,178,37,0,
+66,0,
+114,0,
+181,180,178,37,0,3,4,12,13,126,147,
+113,0,112,145,
+181,178,37,0,3,143,
+181,178,37,0,3,141,
+181,178,68,37,0,3,15,64,65,67,73,139,
+181,178,68,37,0,3,15,64,65,67,73,137,
+146,144,142,140,138,90,18,0,133,136,
+111,110,109,108,107,106,105,104,103,102,101,100,0,35,
+37,0,
+22,0,
+181,180,178,37,0,3,4,126,
+66,0,93,
+181,180,178,90,89,37,22,0,25,
+22,0,
+22,0,
+181,180,178,156,150,117,116,89,63,61,60,59,58,56,37,30,22,20,18,0,25,
+181,180,178,89,37,0,3,4,9,10,11,12,13,57,126,
+183,182,181,180,178,125,114,113,90,71,66,43,37,30,24,22,20,19,14,0,2,5,6,7,
+  29,32,69,72,
+181,178,68,37,0,3,65,67,73,
+181,178,37,0,
+181,178,37,0,
+52,51,50,49,48,47,46,37,0,41,42,44,135,
+22,0,
+19,0,
+180,178,177,176,175,174,173,172,171,170,169,168,0,166,
+181,180,178,89,37,0,3,4,10,12,13,126,
+18,0,
+22,0,
+37,0,8,36,
+37,0,
+19,0,
+37,0,
+37,0,
+181,180,178,89,37,0,3,4,10,12,13,23,126,
+22,19,0,92,
+181,180,178,89,37,24,22,0,25,
+37,0,
+37,0,
+
+};
+
+
+static unsigned const char ag_astt[932] = {
+  1,1,1,1,1,1,1,1,1,8,8,7,0,1,1,1,1,1,1,1,1,1,1,1,1,7,1,7,1,7,1,7,1,7,1,7,1,
+  7,1,7,1,7,1,7,1,1,7,1,1,1,5,1,1,1,1,1,1,1,1,1,1,8,8,7,1,3,1,3,3,3,3,1,1,3,
+  1,1,1,1,7,3,1,7,1,1,1,7,3,1,1,1,1,1,1,1,8,7,3,1,1,1,1,1,5,5,5,1,5,5,5,5,5,
+  5,1,5,5,5,7,1,1,3,3,3,3,1,3,1,1,1,1,5,5,5,1,5,5,5,5,5,5,1,5,5,5,7,1,1,3,3,
+  3,3,1,3,1,1,1,1,1,1,7,1,1,1,1,1,1,1,1,1,1,1,1,1,1,7,1,1,1,1,1,1,1,1,1,1,1,
+  1,1,1,7,1,1,1,1,1,1,1,1,1,1,1,1,1,1,7,1,1,1,1,1,1,1,1,1,1,7,1,7,5,5,5,1,5,
+  5,5,5,5,5,5,5,5,5,5,7,3,5,1,1,5,5,5,5,5,5,5,5,5,5,5,7,3,1,3,1,7,3,3,3,3,3,
+  3,3,3,3,3,3,3,3,3,3,3,5,3,3,3,3,3,7,3,3,3,1,5,1,3,8,8,8,8,1,7,1,1,1,1,1,7,
+  1,5,3,1,1,1,1,7,1,1,1,1,1,3,7,1,7,1,1,1,1,1,1,8,1,1,1,1,1,1,1,1,1,1,1,1,1,
+  1,1,1,7,1,1,1,1,1,1,1,1,1,1,9,9,9,5,1,7,1,7,1,1,7,1,5,1,5,1,5,1,5,1,7,1,1,
+  1,1,1,7,1,1,3,3,1,1,1,7,1,7,1,7,5,1,5,5,5,5,5,5,5,5,5,5,5,7,3,1,7,1,1,1,1,
+  7,1,3,1,1,1,1,3,1,7,3,1,1,1,1,7,1,1,1,1,1,1,1,1,1,1,1,7,1,1,1,3,7,9,5,1,7,
+  1,7,3,1,3,3,7,9,1,9,5,1,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,7,3,1,
+  9,9,9,1,9,9,9,9,9,9,9,9,1,9,1,9,9,9,5,1,1,1,1,3,3,3,3,3,7,1,7,1,1,1,1,1,1,
+  7,1,3,1,1,1,1,1,7,3,1,1,1,1,1,7,1,1,1,1,1,1,1,1,1,1,1,1,7,1,1,3,3,3,3,1,1,
+  1,1,1,1,1,7,1,1,1,1,1,1,1,7,1,1,1,1,1,7,1,1,1,1,1,1,1,1,1,1,1,1,1,1,7,1,1,
+  1,1,1,1,1,1,1,1,1,1,7,1,1,3,3,1,1,1,7,1,1,1,1,1,1,1,8,7,3,1,1,1,1,1,1,1,1,
+  1,1,1,1,1,1,1,1,1,1,1,1,7,1,1,1,1,1,1,1,1,1,9,9,9,5,1,5,3,7,1,1,1,1,7,1,1,
+  3,1,1,3,1,7,3,3,1,1,1,7,1,3,1,1,1,7,1,3,1,1,1,1,7,1,3,1,1,1,1,3,1,1,1,1,7,
+  1,3,1,1,1,1,3,1,1,1,1,1,1,1,7,3,1,1,1,1,1,1,1,1,1,1,1,1,1,7,1,1,7,1,7,1,1,
+  1,1,7,1,3,3,1,5,3,8,8,8,3,8,8,1,7,1,1,7,1,5,8,8,8,5,5,5,5,8,5,5,5,5,5,5,8,
+  5,1,5,5,7,1,1,1,1,1,1,7,1,1,1,1,1,1,1,1,1,1,9,9,9,9,1,9,9,9,3,9,9,9,1,9,1,
+  9,9,9,7,1,1,1,1,3,3,3,3,1,1,1,1,7,1,3,3,3,9,9,9,5,9,9,9,5,1,1,1,1,1,1,1,8,
+  7,3,1,1,3,1,7,1,7,3,3,3,3,3,3,3,3,3,3,3,3,7,3,1,1,1,1,1,7,1,1,3,3,1,1,1,7,
+  1,5,1,7,1,3,1,7,1,7,9,5,1,7,1,1,1,1,1,7,1,1,1,1,1,1,1,5,1,7,3,8,8,8,8,8,3,
+  1,7,1,1,7,3,7
+};
+
+
+static const unsigned char ag_pstt[] = {
+1,4,3,5,6,7,8,9,10,11,11,0,0,13,12,13,13,13,13,13,13,2,11,11,
+14,1,
+15,2,
+16,3,
+17,4,
+18,5,
+19,6,
+20,7,
+21,8,
+22,9,
+23,10,
+24,25,11,26,27,
+28,27,
+1,4,3,5,6,7,8,9,10,29,11,11,13,29,67,12,67,67,67,67,30,30,67,2,11,11,
+31,14,153,
+32,15,33,33,
+34,16,112,
+35,35,35,35,35,35,35,36,17,113,35,36,
+38,37,38,46,46,46,41,46,46,46,46,46,46,38,46,46,46,18,38,39,49,49,49,49,40,
+  49,39,
+38,37,38,46,46,46,41,46,46,46,46,46,46,38,46,46,46,19,38,39,48,48,48,48,40,
+  48,39,
+38,37,38,41,38,20,38,39,42,42,42,42,40,42,39,
+38,37,38,41,38,21,38,39,43,43,43,43,40,43,39,
+38,37,38,41,38,22,38,39,44,44,44,44,40,44,39,
+38,37,38,41,38,23,38,39,45,45,45,45,40,45,39,
+46,24,
+47,25,
+114,114,114,48,114,114,114,114,114,114,114,114,114,114,114,26,116,
+163,49,50,163,163,163,163,163,163,163,163,163,163,163,27,165,51,165,
+52,28,28,
+94,94,94,94,94,94,94,94,94,94,94,94,94,94,94,92,94,94,94,94,94,29,94,94,94,
+29,97,29,96,
+55,55,55,55,53,31,55,54,54,55,
+56,32,
+32,173,172,
+38,37,38,38,34,38,39,57,40,39,
+30,35,
+58,36,58,60,59,
+62,64,64,65,64,63,64,64,64,64,64,64,64,64,61,64,62,64,64,64,37,61,62,62,62,
+  64,64,64,64,64,65,
+8,8,8,174,
+66,39,
+67,40,
+68,69,41,
+70,45,
+70,44,
+70,43,
+70,42,
+71,46,
+38,37,38,72,38,47,38,39,9,9,40,39,
+73,48,
+74,49,
+75,50,
+147,76,147,147,147,147,147,147,147,147,147,147,147,51,149,
+77,52,
+79,79,78,79,53,79,155,80,80,80,80,
+154,53,54,157,
+38,37,38,38,55,38,39,81,40,39,
+82,83,84,85,86,87,56,88,88,87,
+110,57,
+26,23,
+89,59,
+90,60,31,91,
+84,84,61,
+3,61,3,83,61,3,3,
+122,122,122,122,122,122,122,122,122,122,122,122,122,122,122,122,122,122,122,
+  122,63,122,
+62,124,124,124,63,124,124,124,124,124,124,124,124,61,124,62,124,124,124,126,
+  61,62,62,62,124,124,124,124,
+127,65,
+92,66,93,93,
+79,79,78,79,67,79,6,80,80,80,80,
+31,68,91,
+38,37,38,72,38,69,38,39,94,94,40,94,39,
+38,37,38,41,38,70,38,39,51,51,51,51,40,39,
+38,37,38,72,38,71,38,39,95,95,40,39,
+68,72,
+38,37,38,41,38,73,38,39,96,96,96,96,40,96,39,
+38,37,38,72,38,74,38,39,97,97,40,97,39,
+38,37,38,72,38,75,38,39,150,150,40,39,
+98,76,
+35,35,35,35,35,35,35,36,77,152,35,36,
+62,99,99,99,99,63,99,99,99,99,99,99,61,99,62,99,99,99,78,61,62,62,62,99,99,
+  99,99,99,
+8,8,8,60,
+100,52,
+160,81,
+38,37,38,38,82,38,39,138,40,39,138,
+34,83,137,137,
+101,101,101,84,101,136,
+102,102,102,85,102,135,
+79,79,78,79,86,79,134,80,80,80,80,134,
+79,79,78,79,87,79,133,80,80,80,80,133,
+82,83,84,85,86,103,87,88,131,87,
+104,104,104,104,104,104,104,104,104,104,104,104,89,104,
+105,90,
+106,91,
+38,37,38,38,92,38,86,86,
+92,89,88,
+107,107,107,79,107,107,107,94,107,
+108,95,
+70,115,
+107,107,107,151,151,151,151,107,151,151,151,151,151,151,107,151,107,151,151,
+  97,107,
+38,37,38,41,38,98,38,39,109,109,109,109,40,109,39,
+62,56,56,56,56,63,56,56,56,57,56,56,56,61,56,62,56,56,56,99,61,62,62,62,56,
+  56,56,56,
+79,79,78,79,100,79,54,54,54,
+8,8,8,143,
+8,8,8,142,
+35,35,35,35,35,35,35,36,103,132,35,36,132,
+110,104,
+111,105,
+170,170,170,170,170,170,170,170,170,170,170,170,106,170,
+38,37,38,72,38,107,38,39,14,14,40,39,
+112,108,
+70,148,
+113,110,113,22,
+114,111,
+115,112,
+26,24,
+116,114,
+38,37,38,72,38,115,38,39,117,117,40,117,39,
+80,118,116,82,
+107,107,107,107,107,10,107,117,107,
+119,118,
+81,119,
+
+};
+
+
+static const unsigned short ag_sbt[] = {
+     0,  24,  26,  28,  30,  32,  34,  36,  38,  40,  42,  44,  49,  51,
+    77,  80,  84,  87,  99, 126, 153, 168, 183, 198, 213, 215, 217, 234,
+   252, 255, 280, 284, 294, 296, 299, 309, 311, 316, 347, 351, 353, 355,
+   358, 360, 362, 364, 366, 368, 380, 382, 384, 386, 401, 403, 414, 418,
+   428, 438, 440, 442, 444, 448, 451, 458, 480, 508, 510, 514, 525, 528,
+   541, 555, 567, 569, 584, 597, 609, 611, 623, 651, 655, 657, 659, 670,
+   674, 680, 686, 698, 710, 720, 734, 736, 738, 746, 749, 758, 760, 762,
+   783, 798, 826, 835, 839, 843, 856, 858, 860, 874, 886, 888, 890, 894,
+   896, 898, 900, 902, 915, 919, 928, 930, 932
+};
+
+
+static const unsigned short ag_sbe[] = {
+    11,  25,  27,  29,  31,  33,  35,  37,  39,  41,  43,  46,  50,  63,
+    78,  81,  85,  95, 116, 143, 158, 173, 188, 203, 214, 216, 232, 248,
+   253, 276, 281, 289, 295, 297, 303, 310, 312, 336, 350, 352, 354, 357,
+   359, 361, 363, 365, 367, 373, 381, 383, 385, 399, 402, 407, 416, 422,
+   434, 439, 441, 443, 445, 450, 454, 478, 499, 509, 511, 518, 526, 533,
+   546, 560, 568, 574, 589, 602, 610, 619, 641, 654, 656, 658, 663, 671,
+   677, 683, 690, 702, 717, 732, 735, 737, 742, 747, 756, 759, 761, 781,
+   788, 817, 830, 838, 842, 851, 857, 859, 872, 879, 887, 889, 891, 895,
+   897, 899, 901, 907, 917, 926, 929, 931, 932
+};
+
+
+static const unsigned char ag_fl[] = {
+  1,1,1,2,1,1,3,1,2,3,9,1,0,1,3,3,1,1,1,1,1,1,5,1,1,1,2,1,3,0,2,3,1,1,1,
+  1,1,1,1,1,1,1,3,3,3,3,0,1,3,3,1,3,1,1,3,1,2,3,1,1,1,1,1,0,1,4,1,2,1,1,
+  1,1,0,3,2,1,2,1,1,4,0,3,6,1,2,1,2,1,2,3,1,3,0,1,2,1,2,2,1,1,1,1,1,1,1,
+  1,1,1,1,1,3,1,3,3,0,3,2,1,2,1,1,1,2,1,2,0,1,3,1,1,1,2,5,2,2,2,2,2,2,1,
+  1,1,1,1,1,1,1,0,3,2,3,3,3,3,2,2,1,2,0,1,4,0,1,0,1,3,1,1,1,1,3,1,2,3,1,
+  1,1,1,1,1,1,1,1,1,1,1,1,1,1
+};
+
+static const unsigned char ag_ptt[] = {
+    0,  6,  7,  7,  9,  9, 12,  3,  3, 17, 17, 23, 25, 25, 23, 26, 27, 27,
+   27,  2, 28, 28, 33, 34, 36,  8,  8, 38, 38, 44, 44, 41, 42, 42, 42, 42,
+   42, 42, 42, 53, 53, 53, 55, 55, 55, 55, 62, 62, 55, 55, 57, 57, 15, 64,
+   64, 70, 70, 67, 69, 69, 73, 72, 72, 78, 78, 75, 79, 79, 80, 80, 80, 80,
+   85, 85, 77, 87, 87, 83, 76, 11, 92, 92, 91, 32,  5,  5, 93, 94, 94, 13,
+   10, 10, 97, 97, 98, 99, 99,  1, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35,
+   35, 35,112, 82,115, 39,120,120,118,122,122,121,123,123, 29,129,129,130,
+  130,126,128,128,134,134,131,133,133,133,133,133,133,136,137,139,141,143,
+  145,147,135,151,151,148,149,149, 40,155,157,159,158,158,160,160, 95,162,
+  162,163,163, 81, 65, 65, 96,164, 45,167,167,161,  4,  4,166,166,166,166,
+  166,166,166,166,166,166,166,166, 86
+};
+
+
+static void ag_ra(void)
+{
+}
+
+#define TOKEN_NAMES rfc822a_token_names
+const char *const rfc822a_token_names[185] = {
+  "message",
+  "message",
+  "CRLF",
+  "atom",
+  "word",
+  "linear_space",
+  "",
+  "",
+  "number",
+  "address",
+  "mailbox",
+  "group",
+  "addr_spec",
+  "local_part",
+  "'@'",
+  "domain",
+  "ATOM_CHAR",
+  "authentic",
+  "\"FROM\"",
+  "':'",
+  "'('",
+  "\"SENDER\"",
+  "SPACE",
+  "multiple_mailboxes",
+  "')'",
+  "",
+  "comment",
+  "comment_choice",
+  "ctext",
+  "quoted_pair",
+  "\"\\r\\n\"",
+  "",
+  "linear_white_space",
+  "date",
+  "day_numb",
+  "month",
+  "year",
+  "DIGIT",
+  "dates",
+  "orig_date",
+  "resent_date",
+  "date_time",
+  "day",
+  "','",
+  "",
+  "time",
+  "\"MON\"",
+  "\"TUE\"",
+  "\"WED\"",
+  "\"THU\"",
+  "\"FRI\"",
+  "\"SAT\"",
+  "\"SUN\"",
+  "delimeters",
+  "specials",
+  "destination",
+  "\"TO\"",
+  "addresses",
+  "\"RESENT-TO\"",
+  "\"CC\"",
+  "\"RECENT-CC\"",
+  "\"BCC\"",
+  "",
+  "\"RESENT-BCC\"",
+  "multiple_sub_domains",
+  "sub_domain",
+  "'.'",
+  "domain_literal",
+  "'['",
+  "literal_fill",
+  "",
+  "']'",
+  "dtext",
+  "domain_ref",
+  "",
+  "field",
+  "field_name",
+  "field_body",
+  "",
+  "fields",
+  "fields_makeup",
+  "source",
+  "optional_field",
+  "field_body_contents",
+  "LWSP_char",
+  "",
+  "CHAR",
+  "",
+  "",
+  "\"PHRASE\"",
+  "';'",
+  "hour",
+  "",
+  "",
+  "",
+  "route_addr",
+  "text",
+  "",
+  "",
+  "",
+  "\"JAN\"",
+  "\"FEB\"",
+  "\"MAR\"",
+  "\"APR\"",
+  "\"MAY\"",
+  "\"JUN\"",
+  "\"JUL\"",
+  "\"AUG\"",
+  "\"SEP\"",
+  "\"OCT\"",
+  "\"NOV\"",
+  "\"DEC\"",
+  "msg_id",
+  "'<'",
+  "'>'",
+  "optional_fields",
+  "\"MESSAGE-ID\"",
+  "\"DATE\"",
+  "originator",
+  "\"REPLY-TO\"",
+  "",
+  "phrase",
+  "",
+  "qtext",
+  "",
+  "'\\\\'",
+  "quoted_string",
+  "'\\\"'",
+  "QUOTED",
+  "",
+  "",
+  "received",
+  "\"RECEIVED\"",
+  "received_fields",
+  "",
+  "rec_date_time",
+  "from",
+  "from_domain",
+  "\"BY\"",
+  "by_domain",
+  "\"VIA\"",
+  "via_atom",
+  "\"WITH\"",
+  "with_atom",
+  "\"ID\"",
+  "rec_msg_id",
+  "\"FOR\"",
+  "for_addr_spec",
+  "resent",
+  "resent_authentic",
+  "\"RESENT-REPLY-TO\"",
+  "",
+  "\"RESENT-SENDER\"",
+  "\"RESENT-FROM\"",
+  "\"RESENT-DATE\"",
+  "return",
+  "\"RETURN-PATH\"",
+  "route",
+  "route_list",
+  "sub_route",
+  "",
+  "trace",
+  "",
+  "",
+  "text_char",
+  "",
+  "zone",
+  "",
+  "\"UT\"",
+  "\"GMT\"",
+  "\"EST\"",
+  "\"EDT\"",
+  "\"CST\"",
+  "\"CDT\"",
+  "\"MST\"",
+  "\"MDT\"",
+  "\"PST\"",
+  "\"PDT\"",
+  "ALPHA",
+  "",
+  "",
+  "",
+  "",
+  "",
+  "",
+
+};
+
+#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 = (rfc822a_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 == (rfc822a_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 {
+    (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 = (rfc822a_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 == (rfc822a_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 = (rfc822a_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 = (rfc822a_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 = (rfc822a_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;
+  }
+  (PCB).vs[(PCB).ssx] = *(PCB).pointer;
+  GET_CONTEXT;
+  (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;
+  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(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 = (rfc822a_token_type) ag_ptt[(PCB).ag_ap];
+  (PCB).btsx = 0, (PCB).drt = -1;
+  (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();
+  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;
+  (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).reduction_token = (rfc822a_token_type) ag_ptt[(PCB).ag_ap];
+  ag_ra();
+  while ((PCB).exit_flag == AG_RUNNING_CODE) {
+    unsigned ag_t1 = ag_sbe[(PCB).sn] + 1;
+    unsigned ag_t2 = ag_sbt[(PCB).sn+1] - 1;
+    do {
+      unsigned ag_tx = (ag_t1 + ag_t2)/2;
+      if (ag_tstt[ag_tx] < (unsigned char)(PCB).reduction_token) ag_t1 = ag_tx + 1;
+      else ag_t2 = ag_tx;
+    } while (ag_t1 < ag_t2);
+    (PCB).ag_ap = ag_pstt[ag_t1];
+    if ((ag_s_procs_scan[ag_astt[ag_t1]])() == 0) break;
+  }
+  return 0;
+}
+
+static int ag_action_8_proc(void) {
+  ag_undo();
+  (PCB).la_ptr =  (PCB).pointer;
+  (PCB).exit_flag = AG_SYNTAX_ERROR_CODE;
+  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 {
+    GET_CONTEXT;
+    (PCB).ss[(PCB).ssx] = (PCB).sn;
+  }
+  (PCB).la_ptr =  (PCB).pointer;
+  (PCB).reduction_token = (rfc822a_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 = (rfc822a_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;
+    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]])() == 0) break;
+  }
+  return (PCB).exit_flag == AG_RUNNING_CODE;
+}
+
+
+void init_rfc822a(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 rfc822a(void) {
+  init_rfc822a();
+  (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 = (rfc822a_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]])();
+  }
+}
+
+