view help2html/mhh6.c @ 9:60b08b68c750

Switch to static inline as an expedient build fix. Should probably set this up with working C99 inline but for the moment I don't have the energy.
author David A. Holland
date Mon, 30 May 2022 23:56:45 -0400
parents ec2b657edf13
children 5581ef01f993
line wrap: on
line source


/*
 * AnaGram, A System for Syntax Directed Programming
 * File generated by: Version 2.40-current, built Jun 13 2007
 *
 * 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 MHH6_H_1193795958
#include "mhh6.h"
#endif

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



mhh6_pcb_type mhh6_pcb;
#define PCB mhh6_pcb

#line 387 "/disk/disk0/home/dholland/projects/ag/src/help2html/mhh6.syn"
 /* ----- Embedded C --------------------------------------------*/


#include <stdio.h>
#include <string.h>
#include <malloc.h>
#include <assert.h>
#include <ctype.h>
#include <assert.h>
#include <err.h>
#include "uintarray.h"
#include "support.h"
#include "buffer.h"
#include "stringdict.h"
#include "must.h"

  int verbose = 0;

  int total1sttextline = 0;
  int total1sttextlineb = 0;
  int total1sttableline = 0;
  int total1stlist1line = 0;
  int total1stlist2line = 0;
  int total1stlisttabline = 0;
  int total1stcodeline = 0;

  int title_count =0;
  int title_line_count = 0;

  char *helpentStr;
  struct buffer title;
  struct buffer title1;
  struct buffer titleLine;
  struct buffer titleLine1;
  struct stringdict *titleDict;
  struct stringdict *titleDict1;             // upper case
  struct stringdict *titleLineDict;
  struct stringdict *titleLineDict1;         // upper case
  struct buffer topicFrag;
  struct buffer tabFrag;
  struct buffer blankFrag;
  struct buffer topicBody;
  struct stringdict *topicBodyDict;
  struct uintarray titleToTitleLine;
  struct intstack paragType;

  enum paragTypes {Tnone=0, Ttext=1, Ttable=2, Tlist1=3, Tlist2=4, 
        Tlisttab=5, Tcode=6};

  char *charToEntity(const char *instring);
  void putTitle(void);
  void appendTitle(void);
  void saveTitleLine(void);
  void appendEnd(int c);
  void removeFinalNewline(void);
  void saveTopicBody(void);
  void printDict(const struct stringdict *dictionary);
  void writeSortedHtml(FILE *output);
  void writeFullTopics(FILE *output, const struct stringdict *dictionary,
		       const struct stringdict *dictionary1,
		       const struct stringdict *dictionaryb);
  void writeTitles(FILE *output, const struct stringdict *dictionary,
                   const struct stringdict *dictionary1); 
  int processLinkString(FILE *filein, FILE *fileout);


  // replace  &, <, > in S with entities 
  char *charToEntity(const char *s) {
    char *ret;
    int i, j, len=0;

    for (i=0; s[i]; i++) {
      if (s[i] == '&') len += 5; /* &amp; */
      else if (s[i] == '<') len += 4; /* &lt; */
      else if (s[i] == '>') len += 4; /* &gt; */
      else len++;
    }

    ret = malloc(len+1);
    if (!ret) {
      errx(1, "Out of memory");
    }

    for (i=j=0; s[i]; i++) {
      if (s[i] == '&')       { strcpy(ret+j, "&amp;"); j += 5; }
      else if (s[i] == '<' ) { strcpy(ret+j, "&lt;"); j += 4; }
      else if (s[i] == '>' ) { strcpy(ret+j, "&gt;"); j += 4; }
      else ret[j++] = s[i];
    }
    ret[j] = 0;

    return ret;
  }

  // Save title both ways, make map entry for title<--->title line
  void saveTitle(void) {
    if (stringdict_exists(titleDict, title.text)) {
      fprintf( stderr, "Warning: Repeated title %s\n", title.text );
    }
#if 0
    else if (!strcmp(title.text, "Secret of Life")) {
      // Do not save "Secret of Life" title
      return;
    }
#endif
    else {
      // Save title in dictionary
      unsigned titleIndex = stringdict_intern(titleDict, title.text);

      // Save title in upper case dictionary
      stringdict_intern(titleDict1, title1.text);

      // count() should give next index
      unsigned titleLineIndex = stringdict_count(titleLineDict);

      // use an array for this (the keys are array indexes anyway)
      if (titleIndex >= uintarray_num(&titleToTitleLine)) {
        unsigned x, old = uintarray_num(&titleToTitleLine);
        uintarray_setsize(&titleToTitleLine, titleIndex+1);
        for (x=old; x<titleIndex; x++) {
          uintarray_set(&titleToTitleLine, x, (unsigned) -1);
        }
      }
      // Store indices in map
      uintarray_set(&titleToTitleLine, titleIndex, titleLineIndex);
    } 
  }


  void putTitle(void) {
    // Save title itself in both reg. and upper case title dicts
    saveTitle();         
    buffer_append(&titleLine, title.text);
    buffer_append(&titleLine1, title1.text);
  }


  void appendTitle() {
    // Save title itself in both reg. and upper case title dicts
    saveTitle();
    buffer_append(&titleLine, ", ");
    buffer_append(&titleLine1, ", ");
    buffer_append(&titleLine, title.text);
    buffer_append(&titleLine1, title1.text);
  }


  void saveTitleLine() {
#if 0
    static int foundSoL=0;
    if (stringdict_count(titleLineDict)==0 && 
	strcmp(titleLine.text, "Secret of Life")!=0 && foundSoL==0) {
      fprintf(stderr, "Warning: Secret of Life does not lead file!\n");
    }
#endif

#if 0
    if (!strcmp(titleLine.text, "Secret of Life")) {
      //  Don't save title line in dicts.
      // Should be at beginning of help file
      assert(stringdict_count(titleLineDict)==0);
      foundSoL = 1;
      if (verbose) {
        printf( "\n  Found Secret of Life!\n\n" );
      }
    }
    else
#endif
    if ( stringdict_exists(titleLineDict, titleLine.text) ) {
      fprintf( stderr, "Warning: Repeated title line %s\n",
	       titleLine.text );
    }
    else {
      // Save title line in dictionary
      stringdict_intern(titleLineDict, titleLine.text);
      // Save title line in upper case dictionary
      stringdict_intern(titleLineDict1, titleLine1.text);
    }
    buffer_clear(&titleLine);
    buffer_clear(&titleLine1);
  }


  // Append the latter part of the line
  void appendEnd(int c) {
    buffer_add(&topicBody, c);
    buffer_append(&topicBody, topicFrag.text);
    buffer_append(&topicBody,  "\n" );
    buffer_clear(&topicFrag);
  }

  // Append a cell to the table row
  void appendTableCell(int c) {
    // Could insert <pre> </pre>  or <code> </code> tags here for cell
    buffer_append(&topicBody, "<code> " );
    buffer_add(&topicBody, c);
    buffer_append(&topicBody, topicFrag.text);
    buffer_append(&topicBody, "</code>" );
    //buffer_append(&topicBody, "\n" );
    buffer_clear(&topicFrag);
  }

   void removeFinalNewline(void) {
     int x = topicBody.len;
     assert(topicBody.text[x-2]=='\n' && topicBody.text[x-1]=='\n');
     topicBody.text[x-1] = 0; 
   }

   void saveTopicBody(void) {
#if 0
     // do not save Secret of Life topic body
     if (stringdict_count(titleLineDict) != 0) {
#endif
       // save topic body
       stringdict_intern(topicBodyDict, topicBody.text);
#if 0
     }
#endif
     buffer_clear(&topicBody);
   }

