view anagram/guisupport/profile.cpp @ 12:aab9ff6af791

Strengthen the build hack for non-DOS targets.
author David A. Holland
date Tue, 31 May 2022 00:58:42 -0400
parents 13d2b8934445
children 5581ef01f993
line wrap: on
line source

/*
 * AnaGram, A System for Syntax Directed Programming
 * Copyright 1993-2002 Parsifal Software. All Rights Reserved.
 * Copyright 2006 David A. Holland. All Rights Reserved.
 * See the file COPYING for license and usage terms.
 *
 * profile.syn - parse the "profile" (Windows registry entry / .AnaGram file)
 */

#include "port.h"

#include "agcstack.h"
#include "cint.h"
#include "ctrlpanel.hpp"
#include "dspar.hpp"
#include "profile-defs.h"
#include "version.h"

//#define INCLUDE_LOGGING
#include "log.h"

/*
 * AnaGram, A System for Syntax Directed Programming
 * File generated by: Version 2.40-current, built Oct 30 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 PROFILE_H_1198351949
#include "profile.h"
#endif

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



parseRegEntry_pcb_type parseRegEntry_pcb;
#define PCB parseRegEntry_pcb
#define CHANGE_REDUCTION(x) parseRegEntry_change_reduction(parseRegEntry_##x##_token)
int parseRegEntry_change_reduction(parseRegEntry_token_type);


/*  Line 135, regent.syn */
  int lastVersion = 200;

  static AgCharStack charStack;

#ifndef SYNTAX_ERROR
#define SYNTAX_ERROR {\
  char buf[500];\
  sprintf(buf,"%s, line %d, column %d\n", \
  (PCB).error_message, (PCB).line, (PCB).column);\
  LOGV(buf);\
}
#endif

  int initializeFrom(const char *pointer) {
    LOGSECTION("initializeFrom");

    if (pointer == 0) {
      return 1;
    }
    init_parseRegEntry();
    do {
      PCB.input_code = (unsigned char) *pointer;
      parseRegEntry();
    }
    while (*pointer++ && PCB.exit_flag == AG_RUNNING_CODE);
    return PCB.exit_flag != AG_SUCCESS_CODE;
  }

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

#define ag_rp_1(p) (ColorDialog::initColor(charStack.popString(), p))

#define ag_rp_2(id, f, p) (FontDialog::initFont(id, f,p, charStack.popString()))

#define ag_rp_3(i) (controlPanel->autobuildFlag = i)

#define ag_rp_4(i) (controlPanel->showStatsFlag = i)

#define ag_rp_5(i) (controlPanel->showSyntaxFlag = i)

#define ag_rp_6(i) (controlPanel->stayOnTopFlag = i)

#define ag_rp_7(p) (controlPanelLocation = p)

#define ag_rp_8(r) (syntaxFileRect = r)

#define ag_rp_9(i) (lastVersion = i)

static void ag_rp_10(void) {
/* Line 73, regent.syn */
  LOGSECTION("RecentFile");
  LOGV(controlPanel->recentFiles.size());
  //controlPanel->recentFiles << charStack.popString();
  controlPanel->recentFiles.push(charStack.popString());
  LOGV(controlPanel->recentFiles.size());

}

static void ag_rp_11(int t) {
/* Line 81, regent.syn */
 if (!t) CHANGE_REDUCTION(unaccepted_qualifier); 
}

#define ag_rp_12(v1) ((INTVERSION == v1))

#define ag_rp_13(v1) ((INTVERSION >= v1))

#define ag_rp_14(v1, v2) ((INTVERSION >= v1 && INTVERSION <= v2))

#define ag_rp_15() (0)

#define ag_rp_16(f) (f|FontSpec::bold)

#define ag_rp_17(f) (f|FontSpec::italic)

#define ag_rp_18(f) (f|FontSpec::strikeout)

#define ag_rp_19(f) (f|FontSpec::underscore)

#define ag_rp_20(c) (charStack.discardData().push(c))

#define ag_rp_21(c) (charStack.push(c))

#define ag_rp_22() (FontDialog::idField(charStack.popString()))

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

#define ag_rp_24(i, d) (10*i + d - '0')

#define ag_rp_25(i) (-i)

#define ag_rp_26(d) (d)

#define ag_rp_27(i, d) (16*i + d)

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

#define ag_rp_29(d) ((d&7) + 9)

#define ag_rp_30(f, g) (cint(f, g))

