drh | 82415f2 | 2015-11-09 19:33:42 +0000 | [diff] [blame] | 1 | /* |
| 2 | ** 2000-05-29 |
drh | 7589723 | 2000-05-29 14:26:00 +0000 | [diff] [blame] | 3 | ** |
drh | 82415f2 | 2015-11-09 19:33:42 +0000 | [diff] [blame] | 4 | ** The author disclaims copyright to this source code. In place of |
| 5 | ** a legal notice, here is a blessing: |
| 6 | ** |
| 7 | ** May you do good and not evil. |
| 8 | ** May you find forgiveness for yourself and forgive others. |
| 9 | ** May you share freely, never taking more than you give. |
| 10 | ** |
| 11 | ************************************************************************* |
| 12 | ** Driver template for the LEMON parser generator. |
| 13 | ** |
| 14 | ** The "lemon" program processes an LALR(1) input grammar file, then uses |
| 15 | ** this template to construct a parser. The "lemon" program inserts text |
| 16 | ** at each "%%" line. Also, any "P-a-r-s-e" identifer prefix (without the |
| 17 | ** interstitial "-" characters) contained in this template is changed into |
| 18 | ** the value of the %name directive from the grammar. Otherwise, the content |
| 19 | ** of this template is copied straight through into the generate parser |
| 20 | ** source file. |
| 21 | ** |
| 22 | ** The following is the concatenation of all %include directives from the |
| 23 | ** input grammar file: |
drh | 7589723 | 2000-05-29 14:26:00 +0000 | [diff] [blame] | 24 | */ |
drh | 82415f2 | 2015-11-09 19:33:42 +0000 | [diff] [blame] | 25 | #include <stdio.h> |
drh | 60ce5d3 | 2018-11-27 14:34:33 +0000 | [diff] [blame] | 26 | #include <assert.h> |
drh | 82415f2 | 2015-11-09 19:33:42 +0000 | [diff] [blame] | 27 | /************ Begin %include sections from the grammar ************************/ |
drh | 7589723 | 2000-05-29 14:26:00 +0000 | [diff] [blame] | 28 | %% |
drh | 82415f2 | 2015-11-09 19:33:42 +0000 | [diff] [blame] | 29 | /**************** End of %include directives **********************************/ |
| 30 | /* These constants specify the various numeric values for terminal symbols |
| 31 | ** in a format understandable to "makeheaders". This section is blank unless |
| 32 | ** "lemon" is run with the "-m" command-line option. |
| 33 | ***************** Begin makeheaders token definitions *************************/ |
| 34 | %% |
| 35 | /**************** End makeheaders token definitions ***************************/ |
drh | 822a62f | 2015-11-09 19:35:18 +0000 | [diff] [blame] | 36 | |
| 37 | /* The next sections is a series of control #defines. |
drh | 7589723 | 2000-05-29 14:26:00 +0000 | [diff] [blame] | 38 | ** various aspects of the generated parser. |
drh | 82415f2 | 2015-11-09 19:33:42 +0000 | [diff] [blame] | 39 | ** YYCODETYPE is the data type used to store the integer codes |
| 40 | ** that represent terminal and non-terminal symbols. |
| 41 | ** "unsigned char" is used if there are fewer than |
| 42 | ** 256 symbols. Larger types otherwise. |
| 43 | ** YYNOCODE is a number of type YYCODETYPE that is not used for |
| 44 | ** any terminal or nonterminal symbol. |
drh | 0bd1f4e | 2002-06-06 18:54:39 +0000 | [diff] [blame] | 45 | ** YYFALLBACK If defined, this indicates that one or more tokens |
drh | 82415f2 | 2015-11-09 19:33:42 +0000 | [diff] [blame] | 46 | ** (also known as: "terminal symbols") have fall-back |
| 47 | ** values which should be used if the original symbol |
| 48 | ** would not parse. This permits keywords to sometimes |
| 49 | ** be used as identifiers, for example. |
| 50 | ** YYACTIONTYPE is the data type used for "action codes" - numbers |
| 51 | ** that indicate what to do in response to the next |
| 52 | ** token. |
| 53 | ** ParseTOKENTYPE is the data type used for minor type for terminal |
| 54 | ** symbols. Background: A "minor type" is a semantic |
| 55 | ** value associated with a terminal or non-terminal |
| 56 | ** symbols. For example, for an "ID" terminal symbol, |
| 57 | ** the minor type might be the name of the identifier. |
| 58 | ** Each non-terminal can have a different minor type. |
| 59 | ** Terminal symbols all have the same minor type, though. |
| 60 | ** This macros defines the minor type for terminal |
| 61 | ** symbols. |
| 62 | ** YYMINORTYPE is the data type used for all minor types. |
drh | 7589723 | 2000-05-29 14:26:00 +0000 | [diff] [blame] | 63 | ** This is typically a union of many types, one of |
| 64 | ** which is ParseTOKENTYPE. The entry in the union |
drh | 82415f2 | 2015-11-09 19:33:42 +0000 | [diff] [blame] | 65 | ** for terminal symbols is called "yy0". |
drh | b19fd01 | 2007-03-29 01:44:45 +0000 | [diff] [blame] | 66 | ** YYSTACKDEPTH is the maximum depth of the parser's stack. If |
| 67 | ** zero the stack is dynamically sized using realloc() |
drh | 1f245e4 | 2002-03-11 13:55:50 +0000 | [diff] [blame] | 68 | ** ParseARG_SDECL A static variable declaration for the %extra_argument |
| 69 | ** ParseARG_PDECL A parameter declaration for the %extra_argument |
drh | fb32c44 | 2018-04-21 13:51:42 +0000 | [diff] [blame] | 70 | ** ParseARG_PARAM Code to pass %extra_argument as a subroutine parameter |
drh | 1f245e4 | 2002-03-11 13:55:50 +0000 | [diff] [blame] | 71 | ** ParseARG_STORE Code to store %extra_argument into yypParser |
| 72 | ** ParseARG_FETCH Code to extract %extra_argument from yypParser |
drh | fb32c44 | 2018-04-21 13:51:42 +0000 | [diff] [blame] | 73 | ** ParseCTX_* As ParseARG_ except for %extra_context |
drh | 7589723 | 2000-05-29 14:26:00 +0000 | [diff] [blame] | 74 | ** YYERRORSYMBOL is the code number of the error symbol. If not |
| 75 | ** defined, then do no error processing. |
drh | 3bd48ab | 2015-09-07 18:23:37 +0000 | [diff] [blame] | 76 | ** YYNSTATE the combined number of states. |
| 77 | ** YYNRULE the number of rules in the grammar |
drh | 0d9de99 | 2017-12-26 18:04:23 +0000 | [diff] [blame] | 78 | ** YYNTOKEN Number of terminal symbols |
drh | 3bd48ab | 2015-09-07 18:23:37 +0000 | [diff] [blame] | 79 | ** YY_MAX_SHIFT Maximum value for shift actions |
| 80 | ** YY_MIN_SHIFTREDUCE Minimum value for shift-reduce actions |
| 81 | ** YY_MAX_SHIFTREDUCE Maximum value for shift-reduce actions |
drh | 3bd48ab | 2015-09-07 18:23:37 +0000 | [diff] [blame] | 82 | ** YY_ERROR_ACTION The yy_action[] code for syntax error |
| 83 | ** YY_ACCEPT_ACTION The yy_action[] code for accept |
| 84 | ** YY_NO_ACTION The yy_action[] code for no-op |
drh | 5c8241b | 2017-12-24 23:38:10 +0000 | [diff] [blame] | 85 | ** YY_MIN_REDUCE Minimum value for reduce actions |
| 86 | ** YY_MAX_REDUCE Maximum value for reduce actions |
drh | 7589723 | 2000-05-29 14:26:00 +0000 | [diff] [blame] | 87 | */ |
drh | 82415f2 | 2015-11-09 19:33:42 +0000 | [diff] [blame] | 88 | #ifndef INTERFACE |
| 89 | # define INTERFACE 1 |
| 90 | #endif |
| 91 | /************* Begin control #defines *****************************************/ |
drh | 7589723 | 2000-05-29 14:26:00 +0000 | [diff] [blame] | 92 | %% |
drh | 82415f2 | 2015-11-09 19:33:42 +0000 | [diff] [blame] | 93 | /************* End control #defines *******************************************/ |
drh | 3773c25 | 2018-06-28 03:38:49 +0000 | [diff] [blame] | 94 | #define YY_NLOOKAHEAD ((int)(sizeof(yy_lookahead)/sizeof(yy_lookahead[0]))) |
drh | 7589723 | 2000-05-29 14:26:00 +0000 | [diff] [blame] | 95 | |
drh | 8a415d3 | 2009-06-12 13:53:51 +0000 | [diff] [blame] | 96 | /* Define the yytestcase() macro to be a no-op if is not already defined |
| 97 | ** otherwise. |
| 98 | ** |
| 99 | ** Applications can choose to define yytestcase() in the %include section |
| 100 | ** to a macro that can assist in verifying code coverage. For production |
| 101 | ** code the yytestcase() macro should be turned off. But it is useful |
| 102 | ** for testing. |
| 103 | */ |
| 104 | #ifndef yytestcase |
| 105 | # define yytestcase(X) |
| 106 | #endif |
| 107 | |
drh | 26c9b5e | 2008-04-11 14:56:53 +0000 | [diff] [blame] | 108 | |
drh | 34ff57b | 2008-07-14 12:27:51 +0000 | [diff] [blame] | 109 | /* Next are the tables used to determine what action to take based on the |
drh | 8b58201 | 2003-10-21 13:16:03 +0000 | [diff] [blame] | 110 | ** current state and lookahead token. These tables are used to implement |
| 111 | ** functions that take a state number and lookahead value and return an |
| 112 | ** action integer. |
drh | 7589723 | 2000-05-29 14:26:00 +0000 | [diff] [blame] | 113 | ** |
drh | 8548a05 | 2003-10-22 22:15:27 +0000 | [diff] [blame] | 114 | ** Suppose the action integer is N. Then the action is determined as |
| 115 | ** follows |
drh | 7589723 | 2000-05-29 14:26:00 +0000 | [diff] [blame] | 116 | ** |
drh | 3bd48ab | 2015-09-07 18:23:37 +0000 | [diff] [blame] | 117 | ** 0 <= N <= YY_MAX_SHIFT Shift N. That is, push the lookahead |
drh | 8548a05 | 2003-10-22 22:15:27 +0000 | [diff] [blame] | 118 | ** token onto the stack and goto state N. |
| 119 | ** |
drh | 3bd48ab | 2015-09-07 18:23:37 +0000 | [diff] [blame] | 120 | ** N between YY_MIN_SHIFTREDUCE Shift to an arbitrary state then |
| 121 | ** and YY_MAX_SHIFTREDUCE reduce by rule N-YY_MIN_SHIFTREDUCE. |
drh | 8548a05 | 2003-10-22 22:15:27 +0000 | [diff] [blame] | 122 | ** |
drh | 3bd48ab | 2015-09-07 18:23:37 +0000 | [diff] [blame] | 123 | ** N == YY_ERROR_ACTION A syntax error has occurred. |
drh | 8548a05 | 2003-10-22 22:15:27 +0000 | [diff] [blame] | 124 | ** |
drh | 3bd48ab | 2015-09-07 18:23:37 +0000 | [diff] [blame] | 125 | ** N == YY_ACCEPT_ACTION The parser accepts its input. |
drh | 8548a05 | 2003-10-22 22:15:27 +0000 | [diff] [blame] | 126 | ** |
drh | 3bd48ab | 2015-09-07 18:23:37 +0000 | [diff] [blame] | 127 | ** N == YY_NO_ACTION No such action. Denotes unused |
drh | 8548a05 | 2003-10-22 22:15:27 +0000 | [diff] [blame] | 128 | ** slots in the yy_action[] table. |
| 129 | ** |
drh | 5c8241b | 2017-12-24 23:38:10 +0000 | [diff] [blame] | 130 | ** N between YY_MIN_REDUCE Reduce by rule N-YY_MIN_REDUCE |
| 131 | ** and YY_MAX_REDUCE |
| 132 | ** |
drh | 8548a05 | 2003-10-22 22:15:27 +0000 | [diff] [blame] | 133 | ** The action table is constructed as a single large table named yy_action[]. |
drh | 701b688 | 2016-08-10 13:30:43 +0000 | [diff] [blame] | 134 | ** Given state S and lookahead X, the action is computed as either: |
drh | 7589723 | 2000-05-29 14:26:00 +0000 | [diff] [blame] | 135 | ** |
drh | 701b688 | 2016-08-10 13:30:43 +0000 | [diff] [blame] | 136 | ** (A) N = yy_action[ yy_shift_ofst[S] + X ] |
| 137 | ** (B) N = yy_default[S] |
drh | 8b58201 | 2003-10-21 13:16:03 +0000 | [diff] [blame] | 138 | ** |
drh | 3a9d6c7 | 2017-12-25 04:15:38 +0000 | [diff] [blame] | 139 | ** The (A) formula is preferred. The B formula is used instead if |
| 140 | ** yy_lookahead[yy_shift_ofst[S]+X] is not equal to X. |
drh | 8b58201 | 2003-10-21 13:16:03 +0000 | [diff] [blame] | 141 | ** |
drh | 701b688 | 2016-08-10 13:30:43 +0000 | [diff] [blame] | 142 | ** The formulas above are for computing the action when the lookahead is |
drh | 8b58201 | 2003-10-21 13:16:03 +0000 | [diff] [blame] | 143 | ** a terminal symbol. If the lookahead is a non-terminal (as occurs after |
| 144 | ** a reduce action) then the yy_reduce_ofst[] array is used in place of |
drh | 3a9d6c7 | 2017-12-25 04:15:38 +0000 | [diff] [blame] | 145 | ** the yy_shift_ofst[] array. |
drh | 8b58201 | 2003-10-21 13:16:03 +0000 | [diff] [blame] | 146 | ** |
| 147 | ** The following are the tables generated in this section: |
| 148 | ** |
| 149 | ** yy_action[] A single table containing all actions. |
| 150 | ** yy_lookahead[] A table containing the lookahead for each entry in |
| 151 | ** yy_action. Used to detect hash collisions. |
| 152 | ** yy_shift_ofst[] For each state, the offset into yy_action for |
| 153 | ** shifting terminals. |
| 154 | ** yy_reduce_ofst[] For each state, the offset into yy_action for |
| 155 | ** shifting non-terminals after a reduce. |
| 156 | ** yy_default[] Default action for each state. |
drh | 82415f2 | 2015-11-09 19:33:42 +0000 | [diff] [blame] | 157 | ** |
| 158 | *********** Begin parsing tables **********************************************/ |
drh | 7589723 | 2000-05-29 14:26:00 +0000 | [diff] [blame] | 159 | %% |
drh | 82415f2 | 2015-11-09 19:33:42 +0000 | [diff] [blame] | 160 | /********** End of lemon-generated parsing tables *****************************/ |
drh | 7589723 | 2000-05-29 14:26:00 +0000 | [diff] [blame] | 161 | |
drh | 82415f2 | 2015-11-09 19:33:42 +0000 | [diff] [blame] | 162 | /* The next table maps tokens (terminal symbols) into fallback tokens. |
| 163 | ** If a construct like the following: |
drh | 0bd1f4e | 2002-06-06 18:54:39 +0000 | [diff] [blame] | 164 | ** |
| 165 | ** %fallback ID X Y Z. |
| 166 | ** |
drh | 34ff57b | 2008-07-14 12:27:51 +0000 | [diff] [blame] | 167 | ** appears in the grammar, then ID becomes a fallback token for X, Y, |
drh | 0bd1f4e | 2002-06-06 18:54:39 +0000 | [diff] [blame] | 168 | ** and Z. Whenever one of the tokens X, Y, or Z is input to the parser |
| 169 | ** but it does not parse, the type of the token is changed to ID and |
| 170 | ** the parse is retried before an error is thrown. |
drh | 82415f2 | 2015-11-09 19:33:42 +0000 | [diff] [blame] | 171 | ** |
| 172 | ** This feature can be used, for example, to cause some keywords in a language |
| 173 | ** to revert to identifiers if they keyword does not apply in the context where |
| 174 | ** it appears. |
drh | 0bd1f4e | 2002-06-06 18:54:39 +0000 | [diff] [blame] | 175 | */ |
| 176 | #ifdef YYFALLBACK |
| 177 | static const YYCODETYPE yyFallback[] = { |
| 178 | %% |
| 179 | }; |
| 180 | #endif /* YYFALLBACK */ |
| 181 | |
drh | 7589723 | 2000-05-29 14:26:00 +0000 | [diff] [blame] | 182 | /* The following structure represents a single element of the |
| 183 | ** parser's stack. Information stored includes: |
| 184 | ** |
| 185 | ** + The state number for the parser at this level of the stack. |
| 186 | ** |
| 187 | ** + The value of the token stored at this level of the stack. |
| 188 | ** (In other words, the "major" token.) |
| 189 | ** |
| 190 | ** + The semantic value stored at this level of the stack. This is |
| 191 | ** the information used by the action routines in the grammar. |
| 192 | ** It is sometimes called the "minor" token. |
drh | a248a72 | 2015-09-07 19:52:55 +0000 | [diff] [blame] | 193 | ** |
| 194 | ** After the "shift" half of a SHIFTREDUCE action, the stateno field |
| 195 | ** actually contains the reduce action for the second half of the |
| 196 | ** SHIFTREDUCE. |
drh | 7589723 | 2000-05-29 14:26:00 +0000 | [diff] [blame] | 197 | */ |
| 198 | struct yyStackEntry { |
drh | a248a72 | 2015-09-07 19:52:55 +0000 | [diff] [blame] | 199 | YYACTIONTYPE stateno; /* The state-number, or reduce action in SHIFTREDUCE */ |
drh | 2abcd58 | 2008-07-24 23:34:07 +0000 | [diff] [blame] | 200 | YYCODETYPE major; /* The major token value. This is the code |
| 201 | ** number for the token at this stack level */ |
| 202 | YYMINORTYPE minor; /* The user-supplied minor token value. This |
| 203 | ** is the value of the token */ |
drh | 7589723 | 2000-05-29 14:26:00 +0000 | [diff] [blame] | 204 | }; |
drh | 1f245e4 | 2002-03-11 13:55:50 +0000 | [diff] [blame] | 205 | typedef struct yyStackEntry yyStackEntry; |
drh | 7589723 | 2000-05-29 14:26:00 +0000 | [diff] [blame] | 206 | |
| 207 | /* The state of the parser is completely contained in an instance of |
| 208 | ** the following structure */ |
| 209 | struct yyParser { |
drh | 118ab65 | 2016-05-23 21:56:24 +0000 | [diff] [blame] | 210 | yyStackEntry *yytos; /* Pointer to top element of the stack */ |
drh | ec424a5 | 2008-07-25 15:39:03 +0000 | [diff] [blame] | 211 | #ifdef YYTRACKMAXSTACKDEPTH |
drh | 118ab65 | 2016-05-23 21:56:24 +0000 | [diff] [blame] | 212 | int yyhwm; /* High-water mark of the stack */ |
drh | ec424a5 | 2008-07-25 15:39:03 +0000 | [diff] [blame] | 213 | #endif |
drh | dab943c | 2016-02-16 01:01:43 +0000 | [diff] [blame] | 214 | #ifndef YYNOERRORRECOVERY |
drh | 1f245e4 | 2002-03-11 13:55:50 +0000 | [diff] [blame] | 215 | int yyerrcnt; /* Shifts left before out of the error */ |
drh | dab943c | 2016-02-16 01:01:43 +0000 | [diff] [blame] | 216 | #endif |
drh | 1f245e4 | 2002-03-11 13:55:50 +0000 | [diff] [blame] | 217 | ParseARG_SDECL /* A place to hold %extra_argument */ |
drh | fb32c44 | 2018-04-21 13:51:42 +0000 | [diff] [blame] | 218 | ParseCTX_SDECL /* A place to hold %extra_context */ |
drh | b19fd01 | 2007-03-29 01:44:45 +0000 | [diff] [blame] | 219 | #if YYSTACKDEPTH<=0 |
| 220 | int yystksz; /* Current side of the stack */ |
| 221 | yyStackEntry *yystack; /* The parser's stack */ |
drh | 8dc8247 | 2016-05-27 04:10:47 +0000 | [diff] [blame] | 222 | yyStackEntry yystk0; /* First stack entry */ |
drh | b19fd01 | 2007-03-29 01:44:45 +0000 | [diff] [blame] | 223 | #else |
drh | 1f245e4 | 2002-03-11 13:55:50 +0000 | [diff] [blame] | 224 | yyStackEntry yystack[YYSTACKDEPTH]; /* The parser's stack */ |
drh | 8b471e7 | 2017-06-28 15:01:35 +0000 | [diff] [blame] | 225 | yyStackEntry *yystackEnd; /* Last entry in the stack */ |
drh | b19fd01 | 2007-03-29 01:44:45 +0000 | [diff] [blame] | 226 | #endif |
drh | 7589723 | 2000-05-29 14:26:00 +0000 | [diff] [blame] | 227 | }; |
| 228 | typedef struct yyParser yyParser; |
| 229 | |
| 230 | #ifndef NDEBUG |
| 231 | #include <stdio.h> |
| 232 | static FILE *yyTraceFILE = 0; |
| 233 | static char *yyTracePrompt = 0; |
drh | 0bd1f4e | 2002-06-06 18:54:39 +0000 | [diff] [blame] | 234 | #endif /* NDEBUG */ |
drh | 7589723 | 2000-05-29 14:26:00 +0000 | [diff] [blame] | 235 | |
drh | 0bd1f4e | 2002-06-06 18:54:39 +0000 | [diff] [blame] | 236 | #ifndef NDEBUG |
drh | 7589723 | 2000-05-29 14:26:00 +0000 | [diff] [blame] | 237 | /* |
| 238 | ** Turn parser tracing on by giving a stream to which to write the trace |
| 239 | ** and a prompt to preface each trace message. Tracing is turned off |
| 240 | ** by making either argument NULL |
| 241 | ** |
| 242 | ** Inputs: |
| 243 | ** <ul> |
| 244 | ** <li> A FILE* to which trace output should be written. |
| 245 | ** If NULL, then tracing is turned off. |
| 246 | ** <li> A prefix string written at the beginning of every |
| 247 | ** line of trace output. If NULL, then tracing is |
| 248 | ** turned off. |
| 249 | ** </ul> |
| 250 | ** |
| 251 | ** Outputs: |
| 252 | ** None. |
| 253 | */ |
drh | 7589723 | 2000-05-29 14:26:00 +0000 | [diff] [blame] | 254 | void ParseTrace(FILE *TraceFILE, char *zTracePrompt){ |
| 255 | yyTraceFILE = TraceFILE; |
| 256 | yyTracePrompt = zTracePrompt; |
| 257 | if( yyTraceFILE==0 ) yyTracePrompt = 0; |
| 258 | else if( yyTracePrompt==0 ) yyTraceFILE = 0; |
| 259 | } |
drh | 0bd1f4e | 2002-06-06 18:54:39 +0000 | [diff] [blame] | 260 | #endif /* NDEBUG */ |
drh | 7589723 | 2000-05-29 14:26:00 +0000 | [diff] [blame] | 261 | |
drh | 0d9de99 | 2017-12-26 18:04:23 +0000 | [diff] [blame] | 262 | #if defined(YYCOVERAGE) || !defined(NDEBUG) |
drh | 7589723 | 2000-05-29 14:26:00 +0000 | [diff] [blame] | 263 | /* For tracing shifts, the names of all terminals and nonterminals |
| 264 | ** are required. The following table supplies these names */ |
drh | 5719628 | 2004-10-06 15:41:16 +0000 | [diff] [blame] | 265 | static const char *const yyTokenName[] = { |
drh | 7589723 | 2000-05-29 14:26:00 +0000 | [diff] [blame] | 266 | %% |
| 267 | }; |
drh | 0d9de99 | 2017-12-26 18:04:23 +0000 | [diff] [blame] | 268 | #endif /* defined(YYCOVERAGE) || !defined(NDEBUG) */ |
drh | 7589723 | 2000-05-29 14:26:00 +0000 | [diff] [blame] | 269 | |
drh | 0bd1f4e | 2002-06-06 18:54:39 +0000 | [diff] [blame] | 270 | #ifndef NDEBUG |
| 271 | /* For tracing reduce actions, the names of all rules are required. |
| 272 | */ |
drh | 5719628 | 2004-10-06 15:41:16 +0000 | [diff] [blame] | 273 | static const char *const yyRuleName[] = { |
drh | 0bd1f4e | 2002-06-06 18:54:39 +0000 | [diff] [blame] | 274 | %% |
| 275 | }; |
| 276 | #endif /* NDEBUG */ |
drh | a1b351a | 2001-09-14 16:42:12 +0000 | [diff] [blame] | 277 | |
drh | 960e8c6 | 2001-04-03 16:53:21 +0000 | [diff] [blame] | 278 | |
drh | b19fd01 | 2007-03-29 01:44:45 +0000 | [diff] [blame] | 279 | #if YYSTACKDEPTH<=0 |
| 280 | /* |
drh | 8dc8247 | 2016-05-27 04:10:47 +0000 | [diff] [blame] | 281 | ** Try to increase the size of the parser stack. Return the number |
| 282 | ** of errors. Return 0 on success. |
drh | b19fd01 | 2007-03-29 01:44:45 +0000 | [diff] [blame] | 283 | */ |
drh | 8dc8247 | 2016-05-27 04:10:47 +0000 | [diff] [blame] | 284 | static int yyGrowStack(yyParser *p){ |
drh | b19fd01 | 2007-03-29 01:44:45 +0000 | [diff] [blame] | 285 | int newSize; |
drh | abecc0b | 2016-05-24 00:40:54 +0000 | [diff] [blame] | 286 | int idx; |
drh | b19fd01 | 2007-03-29 01:44:45 +0000 | [diff] [blame] | 287 | yyStackEntry *pNew; |
| 288 | |
| 289 | newSize = p->yystksz*2 + 100; |
drh | abecc0b | 2016-05-24 00:40:54 +0000 | [diff] [blame] | 290 | idx = p->yytos ? (int)(p->yytos - p->yystack) : 0; |
drh | 8dc8247 | 2016-05-27 04:10:47 +0000 | [diff] [blame] | 291 | if( p->yystack==&p->yystk0 ){ |
| 292 | pNew = malloc(newSize*sizeof(pNew[0])); |
| 293 | if( pNew ) pNew[0] = p->yystk0; |
| 294 | }else{ |
| 295 | pNew = realloc(p->yystack, newSize*sizeof(pNew[0])); |
| 296 | } |
drh | b19fd01 | 2007-03-29 01:44:45 +0000 | [diff] [blame] | 297 | if( pNew ){ |
| 298 | p->yystack = pNew; |
drh | abecc0b | 2016-05-24 00:40:54 +0000 | [diff] [blame] | 299 | p->yytos = &p->yystack[idx]; |
drh | b19fd01 | 2007-03-29 01:44:45 +0000 | [diff] [blame] | 300 | #ifndef NDEBUG |
| 301 | if( yyTraceFILE ){ |
drh | 8dc8247 | 2016-05-27 04:10:47 +0000 | [diff] [blame] | 302 | fprintf(yyTraceFILE,"%sStack grows from %d to %d entries.\n", |
| 303 | yyTracePrompt, p->yystksz, newSize); |
drh | b19fd01 | 2007-03-29 01:44:45 +0000 | [diff] [blame] | 304 | } |
| 305 | #endif |
drh | 8dc8247 | 2016-05-27 04:10:47 +0000 | [diff] [blame] | 306 | p->yystksz = newSize; |
drh | b19fd01 | 2007-03-29 01:44:45 +0000 | [diff] [blame] | 307 | } |
drh | 8dc8247 | 2016-05-27 04:10:47 +0000 | [diff] [blame] | 308 | return pNew==0; |
drh | b19fd01 | 2007-03-29 01:44:45 +0000 | [diff] [blame] | 309 | } |
| 310 | #endif |
| 311 | |
drh | 82415f2 | 2015-11-09 19:33:42 +0000 | [diff] [blame] | 312 | /* Datatype of the argument to the memory allocated passed as the |
| 313 | ** second argument to ParseAlloc() below. This can be changed by |
| 314 | ** putting an appropriate #define in the %include section of the input |
| 315 | ** grammar. |
| 316 | */ |
| 317 | #ifndef YYMALLOCARGTYPE |
| 318 | # define YYMALLOCARGTYPE size_t |
| 319 | #endif |
| 320 | |
drh | d26cc54 | 2017-01-28 20:46:37 +0000 | [diff] [blame] | 321 | /* Initialize a new parser that has already been allocated. |
| 322 | */ |
drh | fb32c44 | 2018-04-21 13:51:42 +0000 | [diff] [blame] | 323 | void ParseInit(void *yypRawParser ParseCTX_PDECL){ |
| 324 | yyParser *yypParser = (yyParser*)yypRawParser; |
| 325 | ParseCTX_STORE |
drh | d26cc54 | 2017-01-28 20:46:37 +0000 | [diff] [blame] | 326 | #ifdef YYTRACKMAXSTACKDEPTH |
drh | fb32c44 | 2018-04-21 13:51:42 +0000 | [diff] [blame] | 327 | yypParser->yyhwm = 0; |
drh | d26cc54 | 2017-01-28 20:46:37 +0000 | [diff] [blame] | 328 | #endif |
| 329 | #if YYSTACKDEPTH<=0 |
drh | fb32c44 | 2018-04-21 13:51:42 +0000 | [diff] [blame] | 330 | yypParser->yytos = NULL; |
| 331 | yypParser->yystack = NULL; |
| 332 | yypParser->yystksz = 0; |
| 333 | if( yyGrowStack(yypParser) ){ |
| 334 | yypParser->yystack = &yypParser->yystk0; |
| 335 | yypParser->yystksz = 1; |
drh | d26cc54 | 2017-01-28 20:46:37 +0000 | [diff] [blame] | 336 | } |
| 337 | #endif |
| 338 | #ifndef YYNOERRORRECOVERY |
drh | fb32c44 | 2018-04-21 13:51:42 +0000 | [diff] [blame] | 339 | yypParser->yyerrcnt = -1; |
drh | d26cc54 | 2017-01-28 20:46:37 +0000 | [diff] [blame] | 340 | #endif |
drh | fb32c44 | 2018-04-21 13:51:42 +0000 | [diff] [blame] | 341 | yypParser->yytos = yypParser->yystack; |
| 342 | yypParser->yystack[0].stateno = 0; |
| 343 | yypParser->yystack[0].major = 0; |
drh | 92395c5 | 2017-07-04 12:50:00 +0000 | [diff] [blame] | 344 | #if YYSTACKDEPTH>0 |
drh | fb32c44 | 2018-04-21 13:51:42 +0000 | [diff] [blame] | 345 | yypParser->yystackEnd = &yypParser->yystack[YYSTACKDEPTH-1]; |
drh | 92395c5 | 2017-07-04 12:50:00 +0000 | [diff] [blame] | 346 | #endif |
drh | d26cc54 | 2017-01-28 20:46:37 +0000 | [diff] [blame] | 347 | } |
| 348 | |
| 349 | #ifndef Parse_ENGINEALWAYSONSTACK |
drh | 7589723 | 2000-05-29 14:26:00 +0000 | [diff] [blame] | 350 | /* |
| 351 | ** This function allocates a new parser. |
| 352 | ** The only argument is a pointer to a function which works like |
| 353 | ** malloc. |
| 354 | ** |
| 355 | ** Inputs: |
| 356 | ** A pointer to the function used to allocate memory. |
| 357 | ** |
| 358 | ** Outputs: |
| 359 | ** A pointer to a parser. This pointer is used in subsequent calls |
| 360 | ** to Parse and ParseFree. |
| 361 | */ |
drh | fb32c44 | 2018-04-21 13:51:42 +0000 | [diff] [blame] | 362 | void *ParseAlloc(void *(*mallocProc)(YYMALLOCARGTYPE) ParseCTX_PDECL){ |
| 363 | yyParser *yypParser; |
| 364 | yypParser = (yyParser*)(*mallocProc)( (YYMALLOCARGTYPE)sizeof(yyParser) ); |
| 365 | if( yypParser ){ |
| 366 | ParseCTX_STORE |
| 367 | ParseInit(yypParser ParseCTX_PARAM); |
| 368 | } |
| 369 | return (void*)yypParser; |
drh | 7589723 | 2000-05-29 14:26:00 +0000 | [diff] [blame] | 370 | } |
drh | d26cc54 | 2017-01-28 20:46:37 +0000 | [diff] [blame] | 371 | #endif /* Parse_ENGINEALWAYSONSTACK */ |
| 372 | |
drh | 7589723 | 2000-05-29 14:26:00 +0000 | [diff] [blame] | 373 | |
drh | 82415f2 | 2015-11-09 19:33:42 +0000 | [diff] [blame] | 374 | /* The following function deletes the "minor type" or semantic value |
| 375 | ** associated with a symbol. The symbol can be either a terminal |
| 376 | ** or nonterminal. "yymajor" is the symbol code, and "yypminor" is |
| 377 | ** a pointer to the value to be deleted. The code used to do the |
| 378 | ** deletions is derived from the %destructor and/or %token_destructor |
| 379 | ** directives of the input grammar. |
drh | 7589723 | 2000-05-29 14:26:00 +0000 | [diff] [blame] | 380 | */ |
drh | 633e6d5 | 2008-07-28 19:34:53 +0000 | [diff] [blame] | 381 | static void yy_destructor( |
| 382 | yyParser *yypParser, /* The parser */ |
| 383 | YYCODETYPE yymajor, /* Type code for object to destroy */ |
| 384 | YYMINORTYPE *yypminor /* The object to be destroyed */ |
| 385 | ){ |
drh | fb32c44 | 2018-04-21 13:51:42 +0000 | [diff] [blame] | 386 | ParseARG_FETCH |
| 387 | ParseCTX_FETCH |
drh | 7589723 | 2000-05-29 14:26:00 +0000 | [diff] [blame] | 388 | switch( yymajor ){ |
| 389 | /* Here is inserted the actions which take place when a |
| 390 | ** terminal or non-terminal is destroyed. This can happen |
| 391 | ** when the symbol is popped from the stack during a |
| 392 | ** reduce or during error processing or when a parser is |
| 393 | ** being destroyed before it is finished parsing. |
| 394 | ** |
| 395 | ** Note: during a reduce, the only symbols destroyed are those |
drh | 82415f2 | 2015-11-09 19:33:42 +0000 | [diff] [blame] | 396 | ** which appear on the RHS of the rule, but which are *not* used |
drh | 7589723 | 2000-05-29 14:26:00 +0000 | [diff] [blame] | 397 | ** inside the C code. |
| 398 | */ |
drh | 82415f2 | 2015-11-09 19:33:42 +0000 | [diff] [blame] | 399 | /********* Begin destructor definitions ***************************************/ |
drh | 7589723 | 2000-05-29 14:26:00 +0000 | [diff] [blame] | 400 | %% |
drh | 82415f2 | 2015-11-09 19:33:42 +0000 | [diff] [blame] | 401 | /********* End destructor definitions *****************************************/ |
drh | 7589723 | 2000-05-29 14:26:00 +0000 | [diff] [blame] | 402 | default: break; /* If no destructor action specified: do nothing */ |
| 403 | } |
| 404 | } |
| 405 | |
| 406 | /* |
| 407 | ** Pop the parser's stack once. |
| 408 | ** |
| 409 | ** If there is a destructor routine associated with the token which |
| 410 | ** is popped from the stack, then call it. |
drh | 7589723 | 2000-05-29 14:26:00 +0000 | [diff] [blame] | 411 | */ |
drh | 3781f01 | 2015-11-09 14:11:37 +0000 | [diff] [blame] | 412 | static void yy_pop_parser_stack(yyParser *pParser){ |
| 413 | yyStackEntry *yytos; |
drh | 118ab65 | 2016-05-23 21:56:24 +0000 | [diff] [blame] | 414 | assert( pParser->yytos!=0 ); |
drh | 240c7fa | 2016-07-05 12:47:28 +0000 | [diff] [blame] | 415 | assert( pParser->yytos > pParser->yystack ); |
drh | 118ab65 | 2016-05-23 21:56:24 +0000 | [diff] [blame] | 416 | yytos = pParser->yytos--; |
drh | 7589723 | 2000-05-29 14:26:00 +0000 | [diff] [blame] | 417 | #ifndef NDEBUG |
drh | 3781f01 | 2015-11-09 14:11:37 +0000 | [diff] [blame] | 418 | if( yyTraceFILE ){ |
drh | 7589723 | 2000-05-29 14:26:00 +0000 | [diff] [blame] | 419 | fprintf(yyTraceFILE,"%sPopping %s\n", |
| 420 | yyTracePrompt, |
drh | 3ddfdf7 | 2003-12-22 14:53:19 +0000 | [diff] [blame] | 421 | yyTokenName[yytos->major]); |
drh | 7589723 | 2000-05-29 14:26:00 +0000 | [diff] [blame] | 422 | } |
| 423 | #endif |
drh | 3781f01 | 2015-11-09 14:11:37 +0000 | [diff] [blame] | 424 | yy_destructor(pParser, yytos->major, &yytos->minor); |
drh | 7589723 | 2000-05-29 14:26:00 +0000 | [diff] [blame] | 425 | } |
| 426 | |
drh | d26cc54 | 2017-01-28 20:46:37 +0000 | [diff] [blame] | 427 | /* |
| 428 | ** Clear all secondary memory allocations from the parser |
| 429 | */ |
| 430 | void ParseFinalize(void *p){ |
| 431 | yyParser *pParser = (yyParser*)p; |
| 432 | while( pParser->yytos>pParser->yystack ) yy_pop_parser_stack(pParser); |
| 433 | #if YYSTACKDEPTH<=0 |
| 434 | if( pParser->yystack!=&pParser->yystk0 ) free(pParser->yystack); |
| 435 | #endif |
| 436 | } |
| 437 | |
| 438 | #ifndef Parse_ENGINEALWAYSONSTACK |
drh | 7589723 | 2000-05-29 14:26:00 +0000 | [diff] [blame] | 439 | /* |
drh | 82415f2 | 2015-11-09 19:33:42 +0000 | [diff] [blame] | 440 | ** Deallocate and destroy a parser. Destructors are called for |
drh | 7589723 | 2000-05-29 14:26:00 +0000 | [diff] [blame] | 441 | ** all stack elements before shutting the parser down. |
| 442 | ** |
drh | 82415f2 | 2015-11-09 19:33:42 +0000 | [diff] [blame] | 443 | ** If the YYPARSEFREENEVERNULL macro exists (for example because it |
| 444 | ** is defined in a %include section of the input grammar) then it is |
| 445 | ** assumed that the input pointer is never NULL. |
drh | 7589723 | 2000-05-29 14:26:00 +0000 | [diff] [blame] | 446 | */ |
drh | 7589723 | 2000-05-29 14:26:00 +0000 | [diff] [blame] | 447 | void ParseFree( |
drh | 960e8c6 | 2001-04-03 16:53:21 +0000 | [diff] [blame] | 448 | void *p, /* The parser to be deleted */ |
| 449 | void (*freeProc)(void*) /* Function used to reclaim memory */ |
drh | 7589723 | 2000-05-29 14:26:00 +0000 | [diff] [blame] | 450 | ){ |
drh | 82415f2 | 2015-11-09 19:33:42 +0000 | [diff] [blame] | 451 | #ifndef YYPARSEFREENEVERNULL |
drh | d26cc54 | 2017-01-28 20:46:37 +0000 | [diff] [blame] | 452 | if( p==0 ) return; |
drh | 82415f2 | 2015-11-09 19:33:42 +0000 | [diff] [blame] | 453 | #endif |
drh | d26cc54 | 2017-01-28 20:46:37 +0000 | [diff] [blame] | 454 | ParseFinalize(p); |
| 455 | (*freeProc)(p); |
drh | 7589723 | 2000-05-29 14:26:00 +0000 | [diff] [blame] | 456 | } |
drh | d26cc54 | 2017-01-28 20:46:37 +0000 | [diff] [blame] | 457 | #endif /* Parse_ENGINEALWAYSONSTACK */ |
drh | 7589723 | 2000-05-29 14:26:00 +0000 | [diff] [blame] | 458 | |
| 459 | /* |
drh | ec424a5 | 2008-07-25 15:39:03 +0000 | [diff] [blame] | 460 | ** Return the peak depth of the stack for a parser. |
| 461 | */ |
| 462 | #ifdef YYTRACKMAXSTACKDEPTH |
| 463 | int ParseStackPeak(void *p){ |
| 464 | yyParser *pParser = (yyParser*)p; |
drh | 118ab65 | 2016-05-23 21:56:24 +0000 | [diff] [blame] | 465 | return pParser->yyhwm; |
drh | ec424a5 | 2008-07-25 15:39:03 +0000 | [diff] [blame] | 466 | } |
| 467 | #endif |
| 468 | |
drh | 0d9de99 | 2017-12-26 18:04:23 +0000 | [diff] [blame] | 469 | /* This array of booleans keeps track of the parser statement |
| 470 | ** coverage. The element yycoverage[X][Y] is set when the parser |
| 471 | ** is in state X and has a lookahead token Y. In a well-tested |
| 472 | ** systems, every element of this matrix should end up being set. |
| 473 | */ |
| 474 | #if defined(YYCOVERAGE) |
| 475 | static unsigned char yycoverage[YYNSTATE][YYNTOKEN]; |
| 476 | #endif |
| 477 | |
| 478 | /* |
| 479 | ** Write into out a description of every state/lookahead combination that |
drh | 7038a99 | 2017-12-27 17:14:50 +0000 | [diff] [blame] | 480 | ** |
| 481 | ** (1) has not been used by the parser, and |
| 482 | ** (2) is not a syntax error. |
| 483 | ** |
| 484 | ** Return the number of missed state/lookahead combinations. |
drh | 0d9de99 | 2017-12-26 18:04:23 +0000 | [diff] [blame] | 485 | */ |
| 486 | #if defined(YYCOVERAGE) |
| 487 | int ParseCoverage(FILE *out){ |
drh | 7038a99 | 2017-12-27 17:14:50 +0000 | [diff] [blame] | 488 | int stateno, iLookAhead, i; |
drh | 0d9de99 | 2017-12-26 18:04:23 +0000 | [diff] [blame] | 489 | int nMissed = 0; |
drh | 7038a99 | 2017-12-27 17:14:50 +0000 | [diff] [blame] | 490 | for(stateno=0; stateno<YYNSTATE; stateno++){ |
| 491 | i = yy_shift_ofst[stateno]; |
| 492 | for(iLookAhead=0; iLookAhead<YYNTOKEN; iLookAhead++){ |
drh | cf8e0e9 | 2017-12-27 17:36:58 +0000 | [diff] [blame] | 493 | if( yy_lookahead[i+iLookAhead]!=iLookAhead ) continue; |
drh | 7038a99 | 2017-12-27 17:14:50 +0000 | [diff] [blame] | 494 | if( yycoverage[stateno][iLookAhead]==0 ) nMissed++; |
drh | 22716cb | 2017-12-26 18:32:06 +0000 | [diff] [blame] | 495 | if( out ){ |
drh | 7038a99 | 2017-12-27 17:14:50 +0000 | [diff] [blame] | 496 | fprintf(out,"State %d lookahead %s %s\n", stateno, |
| 497 | yyTokenName[iLookAhead], |
| 498 | yycoverage[stateno][iLookAhead] ? "ok" : "missed"); |
drh | 22716cb | 2017-12-26 18:32:06 +0000 | [diff] [blame] | 499 | } |
drh | 0d9de99 | 2017-12-26 18:04:23 +0000 | [diff] [blame] | 500 | } |
| 501 | } |
| 502 | return nMissed; |
| 503 | } |
| 504 | #endif |
| 505 | |
drh | ec424a5 | 2008-07-25 15:39:03 +0000 | [diff] [blame] | 506 | /* |
drh | 8b58201 | 2003-10-21 13:16:03 +0000 | [diff] [blame] | 507 | ** Find the appropriate action for a parser given the terminal |
| 508 | ** look-ahead token iLookAhead. |
drh | 7589723 | 2000-05-29 14:26:00 +0000 | [diff] [blame] | 509 | */ |
drh | fd39c58 | 2018-04-21 22:40:08 +0000 | [diff] [blame] | 510 | static YYACTIONTYPE yy_find_shift_action( |
| 511 | YYCODETYPE iLookAhead, /* The look-ahead token */ |
| 512 | YYACTIONTYPE stateno /* Current state number */ |
drh | 7589723 | 2000-05-29 14:26:00 +0000 | [diff] [blame] | 513 | ){ |
drh | 8b58201 | 2003-10-21 13:16:03 +0000 | [diff] [blame] | 514 | int i; |
drh | fd39c58 | 2018-04-21 22:40:08 +0000 | [diff] [blame] | 515 | |
drh | ef53a9f | 2017-12-25 00:10:05 +0000 | [diff] [blame] | 516 | if( stateno>YY_MAX_SHIFT ) return stateno; |
drh | ae2a408 | 2015-09-07 20:02:39 +0000 | [diff] [blame] | 517 | assert( stateno <= YY_SHIFT_COUNT ); |
drh | 0d9de99 | 2017-12-26 18:04:23 +0000 | [diff] [blame] | 518 | #if defined(YYCOVERAGE) |
| 519 | yycoverage[stateno][iLookAhead] = 1; |
| 520 | #endif |
drh | a441404 | 2015-11-09 15:06:26 +0000 | [diff] [blame] | 521 | do{ |
| 522 | i = yy_shift_ofst[stateno]; |
drh | 54cfb49 | 2018-02-09 15:04:51 +0000 | [diff] [blame] | 523 | assert( i>=0 ); |
drh | 2e51716 | 2019-08-28 02:09:47 +0000 | [diff] [blame] | 524 | assert( i<=YY_ACTTAB_COUNT ); |
| 525 | assert( i+YYNTOKEN<=(int)YY_NLOOKAHEAD ); |
drh | a441404 | 2015-11-09 15:06:26 +0000 | [diff] [blame] | 526 | assert( iLookAhead!=YYNOCODE ); |
drh | 7038a99 | 2017-12-27 17:14:50 +0000 | [diff] [blame] | 527 | assert( iLookAhead < YYNTOKEN ); |
drh | a441404 | 2015-11-09 15:06:26 +0000 | [diff] [blame] | 528 | i += iLookAhead; |
drh | 2e51716 | 2019-08-28 02:09:47 +0000 | [diff] [blame] | 529 | assert( i<(int)YY_NLOOKAHEAD ); |
| 530 | if( yy_lookahead[i]!=iLookAhead ){ |
drh | 4767d97 | 2006-06-14 15:03:49 +0000 | [diff] [blame] | 531 | #ifdef YYFALLBACK |
drh | c83db9e | 2016-08-10 01:43:30 +0000 | [diff] [blame] | 532 | YYCODETYPE iFallback; /* Fallback token */ |
drh | 010bdb4 | 2019-08-28 11:31:11 +0000 | [diff] [blame] | 533 | assert( iLookAhead<sizeof(yyFallback)/sizeof(yyFallback[0]) ); |
| 534 | iFallback = yyFallback[iLookAhead]; |
| 535 | if( iFallback!=0 ){ |
drh | 4767d97 | 2006-06-14 15:03:49 +0000 | [diff] [blame] | 536 | #ifndef NDEBUG |
drh | c83db9e | 2016-08-10 01:43:30 +0000 | [diff] [blame] | 537 | if( yyTraceFILE ){ |
| 538 | fprintf(yyTraceFILE, "%sFALLBACK %s => %s\n", |
| 539 | yyTracePrompt, yyTokenName[iLookAhead], yyTokenName[iFallback]); |
drh | e09daa9 | 2006-06-10 13:29:31 +0000 | [diff] [blame] | 540 | } |
drh | a441404 | 2015-11-09 15:06:26 +0000 | [diff] [blame] | 541 | #endif |
drh | c83db9e | 2016-08-10 01:43:30 +0000 | [diff] [blame] | 542 | assert( yyFallback[iFallback]==0 ); /* Fallback loop must terminate */ |
| 543 | iLookAhead = iFallback; |
| 544 | continue; |
| 545 | } |
| 546 | #endif |
drh | a441404 | 2015-11-09 15:06:26 +0000 | [diff] [blame] | 547 | #ifdef YYWILDCARD |
drh | c83db9e | 2016-08-10 01:43:30 +0000 | [diff] [blame] | 548 | { |
| 549 | int j = i - iLookAhead + YYWILDCARD; |
drh | 010bdb4 | 2019-08-28 11:31:11 +0000 | [diff] [blame] | 550 | assert( j<(int)(sizeof(yy_lookahead)/sizeof(yy_lookahead[0])) ); |
| 551 | if( yy_lookahead[j]==YYWILDCARD && iLookAhead>0 ){ |
drh | a441404 | 2015-11-09 15:06:26 +0000 | [diff] [blame] | 552 | #ifndef NDEBUG |
drh | c83db9e | 2016-08-10 01:43:30 +0000 | [diff] [blame] | 553 | if( yyTraceFILE ){ |
| 554 | fprintf(yyTraceFILE, "%sWILDCARD %s => %s\n", |
| 555 | yyTracePrompt, yyTokenName[iLookAhead], |
| 556 | yyTokenName[YYWILDCARD]); |
drh | a441404 | 2015-11-09 15:06:26 +0000 | [diff] [blame] | 557 | } |
drh | c83db9e | 2016-08-10 01:43:30 +0000 | [diff] [blame] | 558 | #endif /* NDEBUG */ |
| 559 | return yy_action[j]; |
drh | a441404 | 2015-11-09 15:06:26 +0000 | [diff] [blame] | 560 | } |
drh | a441404 | 2015-11-09 15:06:26 +0000 | [diff] [blame] | 561 | } |
drh | c83db9e | 2016-08-10 01:43:30 +0000 | [diff] [blame] | 562 | #endif /* YYWILDCARD */ |
drh | a441404 | 2015-11-09 15:06:26 +0000 | [diff] [blame] | 563 | return yy_default[stateno]; |
| 564 | }else{ |
drh | 55f66b3 | 2019-07-16 19:44:32 +0000 | [diff] [blame] | 565 | assert( i>=0 && i<sizeof(yy_action)/sizeof(yy_action[0]) ); |
drh | a441404 | 2015-11-09 15:06:26 +0000 | [diff] [blame] | 566 | return yy_action[i]; |
drh | 0bd1f4e | 2002-06-06 18:54:39 +0000 | [diff] [blame] | 567 | } |
drh | a441404 | 2015-11-09 15:06:26 +0000 | [diff] [blame] | 568 | }while(1); |
drh | 8b58201 | 2003-10-21 13:16:03 +0000 | [diff] [blame] | 569 | } |
| 570 | |
| 571 | /* |
| 572 | ** Find the appropriate action for a parser given the non-terminal |
| 573 | ** look-ahead token iLookAhead. |
drh | 8b58201 | 2003-10-21 13:16:03 +0000 | [diff] [blame] | 574 | */ |
mistachkin | 709c822 | 2018-07-22 21:23:19 +0000 | [diff] [blame] | 575 | static YYACTIONTYPE yy_find_reduce_action( |
drh | fd39c58 | 2018-04-21 22:40:08 +0000 | [diff] [blame] | 576 | YYACTIONTYPE stateno, /* Current state number */ |
drh | d9f291e | 2006-06-13 11:15:47 +0000 | [diff] [blame] | 577 | YYCODETYPE iLookAhead /* The look-ahead token */ |
drh | 8b58201 | 2003-10-21 13:16:03 +0000 | [diff] [blame] | 578 | ){ |
| 579 | int i; |
drh | 7f7c257 | 2008-04-27 18:45:10 +0000 | [diff] [blame] | 580 | #ifdef YYERRORSYMBOL |
drh | f16371d | 2009-11-03 19:18:31 +0000 | [diff] [blame] | 581 | if( stateno>YY_REDUCE_COUNT ){ |
drh | 7f7c257 | 2008-04-27 18:45:10 +0000 | [diff] [blame] | 582 | return yy_default[stateno]; |
| 583 | } |
| 584 | #else |
drh | f16371d | 2009-11-03 19:18:31 +0000 | [diff] [blame] | 585 | assert( stateno<=YY_REDUCE_COUNT ); |
drh | 7f7c257 | 2008-04-27 18:45:10 +0000 | [diff] [blame] | 586 | #endif |
drh | 01495b9 | 2008-01-23 12:52:40 +0000 | [diff] [blame] | 587 | i = yy_reduce_ofst[stateno]; |
drh | 01495b9 | 2008-01-23 12:52:40 +0000 | [diff] [blame] | 588 | assert( iLookAhead!=YYNOCODE ); |
drh | 8b58201 | 2003-10-21 13:16:03 +0000 | [diff] [blame] | 589 | i += iLookAhead; |
drh | 7f7c257 | 2008-04-27 18:45:10 +0000 | [diff] [blame] | 590 | #ifdef YYERRORSYMBOL |
drh | f16371d | 2009-11-03 19:18:31 +0000 | [diff] [blame] | 591 | if( i<0 || i>=YY_ACTTAB_COUNT || yy_lookahead[i]!=iLookAhead ){ |
drh | 7f7c257 | 2008-04-27 18:45:10 +0000 | [diff] [blame] | 592 | return yy_default[stateno]; |
| 593 | } |
| 594 | #else |
drh | f16371d | 2009-11-03 19:18:31 +0000 | [diff] [blame] | 595 | assert( i>=0 && i<YY_ACTTAB_COUNT ); |
drh | 01495b9 | 2008-01-23 12:52:40 +0000 | [diff] [blame] | 596 | assert( yy_lookahead[i]==iLookAhead ); |
drh | 7f7c257 | 2008-04-27 18:45:10 +0000 | [diff] [blame] | 597 | #endif |
drh | 01495b9 | 2008-01-23 12:52:40 +0000 | [diff] [blame] | 598 | return yy_action[i]; |
drh | 7589723 | 2000-05-29 14:26:00 +0000 | [diff] [blame] | 599 | } |
| 600 | |
| 601 | /* |
drh | b19fd01 | 2007-03-29 01:44:45 +0000 | [diff] [blame] | 602 | ** The following routine is called if the stack overflows. |
| 603 | */ |
drh | 45f31be | 2016-02-16 21:19:49 +0000 | [diff] [blame] | 604 | static void yyStackOverflow(yyParser *yypParser){ |
drh | fb32c44 | 2018-04-21 13:51:42 +0000 | [diff] [blame] | 605 | ParseARG_FETCH |
| 606 | ParseCTX_FETCH |
drh | b19fd01 | 2007-03-29 01:44:45 +0000 | [diff] [blame] | 607 | #ifndef NDEBUG |
| 608 | if( yyTraceFILE ){ |
| 609 | fprintf(yyTraceFILE,"%sStack Overflow!\n",yyTracePrompt); |
| 610 | } |
| 611 | #endif |
drh | abecc0b | 2016-05-24 00:40:54 +0000 | [diff] [blame] | 612 | while( yypParser->yytos>yypParser->yystack ) yy_pop_parser_stack(yypParser); |
drh | b19fd01 | 2007-03-29 01:44:45 +0000 | [diff] [blame] | 613 | /* Here code is inserted which will execute if the parser |
| 614 | ** stack every overflows */ |
drh | 82415f2 | 2015-11-09 19:33:42 +0000 | [diff] [blame] | 615 | /******** Begin %stack_overflow code ******************************************/ |
drh | b19fd01 | 2007-03-29 01:44:45 +0000 | [diff] [blame] | 616 | %% |
drh | 82415f2 | 2015-11-09 19:33:42 +0000 | [diff] [blame] | 617 | /******** End %stack_overflow code ********************************************/ |
drh | fb32c44 | 2018-04-21 13:51:42 +0000 | [diff] [blame] | 618 | ParseARG_STORE /* Suppress warning about unused %extra_argument var */ |
| 619 | ParseCTX_STORE |
drh | b19fd01 | 2007-03-29 01:44:45 +0000 | [diff] [blame] | 620 | } |
| 621 | |
| 622 | /* |
drh | a248a72 | 2015-09-07 19:52:55 +0000 | [diff] [blame] | 623 | ** Print tracing information for a SHIFT action |
| 624 | */ |
| 625 | #ifndef NDEBUG |
drh | e58f74f | 2017-12-24 17:06:41 +0000 | [diff] [blame] | 626 | static void yyTraceShift(yyParser *yypParser, int yyNewState, const char *zTag){ |
drh | a248a72 | 2015-09-07 19:52:55 +0000 | [diff] [blame] | 627 | if( yyTraceFILE ){ |
drh | a248a72 | 2015-09-07 19:52:55 +0000 | [diff] [blame] | 628 | if( yyNewState<YYNSTATE ){ |
drh | e58f74f | 2017-12-24 17:06:41 +0000 | [diff] [blame] | 629 | fprintf(yyTraceFILE,"%s%s '%s', go to state %d\n", |
| 630 | yyTracePrompt, zTag, yyTokenName[yypParser->yytos->major], |
drh | 0c4105e | 2015-11-10 14:51:22 +0000 | [diff] [blame] | 631 | yyNewState); |
drh | a248a72 | 2015-09-07 19:52:55 +0000 | [diff] [blame] | 632 | }else{ |
drh | e58f74f | 2017-12-24 17:06:41 +0000 | [diff] [blame] | 633 | fprintf(yyTraceFILE,"%s%s '%s', pending reduce %d\n", |
| 634 | yyTracePrompt, zTag, yyTokenName[yypParser->yytos->major], |
| 635 | yyNewState - YY_MIN_REDUCE); |
drh | a248a72 | 2015-09-07 19:52:55 +0000 | [diff] [blame] | 636 | } |
| 637 | } |
| 638 | } |
| 639 | #else |
drh | e58f74f | 2017-12-24 17:06:41 +0000 | [diff] [blame] | 640 | # define yyTraceShift(X,Y,Z) |
drh | a248a72 | 2015-09-07 19:52:55 +0000 | [diff] [blame] | 641 | #endif |
| 642 | |
| 643 | /* |
drh | 82415f2 | 2015-11-09 19:33:42 +0000 | [diff] [blame] | 644 | ** Perform a shift action. |
drh | 7589723 | 2000-05-29 14:26:00 +0000 | [diff] [blame] | 645 | */ |
drh | a248a72 | 2015-09-07 19:52:55 +0000 | [diff] [blame] | 646 | static void yy_shift( |
drh | 7589723 | 2000-05-29 14:26:00 +0000 | [diff] [blame] | 647 | yyParser *yypParser, /* The parser to be shifted */ |
drh | fd39c58 | 2018-04-21 22:40:08 +0000 | [diff] [blame] | 648 | YYACTIONTYPE yyNewState, /* The new state to shift in */ |
| 649 | YYCODETYPE yyMajor, /* The major token to shift in */ |
drh | 45f31be | 2016-02-16 21:19:49 +0000 | [diff] [blame] | 650 | ParseTOKENTYPE yyMinor /* The minor token to shift in */ |
drh | 7589723 | 2000-05-29 14:26:00 +0000 | [diff] [blame] | 651 | ){ |
drh | 3ddfdf7 | 2003-12-22 14:53:19 +0000 | [diff] [blame] | 652 | yyStackEntry *yytos; |
drh | 118ab65 | 2016-05-23 21:56:24 +0000 | [diff] [blame] | 653 | yypParser->yytos++; |
drh | ec424a5 | 2008-07-25 15:39:03 +0000 | [diff] [blame] | 654 | #ifdef YYTRACKMAXSTACKDEPTH |
drh | 118ab65 | 2016-05-23 21:56:24 +0000 | [diff] [blame] | 655 | if( (int)(yypParser->yytos - yypParser->yystack)>yypParser->yyhwm ){ |
| 656 | yypParser->yyhwm++; |
| 657 | assert( yypParser->yyhwm == (int)(yypParser->yytos - yypParser->yystack) ); |
drh | ec424a5 | 2008-07-25 15:39:03 +0000 | [diff] [blame] | 658 | } |
| 659 | #endif |
drh | b19fd01 | 2007-03-29 01:44:45 +0000 | [diff] [blame] | 660 | #if YYSTACKDEPTH>0 |
drh | 8b471e7 | 2017-06-28 15:01:35 +0000 | [diff] [blame] | 661 | if( yypParser->yytos>yypParser->yystackEnd ){ |
drh | 6341331 | 2016-12-06 17:59:05 +0000 | [diff] [blame] | 662 | yypParser->yytos--; |
drh | 45f31be | 2016-02-16 21:19:49 +0000 | [diff] [blame] | 663 | yyStackOverflow(yypParser); |
drh | a248a72 | 2015-09-07 19:52:55 +0000 | [diff] [blame] | 664 | return; |
drh | 7589723 | 2000-05-29 14:26:00 +0000 | [diff] [blame] | 665 | } |
drh | b19fd01 | 2007-03-29 01:44:45 +0000 | [diff] [blame] | 666 | #else |
drh | 118ab65 | 2016-05-23 21:56:24 +0000 | [diff] [blame] | 667 | if( yypParser->yytos>=&yypParser->yystack[yypParser->yystksz] ){ |
drh | 8dc8247 | 2016-05-27 04:10:47 +0000 | [diff] [blame] | 668 | if( yyGrowStack(yypParser) ){ |
drh | 6341331 | 2016-12-06 17:59:05 +0000 | [diff] [blame] | 669 | yypParser->yytos--; |
drh | 45f31be | 2016-02-16 21:19:49 +0000 | [diff] [blame] | 670 | yyStackOverflow(yypParser); |
drh | a248a72 | 2015-09-07 19:52:55 +0000 | [diff] [blame] | 671 | return; |
drh | b19fd01 | 2007-03-29 01:44:45 +0000 | [diff] [blame] | 672 | } |
| 673 | } |
| 674 | #endif |
drh | 0efd37f | 2016-06-06 18:17:36 +0000 | [diff] [blame] | 675 | if( yyNewState > YY_MAX_SHIFT ){ |
| 676 | yyNewState += YY_MIN_REDUCE - YY_MIN_SHIFTREDUCE; |
| 677 | } |
drh | 118ab65 | 2016-05-23 21:56:24 +0000 | [diff] [blame] | 678 | yytos = yypParser->yytos; |
drh | fd39c58 | 2018-04-21 22:40:08 +0000 | [diff] [blame] | 679 | yytos->stateno = yyNewState; |
| 680 | yytos->major = yyMajor; |
drh | 45f31be | 2016-02-16 21:19:49 +0000 | [diff] [blame] | 681 | yytos->minor.yy0 = yyMinor; |
drh | e58f74f | 2017-12-24 17:06:41 +0000 | [diff] [blame] | 682 | yyTraceShift(yypParser, yyNewState, "Shift"); |
drh | 7589723 | 2000-05-29 14:26:00 +0000 | [diff] [blame] | 683 | } |
| 684 | |
drh | cfc45b1 | 2018-12-03 23:57:27 +0000 | [diff] [blame] | 685 | /* For rule J, yyRuleInfoLhs[J] contains the symbol on the left-hand side |
| 686 | ** of that rule */ |
| 687 | static const YYCODETYPE yyRuleInfoLhs[] = { |
| 688 | %% |
| 689 | }; |
| 690 | |
| 691 | /* For rule J, yyRuleInfoNRhs[J] contains the negative of the number |
| 692 | ** of symbols on the right-hand side of that rule. */ |
| 693 | static const signed char yyRuleInfoNRhs[] = { |
drh | 7589723 | 2000-05-29 14:26:00 +0000 | [diff] [blame] | 694 | %% |
| 695 | }; |
| 696 | |
drh | 1f245e4 | 2002-03-11 13:55:50 +0000 | [diff] [blame] | 697 | static void yy_accept(yyParser*); /* Forward Declaration */ |
drh | 7589723 | 2000-05-29 14:26:00 +0000 | [diff] [blame] | 698 | |
| 699 | /* |
| 700 | ** Perform a reduce action and the shift that must immediately |
| 701 | ** follow the reduce. |
drh | 087316c | 2017-12-15 12:22:21 +0000 | [diff] [blame] | 702 | ** |
| 703 | ** The yyLookahead and yyLookaheadToken parameters provide reduce actions |
| 704 | ** access to the lookahead token (if any). The yyLookahead will be YYNOCODE |
| 705 | ** if the lookahead token has already been consumed. As this procedure is |
| 706 | ** only called from one place, optimizing compilers will in-line it, which |
| 707 | ** means that the extra parameters have no performance impact. |
drh | 7589723 | 2000-05-29 14:26:00 +0000 | [diff] [blame] | 708 | */ |
drh | fd39c58 | 2018-04-21 22:40:08 +0000 | [diff] [blame] | 709 | static YYACTIONTYPE yy_reduce( |
drh | 7589723 | 2000-05-29 14:26:00 +0000 | [diff] [blame] | 710 | yyParser *yypParser, /* The parser */ |
drh | 087316c | 2017-12-15 12:22:21 +0000 | [diff] [blame] | 711 | unsigned int yyruleno, /* Number of the rule by which to reduce */ |
| 712 | int yyLookahead, /* Lookahead token, or YYNOCODE if none */ |
| 713 | ParseTOKENTYPE yyLookaheadToken /* Value of the lookahead token */ |
drh | fb32c44 | 2018-04-21 13:51:42 +0000 | [diff] [blame] | 714 | ParseCTX_PDECL /* %extra_context */ |
drh | 7589723 | 2000-05-29 14:26:00 +0000 | [diff] [blame] | 715 | ){ |
| 716 | int yygoto; /* The next state */ |
mistachkin | 709c822 | 2018-07-22 21:23:19 +0000 | [diff] [blame] | 717 | YYACTIONTYPE yyact; /* The next action */ |
drh | 1f245e4 | 2002-03-11 13:55:50 +0000 | [diff] [blame] | 718 | yyStackEntry *yymsp; /* The top of the parser's stack */ |
drh | 7589723 | 2000-05-29 14:26:00 +0000 | [diff] [blame] | 719 | int yysize; /* Amount to pop the stack */ |
drh | fb32c44 | 2018-04-21 13:51:42 +0000 | [diff] [blame] | 720 | ParseARG_FETCH |
drh | b968518 | 2018-01-17 13:15:23 +0000 | [diff] [blame] | 721 | (void)yyLookahead; |
| 722 | (void)yyLookaheadToken; |
drh | 118ab65 | 2016-05-23 21:56:24 +0000 | [diff] [blame] | 723 | yymsp = yypParser->yytos; |
drh | 0bd1f4e | 2002-06-06 18:54:39 +0000 | [diff] [blame] | 724 | #ifndef NDEBUG |
drh | 4ef0770 | 2016-03-16 19:45:54 +0000 | [diff] [blame] | 725 | if( yyTraceFILE && yyruleno<(int)(sizeof(yyRuleName)/sizeof(yyRuleName[0])) ){ |
drh | cfc45b1 | 2018-12-03 23:57:27 +0000 | [diff] [blame] | 726 | yysize = yyRuleInfoNRhs[yyruleno]; |
drh | e58f74f | 2017-12-24 17:06:41 +0000 | [diff] [blame] | 727 | if( yysize ){ |
drh | ce678c2 | 2019-12-11 18:53:51 +0000 | [diff] [blame] | 728 | fprintf(yyTraceFILE, "%sReduce %d [%s]%s, pop back to state %d.\n", |
drh | e58f74f | 2017-12-24 17:06:41 +0000 | [diff] [blame] | 729 | yyTracePrompt, |
drh | ce678c2 | 2019-12-11 18:53:51 +0000 | [diff] [blame] | 730 | yyruleno, yyRuleName[yyruleno], |
| 731 | yyruleno<YYNRULE_WITH_ACTION ? "" : " without external action", |
| 732 | yymsp[yysize].stateno); |
drh | e58f74f | 2017-12-24 17:06:41 +0000 | [diff] [blame] | 733 | }else{ |
drh | ce678c2 | 2019-12-11 18:53:51 +0000 | [diff] [blame] | 734 | fprintf(yyTraceFILE, "%sReduce %d [%s]%s.\n", |
| 735 | yyTracePrompt, yyruleno, yyRuleName[yyruleno], |
| 736 | yyruleno<YYNRULE_WITH_ACTION ? "" : " without external action"); |
drh | e58f74f | 2017-12-24 17:06:41 +0000 | [diff] [blame] | 737 | } |
drh | 0bd1f4e | 2002-06-06 18:54:39 +0000 | [diff] [blame] | 738 | } |
| 739 | #endif /* NDEBUG */ |
drh | 45f31be | 2016-02-16 21:19:49 +0000 | [diff] [blame] | 740 | |
| 741 | /* Check that the stack is large enough to grow by a single entry |
| 742 | ** if the RHS of the rule is empty. This ensures that there is room |
| 743 | ** enough on the stack to push the LHS value */ |
drh | cfc45b1 | 2018-12-03 23:57:27 +0000 | [diff] [blame] | 744 | if( yyRuleInfoNRhs[yyruleno]==0 ){ |
drh | 45f31be | 2016-02-16 21:19:49 +0000 | [diff] [blame] | 745 | #ifdef YYTRACKMAXSTACKDEPTH |
drh | 118ab65 | 2016-05-23 21:56:24 +0000 | [diff] [blame] | 746 | if( (int)(yypParser->yytos - yypParser->yystack)>yypParser->yyhwm ){ |
| 747 | yypParser->yyhwm++; |
| 748 | assert( yypParser->yyhwm == (int)(yypParser->yytos - yypParser->yystack)); |
drh | 45f31be | 2016-02-16 21:19:49 +0000 | [diff] [blame] | 749 | } |
| 750 | #endif |
| 751 | #if YYSTACKDEPTH>0 |
drh | 8b471e7 | 2017-06-28 15:01:35 +0000 | [diff] [blame] | 752 | if( yypParser->yytos>=yypParser->yystackEnd ){ |
drh | 45f31be | 2016-02-16 21:19:49 +0000 | [diff] [blame] | 753 | yyStackOverflow(yypParser); |
drh | 05ef50d | 2018-04-23 00:25:31 +0000 | [diff] [blame] | 754 | /* The call to yyStackOverflow() above pops the stack until it is |
| 755 | ** empty, causing the main parser loop to exit. So the return value |
| 756 | ** is never used and does not matter. */ |
| 757 | return 0; |
drh | 45f31be | 2016-02-16 21:19:49 +0000 | [diff] [blame] | 758 | } |
| 759 | #else |
drh | 118ab65 | 2016-05-23 21:56:24 +0000 | [diff] [blame] | 760 | if( yypParser->yytos>=&yypParser->yystack[yypParser->yystksz-1] ){ |
drh | 8dc8247 | 2016-05-27 04:10:47 +0000 | [diff] [blame] | 761 | if( yyGrowStack(yypParser) ){ |
drh | 45f31be | 2016-02-16 21:19:49 +0000 | [diff] [blame] | 762 | yyStackOverflow(yypParser); |
drh | 05ef50d | 2018-04-23 00:25:31 +0000 | [diff] [blame] | 763 | /* The call to yyStackOverflow() above pops the stack until it is |
| 764 | ** empty, causing the main parser loop to exit. So the return value |
| 765 | ** is never used and does not matter. */ |
| 766 | return 0; |
drh | 45f31be | 2016-02-16 21:19:49 +0000 | [diff] [blame] | 767 | } |
drh | 8dc8247 | 2016-05-27 04:10:47 +0000 | [diff] [blame] | 768 | yymsp = yypParser->yytos; |
drh | 45f31be | 2016-02-16 21:19:49 +0000 | [diff] [blame] | 769 | } |
| 770 | #endif |
| 771 | } |
drh | cb6c565 | 2007-01-16 18:19:12 +0000 | [diff] [blame] | 772 | |
drh | 7589723 | 2000-05-29 14:26:00 +0000 | [diff] [blame] | 773 | switch( yyruleno ){ |
| 774 | /* Beginning here are the reduction cases. A typical example |
| 775 | ** follows: |
| 776 | ** case 0: |
drh | 7589723 | 2000-05-29 14:26:00 +0000 | [diff] [blame] | 777 | ** #line <lineno> <grammarfile> |
| 778 | ** { ... } // User supplied code |
| 779 | ** #line <lineno> <thisfile> |
| 780 | ** break; |
| 781 | */ |
drh | 82415f2 | 2015-11-09 19:33:42 +0000 | [diff] [blame] | 782 | /********** Begin reduce actions **********************************************/ |
drh | 7589723 | 2000-05-29 14:26:00 +0000 | [diff] [blame] | 783 | %% |
drh | 82415f2 | 2015-11-09 19:33:42 +0000 | [diff] [blame] | 784 | /********** End reduce actions ************************************************/ |
drh | 7589723 | 2000-05-29 14:26:00 +0000 | [diff] [blame] | 785 | }; |
drh | cfc45b1 | 2018-12-03 23:57:27 +0000 | [diff] [blame] | 786 | assert( yyruleno<sizeof(yyRuleInfoLhs)/sizeof(yyRuleInfoLhs[0]) ); |
| 787 | yygoto = yyRuleInfoLhs[yyruleno]; |
| 788 | yysize = yyRuleInfoNRhs[yyruleno]; |
drh | 6be9536 | 2017-06-28 13:47:56 +0000 | [diff] [blame] | 789 | yyact = yy_find_reduce_action(yymsp[yysize].stateno,(YYCODETYPE)yygoto); |
drh | bd8fcc1 | 2017-06-28 11:56:18 +0000 | [diff] [blame] | 790 | |
| 791 | /* There are no SHIFTREDUCE actions on nonterminals because the table |
| 792 | ** generator has simplified them to pure REDUCE actions. */ |
| 793 | assert( !(yyact>YY_MAX_SHIFT && yyact<=YY_MAX_SHIFTREDUCE) ); |
| 794 | |
| 795 | /* It is not possible for a REDUCE to be followed by an error */ |
| 796 | assert( yyact!=YY_ERROR_ACTION ); |
| 797 | |
drh | ef53a9f | 2017-12-25 00:10:05 +0000 | [diff] [blame] | 798 | yymsp += yysize+1; |
| 799 | yypParser->yytos = yymsp; |
| 800 | yymsp->stateno = (YYACTIONTYPE)yyact; |
| 801 | yymsp->major = (YYCODETYPE)yygoto; |
| 802 | yyTraceShift(yypParser, yyact, "... then shift"); |
drh | fd39c58 | 2018-04-21 22:40:08 +0000 | [diff] [blame] | 803 | return yyact; |
drh | 7589723 | 2000-05-29 14:26:00 +0000 | [diff] [blame] | 804 | } |
| 805 | |
| 806 | /* |
| 807 | ** The following code executes when the parse fails |
| 808 | */ |
drh | d3ec02d | 2009-06-12 02:27:14 +0000 | [diff] [blame] | 809 | #ifndef YYNOERRORRECOVERY |
drh | 7589723 | 2000-05-29 14:26:00 +0000 | [diff] [blame] | 810 | static void yy_parse_failed( |
| 811 | yyParser *yypParser /* The parser */ |
drh | 7589723 | 2000-05-29 14:26:00 +0000 | [diff] [blame] | 812 | ){ |
drh | fb32c44 | 2018-04-21 13:51:42 +0000 | [diff] [blame] | 813 | ParseARG_FETCH |
| 814 | ParseCTX_FETCH |
drh | 7589723 | 2000-05-29 14:26:00 +0000 | [diff] [blame] | 815 | #ifndef NDEBUG |
| 816 | if( yyTraceFILE ){ |
| 817 | fprintf(yyTraceFILE,"%sFail!\n",yyTracePrompt); |
| 818 | } |
| 819 | #endif |
drh | abecc0b | 2016-05-24 00:40:54 +0000 | [diff] [blame] | 820 | while( yypParser->yytos>yypParser->yystack ) yy_pop_parser_stack(yypParser); |
drh | 7589723 | 2000-05-29 14:26:00 +0000 | [diff] [blame] | 821 | /* Here code is inserted which will be executed whenever the |
| 822 | ** parser fails */ |
drh | 82415f2 | 2015-11-09 19:33:42 +0000 | [diff] [blame] | 823 | /************ Begin %parse_failure code ***************************************/ |
drh | 7589723 | 2000-05-29 14:26:00 +0000 | [diff] [blame] | 824 | %% |
drh | 82415f2 | 2015-11-09 19:33:42 +0000 | [diff] [blame] | 825 | /************ End %parse_failure code *****************************************/ |
drh | fb32c44 | 2018-04-21 13:51:42 +0000 | [diff] [blame] | 826 | ParseARG_STORE /* Suppress warning about unused %extra_argument variable */ |
| 827 | ParseCTX_STORE |
drh | 7589723 | 2000-05-29 14:26:00 +0000 | [diff] [blame] | 828 | } |
drh | d3ec02d | 2009-06-12 02:27:14 +0000 | [diff] [blame] | 829 | #endif /* YYNOERRORRECOVERY */ |
drh | 7589723 | 2000-05-29 14:26:00 +0000 | [diff] [blame] | 830 | |
| 831 | /* |
| 832 | ** The following code executes when a syntax error first occurs. |
| 833 | */ |
| 834 | static void yy_syntax_error( |
| 835 | yyParser *yypParser, /* The parser */ |
| 836 | int yymajor, /* The major type of the error token */ |
drh | 45f31be | 2016-02-16 21:19:49 +0000 | [diff] [blame] | 837 | ParseTOKENTYPE yyminor /* The minor type of the error token */ |
drh | 7589723 | 2000-05-29 14:26:00 +0000 | [diff] [blame] | 838 | ){ |
drh | fb32c44 | 2018-04-21 13:51:42 +0000 | [diff] [blame] | 839 | ParseARG_FETCH |
| 840 | ParseCTX_FETCH |
drh | 45f31be | 2016-02-16 21:19:49 +0000 | [diff] [blame] | 841 | #define TOKEN yyminor |
drh | 82415f2 | 2015-11-09 19:33:42 +0000 | [diff] [blame] | 842 | /************ Begin %syntax_error code ****************************************/ |
drh | 7589723 | 2000-05-29 14:26:00 +0000 | [diff] [blame] | 843 | %% |
drh | 82415f2 | 2015-11-09 19:33:42 +0000 | [diff] [blame] | 844 | /************ End %syntax_error code ******************************************/ |
drh | fb32c44 | 2018-04-21 13:51:42 +0000 | [diff] [blame] | 845 | ParseARG_STORE /* Suppress warning about unused %extra_argument variable */ |
| 846 | ParseCTX_STORE |
drh | 7589723 | 2000-05-29 14:26:00 +0000 | [diff] [blame] | 847 | } |
| 848 | |
| 849 | /* |
| 850 | ** The following is executed when the parser accepts |
| 851 | */ |
| 852 | static void yy_accept( |
| 853 | yyParser *yypParser /* The parser */ |
drh | 7589723 | 2000-05-29 14:26:00 +0000 | [diff] [blame] | 854 | ){ |
drh | fb32c44 | 2018-04-21 13:51:42 +0000 | [diff] [blame] | 855 | ParseARG_FETCH |
| 856 | ParseCTX_FETCH |
drh | 7589723 | 2000-05-29 14:26:00 +0000 | [diff] [blame] | 857 | #ifndef NDEBUG |
| 858 | if( yyTraceFILE ){ |
| 859 | fprintf(yyTraceFILE,"%sAccept!\n",yyTracePrompt); |
| 860 | } |
| 861 | #endif |
drh | dd703e2 | 2016-07-12 19:54:49 +0000 | [diff] [blame] | 862 | #ifndef YYNOERRORRECOVERY |
| 863 | yypParser->yyerrcnt = -1; |
| 864 | #endif |
drh | 756b41e | 2016-05-24 18:55:08 +0000 | [diff] [blame] | 865 | assert( yypParser->yytos==yypParser->yystack ); |
drh | 7589723 | 2000-05-29 14:26:00 +0000 | [diff] [blame] | 866 | /* Here code is inserted which will be executed whenever the |
| 867 | ** parser accepts */ |
drh | 82415f2 | 2015-11-09 19:33:42 +0000 | [diff] [blame] | 868 | /*********** Begin %parse_accept code *****************************************/ |
drh | 7589723 | 2000-05-29 14:26:00 +0000 | [diff] [blame] | 869 | %% |
drh | 82415f2 | 2015-11-09 19:33:42 +0000 | [diff] [blame] | 870 | /*********** End %parse_accept code *******************************************/ |
drh | fb32c44 | 2018-04-21 13:51:42 +0000 | [diff] [blame] | 871 | ParseARG_STORE /* Suppress warning about unused %extra_argument variable */ |
| 872 | ParseCTX_STORE |
drh | 7589723 | 2000-05-29 14:26:00 +0000 | [diff] [blame] | 873 | } |
| 874 | |
| 875 | /* The main parser program. |
| 876 | ** The first argument is a pointer to a structure obtained from |
| 877 | ** "ParseAlloc" which describes the current state of the parser. |
| 878 | ** The second argument is the major token number. The third is |
| 879 | ** the minor token. The fourth optional argument is whatever the |
| 880 | ** user wants (and specified in the grammar) and is available for |
| 881 | ** use by the action routines. |
| 882 | ** |
| 883 | ** Inputs: |
| 884 | ** <ul> |
| 885 | ** <li> A pointer to the parser (an opaque structure.) |
| 886 | ** <li> The major token number. |
| 887 | ** <li> The minor token number. |
| 888 | ** <li> An option argument of a grammar-specified type. |
| 889 | ** </ul> |
| 890 | ** |
| 891 | ** Outputs: |
| 892 | ** None. |
| 893 | */ |
drh | 7589723 | 2000-05-29 14:26:00 +0000 | [diff] [blame] | 894 | void Parse( |
| 895 | void *yyp, /* The parser */ |
| 896 | int yymajor, /* The major token code number */ |
| 897 | ParseTOKENTYPE yyminor /* The value for the token */ |
drh | 1f245e4 | 2002-03-11 13:55:50 +0000 | [diff] [blame] | 898 | ParseARG_PDECL /* Optional %extra_argument parameter */ |
drh | 7589723 | 2000-05-29 14:26:00 +0000 | [diff] [blame] | 899 | ){ |
| 900 | YYMINORTYPE yyminorunion; |
drh | fd39c58 | 2018-04-21 22:40:08 +0000 | [diff] [blame] | 901 | YYACTIONTYPE yyact; /* The parser action. */ |
drh | a441404 | 2015-11-09 15:06:26 +0000 | [diff] [blame] | 902 | #if !defined(YYERRORSYMBOL) && !defined(YYNOERRORRECOVERY) |
drh | 7589723 | 2000-05-29 14:26:00 +0000 | [diff] [blame] | 903 | int yyendofinput; /* True if we are at the end of input */ |
drh | a441404 | 2015-11-09 15:06:26 +0000 | [diff] [blame] | 904 | #endif |
drh | c4dd3fd | 2008-01-22 01:48:05 +0000 | [diff] [blame] | 905 | #ifdef YYERRORSYMBOL |
drh | 7589723 | 2000-05-29 14:26:00 +0000 | [diff] [blame] | 906 | int yyerrorhit = 0; /* True if yymajor has invoked an error */ |
drh | c4dd3fd | 2008-01-22 01:48:05 +0000 | [diff] [blame] | 907 | #endif |
drh | fb32c44 | 2018-04-21 13:51:42 +0000 | [diff] [blame] | 908 | yyParser *yypParser = (yyParser*)yyp; /* The parser */ |
| 909 | ParseCTX_FETCH |
| 910 | ParseARG_STORE |
drh | 7589723 | 2000-05-29 14:26:00 +0000 | [diff] [blame] | 911 | |
drh | abecc0b | 2016-05-24 00:40:54 +0000 | [diff] [blame] | 912 | assert( yypParser->yytos!=0 ); |
drh | a441404 | 2015-11-09 15:06:26 +0000 | [diff] [blame] | 913 | #if !defined(YYERRORSYMBOL) && !defined(YYNOERRORRECOVERY) |
drh | 7589723 | 2000-05-29 14:26:00 +0000 | [diff] [blame] | 914 | yyendofinput = (yymajor==0); |
drh | a441404 | 2015-11-09 15:06:26 +0000 | [diff] [blame] | 915 | #endif |
drh | 7589723 | 2000-05-29 14:26:00 +0000 | [diff] [blame] | 916 | |
drh | fd39c58 | 2018-04-21 22:40:08 +0000 | [diff] [blame] | 917 | yyact = yypParser->yytos->stateno; |
drh | 7589723 | 2000-05-29 14:26:00 +0000 | [diff] [blame] | 918 | #ifndef NDEBUG |
| 919 | if( yyTraceFILE ){ |
drh | fd39c58 | 2018-04-21 22:40:08 +0000 | [diff] [blame] | 920 | if( yyact < YY_MIN_REDUCE ){ |
drh | e58f74f | 2017-12-24 17:06:41 +0000 | [diff] [blame] | 921 | fprintf(yyTraceFILE,"%sInput '%s' in state %d\n", |
drh | fd39c58 | 2018-04-21 22:40:08 +0000 | [diff] [blame] | 922 | yyTracePrompt,yyTokenName[yymajor],yyact); |
drh | e58f74f | 2017-12-24 17:06:41 +0000 | [diff] [blame] | 923 | }else{ |
| 924 | fprintf(yyTraceFILE,"%sInput '%s' with pending reduce %d\n", |
drh | fd39c58 | 2018-04-21 22:40:08 +0000 | [diff] [blame] | 925 | yyTracePrompt,yyTokenName[yymajor],yyact-YY_MIN_REDUCE); |
drh | e58f74f | 2017-12-24 17:06:41 +0000 | [diff] [blame] | 926 | } |
drh | 7589723 | 2000-05-29 14:26:00 +0000 | [diff] [blame] | 927 | } |
| 928 | #endif |
| 929 | |
| 930 | do{ |
drh | fd39c58 | 2018-04-21 22:40:08 +0000 | [diff] [blame] | 931 | assert( yyact==yypParser->yytos->stateno ); |
mistachkin | 709c822 | 2018-07-22 21:23:19 +0000 | [diff] [blame] | 932 | yyact = yy_find_shift_action((YYCODETYPE)yymajor,yyact); |
drh | 5c8241b | 2017-12-24 23:38:10 +0000 | [diff] [blame] | 933 | if( yyact >= YY_MIN_REDUCE ){ |
drh | fd39c58 | 2018-04-21 22:40:08 +0000 | [diff] [blame] | 934 | yyact = yy_reduce(yypParser,yyact-YY_MIN_REDUCE,yymajor, |
| 935 | yyminor ParseCTX_PARAM); |
drh | 5c8241b | 2017-12-24 23:38:10 +0000 | [diff] [blame] | 936 | }else if( yyact <= YY_MAX_SHIFTREDUCE ){ |
mistachkin | 709c822 | 2018-07-22 21:23:19 +0000 | [diff] [blame] | 937 | yy_shift(yypParser,yyact,(YYCODETYPE)yymajor,yyminor); |
drh | dab943c | 2016-02-16 01:01:43 +0000 | [diff] [blame] | 938 | #ifndef YYNOERRORRECOVERY |
drh | a248a72 | 2015-09-07 19:52:55 +0000 | [diff] [blame] | 939 | yypParser->yyerrcnt--; |
drh | dab943c | 2016-02-16 01:01:43 +0000 | [diff] [blame] | 940 | #endif |
drh | fd39c58 | 2018-04-21 22:40:08 +0000 | [diff] [blame] | 941 | break; |
drh | ef53a9f | 2017-12-25 00:10:05 +0000 | [diff] [blame] | 942 | }else if( yyact==YY_ACCEPT_ACTION ){ |
drh | 05ef50d | 2018-04-23 00:25:31 +0000 | [diff] [blame] | 943 | yypParser->yytos--; |
| 944 | yy_accept(yypParser); |
drh | ef53a9f | 2017-12-25 00:10:05 +0000 | [diff] [blame] | 945 | return; |
drh | c4dd3fd | 2008-01-22 01:48:05 +0000 | [diff] [blame] | 946 | }else{ |
| 947 | assert( yyact == YY_ERROR_ACTION ); |
drh | 45f31be | 2016-02-16 21:19:49 +0000 | [diff] [blame] | 948 | yyminorunion.yy0 = yyminor; |
drh | c4dd3fd | 2008-01-22 01:48:05 +0000 | [diff] [blame] | 949 | #ifdef YYERRORSYMBOL |
drh | 3ddfdf7 | 2003-12-22 14:53:19 +0000 | [diff] [blame] | 950 | int yymx; |
drh | c4dd3fd | 2008-01-22 01:48:05 +0000 | [diff] [blame] | 951 | #endif |
drh | 7589723 | 2000-05-29 14:26:00 +0000 | [diff] [blame] | 952 | #ifndef NDEBUG |
| 953 | if( yyTraceFILE ){ |
| 954 | fprintf(yyTraceFILE,"%sSyntax Error!\n",yyTracePrompt); |
| 955 | } |
| 956 | #endif |
| 957 | #ifdef YYERRORSYMBOL |
| 958 | /* A syntax error has occurred. |
| 959 | ** The response to an error depends upon whether or not the |
| 960 | ** grammar defines an error token "ERROR". |
| 961 | ** |
| 962 | ** This is what we do if the grammar does define ERROR: |
| 963 | ** |
| 964 | ** * Call the %syntax_error function. |
| 965 | ** |
| 966 | ** * Begin popping the stack until we enter a state where |
| 967 | ** it is legal to shift the error symbol, then shift |
| 968 | ** the error symbol. |
| 969 | ** |
| 970 | ** * Set the error count to three. |
| 971 | ** |
| 972 | ** * Begin accepting and shifting new tokens. No new error |
| 973 | ** processing will occur until three tokens have been |
| 974 | ** shifted successfully. |
| 975 | ** |
| 976 | */ |
drh | 1f245e4 | 2002-03-11 13:55:50 +0000 | [diff] [blame] | 977 | if( yypParser->yyerrcnt<0 ){ |
drh | 45f31be | 2016-02-16 21:19:49 +0000 | [diff] [blame] | 978 | yy_syntax_error(yypParser,yymajor,yyminor); |
drh | 7589723 | 2000-05-29 14:26:00 +0000 | [diff] [blame] | 979 | } |
drh | 118ab65 | 2016-05-23 21:56:24 +0000 | [diff] [blame] | 980 | yymx = yypParser->yytos->major; |
drh | 3ddfdf7 | 2003-12-22 14:53:19 +0000 | [diff] [blame] | 981 | if( yymx==YYERRORSYMBOL || yyerrorhit ){ |
drh | 7589723 | 2000-05-29 14:26:00 +0000 | [diff] [blame] | 982 | #ifndef NDEBUG |
| 983 | if( yyTraceFILE ){ |
| 984 | fprintf(yyTraceFILE,"%sDiscard input token %s\n", |
| 985 | yyTracePrompt,yyTokenName[yymajor]); |
| 986 | } |
| 987 | #endif |
drh | 45f31be | 2016-02-16 21:19:49 +0000 | [diff] [blame] | 988 | yy_destructor(yypParser, (YYCODETYPE)yymajor, &yyminorunion); |
drh | 7589723 | 2000-05-29 14:26:00 +0000 | [diff] [blame] | 989 | yymajor = YYNOCODE; |
| 990 | }else{ |
drh | 4eda15e | 2016-10-04 12:20:12 +0000 | [diff] [blame] | 991 | while( yypParser->yytos >= yypParser->yystack |
drh | 118ab65 | 2016-05-23 21:56:24 +0000 | [diff] [blame] | 992 | && (yyact = yy_find_reduce_action( |
| 993 | yypParser->yytos->stateno, |
drh | b8a7628 | 2018-11-27 14:03:11 +0000 | [diff] [blame] | 994 | YYERRORSYMBOL)) > YY_MAX_SHIFTREDUCE |
drh | 7589723 | 2000-05-29 14:26:00 +0000 | [diff] [blame] | 995 | ){ |
| 996 | yy_pop_parser_stack(yypParser); |
| 997 | } |
drh | 118ab65 | 2016-05-23 21:56:24 +0000 | [diff] [blame] | 998 | if( yypParser->yytos < yypParser->yystack || yymajor==0 ){ |
drh | b27b7f5 | 2008-12-10 18:03:45 +0000 | [diff] [blame] | 999 | yy_destructor(yypParser,(YYCODETYPE)yymajor,&yyminorunion); |
drh | 1f245e4 | 2002-03-11 13:55:50 +0000 | [diff] [blame] | 1000 | yy_parse_failed(yypParser); |
drh | 240c7fa | 2016-07-05 12:47:28 +0000 | [diff] [blame] | 1001 | #ifndef YYNOERRORRECOVERY |
| 1002 | yypParser->yyerrcnt = -1; |
| 1003 | #endif |
drh | 7589723 | 2000-05-29 14:26:00 +0000 | [diff] [blame] | 1004 | yymajor = YYNOCODE; |
drh | 3ddfdf7 | 2003-12-22 14:53:19 +0000 | [diff] [blame] | 1005 | }else if( yymx!=YYERRORSYMBOL ){ |
drh | 45f31be | 2016-02-16 21:19:49 +0000 | [diff] [blame] | 1006 | yy_shift(yypParser,yyact,YYERRORSYMBOL,yyminor); |
drh | 7589723 | 2000-05-29 14:26:00 +0000 | [diff] [blame] | 1007 | } |
| 1008 | } |
drh | 1f245e4 | 2002-03-11 13:55:50 +0000 | [diff] [blame] | 1009 | yypParser->yyerrcnt = 3; |
drh | 7589723 | 2000-05-29 14:26:00 +0000 | [diff] [blame] | 1010 | yyerrorhit = 1; |
drh | fd39c58 | 2018-04-21 22:40:08 +0000 | [diff] [blame] | 1011 | if( yymajor==YYNOCODE ) break; |
| 1012 | yyact = yypParser->yytos->stateno; |
drh | d3ec02d | 2009-06-12 02:27:14 +0000 | [diff] [blame] | 1013 | #elif defined(YYNOERRORRECOVERY) |
| 1014 | /* If the YYNOERRORRECOVERY macro is defined, then do not attempt to |
| 1015 | ** do any kind of error recovery. Instead, simply invoke the syntax |
| 1016 | ** error routine and continue going as if nothing had happened. |
| 1017 | ** |
| 1018 | ** Applications can set this macro (for example inside %include) if |
| 1019 | ** they intend to abandon the parse upon the first syntax error seen. |
| 1020 | */ |
drh | 45f31be | 2016-02-16 21:19:49 +0000 | [diff] [blame] | 1021 | yy_syntax_error(yypParser,yymajor, yyminor); |
drh | d3ec02d | 2009-06-12 02:27:14 +0000 | [diff] [blame] | 1022 | yy_destructor(yypParser,(YYCODETYPE)yymajor,&yyminorunion); |
drh | fd39c58 | 2018-04-21 22:40:08 +0000 | [diff] [blame] | 1023 | break; |
drh | 7589723 | 2000-05-29 14:26:00 +0000 | [diff] [blame] | 1024 | #else /* YYERRORSYMBOL is not defined */ |
| 1025 | /* This is what we do if the grammar does not define ERROR: |
| 1026 | ** |
| 1027 | ** * Report an error message, and throw away the input token. |
| 1028 | ** |
| 1029 | ** * If the input token is $, then fail the parse. |
| 1030 | ** |
| 1031 | ** As before, subsequent error messages are suppressed until |
| 1032 | ** three input tokens have been successfully shifted. |
| 1033 | */ |
drh | 1f245e4 | 2002-03-11 13:55:50 +0000 | [diff] [blame] | 1034 | if( yypParser->yyerrcnt<=0 ){ |
drh | 45f31be | 2016-02-16 21:19:49 +0000 | [diff] [blame] | 1035 | yy_syntax_error(yypParser,yymajor, yyminor); |
drh | 7589723 | 2000-05-29 14:26:00 +0000 | [diff] [blame] | 1036 | } |
drh | 1f245e4 | 2002-03-11 13:55:50 +0000 | [diff] [blame] | 1037 | yypParser->yyerrcnt = 3; |
drh | b27b7f5 | 2008-12-10 18:03:45 +0000 | [diff] [blame] | 1038 | yy_destructor(yypParser,(YYCODETYPE)yymajor,&yyminorunion); |
drh | 7589723 | 2000-05-29 14:26:00 +0000 | [diff] [blame] | 1039 | if( yyendofinput ){ |
drh | 1f245e4 | 2002-03-11 13:55:50 +0000 | [diff] [blame] | 1040 | yy_parse_failed(yypParser); |
drh | d3d4b3c | 2016-07-08 19:54:38 +0000 | [diff] [blame] | 1041 | #ifndef YYNOERRORRECOVERY |
| 1042 | yypParser->yyerrcnt = -1; |
| 1043 | #endif |
drh | 7589723 | 2000-05-29 14:26:00 +0000 | [diff] [blame] | 1044 | } |
drh | fd39c58 | 2018-04-21 22:40:08 +0000 | [diff] [blame] | 1045 | break; |
drh | 7589723 | 2000-05-29 14:26:00 +0000 | [diff] [blame] | 1046 | #endif |
drh | 7589723 | 2000-05-29 14:26:00 +0000 | [diff] [blame] | 1047 | } |
drh | fd39c58 | 2018-04-21 22:40:08 +0000 | [diff] [blame] | 1048 | }while( yypParser->yytos>yypParser->yystack ); |
drh | 3bd48ab | 2015-09-07 18:23:37 +0000 | [diff] [blame] | 1049 | #ifndef NDEBUG |
| 1050 | if( yyTraceFILE ){ |
drh | 118ab65 | 2016-05-23 21:56:24 +0000 | [diff] [blame] | 1051 | yyStackEntry *i; |
| 1052 | char cDiv = '['; |
drh | 0c4105e | 2015-11-10 14:51:22 +0000 | [diff] [blame] | 1053 | fprintf(yyTraceFILE,"%sReturn. Stack=",yyTracePrompt); |
drh | 118ab65 | 2016-05-23 21:56:24 +0000 | [diff] [blame] | 1054 | for(i=&yypParser->yystack[1]; i<=yypParser->yytos; i++){ |
| 1055 | fprintf(yyTraceFILE,"%c%s", cDiv, yyTokenName[i->major]); |
| 1056 | cDiv = ' '; |
| 1057 | } |
drh | 0c4105e | 2015-11-10 14:51:22 +0000 | [diff] [blame] | 1058 | fprintf(yyTraceFILE,"]\n"); |
drh | 3bd48ab | 2015-09-07 18:23:37 +0000 | [diff] [blame] | 1059 | } |
| 1060 | #endif |
drh | 7589723 | 2000-05-29 14:26:00 +0000 | [diff] [blame] | 1061 | return; |
| 1062 | } |
dan | 59ff425 | 2018-06-29 17:44:52 +0000 | [diff] [blame] | 1063 | |
| 1064 | /* |
| 1065 | ** Return the fallback token corresponding to canonical token iToken, or |
| 1066 | ** 0 if iToken has no fallback. |
| 1067 | */ |
| 1068 | int ParseFallback(int iToken){ |
| 1069 | #ifdef YYFALLBACK |
drh | 6ee3fa8 | 2019-08-28 11:49:45 +0000 | [diff] [blame] | 1070 | assert( iToken<(int)(sizeof(yyFallback)/sizeof(yyFallback[0])) ); |
| 1071 | return yyFallback[iToken]; |
drh | c7bf571 | 2018-07-09 22:49:01 +0000 | [diff] [blame] | 1072 | #else |
| 1073 | (void)iToken; |
dan | 59ff425 | 2018-06-29 17:44:52 +0000 | [diff] [blame] | 1074 | return 0; |
drh | 276d7f7 | 2019-10-21 16:15:57 +0000 | [diff] [blame] | 1075 | #endif |
dan | 59ff425 | 2018-06-29 17:44:52 +0000 | [diff] [blame] | 1076 | } |