/*
  void startTable(void) {
    // If we don't currently have table, start a new one
    if (paragType.top() != Ttable) {
      // Start table
      paragType.push( Ttable );
    }
  }
*/

  void finishList(int listtype){
    //printf( "\nfinishList() - top type = %d, listtype = %d, "
    //        "stack size = %d\n"
    //        "  titleLineDict size = %d\n",
    //        paragType.top(), listtype, paragType.size(), 
    //        titleLineDict.size() );
    assert(intstack_top(&paragType) == listtype);
    intstack_pop(&paragType);
    buffer_append(&topicBody, "\n</ul>");
  }

  void printDict(const struct stringdict *dictionary) {
    unsigned i;
    for (i=0; i<stringdict_count(dictionary); i++) {
      printf("%4d: %s\n", i, stringdict_getbynum(dictionary, i));
    }
  }

  char *SqueezeWS(const char *Input) {
    /* return a (strdup()-like) copy of Input, with whitespace squeezed out */
    char *copy;
    int cnt, outcnt;

    copy = must_malloc(strlen(Input)+1);

    for (cnt=0, outcnt=0; Input[cnt]; cnt++) {
      unsigned char ch = Input[cnt];
      if (!isspace(ch)) {
	copy[outcnt]=ch;
	outcnt++;
      }
    }
    copy[outcnt]=0;

    return copy;
  }

  void writeFullTopics(FILE *output,
		       const struct stringdict *dictionary, /* title lines */
		       const struct stringdict *dictionary1, /* UC titlelines*/
		       const struct stringdict *dictionaryb) /* topic bodies */
  {
    unsigned i;

#if 0
    /* Write "Secret of Life" topic at beginning of topics */
    //fprintf(output, "Secret of Life>\n\n");
    //fprintf(output, "No help message for this topic.\n##\n");
#endif

    assert( stringdict_count(dictionary) == stringdict_count(dictionary1) );
    struct permutation *perm = mySort(dictionary1); // Sort  dictionary1


    /* Write out topics in a definition list <dl> */
    fprintf( output, "\n\n<dl>\n\n" );

    // write dictionary, sorted according to dict1
    for (i = 0; i < stringdict_count(dictionary); i++) {  
      //fprintf(output, "<dt><b><a name=\"%04d\">%s</a></b></dt>\n"
      //                "<dd>%s\n</dd><br/>\n\n",
      //  perm->v[i], 
      //  stringdict_getbynum(dictionary, perm->v[i]),
      //  stringdict_getbynum(dictionaryb, perm->v[i])  );

      char *anchorname=SqueezeWS(stringdict_getbynum(dictionary, perm->v[i]));
      fprintf(output, "<dt><b><a name=\"%s\">%s</a></b></dt>\n"
	              "<dd>%s\n</dd>\n\n",
	      anchorname, 
	      stringdict_getbynum(dictionary, perm->v[i]),
	      stringdict_getbynum(dictionaryb, perm->v[i])  );
      free(anchorname);
    }
    fprintf( output, "\n\n</dl>\n\n" );
    permutation_destroy(perm);
  }

  void writeTitles(FILE *output,
		   const struct stringdict *dictionary, /* titles */
		   const struct stringdict *dictionary1) /* uppercase titles */
  {
    assert( stringdict_count(dictionary) == stringdict_count(dictionary1) );
    struct permutation *perm = mySort(dictionary1);   // Sort  dictionary1

    /* Write 2-column table of titles */
    /*
      // n_t is true title count w/o Secret of Life
      int n_t = stringdict_count(dictionary);
      // we better have some titles
      assert( n_t >= 2 );
      // n_t1 is #titles in 1st column
      int n_t1 = n_t%2 ? n_t/2 +1 : n_t/2;
      // n_t2 is #titles in 2nd column
      int n_t2 = n_t%2;
      int i;         	
      fprintf( output, "\n\n<table width=\"100%%\" "
      		       "style=\"margin-left: auto ; margin-right: auto\" \n"
                       "  cellpadding=\"15\" cellspacing=\"5\" >\n"
		       "<tr align=\"left\">\n"
		       "<td valign=\"top\" style=\"white-space: nowrap\">"
		       "\n\n\n");

     // Write out dictionary sorted acc. to dictionary1 
     // write out the first half, sorted
     for (i = 0; i < n_t1; i++) {
       fprintf(output, " \xA9%s\xAA\n<br/>",
               stringdict_getbynum(dictionary, perm->v[i]));
     }

     fprintf(output, "</td>\n\n");
     fprintf(output, "<td valign=\"top\" style=\"white-space: nowrap\">\n\n");

     // write out the last half, sorted
     for ( i = n_t1; i < n_t; i++) {
       fprintf(output, " \xA9%s\xAA\n<br/>",
               stringdict_getbynum(dictionary, perm->v[i]));
     }

     fprintf(output, "</td>\n</tr>\n</table>\n\n<hr><br/><br/>\n\n" );
    */

    /* Write 1-column list of titles */
     
    // n_t is true title count w/o Secret of Life
    unsigned n_t = stringdict_count(dictionary);
    // we better have some titles
    assert( n_t >= 2 );                        
    unsigned i;         	

    fprintf(output, "<h2>Help Topic Index</h2>\n\n" );
    // Write out the index, sorted acc. to dictionary1 
    for (i = 0; i < n_t; i++) {
      fprintf(output, "\xA9%s\xAA\n<br/>",
	      stringdict_getbynum(dictionary, perm->v[i]));
    }
  }

  void writeSortedHtml( FILE *output ) {
    /* Leading HTML */

#ifdef XML_OUTPUT
    fprintf(output, "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n"
	    "<?xml-stylesheet type=\"text/xsl\" href=\"../ag_web.xml\"?>\n"
	    "\n"
	    "<body rootdir=\"..\" navname=\"Documentation: AnaGram Help\">\n");
 
#else
    fprintf(output, "<html>\n<head>\n");
    fprintf(output, "<title>AnaGram Help Topics - HTML version</title>\n");
    fprintf(output, "</head>\n\n\n");
    fprintf(output, "<body bgcolor=\"#ffffff\" text=\"#000000\"");
    fprintf(output, " link=\"#0033CC\" vlink=\"#CC0033\" alink=\"#CC0099\">");
    fprintf(output, "\n\n\n");
#endif

    /* Write page title */
#ifdef XML_OUTPUT
    fprintf(output, "<h1>AnaGram Help</h1>\n\n");
#else
    fprintf(output, "<hr><h2>AnaGram Help Topics - HTML Version</h2><hr>\n\n");
#endif
    /* Write 2-column table of titles */
    writeTitles( output, titleDict, titleDict1 );

    /* Write full topics in single- column table */
    //fprintf( output, "\n\n<table width=\"100%%\">\n<tr><td>\n<p>\n\n");
    //writeFullTopics( output, titleLineDict, titleLineDict1, topicBodyDict );
    //fprintf( output, "</td></tr>\n</table>\n" );

    /* Write full topics directly to the output page */
    writeFullTopics( output, titleLineDict, titleLineDict1, topicBodyDict );

#ifdef XML_OUTPUT
    fprintf(output,"\n</body>\n");
#else 
    /* Ending HTML */
    fprintf( output, "\n<p><br/><address><a "
	     "NAME=\"copyright\">AnaGram Help Topics, HTML version.</a>\n"
	     "<br> Copyright &copy; Parsifal Software, 2001.<br>\n"
	     "All Rights Reserved.</address>" 
	     "\n\n</body>\n</html>\n\n" );
#endif
  }

  int processLinkString( FILE *filein, FILE *fileout ) {
    struct buffer linkString;                   // lower case
    struct buffer linkString1;                  // upper case version
    unsigned index;
    int c;
    int wspaceFlag =0;

    buffer_init(&linkString);
    buffer_init(&linkString1);

    while ( (c=fgetc(filein)) != EOF ) {
    
      if ( c != 0xAA) {                            // test for end of link char
	if ( c == 0x20 || c == 0x0D || c == 0x0A ) {
	  // don't append these chars
	  wspaceFlag = 1;  
	}
	else {
	  if (wspaceFlag) {
            // Replace space, cr, lf with single space
	    buffer_add(&linkString, 0x20);
	    buffer_add(&linkString1, toupper(0x20));         
	  }
	  buffer_add(&linkString, c);
	  buffer_add(&linkString1, toupper(c));
	  wspaceFlag = 0;
	}
      }
      else {
	// end of link - look up using upper case string
	if (!stringdict_exists(titleDict1, linkString1.text)) {
	  // try match w/o final S
	  if ( linkString1.text[linkString1.len - 1] == 'S' ) {
	    linkString1.text[linkString1.len - 1] = 0;
	    if (stringdict_exists(titleDict1, linkString1.text)) {
	      goto matched;      // Eccch - a goto!
	    }
	  }

	  fprintf(stderr, "Can't find this link in titleDict1: %s\n",
		 linkString1.text);
	  return 21; 
	}

        /* find corresp. index in title line direc. */      
    matched:

	index = stringdict_findbyname(titleDict1, linkString1.text);

	unsigned ilink = uintarray_get(&titleToTitleLine, index);
	assert(ilink != (unsigned) -1);

	// Write out string, linked to title line
	char *linkname=SqueezeWS(stringdict_getbynum(titleLineDict, ilink));
	//fprintf(fileout, "<a href=\"#%04d\">%s</a>", ilink, linkString.text);
	fprintf( fileout, "<a href=\"#%s\">%s</a>", linkname, linkString.text);
	free(linkname);

	buffer_cleanup(&linkString);
	buffer_cleanup(&linkString1);

	return 0;            // normal return - have found  and written link 
      }
    }
    // Error - unexpected end of file
    fprintf(stderr, "Error: EOF detected while searching for end of link.\n");
    fprintf(stderr, "  Current link string is: %s\n", linkString.text );
    return 23;
  }

  static void init(void) {
    buffer_init(&title);
    buffer_init(&title1);
    buffer_init(&titleLine);
    buffer_init(&titleLine1);
    titleDict = stringdict_create();
    titleDict1 = stringdict_create();
    titleLineDict = stringdict_create();
    titleLineDict1 = stringdict_create();
    topicBodyDict = stringdict_create();
    buffer_init(&topicFrag);
    buffer_init(&tabFrag);
    buffer_init(&blankFrag);
    buffer_init(&topicBody);
    intstack_init(&paragType);
    uintarray_init(&titleToTitleLine);
  }