#define ag_rp_31(f, g) (IPoint(f, g))

#define ag_rp_32(a, b, c, d) (IRectangle(a, b, c, d))

#define ag_rp_33(c) (charStack.discardData().push(c))

#define ag_rp_34(c) (charStack.push(c))


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

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

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

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

static const unsigned char ag_key_ch[] = {
    0,116,121,255, 83,255,119,255,111,255,104,116,255, 65, 67, 70, 82, 83,
   86, 99,101,115,255,116,121,255, 83,255,119,255,111,255,104,116,255, 65,
   67, 70, 82, 83, 86, 99,115,255,101,255
};

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

static const unsigned char ag_key_parm[] = {
    0, 26, 27,  0,  0,  0,  0,  0,  0,  0,  0, 28,  0, 25, 16, 20, 34,  0,
   33, 29,  5, 31,  0, 26, 27,  0,  0,  0,  0,  0,  0,  0,  0, 28,  0, 25,
   16, 20, 34,  0, 33, 29, 31,  0,  5,  0
};

static const unsigned char ag_key_jmp[] = {
    0, 32, 42,  0,  1,  0,  4,  0,  6,  0,  8, 48,  0,  0, 10, 16, 21, 10,
   57, 65, 71, 92,  0,131,141,  0, 23,  0, 26,  0, 28,  0, 30,147,  0, 99,
  109,115,120, 32,156,164,170,  0,177,  0
};

static const unsigned char ag_key_index[] = {
   13,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0, 35, 13, 44,  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
};

static const unsigned char ag_key_ends[] = {
117,116,111,98,117,105,108,100,61,0, 111,108,111,114,58,0, 
111,110,116,58,0, 101,99,101,110,116,70,105,108,101,58,0, 
97,116,105,115,116,105,99,115,61,0, 110,116,97,120,61,0, 
97,121,79,110,84,111,112,61,0, 101,114,115,105,111,110,61,0, 
112,76,111,99,61,0, 
110,100,73,110,105,116,105,97,108,105,122,97,116,105,111,110,68,97,116,97,0, 
102,82,101,99,116,61,0, 117,116,111,98,117,105,108,100,61,0, 
111,108,111,114,58,0, 111,110,116,58,0, 
101,99,101,110,116,70,105,108,101,58,0, 
97,116,105,115,116,105,99,115,61,0, 110,116,97,120,61,0, 
97,121,79,110,84,111,112,61,0, 101,114,115,105,111,110,61,0, 
112,76,111,99,61,0, 102,82,101,99,116,61,0, 
110,100,73,110,105,116,105,97,108,105,122,97,116,105,111,110,68,97,116,97,0, 
};
#define AG_TCV(x) (((int)(x) >= 0 && (int)(x) <= 255) ? ag_tcv[(x)] : 0)

static const unsigned char ag_tcv[] = {
    7, 51, 51, 51, 51, 51, 51, 51, 51, 51, 14, 51, 51,  0, 51, 51, 51, 51,
   51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51,
   51, 51, 51, 51, 36, 38, 51, 51, 50, 39, 24, 51, 45, 45, 45, 45, 45, 45,
   45, 45, 45, 45, 51, 51, 51, 18, 51, 51, 51, 52, 40, 52, 52, 52, 52, 51,
   51, 41, 51, 51, 51, 51, 51, 51, 51, 51, 51, 42, 51, 43, 51, 51, 51, 51,
   51, 51, 51, 51, 51, 51, 51, 52, 52, 52, 52, 52, 52, 51, 51, 51, 51, 51,
   51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51,
   51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51,
   51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51,
   51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51,
   51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51,
   51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51,
   51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51,
   51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51,
   51, 51, 51, 51
};

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

#ifndef FIRST_LINE
#define FIRST_LINE 1
#endif

#ifndef FIRST_COLUMN
#define FIRST_COLUMN 1
#endif

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

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


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


#ifndef AG_NEWLINE
#define AG_NEWLINE 10
#endif

#ifndef AG_RETURN
#define AG_RETURN 13
#endif

#ifndef AG_FORMFEED
#define AG_FORMFEED 12
#endif

#ifndef AG_TABCHAR
#define AG_TABCHAR 9
#endif

