comparison tests/agcl/parsifal/good/ss-sscx.cpp @ 0:13d2b8934445

Import AnaGram (near-)release tree into Mercurial.
author David A. Holland
date Sat, 22 Dec 2007 17:52:45 -0500
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:13d2b8934445
1 /*
2 Copyright 1992, Jerome T. Holland
3 See the file COPYING for license and usage terms.
4
5 An example syntax and supporting classes for implementing a spreadsheet
6
7 Class definitions are found in sscxdefs.h
8
9 This example is largely intended to serve as an illustration, and is
10 incomplete in a number of ways. In particular, the expression syntax
11 is that of C, except for identifiers, and only a few functions are
12 implemented. More may be implemented trivially by following the
13 patterns provided.
14
15 The supported operations are:
16 Conditional expressions: ? :
17 Logical operators: !, &, |
18 Comparison operators: ==, !=, <, <=, >, >=
19 Binary arithmetic operators: +, -, *, /
20 Exponentiation: **
21 Unary arithmetic operators: +, -
22 Parentheses
23 Function calls abs, sin, asin, atan
24
25 A note on the technique used for compilation:
26
27 The basic approach is to build a Reverse Polish Notation stack.
28 During parsing, the constants, cell locators, and operators are
29 stacked on separate temporary stacks. When parsing is complete,
30 these stacks are unloaded into arrays belonging to the cell
31 expression object. Note that there is a one to one correspondence
32 between items on the constant stack and fd (fetch double) operators
33 in the op stack. Since there are no branching instructions, there
34 there is one and ony one constant corresponding to a fd operation
35 so it is sufficient to simply increment an index into the constant
36 array as execution progresses, to know which constant to use. The
37 same logic holds for cell locators.
38 */
39
40 #include <math.h>
41 #include "agstk.h"
42 #include <string.h>
43 #include <errno.h>
44 #include "sscxdefs.h"
45
46
47 /*
48 * AnaGram, A System for Syntax Directed Programming
49 * File generated by: ...
50 *
51 * AnaGram Parsing Engine
52 * Copyright 1993-2002 Parsifal Software. All Rights Reserved.
53 *
54 * This software is provided 'as-is', without any express or implied
55 * warranty. In no event will the authors be held liable for any damages
56 * arising from the use of this software.
57 *
58 * Permission is granted to anyone to use this software for any purpose,
59 * including commercial applications, and to alter it and redistribute it
60 * freely, subject to the following restrictions:
61 *
62 * 1. The origin of this software must not be misrepresented; you must not
63 * claim that you wrote the original software. If you use this software
64 * in a product, an acknowledgment in the product documentation would be
65 * appreciated but is not required.
66 * 2. Altered source versions must be plainly marked as such, and must not be
67 * misrepresented as being the original software.
68 * 3. This notice may not be removed or altered from any source distribution.
69 */
70
71 #ifndef SS-SSCX_H
72 #include "ss-sscx.h"
73 #endif
74
75 #ifndef SS-SSCX_H
76 #error Mismatched header file
77 #endif
78
79 #include <ctype.h>
80 #include <stdio.h>
81
82 #define RULE_CONTEXT (&((PCB).cs[(PCB).ssx]))
83 #define ERROR_CONTEXT ((PCB).cs[(PCB).error_frame_ssx])
84 #define CONTEXT ((PCB).cs[(PCB).ssx])
85
86
87
88 parseKernel_pcb_type parseKernel_pcb;
89 #define PCB parseKernel_pcb
90
91 #line - "ss-sscx.syn"
92 // Stacks for use in parsing and compiling
93
94 AgStack<double> doubleStack;
95 AgStack<Locator> locatorStack;
96 AgStack<CellExpression::Op> opStack;
97
98 // Data for a simple minded test
99
100 CellExpression *Locator::expression[3][3];
101 int Locator::maxRow = 3;
102 int Locator::maxCol = 3;
103
104 char *expressionText[3][3] = {
105 {"17", "19", "-23"},
106 {"2*a1", "b1 - a2", "a2+b2"},
107 {"b2 + c2", "a3-a2", "a2/b2"}
108 };
109
110 /*
111 Constructor for CellExpression
112
113 Parses the input text and creates byte code for later execution by
114 the value() function.
115 */
116
117 CellExpression::CellExpression(char *text)
118 : constant(0), nConstants(0),
119 locator(0), nLocators(0),
120 op(0), nOps(0),
121 errorFlag(0), busy(0), cycle(0)
122 {
123 doubleStack.reset();
124 locatorStack.reset();
125 opStack.reset();
126 PCB.pointer = (unsigned char *) text;
127 parseKernel(); // Parse expression
128 if (PCB.exit_flag != AG_SUCCESS_CODE) {errorFlag = 1; return;}
129 // save parse results
130 nConstants = doubleStack.size();
131 nLocators = locatorStack.size();
132 nOps = opStack.size();
133 constant = new double[nConstants];
134 locator = new Locator[nLocators];
135 op = new Op[nOps];
136 int i;
137 for (i = nConstants; i--;) constant[i] = doubleStack.pop();
138 for (i = nLocators; i--;) locator[i] = locatorStack.pop();
139 for (i = nOps; i--;) op[i] = opStack.pop();
140 }
141
142 // Function to execute byte code
143
144 Number CellExpression::value() {
145 if (errorFlag) return Number();
146 if (busy) { // Check for cyclic definition
147 errorFlag = cycle = 1;
148 return Number();
149 }
150 busy = 1;
151 int constantIndex = 0;
152 int locatorIndex = 0;
153
154 AgStack<Number> stack; // Arithmetic stack for byte code interpreter
155
156 Number temp; // temporary variable
157 int pc = 0;
158 while (pc < nOps && errorFlag == 0) {
159 switch (op[pc]) {
160 case add: stack.pop(temp); stack.top() += temp; break;
161 case sub: stack.pop(temp); stack.top() -= temp; break;
162 case mpy: stack.pop(temp); stack.top() *= temp; break;
163 case div: stack.pop(temp); stack.top() /= temp; break;
164 case pow: stack.pop(temp); stack.top() = stack.top().pow(temp); break;
165 case lt: stack.pop(temp); stack.top() = stack.top() < temp; break;
166 case le: stack.pop(temp); stack.top() = stack.top() <= temp; break;
167 case gt: stack.pop(temp); stack.top() = stack.top() > temp; break;
168 case ge: stack.pop(temp); stack.top() = stack.top() >= temp; break;
169 case eq: stack.pop(temp); stack.top() = stack.top() == temp; break;
170 case ne: stack.pop(temp); stack.top() = stack.top() != temp; break;
171 case and: stack.pop(temp); stack.top() = stack.top() != Number(0) & temp != Number(0); break;
172 case or: stack.pop(temp); stack.top() = stack.top() != Number(0) | temp != Number(0); break;
173 case minus: stack.top() = -stack.top(); break;
174 case not: stack.top() = stack.top() == Number(0); break;
175 case cond: {
176 Number secondOption = stack.pop();
177 Number firstOption = stack.pop();
178 if (stack.top().bad) break;
179 stack.top() = (stack.top() != Number(0)) ? firstOption : secondOption;
180 break;
181 }
182 case abs: stack.top() = stack.top().abs(); break;
183 case sin: stack.top() = stack.top().sin(); break;
184 case asin: stack.top() = stack.top().asin(); break;
185 case atan: stack.top() = stack.top().atan(); break;
186 case atan2: temp = stack.pop(); stack.top() = stack.top().atan2(temp); break;
187 // Fetch double
188 case fd: stack.push(constant[constantIndex++]); break;
189 // Fetch cell value
190 case fc: {
191 CellExpression *x = locator[locatorIndex++].cellExpression();
192 Number temp;
193 if (x != 0) temp = x->value();
194 stack.push(temp);
195 break;
196 }
197 }
198 pc++;
199 }
200 busy = 0;
201 return stack.top();
202 }
203
204 // Rather trivial test
205
206 int main() {
207 int i, j;
208 // Initialize CellExpresions
209 for (i = 0; i < 3; i++) for (j = 0; j < 3; j++) {
210 Locator::expression[i][j] = new CellExpression(expressionText[i][j]);
211 }
212 // Calculate and print out values
213 for (i = 0; i < 3; i++) for (j = 0; j < 3; j++) {
214 printf("cell[%d][%d] = %G\n", i, j, (double) (Locator::expression[i][j]->value()));
215 }
216 return 0;
217 }
218
219 #line - "ss-sscx.cpp"
220
221 #ifndef CONVERT_CASE
222 #define CONVERT_CASE(c) (c)
223 #endif
224 #ifndef TAB_SPACING
225 #define TAB_SPACING 8
226 #endif
227
228 #define ag_rp_1() (opStack.push(CellExpression::cond))
229
230 #define ag_rp_2() (opStack.push(CellExpression::or))
231
232 #define ag_rp_3() (opStack.push(CellExpression::and))
233
234 #define ag_rp_4(x, y) (opStack.push(CellExpression::eq))
235
236 #define ag_rp_5(x, y) (opStack.push(CellExpression::ne))
237
238 #define ag_rp_6() (opStack.push(CellExpression::lt))
239
240 #define ag_rp_7() (opStack.push(CellExpression::le))
241
242 #define ag_rp_8() (opStack.push(CellExpression::gt))
243
244 #define ag_rp_9() (opStack.push(CellExpression::ge))
245
246 #define ag_rp_10() (opStack.push(CellExpression::add))
247
248 #define ag_rp_11() (opStack.push(CellExpression::sub))
249
250 #define ag_rp_12(x, y) (opStack.push(CellExpression::mpy))
251
252 #define ag_rp_13(x, y) (opStack.push(CellExpression::div))
253
254 #define ag_rp_14() (opStack.push(CellExpression::pow))
255
256 #define ag_rp_15(x) (doubleStack.push(x), opStack.push(CellExpression::fd))
257
258 #define ag_rp_16(n) (locatorStack.push(n), opStack.push(CellExpression::fc))
259
260 #define ag_rp_17() (opStack.push(CellExpression::abs))
261
262 #define ag_rp_18() (opStack.push(CellExpression::sin))
263
264 #define ag_rp_19() (opStack.push(CellExpression::sin))
265
266 #define ag_rp_20() (opStack.push(CellExpression::atan))
267
268 #define ag_rp_21() (opStack.push(CellExpression::atan2))
269
270 #define ag_rp_22() (opStack.push(CellExpression::minus))
271
272 #define ag_rp_23() (opStack.push(CellExpression::not))
273
274 #define ag_rp_24(x, e) (x*pow(10,e))
275
276 #define ag_rp_25(x, e) (x*pow(10,-e))
277
278 #define ag_rp_26(i, f) (i+f)
279
280 #define ag_rp_27(f) (f)
281
282 #define ag_rp_28(d) (d-'0')
283
284 #define ag_rp_29(x, d) (10*x + d-'0')
285
286 #define ag_rp_30(d) ((d-'0')/10.)
287
288 #define ag_rp_31(d, f) ((d-'0' + f)/10.)
289
290 #define ag_rp_32(d) (d-'0')
291
292 #define ag_rp_33(x, d) (10*x + d-'0')
293
294 #define ag_rp_34(c, r) (Locator(r-1,c))
295
296 #define ag_rp_35(c, r) (Locator(r-1,c).setAbsoluteCol())
297
298 #define ag_rp_36(c, r) (Locator(r-1,c).setAbsoluteRow())
299
300 #define ag_rp_37(c, r) (Locator(r-1,c).setAbsoluteRow().setAbsoluteCol())
301
302 #define ag_rp_38(c) (c - 'a')
303
304 #define ag_rp_39(c) (c = 'A')
305
306 #define ag_rp_40(n) (n)
307
308 #define ag_rp_41(c, n) (26*c + n)
309
310 #define ag_rp_42(d) (d - '0')
311
312 #define ag_rp_43(n, d) (10*n + d - '0')
313
314
315 #define READ_COUNTS
316 #define WRITE_COUNTS
317 #undef V
318 #define V(i,t) (*t (&(PCB).vs[(PCB).ssx + i]))
319 #undef VS
320 #define VS(i) (PCB).vs[(PCB).ssx + i]
321
322 #ifndef GET_CONTEXT
323 #define GET_CONTEXT CONTEXT = (PCB).input_context
324 #endif
325
326 typedef enum {
327 ag_action_1,
328 ag_action_2,
329 ag_action_3,
330 ag_action_4,
331 ag_action_5,
332 ag_action_6,
333 ag_action_7,
334 ag_action_8,
335 ag_action_9,
336 ag_action_10,
337 ag_action_11,
338 ag_action_12
339 } ag_parser_action;
340
341
342 #ifndef NULL_VALUE_INITIALIZER
343 #define NULL_VALUE_INITIALIZER = { 0 }
344 #endif
345
346 static parseKernel_vs_type const ag_null_value NULL_VALUE_INITIALIZER;
347
348 static const unsigned char ag_rpx[] = {
349 0, 0, 0, 1, 0, 2, 0, 3, 0, 4, 5, 0, 6, 7, 8, 9, 0, 10,
350 11, 0, 12, 13, 0, 14, 15, 16, 17, 18, 19, 20, 21, 0, 22, 0, 23, 0,
351 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 24, 25, 26, 0, 0,
352 0, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43
353 };
354
355 static const unsigned char ag_key_itt[] = {
356 0
357 };
358
359 static const unsigned short ag_key_pt[] = {
360 0
361 };
362
363 static const unsigned char ag_key_ch[] = {
364 0, 42, 47,255, 98,115,116,255, 47, 97,115,255, 42,255, 42, 47,255, 98,
365 115,116,255, 33, 42, 47, 60, 61, 62, 97,115,255, 98,115,116,255, 97,115,
366 255, 42, 47,255, 33, 42, 47, 60, 61, 62,255, 42, 47,255, 47,255, 33, 42,
367 60, 61, 62,255, 33, 60, 61, 62,255, 33, 61,255
368 };
369
370 static const unsigned char ag_key_act[] = {
371 0,0,0,4,3,3,3,4,2,2,3,4,3,4,0,0,4,3,3,3,4,3,3,2,3,3,3,2,3,4,3,3,3,4,2,
372 3,4,0,0,4,3,3,2,3,3,3,4,0,0,4,2,4,3,3,3,3,3,4,3,3,3,3,4,3,3,4
373 };
374
375 static const unsigned char ag_key_parm[] = {
376 0, 39, 44, 0, 91, 93, 94, 0, 0, 0, 92, 0, 43, 0, 39, 44, 0, 91,
377 93, 94, 0, 77, 86, 0, 79, 76, 81, 0, 92, 0, 91, 93, 94, 0, 0, 92,
378 0, 39, 44, 0, 77, 86, 0, 79, 76, 81, 0, 39, 44, 0, 0, 0, 77, 86,
379 79, 76, 81, 0, 77, 79, 76, 81, 0, 77, 76, 0
380 };
381
382 static const unsigned char ag_key_jmp[] = {
383 0, 0, 0, 0, 0, 2, 5, 0, 1, 4, 8, 0, 11, 0, 0, 0, 0, 23,
384 25, 28, 0, 13, 15, 14, 17, 19, 21, 17, 31, 0, 34, 36, 39, 0, 30, 42,
385 0, 0, 0, 0, 45, 47, 37, 49, 51, 53, 0, 0, 0, 0, 47, 0, 55, 57,
386 59, 61, 63, 0, 65, 67, 69, 71, 0, 73, 75, 0
387 };
388
389 static const unsigned char ag_key_index[] = {
390 8, 0, 12, 21, 34, 0, 0, 12, 12, 0, 40, 0, 0, 40, 8, 8, 8, 8,
391 50, 50, 50, 50, 40, 40, 34, 34, 34, 34, 0, 0, 0, 0, 52, 58, 58, 58,
392 63, 0, 0, 0, 40, 40, 0, 0, 40, 0, 0, 34, 34, 34, 34, 8, 34, 8,
393 34, 8, 34, 34, 34, 8, 34, 8, 34, 8, 34, 8, 34, 8, 34, 8, 34, 8,
394 34, 8, 34, 8, 34, 0, 40, 40, 0, 0, 40, 0, 0, 0, 0, 58, 58, 58,
395 58, 58, 58, 58, 58, 63, 0, 0, 40, 40, 40, 8, 34, 8, 34, 0
396 };
397
398 static const unsigned char ag_key_ends[] = {
399 115,0, 105,110,0, 97,110,0, 105,110,0, 47,0, 61,0, 42,0,
400 61,0, 61,0, 61,0, 115,0, 105,110,0, 97,110,0, 105,110,0, 115,0,
401 105,110,0, 97,110,0, 105,110,0, 61,0, 42,0, 61,0, 61,0, 61,0,
402 61,0, 42,0, 61,0, 61,0, 61,0, 61,0, 61,0, 61,0, 61,0, 61,0,
403 61,0,
404 };
405
406 #define AG_TCV(x) ag_tcv[(x)]
407
408 static const unsigned char ag_tcv[] = {
409 6, 65, 65, 65, 65, 65, 65, 65, 65, 64, 48, 64, 64, 64, 65, 65, 65, 65,
410 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 64, 96, 65, 65,
411 60, 65, 75, 65, 90, 89, 84, 82, 95, 83, 54, 85, 57, 57, 57, 57, 57, 57,
412 57, 57, 57, 57, 72, 65, 78, 65, 80, 73, 65, 66, 66, 66, 66, 67, 66, 66,
413 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66,
414 66, 65, 65, 65, 65, 65, 65, 68, 68, 68, 68, 69, 68, 68, 68, 68, 68, 68,
415 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 65, 74, 65,
416 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65,
417 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65,
418 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65,
419 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65,
420 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65,
421 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65,
422 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65,
423 65, 65, 65, 65
424 };
425
426 #ifndef SYNTAX_ERROR
427 #define SYNTAX_ERROR fprintf(stderr,"%s, line %d, column %d\n", \
428 (PCB).error_message, (PCB).line, (PCB).column)
429 #endif
430
431 #ifndef FIRST_LINE
432 #define FIRST_LINE 1
433 #endif
434
435 #ifndef FIRST_COLUMN
436 #define FIRST_COLUMN 1
437 #endif
438
439 #ifndef PARSER_STACK_OVERFLOW
440 #define PARSER_STACK_OVERFLOW {fprintf(stderr, \
441 "\nParser stack overflow, line %d, column %d\n",\
442 (PCB).line, (PCB).column);}
443 #endif
444
445 #ifndef REDUCTION_TOKEN_ERROR
446 #define REDUCTION_TOKEN_ERROR {fprintf(stderr, \
447 "\nReduction token error, line %d, column %d\n", \
448 (PCB).line, (PCB).column);}
449 #endif
450
451
452 #ifndef INPUT_CODE
453 #define INPUT_CODE(T) (T)
454 #endif
455
456 typedef enum
457 {ag_accept_key, ag_set_key, ag_jmp_key, ag_end_key, ag_no_match_key,
458 ag_cf_accept_key, ag_cf_set_key, ag_cf_end_key} key_words;
459
460 static void ag_get_key_word(int ag_k) {
461 int ag_save = (int) ((PCB).la_ptr - (PCB).pointer);
462 const unsigned char *ag_p;
463 int ag_ch;
464 while (1) {
465 switch (ag_key_act[ag_k]) {
466 case ag_cf_end_key: {
467 const unsigned char *sp = ag_key_ends + ag_key_jmp[ag_k];
468 do {
469 if ((ag_ch = *sp++) == 0) {
470 int ag_k1 = ag_key_parm[ag_k];
471 int ag_k2 = ag_key_pt[ag_k1];
472 if (ag_key_itt[ag_k2 + CONVERT_CASE(*(PCB).la_ptr)]) goto ag_fail;
473 (PCB).token_number = (parseKernel_token_type) ag_key_pt[ag_k1 + 1];
474 return;
475 }
476 } while (CONVERT_CASE(*(PCB).la_ptr++) == ag_ch);
477 goto ag_fail;
478 }
479 case ag_end_key: {
480 const unsigned char *sp = ag_key_ends + ag_key_jmp[ag_k];
481 do {
482 if ((ag_ch = *sp++) == 0) {
483 (PCB).token_number = (parseKernel_token_type) ag_key_parm[ag_k];
484 return;
485 }
486 } while (CONVERT_CASE(*(PCB).la_ptr++) == ag_ch);
487 }
488 case ag_no_match_key:
489 ag_fail:
490 (PCB).la_ptr = (PCB).pointer + ag_save;
491 return;
492 case ag_cf_set_key: {
493 int ag_k1 = ag_key_parm[ag_k];
494 int ag_k2 = ag_key_pt[ag_k1];
495 ag_k = ag_key_jmp[ag_k];
496 if (ag_key_itt[ag_k2 + CONVERT_CASE(*(PCB).la_ptr)]) break;
497 ag_save = (int) ((PCB).la_ptr - (PCB).pointer);
498 (PCB).token_number = (parseKernel_token_type) ag_key_pt[ag_k1+1];
499 break;
500 }
501 case ag_set_key:
502 ag_save = (int) ((PCB).la_ptr - (PCB).pointer);
503 (PCB).token_number = (parseKernel_token_type) ag_key_parm[ag_k];
504 case ag_jmp_key:
505 ag_k = ag_key_jmp[ag_k];
506 break;
507 case ag_accept_key:
508 (PCB).token_number = (parseKernel_token_type) ag_key_parm[ag_k];
509 return;
510 case ag_cf_accept_key: {
511 int ag_k1 = ag_key_parm[ag_k];
512 int ag_k2 = ag_key_pt[ag_k1];
513 if (ag_key_itt[ag_k2 + CONVERT_CASE(*(PCB).la_ptr)])
514 (PCB).la_ptr = (PCB).pointer + ag_save;
515 else (PCB).token_number = (parseKernel_token_type) ag_key_pt[ag_k1+1];
516 return;
517 }
518 }
519 ag_ch = CONVERT_CASE(*(PCB).la_ptr++);
520 ag_p = &ag_key_ch[ag_k];
521 if (ag_ch <= 255) while (*ag_p < ag_ch) ag_p++;
522 if (ag_ch > 255 || *ag_p != ag_ch) {
523 (PCB).la_ptr = (PCB).pointer + ag_save;
524 return;
525 }
526 ag_k = (int) (ag_p - ag_key_ch);
527 }
528 }
529
530
531 #ifndef AG_NEWLINE
532 #define AG_NEWLINE 10
533 #endif
534
535 #ifndef AG_RETURN
536 #define AG_RETURN 13
537 #endif
538
539 #ifndef AG_FORMFEED
540 #define AG_FORMFEED 12
541 #endif
542
543 #ifndef AG_TABCHAR
544 #define AG_TABCHAR 9
545 #endif
546
547 static void ag_track(void) {
548 int ag_k = (int) ((PCB).la_ptr - (PCB).pointer);
549 while (ag_k--) {
550 switch (*(PCB).pointer++) {
551 case AG_NEWLINE:
552 (PCB).column = 1, (PCB).line++;
553 case AG_RETURN:
554 case AG_FORMFEED:
555 break;
556 case AG_TABCHAR:
557 (PCB).column += (TAB_SPACING) - ((PCB).column - 1) % (TAB_SPACING);
558 break;
559 default:
560 (PCB).column++;
561 }
562 }
563 }
564
565
566 static void ag_prot(void) {
567 int ag_k;
568 ag_k = 128 - ++(PCB).btsx;
569 if (ag_k <= (PCB).ssx) {
570 (PCB).exit_flag = AG_STACK_ERROR_CODE;
571 PARSER_STACK_OVERFLOW;
572 return;
573 }
574 (PCB).bts[(PCB).btsx] = (PCB).sn;
575 (PCB).bts[ag_k] = (PCB).ssx;
576 (PCB).vs[ag_k] = (PCB).vs[(PCB).ssx];
577 (PCB).ss[ag_k] = (PCB).ss[(PCB).ssx];
578 }
579
580 static void ag_undo(void) {
581 if ((PCB).drt == -1) return;
582 while ((PCB).btsx) {
583 int ag_k = 128 - (PCB).btsx;
584 (PCB).sn = (PCB).bts[(PCB).btsx--];
585 (PCB).ssx = (PCB).bts[ag_k];
586 (PCB).vs[(PCB).ssx] = (PCB).vs[ag_k];
587 (PCB).ss[(PCB).ssx] = (PCB).ss[ag_k];
588 }
589 (PCB).token_number = (parseKernel_token_type) (PCB).drt;
590 (PCB).ssx = (PCB).dssx;
591 (PCB).sn = (PCB).dsn;
592 (PCB).drt = -1;
593 }
594
595
596 static const unsigned char ag_tstt[] = {
597 96,94,93,92,91,90,83,82,69,68,67,66,64,60,57,54,48,44,39,0,1,70,71,
598 96,95,90,89,85,84,83,82,80,78,75,74,73,72,69,68,67,66,65,64,60,57,54,48,0,
599 46,47,
600 96,95,90,89,85,84,83,82,80,78,75,74,73,72,69,68,67,66,65,64,60,57,54,48,43,
601 0,41,42,
602 64,48,44,39,0,1,
603 96,94,93,92,91,90,83,82,69,68,67,66,60,57,54,0,2,3,4,5,7,10,12,14,17,22,23,
604 24,25,28,30,31,33,34,35,37,49,53,58,61,87,88,
605 96,95,90,89,85,84,83,82,80,78,75,74,73,72,69,68,67,66,65,64,60,57,54,0,
606 48,0,
607 96,95,90,89,85,84,83,82,80,78,75,74,73,72,69,68,67,66,65,64,60,57,54,48,0,
608 43,0,
609 57,0,55,
610 95,89,86,85,84,83,82,81,80,79,78,77,76,75,74,73,72,69,67,64,57,54,48,44,39,
611 6,0,56,
612 69,68,67,66,0,58,61,
613 69,68,67,66,60,57,0,59,61,
614 69,67,0,
615 96,94,93,92,91,90,83,82,69,68,67,66,64,60,57,54,48,44,39,0,1,70,71,
616 96,94,93,92,91,90,83,82,69,68,67,66,64,60,57,54,48,44,39,0,1,70,71,
617 96,94,93,92,91,90,83,82,69,68,67,66,64,60,57,54,48,44,39,0,1,70,71,
618 96,94,93,92,91,90,83,82,69,68,67,66,64,60,57,54,48,44,39,0,1,70,71,
619 90,64,48,44,39,0,1,70,71,
620 90,64,48,44,39,0,1,70,71,
621 90,64,48,44,39,0,1,70,71,
622 90,64,48,44,39,0,1,70,71,
623 95,89,86,85,84,83,82,81,80,79,78,77,76,75,74,73,72,64,48,44,39,6,0,1,70,71,
624 95,89,86,85,84,83,82,81,80,79,78,77,76,75,74,73,72,64,48,44,39,6,0,1,70,71,
625 96,94,93,92,91,90,83,82,69,68,67,66,60,57,54,0,2,3,23,24,28,30,31,33,34,35,
626 37,49,53,58,61,87,88,
627 96,94,93,92,91,90,83,82,69,68,67,66,60,57,54,0,2,3,23,24,28,30,31,33,34,35,
628 37,49,53,58,61,87,88,
629 96,94,93,92,91,90,83,82,69,68,67,66,60,57,54,0,2,3,23,24,28,30,31,33,34,35,
630 37,49,53,58,61,87,88,
631 96,94,93,92,91,90,83,82,69,68,67,66,60,57,54,0,2,3,5,7,10,12,14,17,22,23,24,
632 25,28,30,31,33,34,35,37,49,53,58,61,87,88,
633 90,0,31,
634 90,0,31,
635 90,0,31,
636 90,0,31,
637 86,0,29,
638 85,84,0,26,27,
639 83,82,0,23,24,
640 81,80,79,78,0,18,19,20,21,
641 77,76,0,15,16,
642 75,0,13,
643 74,73,0,8,11,
644 6,0,
645 57,0,55,
646 57,0,55,
647 69,68,67,66,60,57,0,59,61,
648 57,0,59,
649 57,0,
650 83,82,57,0,51,
651 89,0,32,
652 96,94,93,92,91,90,83,82,69,68,67,66,60,57,54,0,2,3,5,7,10,12,14,17,22,23,24,
653 25,28,30,31,33,34,35,37,49,53,58,61,87,88,
654 96,94,93,92,91,90,83,82,69,68,67,66,60,57,54,0,2,3,5,7,10,12,14,17,22,23,24,
655 25,28,30,31,33,34,35,37,49,53,58,61,87,88,
656 96,94,93,92,91,90,83,82,69,68,67,66,60,57,54,0,2,3,5,7,10,12,14,17,22,23,24,
657 25,28,30,31,33,34,35,37,49,53,58,61,87,88,
658 96,94,93,92,91,90,83,82,69,68,67,66,60,57,54,0,2,3,5,7,10,12,14,17,22,23,24,
659 25,28,30,31,33,34,35,37,49,53,58,61,87,88,
660 96,94,93,92,91,90,83,82,69,68,67,66,64,60,57,54,48,44,39,0,1,70,71,
661 96,94,93,92,91,90,83,82,69,68,67,66,60,57,54,0,2,3,23,24,25,28,30,31,33,34,
662 35,37,49,53,58,61,87,88,
663 96,94,93,92,91,90,83,82,69,68,67,66,64,60,57,54,48,44,39,0,1,70,71,
664 96,94,93,92,91,90,83,82,69,68,67,66,60,57,54,0,2,3,23,24,25,28,30,31,33,34,
665 35,37,49,53,58,61,87,88,
666 96,94,93,92,91,90,83,82,69,68,67,66,64,60,57,54,48,44,39,0,1,70,71,
667 96,94,93,92,91,90,83,82,69,68,67,66,60,57,54,0,2,3,23,24,25,28,30,31,33,34,
668 35,37,49,53,58,61,87,88,
669 96,94,93,92,91,90,83,82,69,68,67,66,60,57,54,0,2,3,22,23,24,25,28,30,31,33,
670 34,35,37,49,53,58,61,87,88,
671 96,94,93,92,91,90,83,82,69,68,67,66,60,57,54,0,2,3,22,23,24,25,28,30,31,33,
672 34,35,37,49,53,58,61,87,88,
673 96,94,93,92,91,90,83,82,69,68,67,66,64,60,57,54,48,44,39,0,1,70,71,
674 96,94,93,92,91,90,83,82,69,68,67,66,60,57,54,0,2,3,17,22,23,24,25,28,30,31,
675 33,34,35,37,49,53,58,61,87,88,
676 96,94,93,92,91,90,83,82,69,68,67,66,64,60,57,54,48,44,39,0,1,70,71,
677 96,94,93,92,91,90,83,82,69,68,67,66,60,57,54,0,2,3,17,22,23,24,25,28,30,31,
678 33,34,35,37,49,53,58,61,87,88,
679 96,94,93,92,91,90,83,82,69,68,67,66,64,60,57,54,48,44,39,0,1,70,71,
680 96,94,93,92,91,90,83,82,69,68,67,66,60,57,54,0,2,3,17,22,23,24,25,28,30,31,
681 33,34,35,37,49,53,58,61,87,88,
682 96,94,93,92,91,90,83,82,69,68,67,66,64,60,57,54,48,44,39,0,1,70,71,
683 96,94,93,92,91,90,83,82,69,68,67,66,60,57,54,0,2,3,17,22,23,24,25,28,30,31,
684 33,34,35,37,49,53,58,61,87,88,
685 96,94,93,92,91,90,83,82,69,68,67,66,64,60,57,54,48,44,39,0,1,70,71,
686 96,94,93,92,91,90,83,82,69,68,67,66,60,57,54,0,2,3,14,17,22,23,24,25,28,30,
687 31,33,34,35,37,49,53,58,61,87,88,
688 96,94,93,92,91,90,83,82,69,68,67,66,64,60,57,54,48,44,39,0,1,70,71,
689 96,94,93,92,91,90,83,82,69,68,67,66,60,57,54,0,2,3,14,17,22,23,24,25,28,30,
690 31,33,34,35,37,49,53,58,61,87,88,
691 96,94,93,92,91,90,83,82,69,68,67,66,64,60,57,54,48,44,39,0,1,70,71,
692 96,94,93,92,91,90,83,82,69,68,67,66,60,57,54,0,2,3,12,14,17,22,23,24,25,28,
693 30,31,33,34,35,37,49,53,58,61,87,88,
694 96,94,93,92,91,90,83,82,69,68,67,66,64,60,57,54,48,44,39,0,1,70,71,
695 96,94,93,92,91,90,83,82,69,68,67,66,60,57,54,0,2,3,10,12,14,17,22,23,24,25,
696 28,30,31,33,34,35,37,49,53,58,61,87,88,
697 96,94,93,92,91,90,83,82,69,68,67,66,64,60,57,54,48,44,39,0,1,70,71,
698 96,94,93,92,91,90,83,82,69,68,67,66,60,57,54,0,2,3,5,7,10,12,14,17,22,23,24,
699 25,28,30,31,33,34,35,37,49,53,58,61,87,88,
700 57,0,59,
701 57,0,
702 57,0,
703 57,0,52,
704 57,0,52,
705 95,89,86,85,84,83,82,81,80,79,78,77,76,75,74,73,72,64,48,44,39,6,0,1,70,71,
706 95,89,0,32,36,
707 89,0,32,
708 89,0,32,
709 89,0,32,
710 85,84,0,26,27,
711 85,84,0,26,27,
712 83,82,0,23,24,
713 83,82,0,23,24,
714 83,82,0,23,24,
715 83,82,0,23,24,
716 81,80,79,78,0,18,19,20,21,
717 81,80,79,78,0,18,19,20,21,
718 77,76,0,15,16,
719 75,0,13,
720 72,0,9,
721 57,0,
722 57,0,
723 57,0,
724 96,94,93,92,91,90,83,82,69,68,67,66,64,60,57,54,48,44,39,0,1,70,71,
725 96,94,93,92,91,90,83,82,69,68,67,66,60,57,54,0,2,3,5,7,10,12,14,17,22,23,24,
726 25,28,30,31,33,34,35,37,49,53,58,61,87,88,
727 96,94,93,92,91,90,83,82,69,68,67,66,64,60,57,54,48,44,39,0,1,70,71,
728 96,94,93,92,91,90,83,82,69,68,67,66,60,57,54,0,2,3,5,7,10,12,14,17,22,23,24,
729 25,28,30,31,33,34,35,37,49,53,58,61,87,88,
730 89,0,32,
731
732 };
733
734
735 static unsigned const char ag_astt[1823] = {
736 8,8,8,8,8,8,8,8,8,8,8,8,1,8,8,8,1,1,1,7,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
737 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,1,1,1,
738 8,7,1,1,9,9,1,1,5,3,1,1,1,1,1,1,1,1,2,2,2,2,1,2,1,7,2,2,0,1,1,1,1,1,1,1,1,
739 1,1,1,1,1,1,1,1,1,1,1,1,2,1,1,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,
740 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,9,9,9,5,3,7,1,7,2,5,5,5,
741 5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,10,1,5,5,5,5,7,3,2,2,2,2,7,1,2,2,2,2,2,1,
742 2,7,1,2,1,1,5,5,5,5,5,5,5,5,5,5,5,5,5,1,5,5,5,1,1,1,7,1,1,3,5,5,5,5,5,5,5,
743 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,1,5,5,5,1,1,1,7,1,
744 1,3,5,5,5,5,5,5,5,5,5,5,5,5,1,5,5,5,1,1,1,7,1,1,3,5,1,1,1,1,7,1,1,3,5,1,1,
745 1,1,7,1,1,3,5,1,1,1,1,7,1,1,3,5,1,1,1,1,7,1,1,3,5,5,5,5,5,5,5,5,5,5,5,5,5,
746 5,5,5,5,1,1,1,1,5,7,1,1,3,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,1,1,1,1,5,7,1,
747 1,3,1,1,1,1,1,1,1,1,2,2,2,2,1,2,1,7,2,2,1,1,2,1,1,1,1,1,1,1,1,1,2,1,1,1,1,
748 1,1,1,1,1,1,2,2,2,2,1,2,1,7,2,2,1,1,3,1,1,1,1,1,1,1,1,1,2,1,1,1,1,1,1,1,1,
749 1,1,2,2,2,2,1,2,1,7,2,2,1,1,2,1,1,1,1,1,1,1,1,1,2,1,1,1,1,1,1,1,1,1,1,2,2,
750 2,2,1,2,1,7,2,2,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,2,1,1,1,7,1,1,7,1,
751 1,7,1,1,7,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,1,
752 1,5,1,1,3,7,1,4,2,1,5,2,2,2,2,2,1,2,7,1,2,2,7,1,10,4,1,1,8,7,1,1,7,3,1,1,1,
753 1,1,1,1,1,2,2,2,2,1,2,1,7,2,2,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,2,1,
754 1,1,1,1,1,1,1,1,1,2,2,2,2,1,2,1,7,2,2,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
755 1,1,2,1,1,1,1,1,1,1,1,1,1,2,2,2,2,1,2,1,7,2,2,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
756 1,1,1,1,1,1,2,1,1,1,1,1,1,1,1,1,1,2,2,2,2,1,2,1,7,2,2,1,1,1,1,1,1,1,1,1,1,
757 1,1,1,1,1,1,1,1,1,1,2,1,1,5,5,5,5,5,5,5,5,5,5,5,5,1,5,5,5,1,1,1,7,1,1,3,1,
758 1,1,1,1,1,1,1,2,2,2,2,1,2,1,7,2,2,1,1,2,1,1,1,1,1,1,1,1,1,1,2,1,1,5,5,5,5,
759 5,5,5,5,5,5,5,5,1,5,5,5,1,1,1,7,1,1,3,1,1,1,1,1,1,1,1,2,2,2,2,1,2,1,7,2,2,
760 1,1,2,1,1,1,1,1,1,1,1,1,1,2,1,1,5,5,5,5,5,5,5,5,5,5,5,5,1,5,5,5,1,1,1,7,1,
761 1,3,1,1,1,1,1,1,1,1,2,2,2,2,1,2,1,7,2,2,1,1,2,1,1,1,1,1,1,1,1,1,1,2,1,1,1,
762 1,1,1,1,1,1,1,2,2,2,2,1,2,1,7,2,2,1,1,1,1,1,1,1,1,1,1,1,1,1,1,2,1,1,1,1,1,
763 1,1,1,1,1,2,2,2,2,1,2,1,7,2,2,1,1,1,1,1,1,1,1,1,1,1,1,1,1,2,1,1,5,5,5,5,5,
764 5,5,5,5,5,5,5,1,5,5,5,1,1,1,7,1,1,3,1,1,1,1,1,1,1,1,2,2,2,2,1,2,1,7,2,2,1,
765 1,1,1,1,1,1,1,1,1,1,1,1,1,1,2,1,1,5,5,5,5,5,5,5,5,5,5,5,5,1,5,5,5,1,1,1,7,
766 1,1,3,1,1,1,1,1,1,1,1,2,2,2,2,1,2,1,7,2,2,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,2,
767 1,1,5,5,5,5,5,5,5,5,5,5,5,5,1,5,5,5,1,1,1,7,1,1,3,1,1,1,1,1,1,1,1,2,2,2,2,
768 1,2,1,7,2,2,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,2,1,1,5,5,5,5,5,5,5,5,5,5,5,5,1,
769 5,5,5,1,1,1,7,1,1,3,1,1,1,1,1,1,1,1,2,2,2,2,1,2,1,7,2,2,1,1,1,1,1,1,1,1,1,
770 1,1,1,1,1,1,2,1,1,5,5,5,5,5,5,5,5,5,5,5,5,1,5,5,5,1,1,1,7,1,1,3,1,1,1,1,1,
771 1,1,1,2,2,2,2,1,2,1,7,2,2,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,2,1,1,5,5,5,5,5,
772 5,5,5,5,5,5,5,1,5,5,5,1,1,1,7,1,1,3,1,1,1,1,1,1,1,1,2,2,2,2,1,2,1,7,2,2,1,
773 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,2,1,1,5,5,5,5,5,5,5,5,5,5,5,5,1,5,5,5,1,1,1,
774 7,1,1,3,1,1,1,1,1,1,1,1,2,2,2,2,1,2,1,7,2,2,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
775 1,1,2,1,1,5,5,5,5,5,5,5,5,5,5,5,5,1,5,5,5,1,1,1,7,1,1,3,1,1,1,1,1,1,1,1,2,
776 2,2,2,1,2,1,7,2,2,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,2,1,1,5,5,5,5,5,5,5,
777 5,5,5,5,5,1,5,5,5,1,1,1,7,1,1,3,1,1,1,1,1,1,1,1,2,2,2,2,1,2,1,7,2,2,1,1,1,
778 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,2,1,1,2,7,1,10,4,10,4,2,7,1,2,7,1,5,5,5,
779 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,7,2,1,1,7,2,1,7,2,1,7,2,
780 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,
781 1,1,1,1,1,1,4,1,1,1,1,1,1,4,1,1,1,4,1,1,7,1,10,4,10,4,10,4,5,5,5,5,5,5,5,5,
782 5,5,5,5,1,5,5,5,1,1,1,7,1,1,3,1,1,1,1,1,1,1,1,2,2,2,2,1,2,1,7,2,2,1,1,1,1,
783 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,2,1,1,5,5,5,5,5,5,5,5,5,5,5,5,1,5,5,5,1,1,
784 1,7,1,1,3,1,1,1,1,1,1,1,1,2,2,2,2,1,2,1,7,2,2,2,1,1,1,1,1,1,1,1,1,1,1,1,1,
785 1,1,1,1,1,1,2,1,1,1,7,2
786 };
787
788
789 static const unsigned char ag_pstt[] = {
790 4,4,4,4,4,4,4,4,4,4,4,4,3,4,4,4,3,1,2,0,3,3,4,
791 5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,6,1,5,6,
792 7,7,7,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,
793 128,128,1,2,130,128,
794 14,18,19,20,21,17,16,15,66,66,67,67,11,56,9,4,24,25,0,39,38,37,36,35,34,33,
795 25,26,33,32,31,27,30,29,28,24,13,10,12,68,23,22,
796 42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,44,
797 45,6,
798 37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,39,
799 40,8,
800 40,9,55,
801 52,52,52,52,52,52,52,52,52,52,52,52,52,52,52,52,52,52,52,52,57,41,52,52,52,
802 52,10,54,
803 66,66,67,67,11,42,68,
804 66,66,67,67,43,70,12,44,69,
805 45,45,46,
806 129,129,129,129,129,129,129,129,129,129,129,129,3,129,129,129,3,1,2,14,3,3,
807 155,
808 129,129,129,129,129,129,129,129,129,129,129,129,3,129,129,129,3,1,2,15,3,3,
809 141,
810 129,129,129,129,129,129,129,129,129,129,129,129,3,129,129,129,3,1,2,16,3,3,
811 142,
812 129,129,129,129,129,129,129,129,129,129,129,129,3,129,129,129,3,1,2,17,3,3,
813 149,
814 129,3,3,1,2,18,3,3,153,
815 129,3,3,1,2,19,3,3,152,
816 129,3,3,1,2,20,3,3,151,
817 129,3,3,1,2,21,3,3,150,
818 129,129,129,129,129,129,129,129,129,129,129,129,129,129,129,129,129,3,3,1,2,
819 129,22,3,3,147,
820 129,129,129,129,129,129,129,129,129,129,129,129,129,129,129,129,129,3,3,1,2,
821 129,23,3,3,146,
822 14,18,19,20,21,17,16,15,66,66,67,67,11,56,9,24,24,25,25,26,34,31,27,30,29,
823 28,24,13,10,12,68,23,22,
824 14,18,19,20,21,17,16,15,66,66,67,67,11,56,9,25,24,25,25,26,33,31,27,30,29,
825 28,24,13,10,12,68,23,22,
826 14,18,19,20,21,17,16,15,66,66,67,67,11,56,9,26,24,25,25,26,32,31,27,30,29,
827 28,24,13,10,12,68,23,22,
828 14,18,19,20,21,17,16,15,66,66,67,67,11,56,9,27,24,25,46,38,37,36,35,34,33,
829 25,26,33,32,31,27,30,29,28,24,13,10,12,68,23,22,
830 17,28,47,
831 17,29,48,
832 17,30,49,
833 17,31,50,
834 51,22,52,
835 53,55,16,56,54,
836 16,15,11,58,57,
837 59,61,63,65,8,66,64,62,60,
838 67,69,6,70,68,
839 71,4,72,
840 73,75,2,76,74,
841 1,39,
842 40,58,59,
843 40,53,51,
844 66,66,67,67,77,70,42,78,69,
845 70,43,79,
846 71,62,
847 80,81,81,45,81,
848 82,46,31,
849 14,18,19,20,21,17,16,15,66,66,67,67,11,56,9,47,24,25,83,38,37,36,35,34,33,
850 25,26,33,32,31,27,30,29,28,24,13,10,12,68,23,22,
851 14,18,19,20,21,17,16,15,66,66,67,67,11,56,9,48,24,25,84,38,37,36,35,34,33,
852 25,26,33,32,31,27,30,29,28,24,13,10,12,68,23,22,
853 14,18,19,20,21,17,16,15,66,66,67,67,11,56,9,49,24,25,85,38,37,36,35,34,33,
854 25,26,33,32,31,27,30,29,28,24,13,10,12,68,23,22,
855 14,18,19,20,21,17,16,15,66,66,67,67,11,56,9,50,24,25,86,38,37,36,35,34,33,
856 25,26,33,32,31,27,30,29,28,24,13,10,12,68,23,22,
857 129,129,129,129,129,129,129,129,129,129,129,129,3,129,129,129,3,1,2,51,3,3,
858 145,
859 14,18,19,20,21,17,16,15,66,66,67,67,11,56,9,52,24,25,25,26,23,32,31,27,30,
860 29,28,24,13,10,12,68,23,22,
861 129,129,129,129,129,129,129,129,129,129,129,129,3,129,129,129,3,1,2,53,3,3,
862 144,
863 14,18,19,20,21,17,16,15,66,66,67,67,11,56,9,54,24,25,25,26,21,32,31,27,30,
864 29,28,24,13,10,12,68,23,22,
865 129,129,129,129,129,129,129,129,129,129,129,129,3,129,129,129,3,1,2,55,3,3,
866 143,
867 14,18,19,20,21,17,16,15,66,66,67,67,11,56,9,56,24,25,25,26,20,32,31,27,30,
868 29,28,24,13,10,12,68,23,22,
869 14,18,19,20,21,17,16,15,66,66,67,67,11,56,9,57,24,25,87,25,26,87,32,31,27,
870 30,29,28,24,13,10,12,68,23,22,
871 14,18,19,20,21,17,16,15,66,66,67,67,11,56,9,58,24,25,88,25,26,88,32,31,27,
872 30,29,28,24,13,10,12,68,23,22,
873 129,129,129,129,129,129,129,129,129,129,129,129,3,129,129,129,3,1,2,59,3,3,
874 140,
875 14,18,19,20,21,17,16,15,66,66,67,67,11,56,9,60,24,25,89,33,25,26,33,32,31,
876 27,30,29,28,24,13,10,12,68,23,22,
877 129,129,129,129,129,129,129,129,129,129,129,129,3,129,129,129,3,1,2,61,3,3,
878 139,
879 14,18,19,20,21,17,16,15,66,66,67,67,11,56,9,62,24,25,90,33,25,26,33,32,31,
880 27,30,29,28,24,13,10,12,68,23,22,
881 129,129,129,129,129,129,129,129,129,129,129,129,3,129,129,129,3,1,2,63,3,3,
882 138,
883 14,18,19,20,21,17,16,15,66,66,67,67,11,56,9,64,24,25,91,33,25,26,33,32,31,
884 27,30,29,28,24,13,10,12,68,23,22,
885 129,129,129,129,129,129,129,129,129,129,129,129,3,129,129,129,3,1,2,65,3,3,
886 137,
887 14,18,19,20,21,17,16,15,66,66,67,67,11,56,9,66,24,25,92,33,25,26,33,32,31,
888 27,30,29,28,24,13,10,12,68,23,22,
889 129,129,129,129,129,129,129,129,129,129,129,129,3,129,129,129,3,1,2,67,3,3,
890 136,
891 14,18,19,20,21,17,16,15,66,66,67,67,11,56,9,68,24,25,93,34,33,25,26,33,32,
892 31,27,30,29,28,24,13,10,12,68,23,22,
893 129,129,129,129,129,129,129,129,129,129,129,129,3,129,129,129,3,1,2,69,3,3,
894 135,
895 14,18,19,20,21,17,16,15,66,66,67,67,11,56,9,70,24,25,94,34,33,25,26,33,32,
896 31,27,30,29,28,24,13,10,12,68,23,22,
897 129,129,129,129,129,129,129,129,129,129,129,129,3,129,129,129,3,1,2,71,3,3,
898 134,
899 14,18,19,20,21,17,16,15,66,66,67,67,11,56,9,72,24,25,95,35,34,33,25,26,33,
900 32,31,27,30,29,28,24,13,10,12,68,23,22,
901 129,129,129,129,129,129,129,129,129,129,129,129,3,129,129,129,3,1,2,73,3,3,
902 133,
903 14,18,19,20,21,17,16,15,66,66,67,67,11,56,9,74,24,25,96,36,35,34,33,25,26,
904 33,32,31,27,30,29,28,24,13,10,12,68,23,22,
905 129,129,129,129,129,129,129,129,129,129,129,129,3,129,129,129,3,1,2,75,3,3,
906 132,
907 14,18,19,20,21,17,16,15,66,66,67,67,11,56,9,76,24,25,97,38,37,36,35,34,33,
908 25,26,33,32,31,27,30,29,28,24,13,10,12,68,23,22,
909 70,77,98,
910 71,63,
911 71,64,
912 60,80,99,
913 60,81,100,
914 129,129,129,129,129,129,129,129,129,129,129,129,129,129,129,129,129,3,3,1,2,
915 129,82,3,3,148,
916 101,82,83,29,102,
917 82,84,28,
918 82,85,27,
919 82,86,26,
920 53,55,18,56,54,
921 53,55,17,56,54,
922 16,15,15,58,57,
923 16,15,14,58,57,
924 16,15,13,58,57,
925 16,15,12,58,57,
926 59,61,63,65,10,66,64,62,60,
927 59,61,63,65,9,66,64,62,60,
928 67,69,7,70,68,
929 71,5,72,
930 103,97,104,
931 71,65,
932 61,50,
933 61,49,
934 129,129,129,129,129,129,129,129,129,129,129,129,3,129,129,129,3,1,2,101,3,3,
935 154,
936 14,18,19,20,21,17,16,15,66,66,67,67,11,56,9,102,24,25,105,38,37,36,35,34,33,
937 25,26,33,32,31,27,30,29,28,24,13,10,12,68,23,22,
938 129,129,129,129,129,129,129,129,129,129,129,129,3,129,129,129,3,1,2,103,3,3,
939 131,
940 14,18,19,20,21,17,16,15,66,66,67,67,11,56,9,104,24,25,3,38,37,36,35,34,33,
941 25,26,33,32,31,27,30,29,28,24,13,10,12,68,23,22,
942 82,105,30,
943
944 };
945
946
947 static const unsigned short ag_sbt[] = {
948 0, 23, 50, 78, 84, 126, 150, 152, 177, 179, 182, 210, 217, 226,
949 229, 252, 275, 298, 321, 330, 339, 348, 357, 383, 409, 442, 475, 508,
950 549, 552, 555, 558, 561, 564, 569, 574, 583, 588, 591, 596, 598, 601,
951 604, 613, 616, 618, 623, 626, 667, 708, 749, 790, 813, 847, 870, 904,
952 927, 961, 996,1031,1054,1090,1113,1149,1172,1208,1231,1267,1290,1327,
953 1350,1387,1410,1448,1471,1510,1533,1574,1577,1579,1581,1584,1587,1613,
954 1618,1621,1624,1627,1632,1637,1642,1647,1652,1657,1666,1675,1680,1683,
955 1686,1688,1690,1692,1715,1756,1779,1820,1823
956 };
957
958
959 static const unsigned short ag_sbe[] = {
960 19, 47, 75, 82, 99, 149, 151, 176, 178, 180, 208, 214, 223, 228,
961 248, 271, 294, 317, 326, 335, 344, 353, 379, 405, 424, 457, 490, 523,
962 550, 553, 556, 559, 562, 566, 571, 578, 585, 589, 593, 597, 599, 602,
963 610, 614, 617, 621, 624, 641, 682, 723, 764, 809, 828, 866, 885, 923,
964 942, 976,1011,1050,1069,1109,1128,1168,1187,1227,1246,1286,1305,1346,
965 1365,1406,1425,1467,1486,1529,1548,1575,1578,1580,1582,1585,1609,1615,
966 1619,1622,1625,1629,1634,1639,1644,1649,1654,1661,1670,1677,1681,1684,
967 1687,1689,1691,1711,1730,1775,1794,1821,1823
968 };
969
970
971 static const unsigned char ag_fl[] = {
972 2,2,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,4,4,4,6,3,2,2,2,
973 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,2,3,3,4,1,1,1,2,
974 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,
975 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,
976 2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2
977 };
978
979 static const unsigned char ag_ptt[] = {
980 0, 4, 5, 5, 7, 7, 10, 10, 12, 12, 12, 14, 14, 14, 14, 14, 17, 17,
981 17, 22, 22, 22, 25, 25, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 1,
982 41, 41, 42, 42, 1, 46, 46, 47, 47, 1, 87, 51, 51, 87, 87, 49, 56, 56,
983 49, 49, 53, 53, 55, 55, 52, 52, 88, 88, 88, 88, 61, 61, 58, 58, 59, 59,
984 38, 38, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40,
985 40, 40, 40, 40, 40, 40, 40, 40, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45,
986 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 50, 50, 62, 62, 63,
987 63, 70, 70, 71, 71, 9, 8, 11, 13, 15, 16, 18, 19, 20, 21, 23, 24, 26,
988 27, 29, 2, 3, 32, 31, 30, 33, 34, 35, 36, 37
989 };
990
991
992 static void ag_ra(void)
993 {
994 switch(ag_rpx[(PCB).ag_ap]) {
995 case 1: ag_rp_1(); break;
996 case 2: ag_rp_2(); break;
997 case 3: ag_rp_3(); break;
998 case 4: ag_rp_4(V(0,(void *)), V(2,(void *))); break;
999 case 5: ag_rp_5(V(0,(void *)), V(2,(void *))); break;
1000 case 6: ag_rp_6(); break;
1001 case 7: ag_rp_7(); break;
1002 case 8: ag_rp_8(); break;
1003 case 9: ag_rp_9(); break;
1004 case 10: ag_rp_10(); break;
1005 case 11: ag_rp_11(); break;
1006 case 12: ag_rp_12(V(0,(void *)), V(2,(void *))); break;
1007 case 13: ag_rp_13(V(0,(void *)), V(2,(void *))); break;
1008 case 14: ag_rp_14(); break;
1009 case 15: ag_rp_15(V(0,(double *))); break;
1010 case 16: ag_rp_16(V(0,(Locator *))); break;
1011 case 17: ag_rp_17(); break;
1012 case 18: ag_rp_18(); break;
1013 case 19: ag_rp_19(); break;
1014 case 20: ag_rp_20(); break;
1015 case 21: ag_rp_21(); break;
1016 case 22: ag_rp_22(); break;
1017 case 23: ag_rp_23(); break;
1018 case 24: V(0,(double *)) = ag_rp_24(V(0,(double *)), V(3,(int *))); break;
1019 case 25: V(0,(double *)) = ag_rp_25(V(0,(double *)), V(3,(int *))); break;
1020 case 26: V(0,(double *)) = ag_rp_26(V(0,(double *)), V(2,(double *))); break;
1021 case 27: V(0,(double *)) = ag_rp_27(V(1,(double *))); break;
1022 case 28: V(0,(double *)) = ag_rp_28(V(0,(int *))); break;
1023 case 29: V(0,(double *)) = ag_rp_29(V(0,(double *)), V(1,(int *))); break;
1024 case 30: V(0,(double *)) = ag_rp_30(V(0,(int *))); break;
1025 case 31: V(0,(double *)) = ag_rp_31(V(0,(int *)), V(1,(double *))); break;
1026 case 32: V(0,(int *)) = ag_rp_32(V(0,(int *))); break;
1027 case 33: V(0,(int *)) = ag_rp_33(V(0,(int *)), V(1,(int *))); break;
1028 case 34: V(0,(Locator *)) = ag_rp_34(V(0,(int *)), V(1,(int *))); break;
1029 case 35: V(0,(Locator *)) = ag_rp_35(V(1,(int *)), V(2,(int *))); break;
1030 case 36: V(0,(Locator *)) = ag_rp_36(V(0,(int *)), V(2,(int *))); break;
1031 case 37: V(0,(Locator *)) = ag_rp_37(V(1,(int *)), V(3,(int *))); break;
1032 case 38: V(0,(int *)) = ag_rp_38(V(0,(int *))); break;
1033 case 39: V(0,(int *)) = ag_rp_39(V(0,(int *))); break;
1034 case 40: V(0,(int *)) = ag_rp_40(V(0,(int *))); break;
1035 case 41: V(0,(int *)) = ag_rp_41(V(0,(int *)), V(1,(int *))); break;
1036 case 42: V(0,(int *)) = ag_rp_42(V(0,(int *))); break;
1037 case 43: V(0,(int *)) = ag_rp_43(V(0,(int *)), V(1,(int *))); break;
1038 }
1039 (PCB).la_ptr = (PCB).pointer;
1040 }
1041
1042 #define TOKEN_NAMES parseKernel_token_names
1043 const char *const parseKernel_token_names[97] = {
1044 "input string",
1045 "white space",
1046 "real",
1047 "cell name",
1048 "input string",
1049 "expression",
1050 "eof",
1051 "logical or expression",
1052 "'\\?'",
1053 "':'",
1054 "logical and expression",
1055 "'|'",
1056 "equality expression",
1057 "'&'",
1058 "relational expression",
1059 "\"==\"",
1060 "\"!=\"",
1061 "additive expression",
1062 "'<'",
1063 "\"<=\"",
1064 "'>'",
1065 "\">=\"",
1066 "multiplicative expression",
1067 "'+'",
1068 "'-'",
1069 "factor",
1070 "'*'",
1071 "'/'",
1072 "primary",
1073 "\"**\"",
1074 "\"abs\"",
1075 "'('",
1076 "')'",
1077 "\"sin\"",
1078 "\"asin\"",
1079 "\"atan\"",
1080 "','",
1081 "'!'",
1082 "",
1083 "\"/*\"",
1084 "",
1085 "",
1086 "",
1087 "\"*/\"",
1088 "\"//\"",
1089 "",
1090 "",
1091 "",
1092 "'\\n'",
1093 "simple real",
1094 "",
1095 "",
1096 "exponent",
1097 "integer part",
1098 "'.'",
1099 "fraction part",
1100 "",
1101 "digit",
1102 "column",
1103 "row",
1104 "'$'",
1105 "letter",
1106 "",
1107 "",
1108 "",
1109 "",
1110 "",
1111 "",
1112 "",
1113 "",
1114 "",
1115 "",
1116 "':'",
1117 "'\\?'",
1118 "'|'",
1119 "'&'",
1120 "\"==\"",
1121 "\"!=\"",
1122 "'<'",
1123 "\"<=\"",
1124 "'>'",
1125 "\">=\"",
1126 "'+'",
1127 "'-'",
1128 "'*'",
1129 "'/'",
1130 "\"**\"",
1131 "real",
1132 "cell name",
1133 "')'",
1134 "'('",
1135 "\"abs\"",
1136 "\"sin\"",
1137 "\"asin\"",
1138 "\"atan\"",
1139 "','",
1140 "'!'",
1141
1142 };
1143
1144 #ifndef MISSING_FORMAT
1145 #define MISSING_FORMAT "Missing %s"
1146 #endif
1147 #ifndef UNEXPECTED_FORMAT
1148 #define UNEXPECTED_FORMAT "Unexpected %s"
1149 #endif
1150 #ifndef UNNAMED_TOKEN
1151 #define UNNAMED_TOKEN "input"
1152 #endif
1153
1154
1155 static void ag_diagnose(void) {
1156 int ag_snd = (PCB).sn;
1157 int ag_k = ag_sbt[ag_snd];
1158
1159 if (*TOKEN_NAMES[ag_tstt[ag_k]] && ag_astt[ag_k + 1] == ag_action_8) {
1160 sprintf((PCB).ag_msg, MISSING_FORMAT, TOKEN_NAMES[ag_tstt[ag_k]]);
1161 }
1162 else if (ag_astt[ag_sbe[(PCB).sn]] == ag_action_8
1163 && (ag_k = (int) ag_sbe[(PCB).sn] + 1) == (int) ag_sbt[(PCB).sn+1] - 1
1164 && *TOKEN_NAMES[ag_tstt[ag_k]]) {
1165 sprintf((PCB).ag_msg, MISSING_FORMAT, TOKEN_NAMES[ag_tstt[ag_k]]);
1166 }
1167 else if ((PCB).token_number && *TOKEN_NAMES[(PCB).token_number]) {
1168 sprintf((PCB).ag_msg, UNEXPECTED_FORMAT, TOKEN_NAMES[(PCB).token_number]);
1169 }
1170 else if (isprint(INPUT_CODE((*(PCB).pointer))) && INPUT_CODE((*(PCB).pointer)) != '\\') {
1171 char buf[20];
1172 sprintf(buf, "\'%c\'", (char) INPUT_CODE((*(PCB).pointer)));
1173 sprintf((PCB).ag_msg, UNEXPECTED_FORMAT, buf);
1174 }
1175 else sprintf((PCB).ag_msg, UNEXPECTED_FORMAT, UNNAMED_TOKEN);
1176 (PCB).error_message = (PCB).ag_msg;
1177
1178
1179 }
1180 static int ag_action_1_r_proc(void);
1181 static int ag_action_2_r_proc(void);
1182 static int ag_action_3_r_proc(void);
1183 static int ag_action_4_r_proc(void);
1184 static int ag_action_1_s_proc(void);
1185 static int ag_action_3_s_proc(void);
1186 static int ag_action_1_proc(void);
1187 static int ag_action_2_proc(void);
1188 static int ag_action_3_proc(void);
1189 static int ag_action_4_proc(void);
1190 static int ag_action_5_proc(void);
1191 static int ag_action_6_proc(void);
1192 static int ag_action_7_proc(void);
1193 static int ag_action_8_proc(void);
1194 static int ag_action_9_proc(void);
1195 static int ag_action_10_proc(void);
1196 static int ag_action_11_proc(void);
1197 static int ag_action_8_proc(void);
1198
1199
1200 static int (*const ag_r_procs_scan[])(void) = {
1201 ag_action_1_r_proc,
1202 ag_action_2_r_proc,
1203 ag_action_3_r_proc,
1204 ag_action_4_r_proc
1205 };
1206
1207 static int (*const ag_s_procs_scan[])(void) = {
1208 ag_action_1_s_proc,
1209 ag_action_2_r_proc,
1210 ag_action_3_s_proc,
1211 ag_action_4_r_proc
1212 };
1213
1214 static int (*const ag_gt_procs_scan[])(void) = {
1215 ag_action_1_proc,
1216 ag_action_2_proc,
1217 ag_action_3_proc,
1218 ag_action_4_proc,
1219 ag_action_5_proc,
1220 ag_action_6_proc,
1221 ag_action_7_proc,
1222 ag_action_8_proc,
1223 ag_action_9_proc,
1224 ag_action_10_proc,
1225 ag_action_11_proc,
1226 ag_action_8_proc
1227 };
1228
1229
1230 static int ag_action_10_proc(void) {
1231 int ag_t = (PCB).token_number;
1232 (PCB).btsx = 0, (PCB).drt = -1;
1233 do {
1234 ag_track();
1235 (PCB).token_number = (parseKernel_token_type) AG_TCV(INPUT_CODE(*(PCB).la_ptr));
1236 (PCB).la_ptr++;
1237 if (ag_key_index[(PCB).sn]) {
1238 unsigned ag_k = ag_key_index[(PCB).sn];
1239 int ag_ch = CONVERT_CASE(INPUT_CODE(*(PCB).pointer));
1240 if (ag_ch <= 255) {
1241 while (ag_key_ch[ag_k] < ag_ch) ag_k++;
1242 if (ag_key_ch[ag_k] == ag_ch) ag_get_key_word(ag_k);
1243 }
1244 }
1245 } while ((PCB).token_number == (parseKernel_token_type) ag_t);
1246 (PCB).la_ptr = (PCB).pointer;
1247 return 1;
1248 }
1249
1250 static int ag_action_11_proc(void) {
1251 int ag_t = (PCB).token_number;
1252
1253 (PCB).btsx = 0, (PCB).drt = -1;
1254 do {
1255 (*(int *) &(PCB).vs[(PCB).ssx]) = *(PCB).pointer;
1256 (PCB).ssx--;
1257 ag_track();
1258 ag_ra();
1259 if ((PCB).exit_flag != AG_RUNNING_CODE) return 0;
1260 (PCB).ssx++;
1261 (PCB).token_number = (parseKernel_token_type) AG_TCV(INPUT_CODE(*(PCB).la_ptr));
1262 (PCB).la_ptr++;
1263 if (ag_key_index[(PCB).sn]) {
1264 unsigned ag_k = ag_key_index[(PCB).sn];
1265 int ag_ch = CONVERT_CASE(INPUT_CODE(*(PCB).pointer));
1266 if (ag_ch <= 255) {
1267 while (ag_key_ch[ag_k] < ag_ch) ag_k++;
1268 if (ag_key_ch[ag_k] == ag_ch) ag_get_key_word(ag_k);
1269 }
1270 }
1271 }
1272 while ((PCB).token_number == (parseKernel_token_type) ag_t);
1273 (PCB).la_ptr = (PCB).pointer;
1274 return 1;
1275 }
1276
1277 static int ag_action_3_r_proc(void) {
1278 int ag_sd = ag_fl[(PCB).ag_ap] - 1;
1279 if (ag_sd) (PCB).sn = (PCB).ss[(PCB).ssx -= ag_sd];
1280 (PCB).btsx = 0, (PCB).drt = -1;
1281 (PCB).reduction_token = (parseKernel_token_type) ag_ptt[(PCB).ag_ap];
1282 ag_ra();
1283 return (PCB).exit_flag == AG_RUNNING_CODE;
1284 }
1285
1286 static int ag_action_3_s_proc(void) {
1287 int ag_sd = ag_fl[(PCB).ag_ap] - 1;
1288 if (ag_sd) (PCB).sn = (PCB).ss[(PCB).ssx -= ag_sd];
1289 (PCB).btsx = 0, (PCB).drt = -1;
1290 (PCB).reduction_token = (parseKernel_token_type) ag_ptt[(PCB).ag_ap];
1291 ag_ra();
1292 return (PCB).exit_flag == AG_RUNNING_CODE;
1293 }
1294
1295 static int ag_action_4_r_proc(void) {
1296 int ag_sd = ag_fl[(PCB).ag_ap] - 1;
1297 if (ag_sd) (PCB).sn = (PCB).ss[(PCB).ssx -= ag_sd];
1298 (PCB).reduction_token = (parseKernel_token_type) ag_ptt[(PCB).ag_ap];
1299 return 1;
1300 }
1301
1302 static int ag_action_2_proc(void) {
1303 (PCB).btsx = 0, (PCB).drt = -1;
1304 if ((PCB).ssx >= 128) {
1305 (PCB).exit_flag = AG_STACK_ERROR_CODE;
1306 PARSER_STACK_OVERFLOW;
1307 }
1308 (*(int *) &(PCB).vs[(PCB).ssx]) = *(PCB).pointer;
1309 (PCB).ss[(PCB).ssx] = (PCB).sn;
1310 (PCB).ssx++;
1311 (PCB).sn = (PCB).ag_ap;
1312 ag_track();
1313 return 0;
1314 }
1315
1316 static int ag_action_9_proc(void) {
1317 if ((PCB).drt == -1) {
1318 (PCB).drt=(PCB).token_number;
1319 (PCB).dssx=(PCB).ssx;
1320 (PCB).dsn=(PCB).sn;
1321 }
1322 ag_prot();
1323 (PCB).vs[(PCB).ssx] = ag_null_value;
1324 (PCB).ss[(PCB).ssx] = (PCB).sn;
1325 (PCB).ssx++;
1326 (PCB).sn = (PCB).ag_ap;
1327 (PCB).la_ptr = (PCB).pointer;
1328 return (PCB).exit_flag == AG_RUNNING_CODE;
1329 }
1330
1331 static int ag_action_2_r_proc(void) {
1332 (PCB).ssx++;
1333 (PCB).sn = (PCB).ag_ap;
1334 return 0;
1335 }
1336
1337 static int ag_action_7_proc(void) {
1338 --(PCB).ssx;
1339 (PCB).la_ptr = (PCB).pointer;
1340 (PCB).exit_flag = AG_SUCCESS_CODE;
1341 return 0;
1342 }
1343
1344 static int ag_action_1_proc(void) {
1345 ag_track();
1346 (PCB).exit_flag = AG_SUCCESS_CODE;
1347 return 0;
1348 }
1349
1350 static int ag_action_1_r_proc(void) {
1351 (PCB).exit_flag = AG_SUCCESS_CODE;
1352 return 0;
1353 }
1354
1355 static int ag_action_1_s_proc(void) {
1356 (PCB).exit_flag = AG_SUCCESS_CODE;
1357 return 0;
1358 }
1359
1360 static int ag_action_4_proc(void) {
1361 int ag_sd = ag_fl[(PCB).ag_ap] - 1;
1362 (PCB).reduction_token = (parseKernel_token_type) ag_ptt[(PCB).ag_ap];
1363 (PCB).btsx = 0, (PCB).drt = -1;
1364 (*(int *) &(PCB).vs[(PCB).ssx]) = *(PCB).pointer;
1365 if (ag_sd) (PCB).sn = (PCB).ss[(PCB).ssx -= ag_sd];
1366 else (PCB).ss[(PCB).ssx] = (PCB).sn;
1367 ag_track();
1368 while ((PCB).exit_flag == AG_RUNNING_CODE) {
1369 unsigned ag_t1 = ag_sbe[(PCB).sn] + 1;
1370 unsigned ag_t2 = ag_sbt[(PCB).sn+1] - 1;
1371 do {
1372 unsigned ag_tx = (ag_t1 + ag_t2)/2;
1373 if (ag_tstt[ag_tx] < (unsigned char)(PCB).reduction_token) ag_t1 = ag_tx + 1;
1374 else ag_t2 = ag_tx;
1375 } while (ag_t1 < ag_t2);
1376 (PCB).ag_ap = ag_pstt[ag_t1];
1377 if ((ag_s_procs_scan[ag_astt[ag_t1]])() == 0) break;
1378 }
1379 return 0;
1380 }
1381
1382 static int ag_action_3_proc(void) {
1383 int ag_sd = ag_fl[(PCB).ag_ap] - 1;
1384 (PCB).btsx = 0, (PCB).drt = -1;
1385 (*(int *) &(PCB).vs[(PCB).ssx]) = *(PCB).pointer;
1386 if (ag_sd) (PCB).sn = (PCB).ss[(PCB).ssx -= ag_sd];
1387 else (PCB).ss[(PCB).ssx] = (PCB).sn;
1388 ag_track();
1389 (PCB).reduction_token = (parseKernel_token_type) ag_ptt[(PCB).ag_ap];
1390 ag_ra();
1391 while ((PCB).exit_flag == AG_RUNNING_CODE) {
1392 unsigned ag_t1 = ag_sbe[(PCB).sn] + 1;
1393 unsigned ag_t2 = ag_sbt[(PCB).sn+1] - 1;
1394 do {
1395 unsigned ag_tx = (ag_t1 + ag_t2)/2;
1396 if (ag_tstt[ag_tx] < (unsigned char)(PCB).reduction_token) ag_t1 = ag_tx + 1;
1397 else ag_t2 = ag_tx;
1398 } while (ag_t1 < ag_t2);
1399 (PCB).ag_ap = ag_pstt[ag_t1];
1400 if ((ag_s_procs_scan[ag_astt[ag_t1]])() == 0) break;
1401 }
1402 return 0;
1403 }
1404
1405 static int ag_action_8_proc(void) {
1406 ag_undo();
1407 (PCB).la_ptr = (PCB).pointer;
1408 (PCB).exit_flag = AG_SYNTAX_ERROR_CODE;
1409 ag_diagnose();
1410 SYNTAX_ERROR;
1411 {(PCB).la_ptr = (PCB).pointer + 1; ag_track();}
1412 return (PCB).exit_flag == AG_RUNNING_CODE;
1413 }
1414
1415 static int ag_action_5_proc(void) {
1416 int ag_sd = ag_fl[(PCB).ag_ap];
1417 (PCB).btsx = 0, (PCB).drt = -1;
1418 if (ag_sd) (PCB).sn = (PCB).ss[(PCB).ssx -= ag_sd];
1419 else {
1420 (PCB).ss[(PCB).ssx] = (PCB).sn;
1421 }
1422 (PCB).la_ptr = (PCB).pointer;
1423 (PCB).reduction_token = (parseKernel_token_type) ag_ptt[(PCB).ag_ap];
1424 ag_ra();
1425 while ((PCB).exit_flag == AG_RUNNING_CODE) {
1426 unsigned ag_t1 = ag_sbe[(PCB).sn] + 1;
1427 unsigned ag_t2 = ag_sbt[(PCB).sn+1] - 1;
1428 do {
1429 unsigned ag_tx = (ag_t1 + ag_t2)/2;
1430 if (ag_tstt[ag_tx] < (unsigned char)(PCB).reduction_token) ag_t1 = ag_tx + 1;
1431 else ag_t2 = ag_tx;
1432 } while (ag_t1 < ag_t2);
1433 (PCB).ag_ap = ag_pstt[ag_t1];
1434 if ((ag_r_procs_scan[ag_astt[ag_t1]])() == 0) break;
1435 }
1436 return (PCB).exit_flag == AG_RUNNING_CODE;
1437 }
1438
1439 static int ag_action_6_proc(void) {
1440 int ag_sd = ag_fl[(PCB).ag_ap];
1441 (PCB).reduction_token = (parseKernel_token_type) ag_ptt[(PCB).ag_ap];
1442 if ((PCB).drt == -1) {
1443 (PCB).drt=(PCB).token_number;
1444 (PCB).dssx=(PCB).ssx;
1445 (PCB).dsn=(PCB).sn;
1446 }
1447 if (ag_sd) {
1448 (PCB).sn = (PCB).ss[(PCB).ssx -= ag_sd];
1449 }
1450 else {
1451 ag_prot();
1452 (PCB).vs[(PCB).ssx] = ag_null_value;
1453 (PCB).ss[(PCB).ssx] = (PCB).sn;
1454 }
1455 (PCB).la_ptr = (PCB).pointer;
1456 while ((PCB).exit_flag == AG_RUNNING_CODE) {
1457 unsigned ag_t1 = ag_sbe[(PCB).sn] + 1;
1458 unsigned ag_t2 = ag_sbt[(PCB).sn+1] - 1;
1459 do {
1460 unsigned ag_tx = (ag_t1 + ag_t2)/2;
1461 if (ag_tstt[ag_tx] < (unsigned char)(PCB).reduction_token) ag_t1 = ag_tx + 1;
1462 else ag_t2 = ag_tx;
1463 } while (ag_t1 < ag_t2);
1464 (PCB).ag_ap = ag_pstt[ag_t1];
1465 if ((ag_r_procs_scan[ag_astt[ag_t1]])() == 0) break;
1466 }
1467 return (PCB).exit_flag == AG_RUNNING_CODE;
1468 }
1469
1470
1471 void init_parseKernel(void) {
1472 (PCB).la_ptr = (PCB).pointer;
1473 (PCB).ss[0] = (PCB).sn = (PCB).ssx = 0;
1474 (PCB).exit_flag = AG_RUNNING_CODE;
1475 (PCB).line = FIRST_LINE;
1476 (PCB).column = FIRST_COLUMN;
1477 (PCB).btsx = 0, (PCB).drt = -1;
1478 }
1479
1480 void parseKernel(void) {
1481 init_parseKernel();
1482 (PCB).exit_flag = AG_RUNNING_CODE;
1483 while ((PCB).exit_flag == AG_RUNNING_CODE) {
1484 unsigned ag_t1 = ag_sbt[(PCB).sn];
1485 if (ag_tstt[ag_t1]) {
1486 unsigned ag_t2 = ag_sbe[(PCB).sn] - 1;
1487 (PCB).token_number = (parseKernel_token_type) AG_TCV(INPUT_CODE(*(PCB).la_ptr));
1488 (PCB).la_ptr++;
1489 if (ag_key_index[(PCB).sn]) {
1490 unsigned ag_k = ag_key_index[(PCB).sn];
1491 int ag_ch = CONVERT_CASE(INPUT_CODE(*(PCB).pointer));
1492 if (ag_ch <= 255) {
1493 while (ag_key_ch[ag_k] < ag_ch) ag_k++;
1494 if (ag_key_ch[ag_k] == ag_ch) ag_get_key_word(ag_k);
1495 }
1496 }
1497 do {
1498 unsigned ag_tx = (ag_t1 + ag_t2)/2;
1499 if (ag_tstt[ag_tx] > (unsigned char)(PCB).token_number)
1500 ag_t1 = ag_tx + 1;
1501 else ag_t2 = ag_tx;
1502 } while (ag_t1 < ag_t2);
1503 if (ag_tstt[ag_t1] != (unsigned char)(PCB).token_number)
1504 ag_t1 = ag_sbe[(PCB).sn];
1505 }
1506 (PCB).ag_ap = ag_pstt[ag_t1];
1507 (ag_gt_procs_scan[ag_astt[ag_t1]])();
1508 }
1509 }
1510
1511