/* -- Main Program -- */

int main(int argc, char *argv[]) {

  FILE *input;

  long fileLength;
  size_t stringLength;
  char *helpsrcString;

  init();

  if (verbose) {
    printf( "\n  This program reads a help.src-type file, "
	    "replaces &, <, > with entities,\n"
	    "sorts in a case-insensitive manner and writes "
	    "to output file as HTML\n"
	    "with a preceding list of the help topics. \n\n" );
  }

  /* Check for enough arguments */
  if (argc != 3) {
    fprintf(stderr, "Usage: mhh6 helpdata.src help.html\n");
    return 1;
  }

  /* Open input file */
  input = fopen(argv[1],"r");
  if (input == NULL) {
    fprintf(stderr, "Cannot open %s\n", argv[1]);
    return 2;
  }

  /* find out how big the input file is */
  if (fseek(input, SEEK_SET, SEEK_END)) {
    fprintf(stderr, "Strange problems with %s\n", argv[1]);
    return 3;
  }
  fileLength = ftell(input);
  if (fileLength < 0 ) {    // -1L is error return
    fprintf(stderr, "Error getting file length (%ld) of %s\n",
	    fileLength, argv[1]);
    return 4;
  }

  /* fseek to beginning of file */
  if (fseek(input, 0, SEEK_SET)) {
    fprintf(stderr, "Strange problems with %s\n", argv[1]);
    return 5;
  }

  /* Allocate storage for input string */
  helpsrcString = must_malloc(fileLength + 1);

  /* read file */
  stringLength = fread(helpsrcString, 1, (unsigned)fileLength, input);
  if (stringLength == 0) {
    fprintf(stderr, "Unable to read %s\n", argv[1]);
    free(helpsrcString);
    fclose(input);
    return 7;
  }
  // Terminate string with null
  helpsrcString[stringLength] = 0;

  /* first, replace < > & with entities */
  helpentStr = charToEntity( helpsrcString ); 

  /* no more need for input string or file */
  free(helpsrcString);
  fclose(input);

  /* initialize stack of parag types */
  intstack_push(&paragType, Tnone);
 
  /* call parser */
  PCB.pointer = (unsigned char *)(const char *)helpentStr;
  mhh6();

  /* Print file statistics */
  if (verbose) {
    printf("No. of title lines in line dict.= %d\n",
	   stringdict_count(titleLineDict) );
    printDict(titleLineDict);              // print title lines
    printf( "\n\n" );

    printf( "title count = %d, includes Secret of Life \n\n", title_count );
    printf( "title line count = %d, includes Secret of Life \n\n", 
	    title_line_count );
    printf( "total1sttextline = %d, \n", total1sttextline );
    printf( "total1sttextlineb = %d \n", total1sttextlineb  );
    printf( "total1sttableline = %d \n", total1sttableline  );
    printf( "total1stlist1line = %d \n", total1stlist1line  );
    printf( "total1stlist2line = %d \n", total1stlist2line  );
    printf( "total1stlisttabline = %d \n", total1stlisttabline  );
    printf( "total1stcodeline = %d \n", total1stcodeline  );
  }

  /* check for error */
  if (verbose) {
    printf( "PCB.exit_flag = %d (%d for success)\n", PCB.exit_flag,
	    AG_SUCCESS_CODE);
  }
  if (PCB.exit_flag != AG_SUCCESS_CODE) {
    fprintf(stderr, "File %s: error at line %d, column %d\n",
	    argv[1],
	    PCB.line,
	    PCB.column);
    return 8;
  }

  // Write sorted title lines & topics as HTML to intermediate file
  FILE *intermed;
  const char *filename = "intermed.html";
  /* Open intermediate file */
  intermed = fopen(filename ,"w+");  // create intermediate text file 
  if (intermed == NULL) {
    fprintf(stderr, "Cannot open %s\n", filename);
    return 9;
  }
  if (verbose) {
    printf( "Writing sorted title lines & topic bodies to "
	    "intermediate file in HTML format...\n");
  }
  writeSortedHtml(intermed); 
  rewind(intermed);

  /* Create output HTML file, inserting links */
  FILE *output;
  /* Open output file */
  output = fopen(argv[2] ,"w");   
  if (output == NULL) {
    fprintf(stderr, "Cannot open %s\n", argv[2]);
    return 10;
  }

  if (verbose) {
    printf( "Writing output file with HTML links...\n");
  }

  int c = 0;
  int ctest = 0;
  
  while ( (c=fgetc(intermed)) != EOF ){

    if ( c == 0xA9 ) {            // begins link string
      //  printf( "\n Found beginning of link" );
      int itest = processLinkString(intermed, output);
      if (itest !=0) return itest;    // error return
    }
    else {
      ctest = fputc( c, output );    // write out current character
      if (ctest == EOF) return 11;
    }
  }  

  fclose(intermed);
  fclose(output);


  /* done */
  if (verbose) {
    printf( "All done.\n" );
  }
  return 0;                          // normal return 

}  /* -- End of main() function -- */