static void ag_track(void) {
  int ag_k = 0;
  while (ag_k < (PCB).rx) {
    int ag_ch = (PCB).lab[ag_k++];
    switch (ag_ch) {
    case AG_NEWLINE:
      (PCB).column = 1, (PCB).line++;
    case AG_RETURN:
    case AG_FORMFEED:
      break;
    case AG_TABCHAR:
      (PCB).column += (TAB_SPACING) - ((PCB).column - 1) % (TAB_SPACING);
      break;
    default:
      (PCB).column++;
    }
  }
  ag_k = 0;
  while ((PCB).rx < (PCB).fx) (PCB).lab[ag_k++] = (PCB).lab[(PCB).rx++];
  (PCB).fx = ag_k;
  (PCB).rx = 0;
}


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

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



static const int ag_rtt[] = {
   10, 11,  0
};

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


static unsigned const char ag_astt[346] = {
  1,1,1,1,1,1,1,1,1,1,1,5,8,7,0,1,1,1,1,1,1,1,1,2,2,2,2,2,2,2,2,2,2,2,2,2,7,
  1,2,7,1,1,7,1,1,7,1,2,7,1,2,7,1,2,7,1,2,7,1,2,2,2,2,2,2,2,2,2,2,2,7,1,1,2,
  2,2,2,2,2,2,2,2,2,2,7,1,2,7,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,1,7,3,3,1,1,1,1,1,1,1,1,1,1,1,5,3,3,3,1,1,3,8,1,7,1,10,10,10,10,10,
  10,10,10,10,10,10,10,10,2,7,10,2,7,2,7,1,2,7,2,1,7,1,1,2,7,10,2,7,10,2,7,
  10,2,7,10,2,7,10,10,10,10,10,10,10,10,10,10,10,4,1,7,10,10,10,10,10,10,10,
  10,10,10,10,1,7,10,1,4,2,7,9,9,9,9,9,9,9,9,9,9,9,9,9,3,7,3,7,1,10,7,2,7,1,
  10,5,1,7,4,4,4,4,4,7,1,1,7,1,2,4,1,2,7,1,10,4,2,1,7,1,1,2,10,10,10,10,7,1,
  2,2,2,7,1,2,2,7,10,4,1,10,7,2,7,10,1,7,2,1,2,2,7,2,2,7,1,2,2,2,2,2,2,2,2,2,
  2,2,7,1,2,2,2,7,1,2,1,10,7,10,10,10,10,10,10,10,10,10,10,10,2,7,2,2,2,2,7,
  2,2,7,1,10,2,7,11
};


static const unsigned char ag_pstt[] = {
11,1,2,3,4,5,6,7,8,9,10,3,15,0,0,14,14,15,14,14,13,12,14,
48,48,48,48,48,48,48,48,48,48,48,48,48,1,16,
37,2,17,
18,3,19,
20,4,21,
37,5,22,
37,6,23,
37,7,24,
37,8,25,
34,34,34,34,34,34,34,34,34,34,34,9,26,27,
34,34,34,34,34,34,34,34,34,34,34,10,28,
37,11,29,30,
31,31,31,31,31,31,31,31,31,31,31,31,31,12,31,
1,2,3,4,5,6,7,8,9,10,13,10,10,
11,1,2,3,4,5,6,7,8,9,10,4,2,2,2,13,12,2,
32,32,15,32,
49,49,49,49,49,49,49,49,49,49,49,49,49,24,16,
38,23,17,
37,18,33,
22,19,
37,34,20,35,36,
21,21,
38,20,22,
38,19,23,
38,18,24,
38,17,25,
35,35,35,35,35,35,35,35,35,35,35,36,
37,27,
35,35,35,35,35,35,35,35,35,35,35,38,28,
38,39,26,
25,30,
12,12,12,12,12,12,12,12,12,12,12,12,12,13,31,
7,32,
40,38,33,
37,34,41,
38,39,
42,36,
29,29,29,29,29,37,43,
44,38,45,
37,27,46,
37,40,47,
38,40,
37,34,42,35,48,
37,33,32,31,30,43,49,
44,43,44,44,50,41,
15,45,
38,28,
51,38,47,
46,48,
38,52,49,
44,53,43,44,50,42,
37,51,54,
34,34,34,34,34,34,34,34,34,34,34,52,55,
44,43,44,53,56,41,
57,38,54,
35,35,35,35,35,35,35,35,35,35,35,16,55,
44,43,44,45,56,42,
37,57,58,
38,47,58,
  0
};


