Mercurial > ~dholland > hg > ag > index.cgi
diff tests/agcl/parsifal/good/eval-e.c @ 0:13d2b8934445
Import AnaGram (near-)release tree into Mercurial.
author | David A. Holland |
---|---|
date | Sat, 22 Dec 2007 17:52:45 -0500 |
parents | |
children |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tests/agcl/parsifal/good/eval-e.c Sat Dec 22 17:52:45 2007 -0500 @@ -0,0 +1,1659 @@ +/* + EVALKERN.SYN + + evaluateExpression: A Simple Expression Evaluator + Copyright (c) 1996 Parsifal Software, All Rights Reserved. + See the file COPYING for license and usage terms. + + EVALKERN.SYN is the kernel of the example, consisting + of the expression parser itself. Support functions are + defined in EVALWRAP.C. A test program is defined in + EVALDEMO.C. Global declarations are contained in + EVALDEFS.H. + + The parse function defined in EVALKERN.SYN is called + evalKernel. All communication with evalKernel is via + the parser control block. The wrapper function, + evaluateExpression, defined in EVALWRAP.C, provides + a more convenient interface for the function. + + The expression syntax is borrowed from C but with the + addition of the FORTRAN exponentiation operator (**). + + The cast, increment, and decrement operators are not + implemented, nor are operations that are defined only + for integers: + Bitwise logical operators: &, |, ^, ~, &=, |=, ^= + Remainder operators: %, %= + Shift operators: <<, >>, >>=, <<= + + The supported operations are: + Assignment operators: =, +=, -=, *=, /= + Conditional expressions: ? : + Logical operators: !, &&, || + Comparison operators: ==, !=, <, <=, >, >= + Binary arithmetic operators: +, -, *, / + Exponentiation: ** + Unary arithmetic operators: +, - + Parentheses + Function calls + + All arithmetic is double precision floating point. + + Input strings may contain any number of expressions, separated by + commas or semicolons. White space may be used freely, including + both C and C++ style comments. + + eval makes the following external calls: + void pushChar(int character); + Push the specified character onto a character stack. + + double *locateVariable(int nameLength); + Pop the last nameLength characters from the character stack + and, treating them as the name of a variable, return a pointer + to the location where the value of the variable is stored. + + void pushArg(double value); + Push the specified value onto an argument stack. + + double callFunction(nameLength, int argCount); + Pop the last nameLength characters from the character stack + and, treating them as the name of a function, identify the + function and invoke it with argCount arguments popped from + the argument stack. + + double checkZero(double value); + Verify that value is not zero. + + Overrides for macros defined by AnaGram, such as SYNTAX_ERROR + should are included in EVALDEFS.H + + EVALKERN.SYN is compiled with the AnaGram parser generator + yielding EVALKERN.H and EVALKERN.C. + + For information about AnaGram, visit http://www.parsifalsoft.com. +*/ + +#include <math.h> +#include "evaldefs.h" // defines external interface + + +/* + * AnaGram, A System for Syntax Directed Programming + * File generated by: ... + * + * AnaGram Parsing Engine + * Copyright 1993-2002 Parsifal Software. All Rights Reserved. + * + * This software is provided 'as-is', without any express or implied + * warranty. In no event will the authors be held liable for any damages + * arising from the use of this software. + * + * Permission is granted to anyone to use this software for any purpose, + * including commercial applications, and to alter it and redistribute it + * freely, subject to the following restrictions: + * + * 1. The origin of this software must not be misrepresented; you must not + * claim that you wrote the original software. If you use this software + * in a product, an acknowledgment in the product documentation would be + * appreciated but is not required. + * 2. Altered source versions must be plainly marked as such, and must not be + * misrepresented as being the original software. + * 3. This notice may not be removed or altered from any source distribution. + */ + +#ifndef EVAL-E_H +#include "eval-e.h" +#endif + +#ifndef EVAL-E_H +#error Mismatched header file +#endif + +#include <ctype.h> +#include <stdio.h> + +#define RULE_CONTEXT (&((PCB).cs[(PCB).ssx])) +#define ERROR_CONTEXT ((PCB).cs[(PCB).error_frame_ssx]) +#define CONTEXT ((PCB).cs[(PCB).ssx]) + + + +evalKernel_pcb_type evalKernel_pcb; +#define PCB evalKernel_pcb + +/* Line -, eval-e.syn */ +#define SYNTAX_ERROR printf("%s in %s, line %d, column %d\n", \ + (PCB).error_message, TOKEN_NAMES[(PCB).error_frame_token], (PCB).line, (PCB).column) + + +#ifndef CONVERT_CASE +#define CONVERT_CASE(c) (c) +#endif +#ifndef TAB_SPACING +#define TAB_SPACING 8 +#endif + +#define ag_rp_1(k, x) (*locateVariable(k) = x) + +#define ag_rp_2(k, x) (*locateVariable(k) += x) + +#define ag_rp_3(k, x) (*locateVariable(k) -= x) + +#define ag_rp_4(k, x) (*locateVariable(k) *= x) + +#define ag_rp_5(k, x) (*locateVariable(k) /= x) + +#define ag_rp_6(c, x, y) (c?x:y) + +#define ag_rp_7(x, y) (x||y) + +#define ag_rp_8(x, y) (x&&y) + +#define ag_rp_9(x, y) (x==y) + +#define ag_rp_10(x, y) (x!=y) + +#define ag_rp_11(x, y) (x<y) + +#define ag_rp_12(x, y) (x<=y) + +#define ag_rp_13(x, y) (x>y) + +#define ag_rp_14(x, y) (x>=y) + +#define ag_rp_15(x, y) (x+y) + +#define ag_rp_16(x, y) (x-y) + +#define ag_rp_17(x, y) (x*y) + +#define ag_rp_18(x, y) (x/checkZero(y)) + +#define ag_rp_19(x, y) (pow(x,y)) + +#define ag_rp_20(k) (*locateVariable(k)) + +#define ag_rp_21(k, n) (callFunction(k,n)) + +#define ag_rp_22(x) (x) + +#define ag_rp_23(x) (-x) + +#define ag_rp_24(x) (x) + +#define ag_rp_25(x) (!x) + +#define ag_rp_26() (0) + +#define ag_rp_27(x) (pushArg(x), 1) + +#define ag_rp_28(k, x) (pushArg(x), k+1) + +#define ag_rp_29(x, e) (x*pow(10,e)) + +#define ag_rp_30(x, e) (x*pow(10,-e)) + +#define ag_rp_31(i, f) (i+f) + +#define ag_rp_32(f) (f) + +#define ag_rp_33(d) (d-'0') + +#define ag_rp_34(x, d) (10*x + d-'0') + +#define ag_rp_35(d) ((d-'0')/10.) + +#define ag_rp_36(d, f) ((d-'0' + f)/10.) + +#define ag_rp_37(d) (d-'0') + +#define ag_rp_38(x, d) (10*x + d-'0') + +#define ag_rp_39(c) (pushChar(c), 1) + +#define ag_rp_40(k, c) (pushChar(c), k+1) + + +#define READ_COUNTS +#define WRITE_COUNTS +#undef V +#define V(i,t) (*t (&(PCB).vs[(PCB).ssx + i])) +#undef VS +#define VS(i) (PCB).vs[(PCB).ssx + i] + +#ifndef GET_CONTEXT +#define GET_CONTEXT CONTEXT = (PCB).input_context +#endif + +typedef enum { + ag_action_1, + ag_action_2, + ag_action_3, + ag_action_4, + ag_action_5, + ag_action_6, + ag_action_7, + ag_action_8, + ag_action_9, + ag_action_10, + ag_action_11, + ag_action_12 +} ag_parser_action; + + +#ifndef NULL_VALUE_INITIALIZER +#define NULL_VALUE_INITIALIZER = { 0 } +#endif + +static evalKernel_vs_type const ag_null_value NULL_VALUE_INITIALIZER; + +static const unsigned char ag_rpx[] = { + 0, 0, 0, 0, 0, 0, 0, 1, 2, 3, 4, 5, 0, 6, 0, 7, 0, 8, + 0, 9, 10, 0, 11, 12, 13, 14, 0, 15, 16, 0, 17, 18, 0, 19, 0, 20, + 21, 22, 23, 24, 25, 26, 0, 27, 28, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 29, 30, 31, 0, 0, 0, 32, 33, 34, 35, 36, 37, 38, + 39, 40 +}; + +static const unsigned char ag_key_itt[] = { + 0 +}; + +static const unsigned short ag_key_pt[] = { +0 +}; + +static const unsigned char ag_key_ch[] = { + 0, 42, 47,255, 47,255, 42,255, 42, 61,255, 42, 47, 61,255, 33, 38, 42, + 43, 45, 47, 60, 61, 62,124,255, 42, 47,255, 33, 38, 42, 47, 60, 61, 62, + 124,255, 33, 38, 42, 60, 61, 62,124,255, 33, 38, 60, 61, 62,124,255, 33, + 38, 61,124,255, 38,124,255,124,255, 42, 61,255, 33, 38, 42, 43, 45, 47, + 60, 61, 62,124,255 +}; + +static const unsigned char ag_key_act[] = { + 0,0,0,4,2,4,3,4,0,0,4,0,0,0,4,3,3,2,3,3,2,3,3,3,3,4,0,0,4,3,3,3,2,3,3, + 3,3,4,3,3,3,3,3,3,3,4,3,3,3,3,3,3,4,3,3,3,3,4,3,3,4,3,4,0,0,4,3,3,2,3, + 3,3,3,3,3,3,4 +}; + +static const unsigned char ag_key_parm[] = { + 0, 46, 51, 0, 0, 0, 50, 0, 93, 77, 0, 46, 51, 78, 0, 84, 82, 0, + 75, 76, 0, 86, 83, 88, 81, 0, 46, 51, 0, 84, 82, 93, 0, 86, 83, 88, + 81, 0, 84, 82, 93, 86, 83, 88, 81, 0, 84, 82, 86, 83, 88, 81, 0, 84, + 82, 83, 81, 0, 82, 81, 0, 81, 0, 93, 77, 0, 84, 82, 0, 75, 76, 78, + 86, 83, 88, 81, 0 +}; + +static const unsigned char ag_key_jmp[] = { + 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 4, 8, + 6, 8, 11, 10, 12, 14, 16, 0, 0, 0, 0, 18, 20, 22, 26, 24, 26, 28, + 30, 0, 32, 34, 36, 38, 40, 42, 44, 0, 46, 48, 50, 52, 54, 56, 0, 58, + 60, 62, 64, 0, 66, 68, 0, 70, 0, 0, 0, 0, 72, 74, 63, 76, 78, 80, + 82, 84, 86, 88, 0 +}; + +static const unsigned char ag_key_index[] = { + 4, 0, 6, 15, 0, 0, 0, 6, 6, 0, 29, 29, 4, 4, 4, 4, 29, 0, + 0, 0, 0, 38, 46, 46, 46, 53, 58, 15, 61, 66, 0, 29, 29, 0, 38, 0, + 4, 0, 4, 0, 4, 0, 0, 0, 4, 0, 4, 0, 4, 0, 4, 0, 4, 0, + 4, 0, 4, 0, 4, 0, 4, 0, 0, 4, 0, 4, 0, 4, 0, 4, 0, 4, + 0, 4, 4, 0, 0, 0, 29, 46, 46, 46, 46, 46, 46, 46, 46, 53, 58, 0, + 0, 0, 29, 29, 4, 0, 0, 0 +}; + +static const unsigned char ag_key_ends[] = { +47,0, 61,0, 38,0, 61,0, 61,0, 61,0, 61,0, 61,0, 124,0, +61,0, 38,0, 42,0, 61,0, 61,0, 61,0, 124,0, 61,0, 38,0, 42,0, +61,0, 61,0, 61,0, 124,0, 61,0, 38,0, 61,0, 61,0, 61,0, 124,0, +61,0, 38,0, 61,0, 124,0, 38,0, 124,0, 124,0, 61,0, 38,0, +61,0, 61,0, 61,0, 61,0, 61,0, 61,0, 124,0, +}; +#define AG_TCV(x) (((int)(x) >= -1 && (int)(x) <= 255) ? ag_tcv[(x) + 1] : 0) + +static const unsigned char ag_tcv[] = { + 6, 6, 69, 69, 69, 69, 69, 69, 69, 69, 68, 55, 68, 68, 68, 69, 69, 69, + 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 68, 97, 69, + 69, 69, 69, 69, 69, 96, 95, 91, 89, 98, 90, 61, 92, 64, 64, 64, 64, 64, + 64, 64, 64, 64, 64, 79, 99, 85, 73, 87, 80, 69, 70, 70, 70, 70, 57, 70, + 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, + 70, 70, 69, 69, 69, 69, 70, 69, 70, 70, 70, 70, 57, 70, 70, 70, 70, 70, + 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 69, 69, + 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, + 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, + 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, + 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, + 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, + 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, + 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, + 69, 69, 69, 69, 69 +}; + +#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 = (evalKernel_token_type) (PCB).drt; + (PCB).ssx = (PCB).dssx; + (PCB).sn = (PCB).dsn; + (PCB).drt = -1; +} + + +static const unsigned char ag_tstt[] = { +99,98,97,96,90,89,70,68,64,61,57,55,51,46,6,0,1,71,72, +99,98,97,96,95,92,91,90,89,87,85,80,79,73,70,69,68,64,61,57,55,0,53,54, +99,98,97,96,95,92,91,90,89,87,85,80,79,73,70,69,68,64,61,57,55,50,0,48,49, +68,55,51,46,0,1, +99,98,97,96,90,89,70,64,61,57,6,0,2,3,4,5,7,8,10,16,19,21,23,26,31,32,33,34, + 37,39,42,56,60,74,94, +99,98,97,96,95,92,91,90,89,87,85,80,79,73,70,69,68,64,61,57,0, +55,0, +99,98,97,96,95,92,91,90,89,87,85,80,79,73,70,69,68,64,61,57,55,0, +50,0, +64,0,62, +99,98,95,93,92,91,90,89,88,87,86,85,84,83,82,81,80,79,68,64,61,57,55,51,46, + 6,0,63, +57,0, +97,96,90,89,70,68,64,61,57,55,51,46,0,1,71,72, +97,96,90,89,70,68,64,61,57,55,51,46,0,1,71,72, +97,96,90,89,70,68,64,61,57,55,51,46,0,1,71,72, +97,96,95,90,89,70,68,64,61,57,55,51,46,0,1,71,72, +99,98,95,93,92,91,90,89,88,87,86,85,84,83,82,81,80,79,68,55,51,46,6,0,1,71, + 72, +97,96,90,89,70,64,61,57,0,2,3,32,33,37,39,42,56,60,74,94, +97,96,90,89,70,64,61,57,0,2,3,32,33,37,39,42,56,60,74,94, +97,96,90,89,70,64,61,57,0,2,3,32,33,37,39,42,56,60,74,94, +97,96,90,89,70,64,61,57,0,2,3,7,10,16,19,21,23,26,31,32,33,34,37,39,42,56, + 60,74,94, +93,0,38, +92,91,0,35,36, +90,89,0,32,33, +88,87,86,85,0,27,28,29,30, +84,83,0,24,25, +82,0,22, +99,98,96,95,93,92,91,90,89,88,87,86,85,84,83,82,81,80,79,78,77,76,75,73,70, + 68,64,57,55,51,46,6,0,1,71,72, +81,80,0,17,20, +96,78,77,76,75,73,0,11,12,13,14,15,39, +99,98,6,0,44,67, +64,0,62, +64,0,62, +90,89,64,0,58, +96,0,39, +95,0,41, +97,96,90,89,70,68,64,61,57,55,51,46,0,1,71,72, +97,96,90,89,70,64,61,57,0,2,3,32,33,34,37,39,42,56,60,74,94, +97,96,90,89,70,68,64,61,57,55,51,46,0,1,71,72, +97,96,90,89,70,64,61,57,0,2,3,32,33,34,37,39,42,56,60,74,94, +97,96,90,89,70,68,64,61,57,55,51,46,0,1,71,72, +97,96,90,89,70,64,61,57,0,2,3,32,33,34,37,39,42,56,60,74,94, +97,96,90,89,70,64,61,57,0,2,3,31,32,33,34,37,39,42,56,60,74,94, +97,96,90,89,70,64,61,57,0,2,3,31,32,33,34,37,39,42,56,60,74,94, +97,96,90,89,70,68,64,61,57,55,51,46,0,1,71,72, +97,96,90,89,70,64,61,57,0,2,3,26,31,32,33,34,37,39,42,56,60,74,94, +97,96,90,89,70,68,64,61,57,55,51,46,0,1,71,72, +97,96,90,89,70,64,61,57,0,2,3,26,31,32,33,34,37,39,42,56,60,74,94, +97,96,90,89,70,68,64,61,57,55,51,46,0,1,71,72, +97,96,90,89,70,64,61,57,0,2,3,26,31,32,33,34,37,39,42,56,60,74,94, +97,96,90,89,70,68,64,61,57,55,51,46,0,1,71,72, +97,96,90,89,70,64,61,57,0,2,3,26,31,32,33,34,37,39,42,56,60,74,94, +97,96,90,89,70,68,64,61,57,55,51,46,0,1,71,72, +97,96,90,89,70,64,61,57,0,2,3,23,26,31,32,33,34,37,39,42,56,60,74,94, +97,96,90,89,70,68,64,61,57,55,51,46,0,1,71,72, +97,96,90,89,70,64,61,57,0,2,3,23,26,31,32,33,34,37,39,42,56,60,74,94, +97,96,90,89,70,68,64,61,57,55,51,46,0,1,71,72, +97,96,90,89,70,64,61,57,0,2,3,21,23,26,31,32,33,34,37,39,42,56,60,74,94, +97,96,90,89,70,68,64,61,57,55,51,46,0,1,71,72, +97,96,90,89,70,64,61,57,0,2,3,19,21,23,26,31,32,33,34,37,39,42,56,60,74,94, +97,96,90,89,70,68,64,61,57,55,51,46,0,1,71,72, +97,96,90,89,70,64,61,57,0,2,3,7,10,16,19,21,23,26,31,32,33,34,37,39,42,56, + 60,74,94, +97,96,95,90,89,70,64,61,57,0,2,3,7,10,16,19,21,23,26,31,32,33,34,37,39,40, + 42,43,56,60,74,94, +97,96,90,89,70,68,64,61,57,55,51,46,0,1,71,72, +97,96,90,89,70,64,61,57,0,2,3,7,10,16,19,21,23,26,31,32,33,34,37,39,42,56, + 60,74,94, +97,96,90,89,70,68,64,61,57,55,51,46,0,1,71,72, +97,96,90,89,70,64,61,57,0,2,3,7,10,16,19,21,23,26,31,32,33,34,37,39,42,56, + 60,74,94, +97,96,90,89,70,68,64,61,57,55,51,46,0,1,71,72, +97,96,90,89,70,64,61,57,0,2,3,7,10,16,19,21,23,26,31,32,33,34,37,39,42,56, + 60,74,94, +97,96,90,89,70,68,64,61,57,55,51,46,0,1,71,72, +97,96,90,89,70,64,61,57,0,2,3,7,10,16,19,21,23,26,31,32,33,34,37,39,42,56, + 60,74,94, +97,96,90,89,70,68,64,61,57,55,51,46,0,1,71,72, +97,96,90,89,70,64,61,57,0,2,3,7,10,16,19,21,23,26,31,32,33,34,37,39,42,56, + 60,74,94, +99,98,97,96,90,89,70,68,64,61,57,55,51,46,6,0,1,71,72, +99,98,97,96,90,89,70,68,64,61,57,55,51,46,6,0,1,71,72, +99,98,97,96,90,89,70,64,61,57,6,0,2,3,7,8,10,16,19,21,23,26,31,32,33,34,37, + 39,42,56,60,74,94, +64,0,59, +64,0,59, +99,98,95,93,92,91,90,89,88,87,86,85,84,83,82,81,80,79,68,55,51,46,6,0,1,71, + 72, +92,91,0,35,36, +92,91,0,35,36, +90,89,0,32,33, +90,89,0,32,33, +90,89,0,32,33, +90,89,0,32,33, +88,87,86,85,0,27,28,29,30, +88,87,86,85,0,27,28,29,30, +84,83,0,24,25, +82,0,22, +79,0,18, +98,0,44, +95,0,41, +64,0, +64,0, +97,96,90,89,70,68,64,61,57,55,51,46,0,1,71,72, +97,96,90,89,70,64,61,57,0,2,3,10,16,19,21,23,26,31,32,33,34,37,39,42,56,60, + 74,94, +97,96,90,89,70,64,61,57,0,2,3,7,10,16,19,21,23,26,31,32,33,34,37,39,42,56, + 60,74,94, + 0 +}; + + +static unsigned const char ag_astt[1500] = { + 8,8,8,8,8,8,8,1,8,8,8,1,1,1,8,7,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, + 1,1,8,7,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,8,7,1,1,9,9,1,1,5,3, + 5,5,1,1,1,1,2,2,1,2,5,7,1,1,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,9,9, + 9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,5,3,7,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9, + 9,9,9,9,9,5,3,7,1,7,2,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,10,1,5,5,5,5,5, + 7,3,1,5,5,5,5,5,5,1,5,5,5,1,1,1,7,1,1,3,5,5,5,5,5,1,5,5,5,1,1,1,7,1,1,3,5, + 5,5,5,5,1,5,5,5,1,1,1,7,1,1,3,5,5,5,5,5,5,1,5,5,5,1,1,1,7,1,1,3,5,5,5,5,5, + 5,5,5,5,5,5,5,5,5,5,5,5,5,1,1,1,1,5,7,1,1,3,1,1,1,1,2,2,1,2,7,2,1,1,1,2,1, + 1,1,1,1,1,1,1,1,1,2,2,1,2,7,2,1,1,1,2,1,1,1,1,1,1,1,1,1,1,2,2,1,2,7,2,1,1, + 1,2,1,1,1,1,1,1,1,1,1,1,2,2,1,2,7,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, + 1,5,1,1,1,5,1,1,1,1,5,1,1,1,1,1,1,5,1,1,1,1,1,1,5,1,1,1,5,1,5,5,5,5,5,5,5, + 5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,10,1,10,10,1,1,1,5,7,1,1,3,1,1,5,1,1,1,1, + 1,1,1,1,4,1,1,1,1,1,1,1,1,3,7,1,1,1,4,2,1,5,2,1,1,8,7,1,1,4,1,1,7,2,5,5,5, + 5,5,1,5,5,5,1,1,1,7,1,1,3,1,1,1,1,2,2,1,2,7,1,1,1,1,2,1,1,1,1,1,1,1,5,5,5, + 5,5,1,5,5,5,1,1,1,7,1,1,3,1,1,1,1,2,2,1,2,7,1,1,1,1,2,1,1,1,1,1,1,1,5,5,5, + 5,5,1,5,5,5,1,1,1,7,1,1,3,1,1,1,1,2,2,1,2,7,1,1,1,1,2,1,1,1,1,1,1,1,1,1,1, + 1,2,2,1,2,7,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,2,2,1,2,7,1,1,1,1,1,1,1,1,1, + 1,1,1,1,5,5,5,5,5,1,5,5,5,1,1,1,7,1,1,3,1,1,1,1,2,2,1,2,7,1,1,1,1,1,1,1,1, + 1,1,1,1,1,1,5,5,5,5,5,1,5,5,5,1,1,1,7,1,1,3,1,1,1,1,2,2,1,2,7,1,1,1,1,1,1, + 1,1,1,1,1,1,1,1,5,5,5,5,5,1,5,5,5,1,1,1,7,1,1,3,1,1,1,1,2,2,1,2,7,1,1,1,1, + 1,1,1,1,1,1,1,1,1,1,5,5,5,5,5,1,5,5,5,1,1,1,7,1,1,3,1,1,1,1,2,2,1,2,7,1,1, + 1,1,1,1,1,1,1,1,1,1,1,1,5,5,5,5,5,1,5,5,5,1,1,1,7,1,1,3,1,1,1,1,2,2,1,2,7, + 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,5,5,5,5,5,1,5,5,5,1,1,1,7,1,1,3,1,1,1,1,2,2, + 1,2,7,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,5,5,5,5,5,1,5,5,5,1,1,1,7,1,1,3,1,1,1, + 1,2,2,1,2,7,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,5,5,5,5,5,1,5,5,5,1,1,1,7,1,1, + 3,1,1,1,1,2,2,1,2,7,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,5,5,5,5,5,1,5,5,5,1, + 1,1,7,1,1,3,1,1,1,1,2,2,1,2,7,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, + 4,1,1,2,2,1,2,7,1,1,2,2,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,5,5,5,5,5,1,5, + 5,5,1,1,1,7,1,1,3,1,1,1,1,2,2,1,2,7,1,1,2,2,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, + 1,5,5,5,5,5,1,5,5,5,1,1,1,7,1,1,3,1,1,1,1,2,2,1,2,7,1,1,2,2,1,1,1,1,1,1,1, + 1,1,1,1,1,1,1,1,1,5,5,5,5,5,1,5,5,5,1,1,1,7,1,1,3,1,1,1,1,2,2,1,2,7,1,1,2, + 2,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,5,5,5,5,5,1,5,5,5,1,1,1,7,1,1,3,1,1,1,1, + 2,2,1,2,7,1,1,2,2,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,5,5,5,5,5,1,5,5,5,1,1,1, + 7,1,1,3,1,1,1,1,2,2,1,2,7,1,1,2,2,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,5,5,5,5, + 5,5,5,1,5,5,5,1,1,1,5,7,1,1,3,5,5,5,5,5,5,5,1,5,5,5,1,1,1,5,7,1,1,3,5,5,1, + 1,1,1,2,2,1,2,5,7,1,1,3,3,3,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,2,7,1,2,7,1,5, + 5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,1,1,1,1,5,7,1,1,3,1,1,4,1,1,1,1,4,1,1,1, + 1,4,1,1,1,1,4,1,1,1,1,4,1,1,1,1,4,1,1,1,1,1,1,4,1,1,1,1,1,1,1,1,4,1,1,1,1, + 1,1,4,1,1,1,4,1,1,7,1,1,5,1,1,7,2,10,4,10,4,5,5,5,5,5,1,5,5,5,1,1,1,7,1,1, + 3,1,1,1,1,2,2,1,2,7,1,1,2,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,2,2,1,2, + 7,1,1,2,2,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,11 +}; + + +static const unsigned char ag_pstt[] = { +4,4,4,4,4,4,4,3,4,4,4,3,1,2,4,0,3,3,4, +5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,6,1,5,6, +7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,8,2,7,8, +125,125,1,2,127,125, +2,2,12,15,14,13,72,66,9,72,2,4,21,29,0,30,30,30,30,28,26,25,24,23,22,18,19, + 22,21,20,17,11,10,27,16, +52,52,52,52,52,52,52,52,52,52,52,52,52,52,52,52,52,52,52,52,54, +55,6, +47,47,47,47,47,47,47,47,47,47,47,47,47,47,47,47,47,47,47,47,47,49, +50,8, +31,9,65, +62,62,62,62,62,62,62,62,62,62,62,62,62,62,62,62,62,62,62,67,32,62,62,62,62, + 62,10,64, +33,56, +126,126,126,126,126,3,126,126,126,3,1,2,12,3,3,152, +126,126,126,126,126,3,126,126,126,3,1,2,13,3,3,144, +126,126,126,126,126,3,126,126,126,3,1,2,14,3,3,145, +126,126,126,126,126,126,3,126,126,126,3,1,2,15,3,3,151, +126,126,126,126,126,126,126,126,126,126,126,126,126,126,126,126,126,126,3,3, + 1,2,126,16,3,3,149, +12,15,14,13,72,66,9,72,17,40,34,18,19,40,20,17,11,10,27,16, +12,15,14,13,72,66,9,72,18,39,34,18,19,39,20,17,11,10,27,16, +12,15,14,13,72,66,9,72,19,38,34,18,19,38,20,17,11,10,27,16, +12,15,14,13,72,66,9,72,20,21,29,35,35,28,26,25,24,23,22,18,19,22,21,20,17, + 11,10,27,16, +36,32,37, +38,40,26,41,39, +14,13,21,43,42, +44,46,48,50,18,51,49,47,45, +52,54,16,55,53, +56,14,57, +126,126,126,126,126,126,126,126,126,126,126,126,126,126,126,126,126,126,126, + 126,126,126,126,126,73,3,73,73,3,1,2,126,27,3,3,129, +58,60,12,61,59, +15,63,65,67,69,71,35,72,70,68,66,64,62, +73,74,1,30,75,75, +31,68,69, +31,63,61, +76,77,77,33,77, +15,35,62, +78,35,37, +126,126,126,126,126,3,126,126,126,3,1,2,36,3,3,148, +12,15,14,13,72,66,9,72,37,21,34,18,19,33,21,20,17,11,10,27,16, +126,126,126,126,126,3,126,126,126,3,1,2,38,3,3,147, +12,15,14,13,72,66,9,72,39,21,34,18,19,31,21,20,17,11,10,27,16, +126,126,126,126,126,3,126,126,126,3,1,2,40,3,3,146, +12,15,14,13,72,66,9,72,41,21,34,18,19,30,21,20,17,11,10,27,16, +12,15,14,13,72,66,9,72,42,21,34,79,18,19,79,21,20,17,11,10,27,16, +12,15,14,13,72,66,9,72,43,21,34,80,18,19,80,21,20,17,11,10,27,16, +126,126,126,126,126,3,126,126,126,3,1,2,44,3,3,143, +12,15,14,13,72,66,9,72,45,21,34,81,22,18,19,22,21,20,17,11,10,27,16, +126,126,126,126,126,3,126,126,126,3,1,2,46,3,3,142, +12,15,14,13,72,66,9,72,47,21,34,82,22,18,19,22,21,20,17,11,10,27,16, +126,126,126,126,126,3,126,126,126,3,1,2,48,3,3,141, +12,15,14,13,72,66,9,72,49,21,34,83,22,18,19,22,21,20,17,11,10,27,16, +126,126,126,126,126,3,126,126,126,3,1,2,50,3,3,140, +12,15,14,13,72,66,9,72,51,21,34,84,22,18,19,22,21,20,17,11,10,27,16, +126,126,126,126,126,3,126,126,126,3,1,2,52,3,3,139, +12,15,14,13,72,66,9,72,53,21,34,85,23,22,18,19,22,21,20,17,11,10,27,16, +126,126,126,126,126,3,126,126,126,3,1,2,54,3,3,138, +12,15,14,13,72,66,9,72,55,21,34,86,23,22,18,19,22,21,20,17,11,10,27,16, +126,126,126,126,126,3,126,126,126,3,1,2,56,3,3,137, +12,15,14,13,72,66,9,72,57,21,34,87,24,23,22,18,19,22,21,20,17,11,10,27,16, +126,126,126,126,126,3,126,126,126,3,1,2,58,3,3,136, +12,15,14,13,72,66,9,72,59,21,34,88,25,24,23,22,18,19,22,21,20,17,11,10,27, + 16, +126,126,126,126,126,3,126,126,126,3,1,2,60,3,3,135, +12,15,14,13,72,66,9,72,61,21,29,89,89,28,26,25,24,23,22,18,19,22,21,20,17, + 11,10,27,16, +12,15,41,14,13,72,66,9,72,62,21,29,43,43,28,26,25,24,23,22,18,19,22,21,20, + 91,17,90,11,10,27,16, +126,126,126,126,126,3,126,126,126,3,1,2,63,3,3,133, +12,15,14,13,72,66,9,72,64,21,29,11,11,28,26,25,24,23,22,18,19,22,21,20,17, + 11,10,27,16, +126,126,126,126,126,3,126,126,126,3,1,2,65,3,3,132, +12,15,14,13,72,66,9,72,66,21,29,10,10,28,26,25,24,23,22,18,19,22,21,20,17, + 11,10,27,16, +126,126,126,126,126,3,126,126,126,3,1,2,67,3,3,131, +12,15,14,13,72,66,9,72,68,21,29,9,9,28,26,25,24,23,22,18,19,22,21,20,17,11, + 10,27,16, +126,126,126,126,126,3,126,126,126,3,1,2,69,3,3,130, +12,15,14,13,72,66,9,72,70,21,29,8,8,28,26,25,24,23,22,18,19,22,21,20,17,11, + 10,27,16, +126,126,126,126,126,3,126,126,126,3,1,2,71,3,3,128, +12,15,14,13,72,66,9,72,72,21,29,7,7,28,26,25,24,23,22,18,19,22,21,20,17,11, + 10,27,16, +126,126,126,126,126,126,126,3,126,126,126,3,1,2,126,73,3,3,154, +126,126,126,126,126,126,126,3,126,126,126,3,1,2,126,74,3,3,153, +2,2,12,15,14,13,72,66,9,72,2,75,21,29,5,5,5,28,26,25,24,23,22,18,19,22,21, + 20,17,11,10,27,16, +70,76,92, +70,77,93, +126,126,126,126,126,126,126,126,126,126,126,126,126,126,126,126,126,126,3,3, + 1,2,126,78,3,3,150, +38,40,28,41,39, +38,40,27,41,39, +14,13,25,43,42, +14,13,24,43,42, +14,13,23,43,42, +14,13,22,43,42, +44,46,48,50,20,51,49,47,45, +44,46,48,50,19,51,49,47,45, +52,54,17,55,53, +56,15,57, +94,89,95, +74,42,96, +78,91,36, +71,60, +71,59, +126,126,126,126,126,3,126,126,126,3,1,2,94,3,3,134, +12,15,14,13,72,66,9,72,95,21,34,13,28,26,25,24,23,22,18,19,22,21,20,17,11, + 10,27,16, +12,15,14,13,72,66,9,72,96,21,29,44,44,28,26,25,24,23,22,18,19,22,21,20,17, + 11,10,27,16, + 0 +}; + + +static const unsigned short ag_sbt[] = { + 0, 19, 43, 68, 74, 109, 130, 132, 154, 156, 159, 187, 189, 205, + 221, 237, 254, 281, 301, 321, 341, 370, 373, 378, 383, 392, 397, 400, + 436, 441, 454, 460, 463, 466, 471, 474, 477, 493, 514, 530, 551, 567, + 588, 610, 632, 648, 671, 687, 710, 726, 749, 765, 788, 804, 828, 844, + 868, 884, 909, 925, 951, 967, 996,1028,1044,1073,1089,1118,1134,1163, + 1179,1208,1224,1253,1272,1291,1324,1327,1330,1357,1362,1367,1372,1377, + 1382,1387,1396,1405,1410,1413,1416,1419,1422,1424,1426,1442,1470,1499 +}; + + +static const unsigned short ag_sbe[] = { + 15, 40, 65, 72, 85, 129, 131, 153, 155, 157, 185, 188, 201, 217, + 233, 250, 277, 289, 309, 329, 349, 371, 375, 380, 387, 394, 398, 432, + 438, 447, 457, 461, 464, 469, 472, 475, 489, 501, 526, 538, 563, 575, + 596, 618, 644, 656, 683, 695, 722, 734, 761, 773, 800, 812, 840, 852, + 880, 892, 921, 933, 963, 975,1005,1040,1052,1085,1097,1130,1142,1175, + 1187,1220,1232,1268,1287,1302,1325,1328,1353,1359,1364,1369,1374,1379, + 1384,1391,1400,1407,1411,1414,1417,1420,1423,1425,1438,1450,1478,1499 +}; + + +static const unsigned char ag_fl[] = { + 2,2,0,1,1,3,1,3,3,3,3,3,1,5,1,3,1,3,1,3,3,1,3,3,3,3,1,3,3,1,3,3,1,3,1, + 1,4,3,2,2,2,0,1,1,3,1,1,2,0,1,3,1,2,0,1,3,1,0,1,4,4,3,0,1,2,2,1,2,1,2, + 1,2,1,2,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, + 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,2,0,1,2,2,2,2,2,2,2,2,2,2,2,2, + 2,2,2,2,2,2,2,2,2,2,2,2,2,2,2 +}; + +static const unsigned char ag_ptt[] = { + 0, 4, 8, 8, 5, 5, 7, 7, 7, 7, 7, 7, 10, 10, 16, 16, 19, 19, + 21, 21, 21, 23, 23, 23, 23, 23, 26, 26, 26, 31, 31, 31, 34, 34, 37, 37, + 37, 37, 37, 37, 37, 40, 40, 43, 43, 1, 48, 48, 49, 49, 1, 53, 53, 54, + 54, 1, 94, 58, 58, 94, 94, 56, 63, 63, 56, 56, 60, 60, 62, 62, 59, 59, + 74, 74, 9, 9, 45, 45, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 52, 52, 52, 52, 52, 52, 52, 52, 52, + 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 65, 65, 66, 66, 66, 71, 71, + 72, 72, 11, 3, 12, 13, 14, 15, 18, 17, 20, 22, 24, 25, 27, 28, 29, 30, + 32, 33, 35, 36, 38, 2, 41, 39, 42, 44, 67 +}; + + +static void ag_ra(void) +{ + switch(ag_rpx[(PCB).ag_ap]) { + case 1: V(0,(double *)) = ag_rp_1(V(0,(int *)), V(2,(double *))); break; + case 2: V(0,(double *)) = ag_rp_2(V(0,(int *)), V(2,(double *))); break; + case 3: V(0,(double *)) = ag_rp_3(V(0,(int *)), V(2,(double *))); break; + case 4: V(0,(double *)) = ag_rp_4(V(0,(int *)), V(2,(double *))); break; + case 5: V(0,(double *)) = ag_rp_5(V(0,(int *)), V(2,(double *))); break; + case 6: V(0,(double *)) = ag_rp_6(V(0,(double *)), V(2,(double *)), V(4,(double *))); break; + case 7: V(0,(double *)) = ag_rp_7(V(0,(double *)), V(2,(double *))); break; + case 8: V(0,(double *)) = ag_rp_8(V(0,(double *)), V(2,(double *))); break; + case 9: V(0,(double *)) = ag_rp_9(V(0,(double *)), V(2,(double *))); break; + case 10: V(0,(double *)) = ag_rp_10(V(0,(double *)), V(2,(double *))); break; + case 11: V(0,(double *)) = ag_rp_11(V(0,(double *)), V(2,(double *))); break; + case 12: V(0,(double *)) = ag_rp_12(V(0,(double *)), V(2,(double *))); break; + case 13: V(0,(double *)) = ag_rp_13(V(0,(double *)), V(2,(double *))); break; + case 14: V(0,(double *)) = ag_rp_14(V(0,(double *)), V(2,(double *))); break; + case 15: V(0,(double *)) = ag_rp_15(V(0,(double *)), V(2,(double *))); break; + case 16: V(0,(double *)) = ag_rp_16(V(0,(double *)), V(2,(double *))); break; + case 17: V(0,(double *)) = ag_rp_17(V(0,(double *)), V(2,(double *))); break; + case 18: V(0,(double *)) = ag_rp_18(V(0,(double *)), V(2,(double *))); break; + case 19: V(0,(double *)) = ag_rp_19(V(0,(double *)), V(2,(double *))); break; + case 20: V(0,(double *)) = ag_rp_20(V(0,(int *))); break; + case 21: V(0,(double *)) = ag_rp_21(V(0,(int *)), V(2,(int *))); break; + case 22: V(0,(double *)) = ag_rp_22(V(1,(double *))); break; + case 23: V(0,(double *)) = ag_rp_23(V(1,(double *))); break; + case 24: V(0,(double *)) = ag_rp_24(V(1,(double *))); break; + case 25: V(0,(double *)) = ag_rp_25(V(1,(double *))); break; + case 26: V(0,(int *)) = ag_rp_26(); break; + case 27: V(0,(int *)) = ag_rp_27(V(0,(double *))); break; + case 28: V(0,(int *)) = ag_rp_28(V(0,(int *)), V(2,(double *))); break; + case 29: V(0,(double *)) = ag_rp_29(V(0,(double *)), V(3,(int *))); break; + case 30: V(0,(double *)) = ag_rp_30(V(0,(double *)), V(3,(int *))); break; + case 31: V(0,(double *)) = ag_rp_31(V(0,(double *)), V(2,(double *))); break; + case 32: V(0,(double *)) = ag_rp_32(V(1,(double *))); break; + case 33: V(0,(double *)) = ag_rp_33(V(0,(int *))); break; + case 34: V(0,(double *)) = ag_rp_34(V(0,(double *)), V(1,(int *))); break; + case 35: V(0,(double *)) = ag_rp_35(V(0,(int *))); break; + case 36: V(0,(double *)) = ag_rp_36(V(0,(int *)), V(1,(double *))); break; + case 37: V(0,(int *)) = ag_rp_37(V(0,(int *))); break; + case 38: V(0,(int *)) = ag_rp_38(V(0,(int *)), V(1,(int *))); break; + case 39: V(0,(int *)) = ag_rp_39(V(0,(int *))); break; + case 40: V(0,(int *)) = ag_rp_40(V(0,(int *)), V(1,(int *))); break; + } +} + +#define TOKEN_NAMES evalKernel_token_names +const char *const evalKernel_token_names[100] = { + "input string", + "white space", + "real", + "name", + "input string", + "expressions", + "eof", + "expression", + "", + "", + "conditional expression", + "'='", + "\"+=\"", + "\"-=\"", + "\"*=\"", + "\"/=\"", + "logical or expression", + "'\\?'", + "':'", + "logical and expression", + "\"||\"", + "equality expression", + "\"&&\"", + "relational expression", + "\"==\"", + "\"!=\"", + "additive expression", + "'<'", + "\"<=\"", + "'>'", + "\">=\"", + "multiplicative expression", + "'+'", + "'-'", + "factor", + "'*'", + "'/'", + "primary", + "\"**\"", + "'('", + "arguments", + "')'", + "'!'", + "argument list", + "','", + "", + "\"/*\"", + "", + "", + "", + "\"*/\"", + "\"//\"", + "", + "", + "", + "'\\n'", + "simple real", + "", + "", + "exponent", + "integer part", + "'.'", + "fraction part", + "", + "digit", + "letter", + "", + "", + "", + "", + "", + "", + "", + "'='", + "name", + "\"+=\"", + "\"-=\"", + "\"*=\"", + "\"/=\"", + "':'", + "'\\?'", + "\"||\"", + "\"&&\"", + "\"==\"", + "\"!=\"", + "'<'", + "\"<=\"", + "'>'", + "\">=\"", + "'+'", + "'-'", + "'*'", + "'/'", + "\"**\"", + "real", + "')'", + "'('", + "'!'", + "','", + "", + +}; + + +static const unsigned char ag_ctn[] = { + 0,0, 1,1, 1,1, 0,0, 0,0, 0,0, 1,2, 0,0, 1,2, 56,1, 56,1, 94,1, + 37,1, 0,0, 0,0, 0,0, 37,1, 37,1, 37,1, 37,1, 37,1, 34,1, 31,1, 26,1, + 23,1, 21,1, 19,1, 37,1, 10,1, 7,1, 0,0, 62,1, 56,2, 94,2, 37,1, 37,2, + 0,0, 34,2, 0,0, 31,2, 0,0, 31,2, 26,2, 26,2, 0,0, 23,2, 0,0, 23,2, + 0,0, 23,2, 0,0, 23,2, 0,0, 21,2, 0,0, 21,2, 0,0, 19,2, 0,0, 16,2, + 0,0, 10,2, 37,2, 0,0, 7,2, 0,0, 7,2, 0,0, 7,2, 0,0, 7,2, 0,0, + 7,2, 9,1, 0,0, 5,2, 94,3, 94,3, 0,0, 31,1, 31,1, 26,1, 26,1, 26,1, + 26,1, 23,1, 23,1, 21,1, 19,1, 10,3, 43,1, 37,3, 59,1, 59,1, 0,0, 10,4, + 43,2 +}; + +#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; + + +{ + int ag_sx, ag_t; + + ag_sx = (PCB).ssx; + (PCB).ss[ag_sx] = (PCB).sn; + do { + while (ag_sx && ag_ctn[2*(ag_snd = (PCB).ss[ag_sx])] == 0) ag_sx--; + if (ag_sx) { + ag_t = ag_ctn[2*ag_snd]; + ag_sx -= ag_ctn[2*ag_snd +1]; + ag_snd = (PCB).ss[ag_sx]; + } + else { + ag_snd = 0; + ag_t = ag_ptt[0]; + } + } while (ag_sx && *TOKEN_NAMES[ag_t]==0); + if (*TOKEN_NAMES[ag_t] == 0) ag_t = 0; + (PCB).error_frame_ssx = ag_sx; + (PCB).error_frame_token = (evalKernel_token_type) ag_t; +} + + +} +static int ag_action_1_r_proc(void); +static int ag_action_2_r_proc(void); +static int ag_action_3_r_proc(void); +static int ag_action_4_r_proc(void); +static int ag_action_1_s_proc(void); +static int ag_action_3_s_proc(void); +static int ag_action_1_proc(void); +static int ag_action_2_proc(void); +static int ag_action_3_proc(void); +static int ag_action_4_proc(void); +static int ag_action_5_proc(void); +static int ag_action_6_proc(void); +static int ag_action_7_proc(void); +static int ag_action_8_proc(void); +static int ag_action_9_proc(void); +static int ag_action_10_proc(void); +static int ag_action_11_proc(void); +static int ag_action_12_proc(void); + + +static int (*const ag_r_procs_scan[])(void) = { + ag_action_1_r_proc, + ag_action_2_r_proc, + ag_action_3_r_proc, + ag_action_4_r_proc +}; + +static int (*const ag_s_procs_scan[])(void) = { + ag_action_1_s_proc, + ag_action_2_r_proc, + ag_action_3_s_proc, + ag_action_4_r_proc +}; + +static int (*const ag_gt_procs_scan[])(void) = { + ag_action_1_proc, + ag_action_2_proc, + ag_action_3_proc, + ag_action_4_proc, + ag_action_5_proc, + ag_action_6_proc, + ag_action_7_proc, + ag_action_8_proc, + ag_action_9_proc, + ag_action_10_proc, + ag_action_11_proc, + ag_action_12_proc +}; + + +static int ag_rns(int ag_t, int *ag_sx, int ag_snd) { + while (1) { + int ag_act, ag_k = ag_sbt[ag_snd], ag_lim = ag_sbt[ag_snd+1]; + int ag_p; + + while (ag_k < ag_lim && ag_tstt[ag_k] != ag_t) ag_k++; + if (ag_k == ag_lim) break; + ag_act = ag_astt[ag_k]; + ag_p = ag_pstt[ag_k]; + if (ag_act == ag_action_2) return ag_p; + if (ag_act == ag_action_10 || ag_act == ag_action_11) { + (*ag_sx)--; + return ag_snd; + } + if (ag_act != ag_action_3 && + ag_act != ag_action_4) break; + *ag_sx -= (ag_fl[ag_p] - 1); + ag_snd = (PCB).ss[*ag_sx]; + ag_t = ag_ptt[ag_p]; + } + return 0; +} + +static int ag_jns(int ag_t) { + int ag_k; + + ag_k = ag_sbt[(PCB).sn]; + while (ag_tstt[ag_k] != ag_t && ag_tstt[ag_k]) ag_k++; + while (1) { + int ag_p = ag_pstt[ag_k]; + int ag_sd; + + switch (ag_astt[ag_k]) { + case ag_action_2: + (PCB).ss[(PCB).ssx] = (PCB).sn; + return ag_p; + case ag_action_10: + case ag_action_11: + return (PCB).ss[(PCB).ssx--]; + case ag_action_9: + (PCB).ss[(PCB).ssx] = (PCB).sn; + (PCB).ssx++; + (PCB).sn = ag_p; + ag_k = ag_sbt[(PCB).sn]; + while (ag_tstt[ag_k] != ag_t && ag_tstt[ag_k]) ag_k++; + continue; + case ag_action_3: + case ag_action_4: + ag_sd = ag_fl[ag_p] - 1; + if (ag_sd) (PCB).sn = (PCB).ss[(PCB).ssx -= ag_sd]; + else (PCB).ss[(PCB).ssx] = (PCB).sn; + ag_t = ag_ptt[ag_p]; + ag_k = ag_sbt[(PCB).sn+1]; + while (ag_tstt[--ag_k] != ag_t); + continue; + case ag_action_5: + case ag_action_6: + if (ag_fl[ag_p]) break; + (PCB).sn = ag_rns(ag_ptt[ag_p],&(PCB).ssx, (PCB).sn); + (PCB).ss[++(PCB).ssx] = (PCB).sn; + ag_k = ag_sbt[(PCB).sn]; + while (ag_tstt[ag_k] != ag_t && ag_tstt[ag_k]) ag_k++; + continue; + } + break; + } + return 0; +} + + +static int ag_atx(int ag_t, int *ag_sx, int ag_snd) { + int ag_k, ag_f; + int ag_save_btsx = (PCB).btsx; + int ag_flag = 1; + + while (1) { + int ag_a; + + (PCB).bts[128 - ++(PCB).btsx] = *ag_sx; + (PCB).ss[128 - (PCB).btsx] = (PCB).ss[*ag_sx]; + (PCB).ss[*ag_sx] = ag_snd; + ag_k = ag_sbt[ag_snd]; + while (ag_tstt[ag_k] != ag_t && ag_tstt[ag_k]) ag_k++; + ag_a = ag_astt[ag_k]; + if (ag_a == ag_action_2 || + ag_a == ag_action_3 || + ag_a == ag_action_10 || + ag_a == ag_action_11 || + ag_a == ag_action_1 || + ag_a == ag_action_4) break; + if ((ag_a == ag_action_5 || + ag_a == ag_action_6) && + (ag_k = ag_fl[ag_f = ag_pstt[ag_k]]) == 0) { + ag_snd = ag_rns(ag_ptt[ag_f],ag_sx, (PCB).ss[*ag_sx]); + (*ag_sx)++; + continue; + } + if (ag_a == ag_action_9) { + ag_snd = ag_pstt[ag_k]; + (*ag_sx)++; + continue; + } + ag_flag = 0; + break; + } + while ((PCB).btsx > ag_save_btsx) { + *ag_sx = (PCB).bts[128 - (PCB).btsx]; + (PCB).ss[*ag_sx] = (PCB).ss[128 - (PCB).btsx--]; + } + return ag_flag; +} + +static int ag_tst_tkn(void) { + int ag_rk, ag_sx, ag_snd; + + for (ag_rk = 0; ag_rk < (PCB).ag_lrss; ag_rk += 2) { + ag_sx = (PCB).ag_rss[ag_rk]; + if (ag_sx > (PCB).ssx) continue; + ag_snd = (PCB).ag_rss[ag_rk + 1]; + if (ag_sx > (PCB).ag_min_depth) continue; + if (ag_atx((PCB).token_number, &ag_sx, ag_snd)) break; + } + return ag_rk; +} + +static void ag_set_error_procs(void); + +static void ag_auto_resynch(void) { + int ag_sx; + (PCB).ss[(PCB).ssx] = (PCB).sn; + if ((PCB).ag_error_depth && (PCB).ag_min_depth >= (PCB).ag_error_depth) { + (PCB).ssx = (PCB).ag_error_depth; + (PCB).sn = (PCB).ss[(PCB).ssx]; + } + else { + ag_diagnose(); + SYNTAX_ERROR; + if ((PCB).exit_flag != AG_RUNNING_CODE) return; + (PCB).ag_error_depth = (PCB).ag_min_depth = 0; + (PCB).ag_lrss = 0; + (PCB).ss[ag_sx = (PCB).ssx] = (PCB).sn; + (PCB).ag_min_depth = (PCB).ag_rss[(PCB).ag_lrss++] = ag_sx; + (PCB).ag_rss[(PCB).ag_lrss++] = (PCB).sn; + while (ag_sx && (PCB).ag_lrss < 2*128) { + int ag_t = 0, ag_x, ag_s, ag_sxs = ag_sx; + + while (ag_sx && (ag_t = ag_ctn[2*(PCB).sn]) == 0) (PCB).sn = (PCB).ss[--ag_sx]; + if (ag_t) (PCB).sn = (PCB).ss[ag_sx -= ag_ctn[2*(PCB).sn +1]]; + else { + if (ag_sx == 0) (PCB).sn = 0; + ag_t = ag_ptt[0]; + } + if ((ag_s = ag_rns(ag_t, &ag_sx, (PCB).sn)) == 0) break; + for (ag_x = 0; ag_x < (PCB).ag_lrss; ag_x += 2) + if ((PCB).ag_rss[ag_x] == ag_sx + 1 && (PCB).ag_rss[ag_x+1] == ag_s) break; + if (ag_x == (PCB).ag_lrss) { + (PCB).ag_rss[(PCB).ag_lrss++] = ++ag_sx; + (PCB).ag_rss[(PCB).ag_lrss++] = (PCB).sn = ag_s; + } + else if (ag_sx >= ag_sxs) ag_sx--; + } + ag_set_error_procs(); + } + (PCB).ssx++; + (PCB).sn = 97; + (PCB).ag_rk1 = (PCB).ag_lrss; + return; +} + +static int ag_action_12_proc(void) { + int ag_k, ag_rk; + + (PCB).ssx--; + if ((PCB).ag_rk1 == (PCB).ag_lrss) { + (PCB).ag_rk1 = ag_tst_tkn(); + (PCB).ssx++; + if ((PCB).token_number == 6) + {(PCB).exit_flag = AG_SYNTAX_ERROR_CODE; return 0;} + (PCB).ag_tk1 = (PCB).token_number; + ag_track(); + return 0; + } + ag_rk = ag_tst_tkn(); + if (ag_rk < (PCB).ag_rk1) { + ag_k = 0; + ag_track(); + } + else { + ag_k = 1; + ag_rk = (PCB).ag_rk1; + (PCB).token_number = (evalKernel_token_type) (PCB).ag_tk1; + (PCB).rx = 0; + } + (PCB).ag_min_depth = (PCB).ssx = (PCB).ag_rss[ag_rk++]; + (PCB).sn = (PCB).ss[(PCB).ssx] = (PCB).ag_rss[ag_rk]; + (PCB).sn = ag_jns((PCB).token_number); + if ((PCB).ag_error_depth == 0 || (PCB).ag_error_depth > (PCB).ssx) + (PCB).ag_error_depth = (PCB).ssx; + if (++(PCB).ssx >= 128) { + (PCB).exit_flag = AG_STACK_ERROR_CODE; + PARSER_STACK_OVERFLOW; + return 0; + } + (PCB).ss[(PCB).ssx] = (PCB).sn; + (PCB).ag_tmp_depth = (PCB).ag_min_depth; + return ag_k; +} + + +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 = (evalKernel_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 = (evalKernel_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 = (evalKernel_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 = (evalKernel_token_type) ag_ptt[(PCB).ag_ap]; + (PCB).btsx = 0, (PCB).drt = -1; + (*(int *) &(PCB).vs[(PCB).ssx]) = *(PCB).lab; + if (ag_sd) (PCB).sn = (PCB).ss[(PCB).ssx -= ag_sd]; + else (PCB).ss[(PCB).ssx] = (PCB).sn; + ag_track(); + while ((PCB).exit_flag == AG_RUNNING_CODE) { + unsigned ag_t1 = ag_sbe[(PCB).sn] + 1; + unsigned ag_t2 = ag_sbt[(PCB).sn+1] - 1; + do { + unsigned ag_tx = (ag_t1 + ag_t2)/2; + if (ag_tstt[ag_tx] < (unsigned char)(PCB).reduction_token) ag_t1 = ag_tx + 1; + else ag_t2 = ag_tx; + } while (ag_t1 < ag_t2); + (PCB).ag_ap = ag_pstt[ag_t1]; + if ((*(PCB).s_procs[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 = (evalKernel_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 ((*(PCB).s_procs[ag_astt[ag_t1]])() == 0) break; + } + return 0; +} + +static int ag_action_8_proc(void) { + ag_undo(); + (PCB).rx = 0; + ag_auto_resynch(); + return (PCB).exit_flag == AG_RUNNING_CODE; +} + +static int ag_action_5_proc(void) { + int ag_sd = ag_fl[(PCB).ag_ap]; + (PCB).btsx = 0, (PCB).drt = -1; + if (ag_sd) (PCB).sn = (PCB).ss[(PCB).ssx -= ag_sd]; + else { + (PCB).ss[(PCB).ssx] = (PCB).sn; + } + (PCB).rx = 0; + (PCB).reduction_token = (evalKernel_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 ((*(PCB).r_procs[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 = (evalKernel_token_type) ag_ptt[(PCB).ag_ap]; + if ((PCB).drt == -1) { + (PCB).drt=(PCB).token_number; + (PCB).dssx=(PCB).ssx; + (PCB).dsn=(PCB).sn; + } + if (ag_sd) { + (PCB).sn = (PCB).ss[(PCB).ssx -= ag_sd]; + } + else { + ag_prot(); + (PCB).vs[(PCB).ssx] = ag_null_value; + (PCB).ss[(PCB).ssx] = (PCB).sn; + } + (PCB).rx = 0; + while ((PCB).exit_flag == AG_RUNNING_CODE) { + unsigned ag_t1 = ag_sbe[(PCB).sn] + 1; + unsigned ag_t2 = ag_sbt[(PCB).sn+1] - 1; + do { + unsigned ag_tx = (ag_t1 + ag_t2)/2; + if (ag_tstt[ag_tx] < (unsigned char)(PCB).reduction_token) ag_t1 = ag_tx + 1; + else ag_t2 = ag_tx; + } while (ag_t1 < ag_t2); + (PCB).ag_ap = ag_pstt[ag_t1]; + if ((*(PCB).r_procs[ag_astt[ag_t1]])() == 0) break; + } + return (PCB).exit_flag == AG_RUNNING_CODE; +} + + +static void ag_check_depth(int ag_fl) { + int ag_sx = (PCB).ssx - ag_fl; + if ((PCB).ag_error_depth && ag_sx < (PCB).ag_tmp_depth) (PCB).ag_tmp_depth = ag_sx; +} + +static int ag_action_3_er_proc(void) { + ag_check_depth(ag_fl[(PCB).ag_ap] - 1); + return ag_action_4_r_proc(); +} + +static int ag_action_2_e_proc(void) { + ag_action_2_proc(); + (PCB).ag_min_depth = (PCB).ag_tmp_depth; + return 0; +} + +static int ag_action_4_e_proc(void) { + ag_check_depth(ag_fl[(PCB).ag_ap] - 1); + (PCB).ag_min_depth = (PCB).ag_tmp_depth; + return ag_action_4_proc(); +} + +static int ag_action_6_e_proc(void) { + ag_check_depth(ag_fl[(PCB).ag_ap]); + return ag_action_6_proc(); +} + +static int ag_action_11_e_proc(void) { + return ag_action_10_proc(); +} + +static int (*ag_r_procs_error[])(void) = { + ag_action_1_r_proc, + ag_action_2_r_proc, + ag_action_3_er_proc, + ag_action_3_er_proc +}; + +static int (*ag_s_procs_error[])(void) = { + ag_action_1_s_proc, + ag_action_2_r_proc, + ag_action_3_er_proc, + ag_action_3_er_proc +}; + +static int (*ag_gt_procs_error[])(void) = { + ag_action_1_proc, + ag_action_2_e_proc, + ag_action_4_e_proc, + ag_action_4_e_proc, + ag_action_6_e_proc, + ag_action_6_e_proc, + ag_action_7_proc, + ag_action_8_proc, + ag_action_9_proc, + ag_action_10_proc, + ag_action_11_e_proc, + ag_action_12_proc +}; + +static void ag_set_error_procs(void) { + (PCB).gt_procs = ag_gt_procs_error; + (PCB).r_procs = ag_r_procs_error; + (PCB).s_procs = ag_s_procs_error; +} + + +void init_evalKernel(void) { + unsigned ag_t1; + ag_t1 = 0; + (PCB).rx = (PCB).fx = 0; + (PCB).gt_procs = ag_gt_procs_scan; + (PCB).r_procs = ag_r_procs_scan; + (PCB).s_procs = ag_s_procs_scan; + (PCB).ag_error_depth = (PCB).ag_min_depth = (PCB).ag_tmp_depth = 0; + (PCB).ag_resynch_active = 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]; + (*(PCB).gt_procs[ag_astt[ag_t1]])(); + ag_t1 = ag_sbt[(PCB).sn]; + } +} + +void evalKernel(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 = (evalKernel_token_type) ag_key_pt[ag_k1+1]; + (PCB).key_state = 0; + } + break; + } + else { + (PCB).token_number = (evalKernel_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 = (evalKernel_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 = (evalKernel_token_type) ag_key_pt[ag_k1+1]; + continue; + } + case ag_set_key: + (PCB).save_index = (PCB).rx; + (PCB).token_number = (evalKernel_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 = (evalKernel_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 = (evalKernel_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]; + (*(PCB).gt_procs[ag_astt[ag_t1]])(); + } + } +} + +