#line 719 "mhh6.c"

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

static void ag_rp_1(void) {
#line 71 "/disk/disk0/home/dholland/projects/ag/src/help2html/mhh6.syn"
		title_line_count++; 
                //  buffer_append(&titleLine, "</h3>\n<p>"); 
                saveTitleLine();
         
#line 734 "mhh6.c"
}

#define ag_rp_2() (title_count++, putTitle())

#define ag_rp_3() (title_count++, appendTitle())

#define ag_rp_4(c) (buffer_start(&title, c), buffer_start(&title1, toupper(c)))

#define ag_rp_5(c) (buffer_add(&title, c), buffer_add(&title1, toupper(c)))

static void ag_rp_6(void) {
#line 92 "/disk/disk0/home/dholland/projects/ag/src/help2html/mhh6.syn"
 saveTopicBody(); 
#line 748 "mhh6.c"
}

#define ag_rp_7() (buffer_append(&topicBody,"\n"))

#define ag_rp_8() (buffer_append(&topicBody,"\n"))

#define ag_rp_9() (finishList(Tlist1))

#define ag_rp_10() (finishList(Tlist2))

#define ag_rp_11() (finishList(Tlisttab))

#define ag_rp_12() (finishList(Tlist1))

#define ag_rp_13() (finishList(Tlisttab))

#define ag_rp_14() (buffer_append(&topicBody, "<p>"))

#define ag_rp_15() (buffer_append(&topicBody, "</p>"))

#define ag_rp_16() (buffer_append(&topicBody, "\n</table>\n\n"))

#define ag_rp_17() (buffer_append(&topicBody, "</li>\n"))

#define ag_rp_18() (buffer_append(&topicBody, "</li>\n"))

#define ag_rp_19() (buffer_append(&topicBody, "</li>\n"))

#define ag_rp_20() (buffer_append(&topicBody, "</li>\n"))

#define ag_rp_21() (buffer_append(&topicBody, "</li>\n"))