static const unsigned short ag_sbt[] = {
     0,  23,  38,  41,  44,  47,  50,  53,  56,  59,  73,  86,  90, 105,
   118, 136, 140, 155, 158, 161, 163, 168, 170, 173, 176, 179, 182, 194,
   196, 209, 212, 214, 229, 231, 234, 237, 239, 241, 248, 251, 254, 257,
   259, 264, 271, 277, 279, 281, 284, 286, 289, 295, 298, 311, 317, 320,
   333, 339, 342, 345
};


static const unsigned short ag_sbe[] = {
    13,  36,  39,  42,  45,  48,  51,  54,  57,  70,  84,  87, 103, 115,
   129, 138, 154, 157, 159, 162, 165, 169, 172, 175, 178, 181, 193, 195,
   208, 211, 213, 228, 230, 233, 235, 238, 240, 246, 249, 252, 255, 258,
   261, 269, 274, 278, 280, 283, 285, 288, 293, 296, 309, 314, 319, 332,
   337, 340, 344, 345
};


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

static const unsigned char ag_ptt[] = {
    0,  3,  3,  4,  4,  6,  6,  1,  2,  2,  8, 13, 13,  8,  9, 15, 15, 15,
   15, 15, 15, 15, 15, 15, 15, 10, 37, 37, 37, 22, 22, 22, 22, 22, 17, 17,
   21, 23, 23, 46, 46, 47, 47, 48, 48, 19, 30, 32, 35, 35
};

static const unsigned char  *ag_valid(int ag_k) {
  const unsigned char  *ag_tp = &ag_tstt[ag_sbt[(PCB).sn+1]];
  while (*--ag_tp != (unsigned char) ag_k) if (*ag_tp == 0) return NULL;
  return ag_tp;
}

int parseRegEntry_change_reduction(parseRegEntry_token_type ag_k) {
  if (!ag_valid(ag_k)) return 0;
  (PCB).reduction_token = ag_k;
  return 1;
}

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



static void ag_ra(void)
{
  switch(ag_rpx[(PCB).ag_ap]) {
    case 1: ag_rp_1(V(3,(cint *))); break;
    case 2: ag_rp_2(V(1,(int *)), V(3,(int *)), V(4,(int *))); break;
    case 3: ag_rp_3(V(1,(int *))); break;
    case 4: ag_rp_4(V(1,(int *))); break;
    case 5: ag_rp_5(V(1,(int *))); break;
    case 6: ag_rp_6(V(1,(int *))); break;
    case 7: ag_rp_7(V(1,(IPoint *))); break;
    case 8: ag_rp_8(V(1,(IRectangle *))); break;
    case 9: ag_rp_9(V(1,(int *))); break;
    case 10: ag_rp_10(); break;
    case 11: ag_default(&ag_rtt[0]); ag_rp_11(V(1,(int *))); break;
    case 12: V(0,(int *)) = ag_rp_12(V(0,(int *))); break;
    case 13: V(0,(int *)) = ag_rp_13(V(0,(int *))); break;
    case 14: V(0,(int *)) = ag_rp_14(V(0,(int *)), V(2,(int *))); break;
    case 15: V(0,(int *)) = ag_rp_15(); break;
    case 16: V(0,(int *)) = ag_rp_16(V(0,(int *))); break;
    case 17: V(0,(int *)) = ag_rp_17(V(0,(int *))); break;
    case 18: V(0,(int *)) = ag_rp_18(V(0,(int *))); break;
    case 19: V(0,(int *)) = ag_rp_19(V(0,(int *))); break;
    case 20: ag_rp_20(V(0,(int *))); break;
    case 21: ag_rp_21(V(1,(int *))); break;
    case 22: V(0,(int *)) = ag_rp_22(); break;
    case 23: V(0,(int *)) = ag_rp_23(V(0,(int *))); break;
    case 24: V(0,(int *)) = ag_rp_24(V(0,(int *)), V(1,(int *))); break;
    case 25: V(0,(int *)) = ag_rp_25(V(1,(int *))); break;
    case 26: V(0,(int *)) = ag_rp_26(V(0,(int *))); break;
    case 27: V(0,(int *)) = ag_rp_27(V(0,(int *)), V(1,(int *))); break;
    case 28: V(0,(int *)) = ag_rp_28(V(0,(int *))); break;
    case 29: V(0,(int *)) = ag_rp_29(V(0,(int *))); break;
    case 30: V(0,(cint *)) = ag_rp_30(V(1,(int *)), V(3,(int *))); break;
    case 31: V(0,(IPoint *)) = ag_rp_31(V(1,(int *)), V(3,(int *))); break;
    case 32: V(0,(IRectangle *)) = ag_rp_32(V(1,(int *)), V(3,(int *)), V(5,(int *)), V(7,(int *))); break;
    case 33: ag_rp_33(V(0,(int *))); break;
    case 34: ag_rp_34(V(1,(int *))); break;
  }
}

