mpw/bin/parser.cpp

1869 lines
66 KiB
C++
Raw Permalink Normal View History

/*
** 2000-05-29
**
** The author disclaims copyright to this source code. In place of
** a legal notice, here is a blessing:
**
** May you do good and not evil.
** May you find forgiveness for yourself and forgive others.
** May you share freely, never taking more than you give.
**
*************************************************************************
** Driver template for the LEMON parser generator.
**
** The "lemon" program processes an LALR(1) input grammar file, then uses
** this template to construct a parser. The "lemon" program inserts text
2023-09-14 17:27:53 +00:00
** at each "%%" line. Also, any "P-a-r-s-e" identifier prefix (without the
** interstitial "-" characters) contained in this template is changed into
** the value of the %name directive from the grammar. Otherwise, the content
** of this template is copied straight through into the generate parser
** source file.
**
** The following is the concatenation of all %include directives from the
** input grammar file:
*/
#include <stdio.h>
#include <assert.h>
/************ Begin %include sections from the grammar ************************/
#line 6 "parser.lemon"
#include <stdbool.h>
#include <stdint.h>
#include <string.h>
#include <cassert>
#include <cstddef>
#include "debugger.h"
#include <toolbox/mm.h>
using Debug::Token;
#ifdef __cplusplus
extern "C" {
#endif
uint32_t cpuGetSR();
uint32_t cpuGetPC();
uint32_t cpuGetAReg(unsigned);
uint32_t cpuGetDReg(unsigned);
#ifdef __cplusplus
}
#endif
#undef NDEBUG
#line 58 "parser.c"
/**************** End of %include directives **********************************/
/* These constants specify the various numeric values for terminal symbols
** in a format understandable to "makeheaders". This section is blank unless
** "lemon" is run with the "-m" command-line option.
***************** Begin makeheaders token definitions *************************/
/**************** End makeheaders token definitions ***************************/
/* The next sections is a series of control #defines.
** various aspects of the generated parser.
** YYCODETYPE is the data type used to store the integer codes
** that represent terminal and non-terminal symbols.
** "unsigned char" is used if there are fewer than
** 256 symbols. Larger types otherwise.
** YYNOCODE is a number of type YYCODETYPE that is not used for
** any terminal or nonterminal symbol.
** YYFALLBACK If defined, this indicates that one or more tokens
** (also known as: "terminal symbols") have fall-back
** values which should be used if the original symbol
** would not parse. This permits keywords to sometimes
** be used as identifiers, for example.
** YYACTIONTYPE is the data type used for "action codes" - numbers
** that indicate what to do in response to the next
** token.
** ParseTOKENTYPE is the data type used for minor type for terminal
** symbols. Background: A "minor type" is a semantic
** value associated with a terminal or non-terminal
** symbols. For example, for an "ID" terminal symbol,
** the minor type might be the name of the identifier.
** Each non-terminal can have a different minor type.
** Terminal symbols all have the same minor type, though.
** This macros defines the minor type for terminal
** symbols.
** YYMINORTYPE is the data type used for all minor types.
** This is typically a union of many types, one of
** which is ParseTOKENTYPE. The entry in the union
** for terminal symbols is called "yy0".
** YYSTACKDEPTH is the maximum depth of the parser's stack. If
** zero the stack is dynamically sized using realloc()
** ParseARG_SDECL A static variable declaration for the %extra_argument
** ParseARG_PDECL A parameter declaration for the %extra_argument
** ParseARG_STORE Code to store %extra_argument into yypParser
** ParseARG_FETCH Code to extract %extra_argument from yypParser
** YYERRORSYMBOL is the code number of the error symbol. If not
** defined, then do no error processing.
** YYNSTATE the combined number of states.
** YYNRULE the number of rules in the grammar
** YY_MAX_SHIFT Maximum value for shift actions
** YY_MIN_SHIFTREDUCE Minimum value for shift-reduce actions
** YY_MAX_SHIFTREDUCE Maximum value for shift-reduce actions
** YY_MIN_REDUCE Maximum value for reduce actions
** YY_ERROR_ACTION The yy_action[] code for syntax error
** YY_ACCEPT_ACTION The yy_action[] code for accept
** YY_NO_ACTION The yy_action[] code for no-op
*/
#ifndef INTERFACE
# define INTERFACE 1
#endif
/************* Begin control #defines *****************************************/
#define YYCODETYPE unsigned char
#define YYNOCODE 59
#define YYACTIONTYPE unsigned short int
#define ParseTOKENTYPE Token
typedef union {
int yyinit;
ParseTOKENTYPE yy0;
int yy117;
} YYMINORTYPE;
#ifndef YYSTACKDEPTH
#define YYSTACKDEPTH 100
#endif
#define ParseARG_SDECL Debug::Command *command ;
#define ParseARG_PDECL , Debug::Command *command
#define ParseARG_FETCH Debug::Command *command = yypParser->command
#define ParseARG_STORE yypParser->command = command
#define YYERRORSYMBOL 52
#define YYERRSYMDT yy117
#define YYNSTATE 140
#define YYNRULE 70
#define YY_MAX_SHIFT 139
#define YY_MIN_SHIFTREDUCE 157
#define YY_MAX_SHIFTREDUCE 226
#define YY_MIN_REDUCE 227
#define YY_MAX_REDUCE 296
#define YY_ERROR_ACTION 297
#define YY_ACCEPT_ACTION 298
#define YY_NO_ACTION 299
/************* End control #defines *******************************************/
/* Define the yytestcase() macro to be a no-op if is not already defined
** otherwise.
**
** Applications can choose to define yytestcase() in the %include section
** to a macro that can assist in verifying code coverage. For production
** code the yytestcase() macro should be turned off. But it is useful
** for testing.
*/
#ifndef yytestcase
# define yytestcase(X)
#endif
/* Next are the tables used to determine what action to take based on the
** current state and lookahead token. These tables are used to implement
** functions that take a state number and lookahead value and return an
** action integer.
**
** Suppose the action integer is N. Then the action is determined as
** follows
**
** 0 <= N <= YY_MAX_SHIFT Shift N. That is, push the lookahead
** token onto the stack and goto state N.
**
** N between YY_MIN_SHIFTREDUCE Shift to an arbitrary state then
** and YY_MAX_SHIFTREDUCE reduce by rule N-YY_MIN_SHIFTREDUCE.
**
** N between YY_MIN_REDUCE Reduce by rule N-YY_MIN_REDUCE
** and YY_MAX_REDUCE
**
** N == YY_ERROR_ACTION A syntax error has occurred.
**
** N == YY_ACCEPT_ACTION The parser accepts its input.
**
** N == YY_NO_ACTION No such action. Denotes unused
** slots in the yy_action[] table.
**
** The action table is constructed as a single large table named yy_action[].
** Given state S and lookahead X, the action is computed as either:
**
** (A) N = yy_action[ yy_shift_ofst[S] + X ]
** (B) N = yy_default[S]
**
** The (A) formula is preferred. The B formula is used instead if:
** (1) The yy_shift_ofst[S]+X value is out of range, or
** (2) yy_lookahead[yy_shift_ofst[S]+X] is not equal to X, or
** (3) yy_shift_ofst[S] equal YY_SHIFT_USE_DFLT.
** (Implementation note: YY_SHIFT_USE_DFLT is chosen so that
** YY_SHIFT_USE_DFLT+X will be out of range for all possible lookaheads X.
** Hence only tests (1) and (2) need to be evaluated.)
**
** The formulas above are for computing the action when the lookahead is
** a terminal symbol. If the lookahead is a non-terminal (as occurs after
** a reduce action) then the yy_reduce_ofst[] array is used in place of
** the yy_shift_ofst[] array and YY_REDUCE_USE_DFLT is used in place of
** YY_SHIFT_USE_DFLT.
**
** The following are the tables generated in this section:
**
** yy_action[] A single table containing all actions.
** yy_lookahead[] A table containing the lookahead for each entry in
** yy_action. Used to detect hash collisions.
** yy_shift_ofst[] For each state, the offset into yy_action for
** shifting terminals.
** yy_reduce_ofst[] For each state, the offset into yy_action for
** shifting non-terminals after a reduce.
** yy_default[] Default action for each state.
**
*********** Begin parsing tables **********************************************/
#define YY_ACTTAB_COUNT (849)
static const YYACTIONTYPE yy_action[] = {
/* 0 */ 42, 41, 37, 119, 128, 39, 40, 126, 15, 5,
/* 10 */ 110, 108, 4, 3, 2, 14, 1, 13, 263, 6,
/* 20 */ 10, 93, 30, 29, 35, 34, 33, 32, 31, 83,
/* 30 */ 91, 262, 89, 87, 85, 17, 118, 221, 116, 18,
/* 40 */ 19, 20, 21, 22, 24, 23, 28, 27, 26, 25,
/* 50 */ 30, 29, 35, 34, 33, 32, 31, 261, 84, 139,
/* 60 */ 138, 136, 134, 132, 130, 44, 54, 120, 292, 284,
/* 70 */ 36, 16, 7, 124, 75, 122, 18, 19, 20, 21,
/* 80 */ 22, 24, 23, 28, 27, 26, 25, 30, 29, 35,
/* 90 */ 34, 33, 32, 31, 260, 8, 97, 298, 45, 120,
/* 100 */ 292, 284, 35, 34, 33, 32, 31, 12, 11, 18,
/* 110 */ 19, 20, 21, 22, 24, 23, 28, 27, 26, 25,
/* 120 */ 30, 29, 35, 34, 33, 32, 31, 259, 9, 82,
/* 130 */ 92, 18, 19, 20, 21, 22, 24, 23, 28, 27,
/* 140 */ 26, 25, 30, 29, 35, 34, 33, 32, 31, 247,
/* 150 */ 246, 86, 107, 18, 19, 20, 21, 22, 24, 23,
/* 160 */ 28, 27, 26, 25, 30, 29, 35, 34, 33, 32,
/* 170 */ 31, 245, 244, 88, 109, 18, 19, 20, 21, 22,
/* 180 */ 24, 23, 28, 27, 26, 25, 30, 29, 35, 34,
/* 190 */ 33, 32, 31, 243, 242, 90, 115, 18, 19, 20,
/* 200 */ 21, 22, 24, 23, 28, 27, 26, 25, 30, 29,
/* 210 */ 35, 34, 33, 32, 31, 241, 240, 94, 117, 18,
/* 220 */ 19, 20, 21, 22, 24, 23, 28, 27, 26, 25,
/* 230 */ 30, 29, 35, 34, 33, 32, 31, 239, 238, 95,
/* 240 */ 213, 18, 19, 20, 21, 22, 24, 23, 28, 27,
/* 250 */ 26, 25, 30, 29, 35, 34, 33, 32, 31, 237,
/* 260 */ 236, 96, 43, 18, 19, 20, 21, 22, 24, 23,
/* 270 */ 28, 27, 26, 25, 30, 29, 35, 34, 33, 32,
/* 280 */ 31, 235, 234, 98, 121, 18, 19, 20, 21, 22,
/* 290 */ 24, 23, 28, 27, 26, 25, 30, 29, 35, 34,
/* 300 */ 33, 32, 31, 233, 232, 100, 123, 18, 19, 20,
/* 310 */ 21, 22, 24, 23, 28, 27, 26, 25, 30, 29,
/* 320 */ 35, 34, 33, 32, 31, 231, 230, 101, 125, 18,
/* 330 */ 19, 20, 21, 22, 24, 23, 28, 27, 26, 25,
/* 340 */ 30, 29, 35, 34, 33, 32, 31, 229, 228, 103,
/* 350 */ 127, 18, 19, 20, 21, 22, 24, 23, 28, 27,
/* 360 */ 26, 25, 30, 29, 35, 34, 33, 32, 31, 253,
/* 370 */ 250, 105, 129, 18, 19, 20, 21, 22, 24, 23,
/* 380 */ 28, 27, 26, 25, 30, 29, 35, 34, 33, 32,
/* 390 */ 31, 254, 249, 111, 131, 18, 19, 20, 21, 22,
/* 400 */ 24, 23, 28, 27, 26, 25, 30, 29, 35, 34,
/* 410 */ 33, 32, 31, 258, 257, 113, 133, 18, 19, 20,
/* 420 */ 21, 22, 24, 23, 28, 27, 26, 25, 30, 29,
/* 430 */ 35, 34, 33, 32, 31, 19, 20, 21, 22, 24,
/* 440 */ 23, 28, 27, 26, 25, 30, 29, 35, 34, 33,
/* 450 */ 32, 31, 80, 135, 18, 19, 20, 21, 22, 24,
/* 460 */ 23, 28, 27, 26, 25, 30, 29, 35, 34, 33,
/* 470 */ 32, 31, 18, 19, 20, 21, 22, 24, 23, 28,
/* 480 */ 27, 26, 25, 30, 29, 35, 34, 33, 32, 31,
/* 490 */ 24, 23, 28, 27, 26, 25, 30, 29, 35, 34,
/* 500 */ 33, 32, 31, 220, 289, 292, 284, 81, 33, 32,
/* 510 */ 31, 20, 21, 22, 24, 23, 28, 27, 26, 25,
/* 520 */ 30, 29, 35, 34, 33, 32, 31, 21, 22, 24,
/* 530 */ 23, 28, 27, 26, 25, 30, 29, 35, 34, 33,
/* 540 */ 32, 31, 22, 24, 23, 28, 27, 26, 25, 30,
/* 550 */ 29, 35, 34, 33, 32, 31, 42, 41, 38, 256,
/* 560 */ 255, 39, 40, 99, 252, 42, 41, 38, 251, 248,
/* 570 */ 39, 40, 102, 288, 292, 284, 42, 41, 38, 137,
/* 580 */ 227, 39, 40, 104, 229, 223, 224, 229, 225, 226,
/* 590 */ 229, 17, 229, 221, 223, 224, 229, 225, 226, 229,
/* 600 */ 17, 224, 221, 225, 226, 223, 224, 229, 225, 226,
/* 610 */ 229, 17, 229, 221, 229, 42, 41, 38, 229, 229,
/* 620 */ 39, 40, 106, 229, 42, 41, 38, 229, 229, 39,
/* 630 */ 40, 112, 287, 292, 284, 42, 41, 38, 229, 229,
/* 640 */ 39, 40, 114, 229, 223, 224, 229, 225, 226, 229,
/* 650 */ 17, 229, 221, 223, 224, 229, 225, 226, 229, 17,
/* 660 */ 229, 221, 229, 229, 223, 224, 229, 225, 226, 229,
/* 670 */ 17, 229, 221, 229, 42, 41, 38, 229, 229, 39,
/* 680 */ 40, 28, 27, 26, 25, 30, 29, 35, 34, 33,
/* 690 */ 32, 31, 56, 120, 292, 284, 57, 120, 292, 284,
/* 700 */ 286, 292, 284, 223, 224, 229, 225, 226, 229, 17,
/* 710 */ 229, 221, 58, 120, 292, 284, 59, 120, 292, 284,
/* 720 */ 47, 120, 292, 284, 229, 48, 120, 292, 284, 49,
/* 730 */ 120, 292, 284, 229, 50, 120, 292, 284, 51, 120,
/* 740 */ 292, 284, 52, 120, 292, 284, 53, 120, 292, 284,
/* 750 */ 46, 120, 292, 284, 55, 120, 292, 284, 60, 120,
/* 760 */ 292, 284, 61, 120, 292, 284, 62, 120, 292, 284,
/* 770 */ 64, 120, 292, 284, 65, 120, 292, 284, 66, 120,
/* 780 */ 292, 284, 67, 120, 292, 284, 68, 120, 292, 284,
/* 790 */ 69, 120, 292, 284, 70, 120, 292, 284, 71, 120,
/* 800 */ 292, 284, 72, 120, 292, 284, 73, 120, 292, 284,
/* 810 */ 74, 120, 292, 284, 76, 120, 292, 284, 77, 120,
/* 820 */ 292, 284, 269, 120, 292, 284, 268, 120, 292, 284,
/* 830 */ 267, 120, 292, 284, 78, 120, 292, 284, 79, 120,
/* 840 */ 292, 284, 63, 120, 292, 284, 285, 292, 284,
};
static const YYCODETYPE yy_lookahead[] = {
/* 0 */ 14, 15, 16, 56, 43, 19, 20, 52, 22, 23,
/* 10 */ 24, 25, 26, 27, 28, 29, 30, 31, 0, 45,
/* 20 */ 34, 35, 12, 13, 14, 15, 16, 17, 18, 43,
/* 30 */ 44, 0, 46, 47, 48, 49, 37, 51, 39, 1,
/* 40 */ 2, 3, 4, 5, 6, 7, 8, 9, 10, 11,
/* 50 */ 12, 13, 14, 15, 16, 17, 18, 0, 21, 21,
/* 60 */ 37, 38, 39, 40, 41, 42, 54, 55, 56, 57,
/* 70 */ 32, 33, 45, 37, 36, 39, 1, 2, 3, 4,
/* 80 */ 5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
/* 90 */ 15, 16, 17, 18, 0, 45, 21, 53, 54, 55,
/* 100 */ 56, 57, 14, 15, 16, 17, 18, 32, 33, 1,
/* 110 */ 2, 3, 4, 5, 6, 7, 8, 9, 10, 11,
/* 120 */ 12, 13, 14, 15, 16, 17, 18, 0, 45, 21,
/* 130 */ 21, 1, 2, 3, 4, 5, 6, 7, 8, 9,
/* 140 */ 10, 11, 12, 13, 14, 15, 16, 17, 18, 0,
/* 150 */ 0, 21, 21, 1, 2, 3, 4, 5, 6, 7,
/* 160 */ 8, 9, 10, 11, 12, 13, 14, 15, 16, 17,
/* 170 */ 18, 0, 0, 21, 21, 1, 2, 3, 4, 5,
/* 180 */ 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
/* 190 */ 16, 17, 18, 0, 0, 21, 21, 1, 2, 3,
/* 200 */ 4, 5, 6, 7, 8, 9, 10, 11, 12, 13,
/* 210 */ 14, 15, 16, 17, 18, 0, 0, 21, 21, 1,
/* 220 */ 2, 3, 4, 5, 6, 7, 8, 9, 10, 11,
/* 230 */ 12, 13, 14, 15, 16, 17, 18, 0, 0, 21,
/* 240 */ 50, 1, 2, 3, 4, 5, 6, 7, 8, 9,
/* 250 */ 10, 11, 12, 13, 14, 15, 16, 17, 18, 0,
/* 260 */ 0, 21, 49, 1, 2, 3, 4, 5, 6, 7,
/* 270 */ 8, 9, 10, 11, 12, 13, 14, 15, 16, 17,
/* 280 */ 18, 0, 0, 21, 21, 1, 2, 3, 4, 5,
/* 290 */ 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
/* 300 */ 16, 17, 18, 0, 0, 21, 21, 1, 2, 3,
/* 310 */ 4, 5, 6, 7, 8, 9, 10, 11, 12, 13,
/* 320 */ 14, 15, 16, 17, 18, 0, 0, 21, 21, 1,
/* 330 */ 2, 3, 4, 5, 6, 7, 8, 9, 10, 11,
/* 340 */ 12, 13, 14, 15, 16, 17, 18, 0, 0, 21,
/* 350 */ 21, 1, 2, 3, 4, 5, 6, 7, 8, 9,
/* 360 */ 10, 11, 12, 13, 14, 15, 16, 17, 18, 0,
/* 370 */ 0, 21, 21, 1, 2, 3, 4, 5, 6, 7,
/* 380 */ 8, 9, 10, 11, 12, 13, 14, 15, 16, 17,
/* 390 */ 18, 0, 0, 21, 21, 1, 2, 3, 4, 5,
/* 400 */ 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
/* 410 */ 16, 17, 18, 0, 0, 21, 21, 1, 2, 3,
/* 420 */ 4, 5, 6, 7, 8, 9, 10, 11, 12, 13,
/* 430 */ 14, 15, 16, 17, 18, 2, 3, 4, 5, 6,
/* 440 */ 7, 8, 9, 10, 11, 12, 13, 14, 15, 16,
/* 450 */ 17, 18, 36, 21, 1, 2, 3, 4, 5, 6,
/* 460 */ 7, 8, 9, 10, 11, 12, 13, 14, 15, 16,
/* 470 */ 17, 18, 1, 2, 3, 4, 5, 6, 7, 8,
/* 480 */ 9, 10, 11, 12, 13, 14, 15, 16, 17, 18,
/* 490 */ 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
/* 500 */ 16, 17, 18, 50, 55, 56, 57, 36, 16, 17,
/* 510 */ 18, 3, 4, 5, 6, 7, 8, 9, 10, 11,
/* 520 */ 12, 13, 14, 15, 16, 17, 18, 4, 5, 6,
/* 530 */ 7, 8, 9, 10, 11, 12, 13, 14, 15, 16,
/* 540 */ 17, 18, 5, 6, 7, 8, 9, 10, 11, 12,
/* 550 */ 13, 14, 15, 16, 17, 18, 14, 15, 16, 0,
/* 560 */ 0, 19, 20, 21, 0, 14, 15, 16, 0, 0,
/* 570 */ 19, 20, 21, 55, 56, 57, 14, 15, 16, 21,
/* 580 */ 0, 19, 20, 21, 58, 43, 44, 58, 46, 47,
/* 590 */ 58, 49, 58, 51, 43, 44, 58, 46, 47, 58,
/* 600 */ 49, 44, 51, 46, 47, 43, 44, 58, 46, 47,
/* 610 */ 58, 49, 58, 51, 58, 14, 15, 16, 58, 58,
/* 620 */ 19, 20, 21, 58, 14, 15, 16, 58, 58, 19,
/* 630 */ 20, 21, 55, 56, 57, 14, 15, 16, 58, 58,
/* 640 */ 19, 20, 21, 58, 43, 44, 58, 46, 47, 58,
/* 650 */ 49, 58, 51, 43, 44, 58, 46, 47, 58, 49,
/* 660 */ 58, 51, 58, 58, 43, 44, 58, 46, 47, 58,
/* 670 */ 49, 58, 51, 58, 14, 15, 16, 58, 58, 19,
/* 680 */ 20, 8, 9, 10, 11, 12, 13, 14, 15, 16,
/* 690 */ 17, 18, 54, 55, 56, 57, 54, 55, 56, 57,
/* 700 */ 55, 56, 57, 43, 44, 58, 46, 47, 58, 49,
/* 710 */ 58, 51, 54, 55, 56, 57, 54, 55, 56, 57,
/* 720 */ 54, 55, 56, 57, 58, 54, 55, 56, 57, 54,
/* 730 */ 55, 56, 57, 58, 54, 55, 56, 57, 54, 55,
/* 740 */ 56, 57, 54, 55, 56, 57, 54, 55, 56, 57,
/* 750 */ 54, 55, 56, 57, 54, 55, 56, 57, 54, 55,
/* 760 */ 56, 57, 54, 55, 56, 57, 54, 55, 56, 57,
/* 770 */ 54, 55, 56, 57, 54, 55, 56, 57, 54, 55,
/* 780 */ 56, 57, 54, 55, 56, 57, 54, 55, 56, 57,
/* 790 */ 54, 55, 56, 57, 54, 55, 56, 57, 54, 55,
/* 800 */ 56, 57, 54, 55, 56, 57, 54, 55, 56, 57,
/* 810 */ 54, 55, 56, 57, 54, 55, 56, 57, 54, 55,
/* 820 */ 56, 57, 54, 55, 56, 57, 54, 55, 56, 57,
/* 830 */ 54, 55, 56, 57, 54, 55, 56, 57, 54, 55,
/* 840 */ 56, 57, 54, 55, 56, 57, 55, 56, 57,
};
#define YY_SHIFT_USE_DFLT (849)
#define YY_SHIFT_COUNT (139)
#define YY_SHIFT_MIN (-39)
#define YY_SHIFT_MAX (673)
static const short yy_shift_ofst[] = {
/* 0 */ -14, 542, 551, 562, 601, 610, 660, 660, 660, 660,
/* 10 */ 660, 660, 660, 660, 660, 660, 660, 660, 660, 660,
/* 20 */ 660, 660, 660, 660, 660, 660, 660, 660, 660, 660,
/* 30 */ 660, 660, 660, 660, 660, 660, 660, 621, 660, 660,
/* 40 */ 660, 660, 660, 557, -39, 38, 75, 108, 130, 152,
/* 50 */ 174, 196, 218, 240, 262, 284, 306, 328, 350, 372,
/* 60 */ 394, 416, 453, 471, 433, 508, 523, 537, 484, 673,
/* 70 */ 673, 10, 10, 10, 10, 23, 88, 88, 492, 492,
/* 80 */ -1, 36, 18, -26, 31, 37, 57, 27, 94, 50,
/* 90 */ 127, 83, 149, 109, 150, 171, 172, 193, 194, 215,
/* 100 */ 216, 237, 238, 259, 260, 281, 282, 303, 131, 304,
/* 110 */ 153, 325, 326, 347, 348, 369, 175, 370, 197, 190,
/* 120 */ 213, 391, 263, 392, 285, 413, 307, 414, 329, 559,
/* 130 */ 351, 560, 373, 564, 395, 568, 432, 569, 558, 580,
};
#define YY_REDUCE_USE_DFLT (-54)
#define YY_REDUCE_COUNT (44)
#define YY_REDUCE_MIN (-53)
#define YY_REDUCE_MAX (791)
static const short yy_reduce_ofst[] = {
/* 0 */ 44, 12, 638, 642, 658, 662, 666, 671, 675, 680,
/* 10 */ 684, 688, 692, 696, 700, 704, 708, 712, 716, 720,
/* 20 */ 724, 728, 732, 736, 740, 744, 748, 752, 756, 760,
/* 30 */ 764, 768, 772, 776, 780, 784, 788, 449, 449, 518,
/* 40 */ 577, 645, 791, -53, -45,
};
static const YYACTIONTYPE yy_default[] = {
/* 0 */ 297, 297, 297, 297, 297, 297, 297, 297, 297, 297,
/* 10 */ 297, 297, 297, 297, 297, 297, 297, 297, 297, 297,
/* 20 */ 297, 297, 297, 297, 297, 297, 297, 297, 297, 297,
/* 30 */ 297, 297, 297, 297, 297, 297, 297, 297, 297, 297,
/* 40 */ 297, 297, 297, 297, 297, 297, 297, 297, 297, 297,
/* 50 */ 297, 297, 297, 297, 297, 297, 297, 297, 297, 297,
/* 60 */ 297, 297, 297, 297, 282, 281, 280, 279, 278, 277,
/* 70 */ 276, 275, 274, 273, 272, 297, 271, 270, 266, 265,
/* 80 */ 297, 297, 297, 293, 297, 297, 297, 296, 297, 295,
/* 90 */ 297, 294, 297, 297, 297, 297, 297, 297, 297, 297,
/* 100 */ 297, 297, 297, 297, 297, 297, 297, 297, 297, 297,
/* 110 */ 297, 297, 297, 297, 297, 297, 297, 297, 297, 297,
/* 120 */ 264, 297, 297, 297, 297, 297, 297, 297, 297, 297,
/* 130 */ 297, 297, 297, 297, 297, 297, 297, 297, 297, 297,
};
/********** End of lemon-generated parsing tables *****************************/
/* The next table maps tokens (terminal symbols) into fallback tokens.
** If a construct like the following:
**
** %fallback ID X Y Z.
**
** appears in the grammar, then ID becomes a fallback token for X, Y,
** and Z. Whenever one of the tokens X, Y, or Z is input to the parser
** but it does not parse, the type of the token is changed to ID and
** the parse is retried before an error is thrown.
**
** This feature can be used, for example, to cause some keywords in a language
** to revert to identifiers if they keyword does not apply in the context where
** it appears.
*/
#ifdef YYFALLBACK
static const YYCODETYPE yyFallback[] = {
};
#endif /* YYFALLBACK */
/* The following structure represents a single element of the
** parser's stack. Information stored includes:
**
** + The state number for the parser at this level of the stack.
**
** + The value of the token stored at this level of the stack.
** (In other words, the "major" token.)
**
** + The semantic value stored at this level of the stack. This is
** the information used by the action routines in the grammar.
** It is sometimes called the "minor" token.
**
** After the "shift" half of a SHIFTREDUCE action, the stateno field
** actually contains the reduce action for the second half of the
** SHIFTREDUCE.
*/
struct yyStackEntry {
YYACTIONTYPE stateno; /* The state-number, or reduce action in SHIFTREDUCE */
YYCODETYPE major; /* The major token value. This is the code
** number for the token at this stack level */
YYMINORTYPE minor; /* The user-supplied minor token value. This
** is the value of the token */
};
typedef struct yyStackEntry yyStackEntry;
/* The state of the parser is completely contained in an instance of
** the following structure */
struct yyParser {
yyStackEntry *yytos; /* Pointer to top element of the stack */
#ifdef YYTRACKMAXSTACKDEPTH
int yyhwm; /* High-water mark of the stack */
#endif
#ifndef YYNOERRORRECOVERY
int yyerrcnt; /* Shifts left before out of the error */
#endif
ParseARG_SDECL /* A place to hold %extra_argument */
#if YYSTACKDEPTH<=0
int yystksz; /* Current side of the stack */
yyStackEntry *yystack; /* The parser's stack */
yyStackEntry yystk0; /* First stack entry */
#else
yyStackEntry yystack[YYSTACKDEPTH]; /* The parser's stack */
yyStackEntry *yystackEnd; /* Last entry in the stack */
#endif
};
typedef struct yyParser yyParser;
#ifndef NDEBUG
#include <stdio.h>
static FILE *yyTraceFILE = 0;
static char *yyTracePrompt = 0;
#endif /* NDEBUG */
#ifndef NDEBUG
/*
** Turn parser tracing on by giving a stream to which to write the trace
** and a prompt to preface each trace message. Tracing is turned off
** by making either argument NULL
**
** Inputs:
** <ul>
** <li> A FILE* to which trace output should be written.
** If NULL, then tracing is turned off.
** <li> A prefix string written at the beginning of every
** line of trace output. If NULL, then tracing is
** turned off.
** </ul>
**
** Outputs:
** None.
*/
void ParseTrace(FILE *TraceFILE, char *zTracePrompt){
yyTraceFILE = TraceFILE;
yyTracePrompt = zTracePrompt;
if( yyTraceFILE==0 ) yyTracePrompt = 0;
else if( yyTracePrompt==0 ) yyTraceFILE = 0;
}
#endif /* NDEBUG */
#ifndef NDEBUG
/* For tracing shifts, the names of all terminals and nonterminals
** are required. The following table supplies these names */
static const char *const yyTokenName[] = {
"$", "PIPEPIPE", "AMPAMP", "PIPE",
"CARET", "AMP", "EQEQ", "BANGEQ",
"LT", "LTEQ", "GT", "GTEQ",
"LTLT", "GTGT", "PLUS", "MINUS",
"STAR", "SLASH", "PERCENT", "BANG",
"TILDE", "EOL", "PRINT", "BREAK",
"BACKTRACE", "CONTINUE", "TBREAK", "RBREAK",
"WBREAK", "RWBREAK", "NEXT", "DUMP",
"COLON", "AT", "LIST", "STACKCRAWL",
"SEMI", "SEMIH", "SEMII", "SEMIL",
"SEMIDATE", "SEMIERROR", "SEMIT", "IDENTIFIER",
"DREGISTER", "EQ", "AREGISTER", "XREGISTER",
"HELP", "LPAREN", "RPAREN", "INTEGER",
"error", "stmt", "expr", "unary",
"register", "term",
};
#endif /* NDEBUG */
#ifndef NDEBUG
/* For tracing reduce actions, the names of all rules are required.
*/
static const char *const yyRuleName[] = {
/* 0 */ "stmt ::= expr EOL",
/* 1 */ "stmt ::= STAR EOL",
/* 2 */ "stmt ::= PRINT expr EOL",
/* 3 */ "stmt ::= BREAK EOL",
/* 4 */ "stmt ::= BREAK expr EOL",
/* 5 */ "stmt ::= BACKTRACE EOL",
/* 6 */ "stmt ::= CONTINUE EOL",
/* 7 */ "stmt ::= TBREAK EOL",
/* 8 */ "stmt ::= TBREAK expr EOL",
/* 9 */ "stmt ::= RBREAK EOL",
/* 10 */ "stmt ::= RBREAK expr EOL",
/* 11 */ "stmt ::= WBREAK EOL",
/* 12 */ "stmt ::= WBREAK expr EOL",
/* 13 */ "stmt ::= RWBREAK expr EOL",
/* 14 */ "stmt ::= NEXT EOL",
/* 15 */ "stmt ::= NEXT expr EOL",
/* 16 */ "stmt ::= DUMP expr EOL",
/* 17 */ "stmt ::= DUMP expr COLON expr EOL",
/* 18 */ "stmt ::= DUMP expr AT expr EOL",
/* 19 */ "stmt ::= LIST expr EOL",
/* 20 */ "stmt ::= STACKCRAWL EOL",
/* 21 */ "stmt ::= expr SEMI SEMIH EOL",
/* 22 */ "stmt ::= expr COLON expr SEMI SEMIH EOL",
/* 23 */ "stmt ::= expr AT expr SEMI SEMIH EOL",
/* 24 */ "stmt ::= expr SEMI SEMII EOL",
/* 25 */ "stmt ::= expr SEMI SEMIL EOL",
/* 26 */ "stmt ::= expr AT expr SEMI SEMIL EOL",
/* 27 */ "stmt ::= expr COLON expr SEMI SEMIL EOL",
/* 28 */ "stmt ::= expr SEMI SEMIDATE EOL",
/* 29 */ "stmt ::= expr SEMI SEMIERROR EOL",
/* 30 */ "stmt ::= expr SEMI SEMIT IDENTIFIER EOL",
/* 31 */ "stmt ::= expr SEMI SEMIT error EOL",
/* 32 */ "stmt ::= DREGISTER EQ expr EOL",
/* 33 */ "stmt ::= AREGISTER EQ expr EOL",
/* 34 */ "stmt ::= XREGISTER EQ expr EOL",
/* 35 */ "stmt ::= HELP EOL",
/* 36 */ "stmt ::= IDENTIFIER EQ expr EOL",
/* 37 */ "expr ::= unary",
/* 38 */ "expr ::= expr PLUS expr",
/* 39 */ "expr ::= expr MINUS expr",
/* 40 */ "expr ::= expr STAR expr",
/* 41 */ "expr ::= expr SLASH expr",
/* 42 */ "expr ::= expr PERCENT expr",
/* 43 */ "expr ::= expr LTLT expr",
/* 44 */ "expr ::= expr GTGT expr",
/* 45 */ "expr ::= expr LT expr",
/* 46 */ "expr ::= expr LTEQ expr",
/* 47 */ "expr ::= expr GT expr",
/* 48 */ "expr ::= expr GTEQ expr",
/* 49 */ "expr ::= expr EQEQ expr",
/* 50 */ "expr ::= expr BANGEQ expr",
/* 51 */ "expr ::= expr AMP expr",
/* 52 */ "expr ::= expr CARET expr",
/* 53 */ "expr ::= expr PIPE expr",
/* 54 */ "expr ::= expr AMPAMP expr",
/* 55 */ "expr ::= expr PIPEPIPE expr",
/* 56 */ "expr ::= unary LPAREN register RPAREN",
/* 57 */ "unary ::= term",
/* 58 */ "unary ::= PLUS unary",
/* 59 */ "unary ::= MINUS unary",
/* 60 */ "unary ::= TILDE unary",
/* 61 */ "unary ::= BANG unary",
/* 62 */ "unary ::= STAR unary",
/* 63 */ "term ::= LPAREN expr RPAREN",
/* 64 */ "term ::= INTEGER",
/* 65 */ "term ::= register",
/* 66 */ "term ::= IDENTIFIER",
/* 67 */ "register ::= DREGISTER",
/* 68 */ "register ::= AREGISTER",
/* 69 */ "register ::= XREGISTER",
};
#endif /* NDEBUG */
#if YYSTACKDEPTH<=0
/*
** Try to increase the size of the parser stack. Return the number
** of errors. Return 0 on success.
*/
static int yyGrowStack(yyParser *p){
int newSize;
int idx;
yyStackEntry *pNew;
newSize = p->yystksz*2 + 100;
idx = p->yytos ? (int)(p->yytos - p->yystack) : 0;
if( p->yystack==&p->yystk0 ){
pNew = malloc(newSize*sizeof(pNew[0]));
if( pNew ) pNew[0] = p->yystk0;
}else{
pNew = realloc(p->yystack, newSize*sizeof(pNew[0]));
}
if( pNew ){
p->yystack = pNew;
p->yytos = &p->yystack[idx];
#ifndef NDEBUG
if( yyTraceFILE ){
fprintf(yyTraceFILE,"%sStack grows from %d to %d entries.\n",
yyTracePrompt, p->yystksz, newSize);
}
#endif
p->yystksz = newSize;
}
return pNew==0;
}
#endif
/* Datatype of the argument to the memory allocated passed as the
** second argument to ParseAlloc() below. This can be changed by
** putting an appropriate #define in the %include section of the input
** grammar.
*/
#ifndef YYMALLOCARGTYPE
# define YYMALLOCARGTYPE size_t
#endif
/* Initialize a new parser that has already been allocated.
*/
void ParseInit(void *yypParser){
yyParser *pParser = (yyParser*)yypParser;
#ifdef YYTRACKMAXSTACKDEPTH
pParser->yyhwm = 0;
#endif
#if YYSTACKDEPTH<=0
pParser->yytos = NULL;
pParser->yystack = NULL;
pParser->yystksz = 0;
if( yyGrowStack(pParser) ){
pParser->yystack = &pParser->yystk0;
pParser->yystksz = 1;
}
#endif
#ifndef YYNOERRORRECOVERY
pParser->yyerrcnt = -1;
#endif
pParser->yytos = pParser->yystack;
pParser->yystack[0].stateno = 0;
pParser->yystack[0].major = 0;
#if YYSTACKDEPTH>0
pParser->yystackEnd = &pParser->yystack[YYSTACKDEPTH-1];
#endif
}
#ifndef Parse_ENGINEALWAYSONSTACK
/*
** This function allocates a new parser.
** The only argument is a pointer to a function which works like
** malloc.
**
** Inputs:
** A pointer to the function used to allocate memory.
**
** Outputs:
** A pointer to a parser. This pointer is used in subsequent calls
** to Parse and ParseFree.
*/
void *ParseAlloc(void *(*mallocProc)(YYMALLOCARGTYPE)){
yyParser *pParser;
pParser = (yyParser*)(*mallocProc)( (YYMALLOCARGTYPE)sizeof(yyParser) );
if( pParser ) ParseInit(pParser);
return pParser;
}
#endif /* Parse_ENGINEALWAYSONSTACK */
/* The following function deletes the "minor type" or semantic value
** associated with a symbol. The symbol can be either a terminal
** or nonterminal. "yymajor" is the symbol code, and "yypminor" is
** a pointer to the value to be deleted. The code used to do the
** deletions is derived from the %destructor and/or %token_destructor
** directives of the input grammar.
*/
static void yy_destructor(
yyParser *yypParser, /* The parser */
YYCODETYPE yymajor, /* Type code for object to destroy */
YYMINORTYPE *yypminor /* The object to be destroyed */
){
ParseARG_FETCH;
switch( yymajor ){
/* Here is inserted the actions which take place when a
** terminal or non-terminal is destroyed. This can happen
** when the symbol is popped from the stack during a
** reduce or during error processing or when a parser is
** being destroyed before it is finished parsing.
**
** Note: during a reduce, the only symbols destroyed are those
** which appear on the RHS of the rule, but which are *not* used
** inside the C code.
*/
/********* Begin destructor definitions ***************************************/
/********* End destructor definitions *****************************************/
default: break; /* If no destructor action specified: do nothing */
}
}
/*
** Pop the parser's stack once.
**
** If there is a destructor routine associated with the token which
** is popped from the stack, then call it.
*/
static void yy_pop_parser_stack(yyParser *pParser){
yyStackEntry *yytos;
assert( pParser->yytos!=0 );
assert( pParser->yytos > pParser->yystack );
yytos = pParser->yytos--;
#ifndef NDEBUG
if( yyTraceFILE ){
fprintf(yyTraceFILE,"%sPopping %s\n",
yyTracePrompt,
yyTokenName[yytos->major]);
}
#endif
yy_destructor(pParser, yytos->major, &yytos->minor);
}
/*
** Clear all secondary memory allocations from the parser
*/
void ParseFinalize(void *p){
yyParser *pParser = (yyParser*)p;
while( pParser->yytos>pParser->yystack ) yy_pop_parser_stack(pParser);
#if YYSTACKDEPTH<=0
if( pParser->yystack!=&pParser->yystk0 ) free(pParser->yystack);
#endif
}
#ifndef Parse_ENGINEALWAYSONSTACK
/*
** Deallocate and destroy a parser. Destructors are called for
** all stack elements before shutting the parser down.
**
** If the YYPARSEFREENEVERNULL macro exists (for example because it
** is defined in a %include section of the input grammar) then it is
** assumed that the input pointer is never NULL.
*/
void ParseFree(
void *p, /* The parser to be deleted */
void (*freeProc)(void*) /* Function used to reclaim memory */
){
#ifndef YYPARSEFREENEVERNULL
if( p==0 ) return;
#endif
ParseFinalize(p);
(*freeProc)(p);
}
#endif /* Parse_ENGINEALWAYSONSTACK */
/*
** Return the peak depth of the stack for a parser.
*/
#ifdef YYTRACKMAXSTACKDEPTH
int ParseStackPeak(void *p){
yyParser *pParser = (yyParser*)p;
return pParser->yyhwm;
}
#endif
/*
** Find the appropriate action for a parser given the terminal
** look-ahead token iLookAhead.
*/
static unsigned int yy_find_shift_action(
yyParser *pParser, /* The parser */
YYCODETYPE iLookAhead /* The look-ahead token */
){
int i;
int stateno = pParser->yytos->stateno;
if( stateno>=YY_MIN_REDUCE ) return stateno;
assert( stateno <= YY_SHIFT_COUNT );
do{
i = yy_shift_ofst[stateno];
assert( iLookAhead!=YYNOCODE );
i += iLookAhead;
if( i<0 || i>=YY_ACTTAB_COUNT || yy_lookahead[i]!=iLookAhead ){
#ifdef YYFALLBACK
YYCODETYPE iFallback; /* Fallback token */
if( iLookAhead<sizeof(yyFallback)/sizeof(yyFallback[0])
&& (iFallback = yyFallback[iLookAhead])!=0 ){
#ifndef NDEBUG
if( yyTraceFILE ){
fprintf(yyTraceFILE, "%sFALLBACK %s => %s\n",
yyTracePrompt, yyTokenName[iLookAhead], yyTokenName[iFallback]);
}
#endif
assert( yyFallback[iFallback]==0 ); /* Fallback loop must terminate */
iLookAhead = iFallback;
continue;
}
#endif
#ifdef YYWILDCARD
{
int j = i - iLookAhead + YYWILDCARD;
if(
#if YY_SHIFT_MIN+YYWILDCARD<0
j>=0 &&
#endif
#if YY_SHIFT_MAX+YYWILDCARD>=YY_ACTTAB_COUNT
j<YY_ACTTAB_COUNT &&
#endif
yy_lookahead[j]==YYWILDCARD && iLookAhead>0
){
#ifndef NDEBUG
if( yyTraceFILE ){
fprintf(yyTraceFILE, "%sWILDCARD %s => %s\n",
yyTracePrompt, yyTokenName[iLookAhead],
yyTokenName[YYWILDCARD]);
}
#endif /* NDEBUG */
return yy_action[j];
}
}
#endif /* YYWILDCARD */
return yy_default[stateno];
}else{
return yy_action[i];
}
}while(1);
}
/*
** Find the appropriate action for a parser given the non-terminal
** look-ahead token iLookAhead.
*/
static int yy_find_reduce_action(
int stateno, /* Current state number */
YYCODETYPE iLookAhead /* The look-ahead token */
){
int i;
#ifdef YYERRORSYMBOL
if( stateno>YY_REDUCE_COUNT ){
return yy_default[stateno];
}
#else
assert( stateno<=YY_REDUCE_COUNT );
#endif
i = yy_reduce_ofst[stateno];
assert( i!=YY_REDUCE_USE_DFLT );
assert( iLookAhead!=YYNOCODE );
i += iLookAhead;
#ifdef YYERRORSYMBOL
if( i<0 || i>=YY_ACTTAB_COUNT || yy_lookahead[i]!=iLookAhead ){
return yy_default[stateno];
}
#else
assert( i>=0 && i<YY_ACTTAB_COUNT );
assert( yy_lookahead[i]==iLookAhead );
#endif
return yy_action[i];
}
/*
** The following routine is called if the stack overflows.
*/
static void yyStackOverflow(yyParser *yypParser){
ParseARG_FETCH;
#ifndef NDEBUG
if( yyTraceFILE ){
fprintf(yyTraceFILE,"%sStack Overflow!\n",yyTracePrompt);
}
#endif
while( yypParser->yytos>yypParser->yystack ) yy_pop_parser_stack(yypParser);
/* Here code is inserted which will execute if the parser
** stack every overflows */
/******** Begin %stack_overflow code ******************************************/
/******** End %stack_overflow code ********************************************/
ParseARG_STORE; /* Suppress warning about unused %extra_argument var */
}
/*
** Print tracing information for a SHIFT action
*/
#ifndef NDEBUG
static void yyTraceShift(yyParser *yypParser, int yyNewState){
if( yyTraceFILE ){
if( yyNewState<YYNSTATE ){
fprintf(yyTraceFILE,"%sShift '%s', go to state %d\n",
yyTracePrompt,yyTokenName[yypParser->yytos->major],
yyNewState);
}else{
fprintf(yyTraceFILE,"%sShift '%s'\n",
yyTracePrompt,yyTokenName[yypParser->yytos->major]);
}
}
}
#else
# define yyTraceShift(X,Y)
#endif
/*
** Perform a shift action.
*/
static void yy_shift(
yyParser *yypParser, /* The parser to be shifted */
int yyNewState, /* The new state to shift in */
int yyMajor, /* The major token to shift in */
ParseTOKENTYPE yyMinor /* The minor token to shift in */
){
yyStackEntry *yytos;
yypParser->yytos++;
#ifdef YYTRACKMAXSTACKDEPTH
if( (int)(yypParser->yytos - yypParser->yystack)>yypParser->yyhwm ){
yypParser->yyhwm++;
assert( yypParser->yyhwm == (int)(yypParser->yytos - yypParser->yystack) );
}
#endif
#if YYSTACKDEPTH>0
if( yypParser->yytos>yypParser->yystackEnd ){
yypParser->yytos--;
yyStackOverflow(yypParser);
return;
}
#else
if( yypParser->yytos>=&yypParser->yystack[yypParser->yystksz] ){
if( yyGrowStack(yypParser) ){
yypParser->yytos--;
yyStackOverflow(yypParser);
return;
}
}
#endif
if( yyNewState > YY_MAX_SHIFT ){
yyNewState += YY_MIN_REDUCE - YY_MIN_SHIFTREDUCE;
}
yytos = yypParser->yytos;
yytos->stateno = (YYACTIONTYPE)yyNewState;
yytos->major = (YYCODETYPE)yyMajor;
yytos->minor.yy0 = yyMinor;
yyTraceShift(yypParser, yyNewState);
}
/* The following table contains information about every rule that
** is used during the reduce.
*/
static const struct {
YYCODETYPE lhs; /* Symbol on the left-hand side of the rule */
signed char nrhs; /* Negative of the number of RHS symbols in the rule */
} yyRuleInfo[] = {
{ 53, -2 },
{ 53, -2 },
{ 53, -3 },