#define ag_rp_22() (buffer_append(&topicBody, "</li>\n"))

#define ag_rp_23() (buffer_append(&topicBody, "\n</pre>"))

static void ag_rp_24(int c) {
#line 172 "/disk/disk0/home/dholland/projects/ag/src/help2html/mhh6.syn"
		total1sttextline++;
		appendEnd(c);
	 
#line 790 "mhh6.c"
}

static void ag_rp_25(int c) {
#line 176 "/disk/disk0/home/dholland/projects/ag/src/help2html/mhh6.syn"
		total1sttextlineb++;
                buffer_add(&topicBody, 0x20);
		appendEnd(c);
	 
#line 799 "mhh6.c"
}

#define ag_rp_26(c) (appendEnd(c))

#define ag_rp_27() (buffer_append(&topicBody, "</td></tr>"))

static void ag_rp_28(int c) {
#line 211 "/disk/disk0/home/dholland/projects/ag/src/help2html/mhh6.syn"
 
		total1sttableline++;
                buffer_append(&topicBody,
  "\n\n<table cellpadding=\"7\" cellspacing=\"2\" >\n<tr><td>  ");
                appendTableCell(c);
		buffer_clear(&tabFrag);
		buffer_clear(&blankFrag);
	
#line 816 "mhh6.c"
}

static void ag_rp_29(int c) {
#line 222 "/disk/disk0/home/dholland/projects/ag/src/help2html/mhh6.syn"
		buffer_append(&topicBody, "</td>\n<td>  ");
		appendTableCell(c); 
		buffer_clear(&tabFrag);
		buffer_clear(&blankFrag);
	 
#line 826 "mhh6.c"
}

#define ag_rp_30() (buffer_append(&topicBody, "</td></tr>"))

static void ag_rp_31(int c) {
#line 234 "/disk/disk0/home/dholland/projects/ag/src/help2html/mhh6.syn"
		buffer_append(&topicBody, "\n\n<tr><td>  ");
		appendTableCell(c);
		buffer_clear(&tabFrag);
		buffer_clear(&blankFrag);
	 
#line 838 "mhh6.c"
}

static void ag_rp_32(int c) {
#line 242 "/disk/disk0/home/dholland/projects/ag/src/help2html/mhh6.syn"
		buffer_append(&topicBody, "</td>\n<td>  ");
		appendTableCell(c);
		buffer_clear(&tabFrag);
		buffer_clear(&blankFrag);
	 
#line 848 "mhh6.c"
}

static void ag_rp_33(int c) {
#line 252 "/disk/disk0/home/dholland/projects/ag/src/help2html/mhh6.syn"
		total1stlist1line++;
	        if (intstack_top(&paragType) != Tlist1) {
		  intstack_push(&paragType, Tlist1);
		  buffer_append(&topicBody, "\n<ul>");
		}
        	buffer_append(&topicBody, "\n<li>");
		buffer_add(&topicBody, 0x20);
		appendEnd(c);
	 
#line 862 "mhh6.c"
}

#define ag_rp_34(c) (appendEnd(c))

static void ag_rp_35(int c) {
#line 268 "/disk/disk0/home/dholland/projects/ag/src/help2html/mhh6.syn"
		total1stlist2line++;
		if (intstack_top(&paragType) != Tlist2) {
		  intstack_push(&paragType, Tlist2);
		  buffer_append(&topicBody, "\n<ul>");
		}
 		buffer_append(&topicBody, "\n<li>");
		buffer_append(&topicBody, "  ");
		appendEnd(c);
	 
#line 878 "mhh6.c"
}

#define ag_rp_36(c) (appendEnd(c))

static void ag_rp_37(int t, int c) {
#line 284 "/disk/disk0/home/dholland/projects/ag/src/help2html/mhh6.syn"
		total1stlisttabline++;
  		if (intstack_top(&paragType) != Tlisttab) {
		  intstack_push(&paragType, Tlisttab);
		  buffer_append(&topicBody, "\n<ul>");
		}
		buffer_append(&topicBody, "\n<li>");
		buffer_add(&topicBody, t);
		appendEnd(c);
	 
#line 894 "mhh6.c"
}

#define ag_rp_38(c) (appendEnd(c))

static void ag_rp_39(int c) {
#line 301 "/disk/disk0/home/dholland/projects/ag/src/help2html/mhh6.syn"
		total1stcodeline++;
		buffer_append(&topicBody, "\n<pre>  ");
		appendEnd(c);
	 
#line 905 "mhh6.c"
}

static void ag_rp_40(int c) {
#line 306 "/disk/disk0/home/dholland/projects/ag/src/help2html/mhh6.syn"
		total1stcodeline++;
		buffer_append(&topicBody, "\n<pre>   ");
		appendEnd(c);
	 
#line 914 "mhh6.c"
}

static void ag_rp_41(int c) {
#line 311 "/disk/disk0/home/dholland/projects/ag/src/help2html/mhh6.syn"
		total1stcodeline++;
		buffer_append(&topicBody, "\n<pre>    ");
		appendEnd(c); 
	 
#line 923 "mhh6.c"
}

static void ag_rp_42(int c) {
#line 316 "/disk/disk0/home/dholland/projects/ag/src/help2html/mhh6.syn"
		total1stcodeline++;
		buffer_append(&topicBody, "\n<pre>     ");
		appendEnd(c); 
	 
#line 932 "mhh6.c"
}

static void ag_rp_43(int c) {
#line 320 "/disk/disk0/home/dholland/projects/ag/src/help2html/mhh6.syn"
 
		total1stcodeline++;
		buffer_append(&topicBody, "\n<pre>      ");
		appendEnd(c);
	 
#line 942 "mhh6.c"
}

static void ag_rp_44(int c) {
#line 326 "/disk/disk0/home/dholland/projects/ag/src/help2html/mhh6.syn"
		total1stcodeline++;
		buffer_append(&topicBody, "\n<pre>        ");
		appendEnd(c);
	 
#line 951 "mhh6.c"
}

static void ag_rp_45(int c) {
#line 330 "/disk/disk0/home/dholland/projects/ag/src/help2html/mhh6.syn"
 
		total1stcodeline++;
		buffer_append(&topicBody, "\n<pre>          ");
		appendEnd(c);
	 
#line 961 "mhh6.c"
}