#define TOKEN_NAMES parseRegEntry_token_names
const char *const parseRegEntry_token_names[53] = {
  "registry data",
  "registry data",
  "registry entry",
  "",
  "",
  "\"endInitializationData\"",
  "",
  "eof",
  "qualified registry entry",
  "pure registry entry",
  "accepted qualifier",
  "unaccepted qualifier",
  "file name char",
  "",
  "'\\n'",
  "ag201 registry entry",
  "\"Color:\"",
  "name",
  "'='",
  "color pair",
  "\"Font:\"",
  "field id",
  "font flags",
  "integer",
  "'.'",
  "\"Autobuild=\"",
  "\"ShowStatistics=\"",
  "\"ShowSyntax=\"",
  "\"StayOnTop=\"",
  "\"cpLoc=\"",
  "point",
  "\"sfRect=\"",
  "rectangle",
  "\"Version=\"",
  "\"RecentFile:\"",
  "file name",
  "'('",
  "qual expr",
  "')'",
  "'-'",
  "'B'",
  "'I'",
  "'S'",
  "'U'",
  "name char",
  "digit",
  "signed integer",
  "hex integer",
  "hex digit",
  "",
  "','",
  "",
  "",

};

#ifndef MISSING_FORMAT
#define MISSING_FORMAT "Missing %s"
#endif
#ifndef UNEXPECTED_FORMAT
#define UNEXPECTED_FORMAT "Unexpected %s"
#endif
#ifndef UNNAMED_TOKEN
#define UNNAMED_TOKEN "input"
#endif


static void ag_diagnose(void) {
  int ag_snd = (PCB).sn;
  int ag_k = ag_sbt[ag_snd];

  if (*TOKEN_NAMES[ag_tstt[ag_k]] && ag_astt[ag_k + 1] == ag_action_8) {
    sprintf((PCB).ag_msg, MISSING_FORMAT, TOKEN_NAMES[ag_tstt[ag_k]]);
  }
  else if (ag_astt[ag_sbe[(PCB).sn]] == ag_action_8
          && (ag_k = (int) ag_sbe[(PCB).sn] + 1) == (int) ag_sbt[(PCB).sn+1] - 1
          && *TOKEN_NAMES[ag_tstt[ag_k]]) {
    sprintf((PCB).ag_msg, MISSING_FORMAT, TOKEN_NAMES[ag_tstt[ag_k]]);
  }
  else if ((PCB).token_number && *TOKEN_NAMES[(PCB).token_number]) {
    sprintf((PCB).ag_msg, UNEXPECTED_FORMAT, TOKEN_NAMES[(PCB).token_number]);
  }
  else if (isprint((*(PCB).lab)) && (*(PCB).lab) != '\\') {
    char buf[20];
    sprintf(buf, "\'%c\'", (char) (*(PCB).lab));
    sprintf((PCB).ag_msg, UNEXPECTED_FORMAT, buf);
  }
  else sprintf((PCB).ag_msg, UNEXPECTED_FORMAT, UNNAMED_TOKEN);
  (PCB).error_message = (PCB).ag_msg;


}
static int ag_action_1_r_proc(void);
static int ag_action_2_r_proc(void);
static int ag_action_3_r_proc(void);
static int ag_action_4_r_proc(void);
static int ag_action_1_s_proc(void);
static int ag_action_3_s_proc(void);
static int ag_action_1_proc(void);
static int ag_action_2_proc(void);
static int ag_action_3_proc(void);
static int ag_action_4_proc(void);
static int ag_action_5_proc(void);
static int ag_action_6_proc(void);
static int ag_action_7_proc(void);
static int ag_action_8_proc(void);
static int ag_action_9_proc(void);
static int ag_action_10_proc(void);
static int ag_action_11_proc(void);
static int ag_action_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) {
  (PCB).btsx = 0, (PCB).drt = -1;
  ag_track();
  return 0;
}

static int ag_action_11_proc(void) {
  (PCB).btsx = 0, (PCB).drt = -1;
  (*(int *) &(PCB).vs[(PCB).ssx]) = *(PCB).lab;
  (PCB).ssx--;
  ag_ra();
  (PCB).ssx++;
  ag_track();
  return 0;
}