static void ag_rp_46(int c) {
#line 339 "/disk/disk0/home/dholland/projects/ag/src/help2html/mhh6.syn"
		buffer_append(&topicBody, "  ");
		appendEnd(c);
	 
#line 969 "mhh6.c"
}

static void ag_rp_47(int c) {
#line 343 "/disk/disk0/home/dholland/projects/ag/src/help2html/mhh6.syn"
		buffer_append(&topicBody, "   ");
		appendEnd(c);
	 
#line 977 "mhh6.c"
}

static void ag_rp_48(int c) {
#line 347 "/disk/disk0/home/dholland/projects/ag/src/help2html/mhh6.syn"
		buffer_append(&topicBody, "    ");
		appendEnd(c);
	 
#line 985 "mhh6.c"
}

static void ag_rp_49(int c) {
#line 351 "/disk/disk0/home/dholland/projects/ag/src/help2html/mhh6.syn"
		buffer_append(&topicBody, "     ");
		appendEnd(c);
	 
#line 993 "mhh6.c"
}

static void ag_rp_50(int c) {
#line 355 "/disk/disk0/home/dholland/projects/ag/src/help2html/mhh6.syn"
		buffer_append(&topicBody, "      ");
		appendEnd(c);
	 
#line 1001 "mhh6.c"
}

static void ag_rp_51(int c) {
#line 359 "/disk/disk0/home/dholland/projects/ag/src/help2html/mhh6.syn"
		buffer_append(&topicBody, "        ");
		appendEnd(c);
	 
#line 1009 "mhh6.c"
}

static void ag_rp_52(int c) {
#line 363 "/disk/disk0/home/dholland/projects/ag/src/help2html/mhh6.syn"
		buffer_append(&topicBody, "          ");
		appendEnd(c);
	 
#line 1017 "mhh6.c"
}

#define ag_rp_53(c) (buffer_start(&topicFrag, c))

#define ag_rp_54(c) (buffer_add(&topicFrag, c))

#define ag_rp_55(c) (buffer_start(&topicFrag, c))

#define ag_rp_56(c) (buffer_add(&topicFrag, c))

#define ag_rp_57(t) (buffer_start(&tabFrag, t))

#define ag_rp_58(t) (buffer_add(&tabFrag, t))

#define ag_rp_59() (buffer_start(&blankFrag, 0x20))

#define ag_rp_60() (buffer_add(&blankFrag, 0x20))


#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,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,
    0,  0,  1,  2,  3,  4,  5,  0,  0,  0,  6,  7,  8,  0,  0,  9, 10, 11,
    0,  0,  0, 12, 13,  0,  0,  0,  0, 14,  0,  0,  0,  0, 15, 16,  0,  0,
    0,  0,  0,  0,  0,  0,  0,  0,  0, 17, 18, 19,  0,  0,  0,  0, 20,  0,
    0,  0,  0,  0,  0,  0,  0,  0, 21, 22, 23,  0,  0,  0,  0, 24, 25, 26,
   27,  0,  0,  0,  0, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40,
   41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58,
   59, 60
};

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

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

static const unsigned char ag_key_ch[] = {
    0, 32,255, 32,255, 32,255, 32,255, 32,255, 32,255, 32,255, 32,255, 10,
   13, 32, 35,255, 10, 13, 35,255, 32,255, 32,255, 32,255, 32,255, 32,255,
   32,255, 32,255, 32,255, 32,255
};

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

static const unsigned char ag_key_parm[] = {
    0, 84,  0, 83,  0,  0,  0, 82,  0, 81,  0, 80,  0, 79,  0, 78,  0, 25,
   26,  0, 24,  0, 25, 26, 24,  0, 84,  0, 83,  0,  0,  0, 82,  0, 81,  0,
   80,  0, 79,  0, 78,  0,  0,  0
};

static const unsigned char ag_key_jmp[] = {
    0,  7,  0,  1,  0,  3,  0,  5,  0,  7,  0,  9,  0, 11,  0, 13,  0,  0,
    3, 15,  9,  0, 11, 14, 18,  0, 20,  0, 26,  0, 28,  0, 30,  0, 32,  0,
   34,  0, 36,  0, 38,  0, 40,  0
};

static const unsigned char ag_key_index[] = {
    0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,
    0, 17, 22, 22, 22,  0,  0, 17,  0,  0,  0,  0,  0,  0,  0, 17, 22, 22,
   22,  0, 17, 22,  0,  0, 22, 22, 42,  0,  0,  0,  0,  0,  0,  0, 17,  0,
    0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0, 22, 22,  0, 22,
    0,  0,  0, 17, 17,  0, 22,  0,  0,  0,  0,  0,  0, 22,  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, 22,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,
    0,  0,  0,  0,  0,  0,  0,  0
};

static const unsigned char ag_key_ends[] = {
35,35,0, 10,35,35,0, 32,0, 35,0, 35,35,0, 10,35,35,0, 35,0, 
32,0, 
};

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

static const unsigned char ag_tcv[] = {
    8, 22, 22, 22, 22, 22, 22, 76, 22, 77,  2, 22, 22,  3, 22, 22, 22, 22,
   22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22,  5, 22, 22, 22,
   22, 22, 22, 22, 22, 22, 22, 22, 21, 22, 22, 22, 22, 22, 22, 22, 22, 22,
   22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22,
   22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22,
   22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22,
   22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22,
   22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22,
   22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22,
   22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22,
   22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22,
   22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22,
   22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22,
   22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22,
   22, 22, 22, 22
};

#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 = (mhh6_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 = (mhh6_token_type) ag_key_parm[ag_k];
          return;
        }
      } while (CONVERT_CASE(*(PCB).la_ptr++) == ag_ch);
    }
    /* FALLTHROUGH */
    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 = (mhh6_token_type) ag_key_pt[ag_k1+1];
      break;
    }
    case ag_set_key:
      ag_save = (int) ((PCB).la_ptr - (PCB).pointer);
      (PCB).token_number = (mhh6_token_type) ag_key_parm[ag_k];
      /* FALLTHROUGH */
    case ag_jmp_key:
      ag_k = ag_key_jmp[ag_k];
      break;
    case ag_accept_key:
      (PCB).token_number = (mhh6_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 = (mhh6_token_type) ag_key_pt[ag_k1+1];
      return;
    }
    }
    ag_ch = CONVERT_CASE(*(PCB).la_ptr++);
    ag_p = &ag_key_ch[ag_k];
    if (ag_ch <= 255) while (*ag_p < ag_ch) ag_p++;
    if (ag_ch > 255 || *ag_p != ag_ch) {
      (PCB).la_ptr = (PCB).pointer + ag_save;
      return;
    }
    ag_k = (int) (ag_p - ag_key_ch);
  }
}


#ifndef AG_NEWLINE
#define AG_NEWLINE 10
#endif

#ifndef AG_RETURN
#define AG_RETURN 13
#endif

#ifndef AG_FORMFEED
#define AG_FORMFEED 12
#endif

#ifndef AG_TABCHAR
#define AG_TABCHAR 9
#endif

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


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

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


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

};


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


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

};


static const unsigned short ag_sbt[] = {
     0,  10,  12,  16,  21,  32,  36,  38,  42,  48,  54,  59,  61,  70,
    72,  74,  77,  87,  91,  96, 114, 121, 126, 131, 140, 143, 163, 166,
   169, 172, 175, 178, 181, 184, 193, 204, 217, 228, 231, 251, 262, 269,
   275, 280, 291, 328, 334, 340, 346, 351, 355, 364, 373, 377, 386, 395,
   404, 413, 422, 431, 440, 443, 446, 449, 452, 455, 458, 461, 470, 474,
   481, 483, 487, 490, 493, 502, 506, 523, 525, 529, 531, 534, 541, 548,
   554, 557, 568, 572, 576, 580, 584, 588, 592, 596, 600, 604, 608, 612,
   616, 625, 634, 643, 652, 661, 670, 679, 683, 692, 701, 705, 715, 718,
   721, 728, 732, 741, 745, 749, 753, 757, 761, 765, 769, 773, 777, 781,
   786, 796, 806, 809, 812, 816, 826, 835, 839
};


static const unsigned short ag_sbe[] = {
     3,  11,  14,  17,  26,  35,  37,  40,  44,  53,  56,  60,  66,  71,
    73,  75,  80,  90,  94, 104, 115, 123, 129, 137, 142, 159, 165, 168,
   171, 174, 177, 180, 183, 191, 201, 213, 223, 230, 247, 257, 266, 272,
   276, 288, 305, 331, 337, 343, 350, 353, 361, 370, 375, 383, 392, 401,
   410, 419, 428, 437, 442, 445, 448, 451, 454, 457, 460, 467, 472, 475,
   482, 484, 489, 492, 499, 504, 514, 524, 526, 530, 533, 538, 545, 551,
   556, 564, 570, 574, 578, 582, 586, 590, 594, 598, 602, 606, 610, 614,
   622, 631, 640, 649, 658, 667, 676, 681, 689, 698, 703, 712, 717, 720,
   725, 731, 738, 743, 747, 751, 755, 759, 763, 767, 771, 775, 779, 785,
   793, 803, 808, 811, 814, 823, 832, 837, 839
};


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

static const unsigned char ag_ptt[] = {
    0,  1,  1,  6,  6,  7,  7,  4,  9,  9, 12, 12, 13, 13, 10, 14, 14, 15,
   15, 11, 16, 19, 19, 20, 20, 18, 18, 18, 17, 27, 27, 29, 29, 29, 29, 29,
   29, 28, 28, 28, 28, 28, 28, 35, 35, 37, 40, 40, 41, 41, 36, 30, 42, 42,
   46, 46, 47, 47, 31, 50, 50, 51, 51, 45, 45, 45, 54, 54, 55, 55, 32, 57,
   57, 58, 58, 33, 61, 61, 62, 62, 56, 56, 34, 63, 63, 68, 68, 38, 38, 39,
   43, 72, 72, 74, 74, 69, 69, 44, 75, 75, 48, 49, 52, 53, 59, 60, 64, 64,
   64, 64, 64, 64, 64, 65, 65, 65, 65, 65, 65, 65, 67, 67, 73, 73, 70, 70,
   71, 71
};


static void ag_ra(void)
{
  switch(ag_rpx[(PCB).ag_ap]) {
    case 1: ag_rp_1(); break;
    case 2: ag_rp_2(); break;
    case 3: ag_rp_3(); break;
    case 4: ag_rp_4(VS(0)); break;
    case 5: ag_rp_5(VS(1)); break;
    case 6: ag_rp_6(); break;
    case 7: ag_rp_7(); break;
    case 8: ag_rp_8(); break;
    case 9: ag_rp_9(); break;
    case 10: ag_rp_10(); break;
    case 11: ag_rp_11(); break;
    case 12: ag_rp_12(); break;
    case 13: ag_rp_13(); break;
    case 14: ag_rp_14(); break;
    case 15: ag_rp_15(); break;
    case 16: ag_rp_16(); break;
    case 17: ag_rp_17(); break;
    case 18: ag_rp_18(); break;
    case 19: ag_rp_19(); break;
    case 20: ag_rp_20(); break;
    case 21: ag_rp_21(); break;
    case 22: ag_rp_22(); break;
    case 23: ag_rp_23(); break;
    case 24: ag_rp_24(VS(0)); break;
    case 25: ag_rp_25(VS(1)); break;
    case 26: ag_rp_26(VS(0)); break;
    case 27: ag_rp_27(); break;
    case 28: ag_rp_28(VS(2)); break;
    case 29: ag_rp_29(VS(3)); break;
    case 30: ag_rp_30(); break;
    case 31: ag_rp_31(VS(2)); break;
    case 32: ag_rp_32(VS(3)); break;
    case 33: ag_rp_33(VS(2)); break;
    case 34: ag_rp_34(VS(0)); break;
    case 35: ag_rp_35(VS(3)); break;
    case 36: ag_rp_36(VS(0)); break;
    case 37: ag_rp_37(VS(1), VS(2)); break;
    case 38: ag_rp_38(VS(0)); break;
    case 39: ag_rp_39(VS(1)); break;
    case 40: ag_rp_40(VS(1)); break;
    case 41: ag_rp_41(VS(1)); break;
    case 42: ag_rp_42(VS(1)); break;
    case 43: ag_rp_43(VS(1)); break;
    case 44: ag_rp_44(VS(1)); break;
    case 45: ag_rp_45(VS(1)); break;
    case 46: ag_rp_46(VS(1)); break;
    case 47: ag_rp_47(VS(1)); break;
    case 48: ag_rp_48(VS(1)); break;
    case 49: ag_rp_49(VS(1)); break;
    case 50: ag_rp_50(VS(1)); break;
    case 51: ag_rp_51(VS(1)); break;
    case 52: ag_rp_52(VS(1)); break;
    case 53: ag_rp_53(VS(0)); break;
    case 54: ag_rp_54(VS(1)); break;
    case 55: ag_rp_55(VS(0)); break;
    case 56: ag_rp_56(VS(1)); break;
    case 57: ag_rp_57(VS(0)); break;
    case 58: ag_rp_58(VS(1)); break;
    case 59: ag_rp_59(); break;
    case 60: ag_rp_60(); break;
  }
  (PCB).la_ptr = (PCB).pointer;
}