static int ag_action_3_r_proc(void) {
  int ag_sd = ag_fl[(PCB).ag_ap] - 1;
  if (ag_sd) (PCB).sn = (PCB).ss[(PCB).ssx -= ag_sd];
  (PCB).btsx = 0, (PCB).drt = -1;
  (PCB).reduction_token = (parseRegEntry_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 = (parseRegEntry_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 = (parseRegEntry_token_type) ag_ptt[(PCB).ag_ap];
  return 1;
}

static int ag_action_2_proc(void) {
  (PCB).btsx = 0, (PCB).drt = -1;
  if ((PCB).ssx >= 128) {
    (PCB).exit_flag = AG_STACK_ERROR_CODE;
    PARSER_STACK_OVERFLOW;
  }
  (*(int *) &(PCB).vs[(PCB).ssx]) = *(PCB).lab;
  (PCB).ss[(PCB).ssx] = (PCB).sn;
  (PCB).ssx++;
  (PCB).sn = (PCB).ag_ap;
  ag_track();
  return 0;
}

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

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

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

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

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

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

static int ag_action_4_proc(void) {
  int ag_sd = ag_fl[(PCB).ag_ap] - 1;
  (PCB).reduction_token = (parseRegEntry_token_type) ag_ptt[(PCB).ag_ap];
  (PCB).btsx = 0, (PCB).drt = -1;
  (*(int *) &(PCB).vs[(PCB).ssx]) = *(PCB).lab;
  if (ag_sd) (PCB).sn = (PCB).ss[(PCB).ssx -= ag_sd];
  else (PCB).ss[(PCB).ssx] = (PCB).sn;
  ag_track();
  while ((PCB).exit_flag == AG_RUNNING_CODE) {
    unsigned ag_t1 = ag_sbe[(PCB).sn] + 1;
    unsigned ag_t2 = ag_sbt[(PCB).sn+1] - 1;
    do {
      unsigned ag_tx = (ag_t1 + ag_t2)/2;
      if (ag_tstt[ag_tx] < (unsigned char)(PCB).reduction_token) ag_t1 = ag_tx + 1;
      else ag_t2 = ag_tx;
    } while (ag_t1 < ag_t2);
    if (ag_tstt[ag_t1] != (PCB).reduction_token) {
      (PCB).exit_flag = AG_REDUCTION_ERROR_CODE; 
      REDUCTION_TOKEN_ERROR; break;}
      (PCB).ag_ap = ag_pstt[ag_t1];
    if ((ag_s_procs_scan[ag_astt[ag_t1]])() == 0) break;
  }
  return 0;
}

static int ag_action_3_proc(void) {
  int ag_sd = ag_fl[(PCB).ag_ap] - 1;
  (PCB).btsx = 0, (PCB).drt = -1;
  (*(int *) &(PCB).vs[(PCB).ssx]) = *(PCB).lab;
  if (ag_sd) (PCB).sn = (PCB).ss[(PCB).ssx -= ag_sd];
  else (PCB).ss[(PCB).ssx] = (PCB).sn;
  ag_track();
  (PCB).reduction_token = (parseRegEntry_token_type) ag_ptt[(PCB).ag_ap];
  ag_ra();
  while ((PCB).exit_flag == AG_RUNNING_CODE) {
    unsigned ag_t1 = ag_sbe[(PCB).sn] + 1;
    unsigned ag_t2 = ag_sbt[(PCB).sn+1] - 1;
    do {
      unsigned ag_tx = (ag_t1 + ag_t2)/2;
      if (ag_tstt[ag_tx] < (unsigned char)(PCB).reduction_token) ag_t1 = ag_tx + 1;
      else ag_t2 = ag_tx;
    } while (ag_t1 < ag_t2);
    if (ag_tstt[ag_t1] != (PCB).reduction_token) {
      (PCB).exit_flag = AG_REDUCTION_ERROR_CODE; 
      REDUCTION_TOKEN_ERROR; break;}
      (PCB).ag_ap = ag_pstt[ag_t1];
    if ((ag_s_procs_scan[ag_astt[ag_t1]])() == 0) break;
  }
  return 0;
}

static int ag_action_8_proc(void) {
  ag_undo();
  (PCB).rx = 0;
  (PCB).exit_flag = AG_SYNTAX_ERROR_CODE;
  ag_diagnose();
  SYNTAX_ERROR;
  {(PCB).rx = 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).rx = 0;
  (PCB).reduction_token = (parseRegEntry_token_type) ag_ptt[(PCB).ag_ap];
  ag_ra();
  while ((PCB).exit_flag == AG_RUNNING_CODE) {
    unsigned ag_t1 = ag_sbe[(PCB).sn] + 1;
    unsigned ag_t2 = ag_sbt[(PCB).sn+1] - 1;
    do {
      unsigned ag_tx = (ag_t1 + ag_t2)/2;
      if (ag_tstt[ag_tx] < (unsigned char)(PCB).reduction_token) ag_t1 = ag_tx + 1;
      else ag_t2 = ag_tx;
    } while (ag_t1 < ag_t2);
    if (ag_tstt[ag_t1] != (PCB).reduction_token) {
      (PCB).exit_flag = AG_REDUCTION_ERROR_CODE; 
      REDUCTION_TOKEN_ERROR; break;}
      (PCB).ag_ap = ag_pstt[ag_t1];
    if ((ag_r_procs_scan[ag_astt[ag_t1]])() == 0) break;
  }
  return (PCB).exit_flag == AG_RUNNING_CODE;
}

static int ag_action_6_proc(void) {
  int ag_sd = ag_fl[(PCB).ag_ap];
  (PCB).reduction_token = (parseRegEntry_token_type) ag_ptt[(PCB).ag_ap];
  if ((PCB).drt == -1) {
    (PCB).drt=(PCB).token_number;
    (PCB).dssx=(PCB).ssx;
    (PCB).dsn=(PCB).sn;
  }
  if (ag_sd) {
    (PCB).sn = (PCB).ss[(PCB).ssx -= ag_sd];
  }
  else {
    ag_prot();
    (PCB).vs[(PCB).ssx] = ag_null_value;
    (PCB).ss[(PCB).ssx] = (PCB).sn;
  }
  (PCB).rx = 0;
  while ((PCB).exit_flag == AG_RUNNING_CODE) {
    unsigned ag_t1 = ag_sbe[(PCB).sn] + 1;
    unsigned ag_t2 = ag_sbt[(PCB).sn+1] - 1;
    do {
      unsigned ag_tx = (ag_t1 + ag_t2)/2;
      if (ag_tstt[ag_tx] < (unsigned char)(PCB).reduction_token) ag_t1 = ag_tx + 1;
      else ag_t2 = ag_tx;
    } while (ag_t1 < ag_t2);
    if (ag_tstt[ag_t1] != (PCB).reduction_token) {
      (PCB).exit_flag = AG_REDUCTION_ERROR_CODE; 
      REDUCTION_TOKEN_ERROR; break;}
      (PCB).ag_ap = ag_pstt[ag_t1];
    if ((ag_r_procs_scan[ag_astt[ag_t1]])() == 0) break;
  }
  return (PCB).exit_flag == AG_RUNNING_CODE;
}


void init_parseRegEntry(void) {
  unsigned ag_t1;
  ag_t1 = 0;
  (PCB).rx = (PCB).fx = 0;
  (PCB).ss[0] = (PCB).sn = (PCB).ssx = 0;
  (PCB).exit_flag = AG_RUNNING_CODE;
  (PCB).key_sp = NULL;
  (PCB).key_state = 0;
  (PCB).line = FIRST_LINE;
  (PCB).column = FIRST_COLUMN;
  (PCB).btsx = 0, (PCB).drt = -1;
  while (ag_tstt[ag_t1] == 0) {
    (PCB).ag_ap = ag_pstt[ag_t1];
    (ag_gt_procs_scan[ag_astt[ag_t1]])();
    ag_t1 = ag_sbt[(PCB).sn];
  }
}

void parseRegEntry(void) {
  (PCB).lab[(PCB).fx++] = (PCB).input_code;
  while ((PCB).exit_flag == AG_RUNNING_CODE) {
    while (1) {
      const  unsigned char *ag_p;
      int ag_ch;
      if ((PCB).rx >= (PCB).fx) return;
      ag_ch = CONVERT_CASE((PCB).lab[(PCB).rx++]);
      if ((PCB).key_sp) {
        if (ag_ch != *(PCB).key_sp++) {
          (PCB).rx = (PCB).save_index;
          (PCB).key_sp = NULL;
          (PCB).key_state = 0;
          break;
        } else if (*(PCB).key_sp) continue;
        if (ag_key_act[(PCB).key_state] == ag_cf_end_key) {
          int ag_k1;
          int ag_k2;
          if ((PCB).rx >= (PCB).fx) {
            (PCB).rx--;
            (PCB).key_sp--;
            return;
          }
          (PCB).key_sp = NULL;
          ag_k1 = ag_key_parm[(PCB).key_state];
          ag_k2 = ag_key_pt[ag_k1];
          if (ag_key_itt[ag_k2 + CONVERT_CASE((PCB).lab[(PCB).rx])])
            (PCB).rx = (PCB).save_index;
          else {
            (PCB).token_number =  (parseRegEntry_token_type) ag_key_pt[ag_k1+1];
            (PCB).key_state = 0;
          }
          break;
        }
        else {
          (PCB).token_number = (parseRegEntry_token_type) ag_key_parm[(PCB).key_state];
          (PCB).key_state = 0;
          (PCB).key_sp = NULL;
        }
        break;
      }
      if ((PCB).key_state == 0) {
        (PCB).token_number = (parseRegEntry_token_type) AG_TCV(ag_ch);
        if (((PCB).key_state = ag_key_index[(PCB).sn]) == 0) break;
        (PCB).save_index = 1;
      }
      ag_p = &ag_key_ch[(PCB).key_state];
      if (ag_ch <= 255) while (*ag_p < ag_ch) ag_p++;
      if (*ag_p == ag_ch) {
        (PCB).key_state = (int)(ag_p - ag_key_ch);
        switch (ag_key_act[(PCB).key_state]) {
        case ag_cf_set_key: {
          int ag_k1;
          int ag_k2;
          if ((PCB).rx >= (PCB).fx) {
            (PCB).rx--;
            return;
          }
          ag_k1 = ag_key_parm[(PCB).key_state];
          ag_k2 = ag_key_pt[ag_k1];
          (PCB).key_state = ag_key_jmp[(PCB).key_state];
          if (ag_key_itt[ag_k2 + CONVERT_CASE((PCB).lab[(PCB).rx])]) continue;
          (PCB).save_index = (PCB).rx;
          (PCB).token_number = (parseRegEntry_token_type) ag_key_pt[ag_k1+1];
          continue;
        }
        case ag_set_key:
          (PCB).save_index = (PCB).rx;
          (PCB).token_number = (parseRegEntry_token_type) ag_key_parm[(PCB).key_state];
        case ag_jmp_key:
          (PCB).key_state = ag_key_jmp[(PCB).key_state];
          continue;
        case ag_cf_end_key:
        case ag_end_key:
          (PCB).key_sp = ag_key_ends + ag_key_jmp[(PCB).key_state];
          continue;
        case ag_accept_key:
          (PCB).token_number = (parseRegEntry_token_type) ag_key_parm[(PCB).key_state];
          (PCB).key_state = 0;
          break;
        case ag_cf_accept_key: {
          int ag_k1;
          int ag_k2;
          if ((PCB).rx >= (PCB).fx) {
            (PCB).rx--;
            return;
          }
          ag_k1 = ag_key_parm[(PCB).key_state];
          ag_k2 = ag_key_pt[ag_k1];
          if (ag_key_itt[ag_k2 + CONVERT_CASE((PCB).lab[(PCB).rx])])
            (PCB).rx = (PCB).save_index;
          else {
            (PCB).token_number = (parseRegEntry_token_type) ag_key_pt[ag_k1+1];
            (PCB).key_state = 0;
          }
          break;
        }
        }
        break;
      } else {
        (PCB).rx = (PCB).save_index;
        (PCB).key_state = 0;
        break;
      }
    }

    {
      unsigned ag_t1 = ag_sbt[(PCB).sn];
      unsigned ag_t2 = ag_sbe[(PCB).sn] - 1;
      do {
        unsigned ag_tx = (ag_t1 + ag_t2)/2;
        if (ag_tstt[ag_tx] > (unsigned char)(PCB).token_number)
          ag_t1 = ag_tx + 1;
        else ag_t2 = ag_tx;
      } while (ag_t1 < ag_t2);
      if (ag_tstt[ag_t1] != (PCB).token_number)  ag_t1 = ag_sbe[(PCB).sn];
      (PCB).ag_ap = ag_pstt[ag_t1];
      (ag_gt_procs_scan[ag_astt[ag_t1]])();
    }
  }
}