#define TOKEN_NAMES mhh6_token_names
const char *const mhh6_token_names[87] = {
  "help sourcefile",
  "blank line",
  "'\\n'",
  "'\\r'",
  "eof line",
  "blank",
  "",
  "",
  "eof",
  "eol",
  "help sourcefile",
  "topic",
  "",
  "",
  "",
  "",
  "title line",
  "topic lines",
  "end topic",
  "title line too",
  "title",
  "','",
  "lead title char",
  "title char",
  "\"##\"",
  "\"\\n##\"",
  "\"\\r\\n##\"",
  "topic lines too",
  "text parag",
  "parag",
  "table parag",
  "list1 parag",
  "list2 parag",
  "listtab parag",
  "code parag",
  "partial text parag",
  "text block",
  "",
  "first text line",
  "other text line",
  "",
  "",
  "table parag too",
  "first table line",
  "other table line",
  "list1 block",
  "",
  "",
  "first list1 line",
  "other list1 line",
  "",
  "",
  "first list2 line",
  "other list2 line",
  "",
  "",
  "listtab block",
  "",
  "",
  "first listtab line",
  "other listtab line",
  "",
  "",
  "code parag too",
  "first code line",
  "other code line",
  "lead topic char",
  "text frag",
  "",
  "first table line body",
  "tab seq",
  "blank seq",
  "",
  "table frag",
  "",
  "other table line body",
  "bullet",
  "tab",
  "\"  \"",
  "\"   \"",
  "\"    \"",
  "\"     \"",
  "\"      \"",
  "\"        \"",
  "\"          \"",
  "text char",
  "table char",

};

#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 = (mhh6_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 == (mhh6_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 = (mhh6_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 == (mhh6_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 = (mhh6_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 = (mhh6_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 = (mhh6_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;
  (PCB).ss[(PCB).ssx] = (PCB).sn;
  (PCB).ssx++;
  (PCB).sn = (PCB).ag_ap;
  ag_track();
  return 0;
}

static int ag_action_9_proc(void) {
  if ((PCB).drt == -1) {
    (PCB).drt=(PCB).token_number;
    (PCB).dssx=(PCB).ssx;
    (PCB).dsn=(PCB).sn;
  }
  ag_prot();
  (PCB).vs[(PCB).ssx] = ag_null_value;
  (PCB).ss[(PCB).ssx] = (PCB).sn;
  (PCB).ssx++;
  (PCB).sn = (PCB).ag_ap;
  (PCB).la_ptr =  (PCB).pointer;
  return (PCB).exit_flag == AG_RUNNING_CODE;
}

static int ag_action_2_r_proc(void) {
  (PCB).ssx++;
  (PCB).sn = (PCB).ag_ap;
  return 0;
}

static int ag_action_7_proc(void) {
  --(PCB).ssx;
  (PCB).la_ptr =  (PCB).pointer;
  (PCB).exit_flag = AG_SUCCESS_CODE;
  return 0;
}

static int ag_action_1_proc(void) {
  ag_track();
  (PCB).exit_flag = AG_SUCCESS_CODE;
  return 0;
}

static int ag_action_1_r_proc(void) {
  (PCB).exit_flag = AG_SUCCESS_CODE;
  return 0;
}

static int ag_action_1_s_proc(void) {
  (PCB).exit_flag = AG_SUCCESS_CODE;
  return 0;
}

static int ag_action_4_proc(void) {
  int ag_sd = ag_fl[(PCB).ag_ap] - 1;
  (PCB).reduction_token = (mhh6_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 (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 (PCB).ss[(PCB).ssx] = (PCB).sn;
  ag_track();
  (PCB).reduction_token = (mhh6_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 {
    (PCB).ss[(PCB).ssx] = (PCB).sn;
  }
  (PCB).la_ptr =  (PCB).pointer;
  (PCB).reduction_token = (mhh6_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 = (mhh6_token_type) ag_ptt[(PCB).ag_ap];
  if ((PCB).drt == -1) {
    (PCB).drt=(PCB).token_number;
    (PCB).dssx=(PCB).ssx;
    (PCB).dsn=(PCB).sn;
  }
  if (ag_sd) {
    (PCB).sn = (PCB).ss[(PCB).ssx -= ag_sd];
  }
  else {
    ag_prot();
    (PCB).vs[(PCB).ssx] = ag_null_value;
    (PCB).ss[(PCB).ssx] = (PCB).sn;
  }
  (PCB).la_ptr =  (PCB).pointer;
  while ((PCB).exit_flag == AG_RUNNING_CODE) {
    unsigned ag_t1 = ag_sbe[(PCB).sn] + 1;
    unsigned ag_t2 = ag_sbt[(PCB).sn+1] - 1;
    do {
      unsigned ag_tx = (ag_t1 + ag_t2)/2;
      if (ag_tstt[ag_tx] < (unsigned char)(PCB).reduction_token) ag_t1 = ag_tx + 1;
      else ag_t2 = ag_tx;
    } while (ag_t1 < ag_t2);
    (PCB).ag_ap = ag_pstt[ag_t1];
    if ((ag_r_procs_scan[ag_astt[ag_t1]])() == 0) break;
  }
  return (PCB).exit_flag == AG_RUNNING_CODE;
}


void init_mhh6(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 mhh6(void) {
  init_mhh6();
  (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 = (mhh6_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]])();
  }
}