/* This file is automatically generated by Lemon from input grammar ** source file "examples/bootstrap/boot_grammar.lime". */ /* ** 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 lime 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 ** 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 generated parser ** source file. ** ** The following is the concatenation of all %include directives from the ** input grammar file: */ /************ Begin %include sections from the grammar ************************/ #line 47 "examples/bootstrap/boot_grammar.lime" #include "boot_gram_defs.h" #line 33 "examples/bootstrap/boot_grammar.c" /**************** End of %include directives **********************************/ /* These constants specify the various numeric values for terminal symbols. ***************** Begin token definitions *************************************/ #ifndef ID #define ID 1 #define COMMA 2 #define EQUALS 3 #define LPAREN 4 #define RPAREN 5 #define NULLVAL 6 #define OPEN 7 #define XCLOSE 8 #define XCREATE 9 #define INSERT_TUPLE 10 #define XDECLARE 11 #define INDEX 12 #define ON 13 #define USING 14 #define XBUILD 15 #define INDICES 16 #define UNIQUE 17 #define XTOAST 18 #define OBJ_ID 19 #define XBOOTSTRAP 20 #define XSHARED_RELATION 21 #define XROWTYPE_OID 22 #define XFORCE 23 #define XNOT 24 #define XNULL 25 #endif /**************** End 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. ** bootTOKENTYPE 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 bootTOKENTYPE. 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() ** bootARG_SDECL A static variable declaration for the %extra_argument ** bootARG_PDECL A parameter declaration for the %extra_argument ** bootARG_PARAM Code to pass %extra_argument as a subroutine parameter ** bootARG_STORE Code to store %extra_argument into yypParser ** bootARG_FETCH Code to extract %extra_argument from yypParser ** bootCTX_* As bootARG_ except for %extra_context ** YYREALLOC Name of the realloc() function to use ** YYFREE Name of the free() function to use ** YYDYNSTACK True if stack space should be extended on heap ** 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 ** YYNTOKEN Number of terminal symbols ** 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_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 ** YY_MIN_REDUCE Minimum value for reduce actions ** YY_MAX_REDUCE Maximum value for reduce actions ** YY_MIN_DSTRCTR Minimum symbol value that has a destructor ** YY_MAX_DSTRCTR Maximum symbol value that has a destructor */ #ifndef INTERFACE # define INTERFACE 1 #endif /************* Begin control #defines *****************************************/ #define YYCODETYPE unsigned char #define YYNOCODE 49 #define YYACTIONTYPE unsigned char #define bootTOKENTYPE BootToken typedef union { int yyinit; bootTOKENTYPE yy0; Oid yy21; char * yy29; int yy32; BootIndexParamList * yy68; BootIndexParam * yy82; } YYMINORTYPE; #ifndef YYSTACKDEPTH #define YYSTACKDEPTH 100 #endif #define bootARG_SDECL BootParseState *pstate; #define bootARG_PDECL ,BootParseState *pstate #define bootARG_PARAM ,pstate #define bootARG_FETCH BootParseState *pstate=yypParser->pstate; #define bootARG_STORE yypParser->pstate=pstate; #undef YYREALLOC #define YYREALLOC realloc #undef YYFREE #define YYFREE free #undef YYDYNSTACK #define YYDYNSTACK 0 #undef YYSIZELIMIT #define bootCTX(P) 0 #define bootCTX_SDECL #define bootCTX_PDECL #define bootCTX_PARAM #define bootCTX_FETCH #define bootCTX_STORE #undef YYERRORSYMBOL #undef YYERRSYMDT #undef YYFALLBACK #define YYNSTATE 50 #define YYNRULE 61 #define YYNRULE_WITH_ACTION 61 #define YYNTOKEN 26 #define YY_MAX_SHIFT 49 #define YY_MIN_SHIFTREDUCE 105 #define YY_MAX_SHIFTREDUCE 165 #define YY_ERROR_ACTION 166 #define YY_ACCEPT_ACTION 167 #define YY_NO_ACTION 168 #define YY_MIN_REDUCE 169 #define YY_MAX_REDUCE 229 #define YY_MIN_DSTRCTR 0 #define YY_MAX_DSTRCTR 0 /************* End control #defines *******************************************/ #define YY_NLOOKAHEAD ((int)(sizeof(yy_lookahead)/sizeof(yy_lookahead[0]))) /* 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 /* Macro to determine if stack space has the ability to grow using ** heap memory. */ #if YYSTACKDEPTH<=0 || YYDYNSTACK # define YYGROWABLESTACK 1 #else # define YYGROWABLESTACK 0 #endif /* Guarantee a minimum number of initial stack slots. */ #if YYSTACKDEPTH<=0 # undef YYSTACKDEPTH # define YYSTACKDEPTH 2 /* Need a minimum stack size */ #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 == 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. ** ** N between YY_MIN_REDUCE Reduce by rule N-YY_MIN_REDUCE ** and YY_MAX_REDUCE ** ** 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 ** yy_lookahead[yy_shift_ofst[S]+X] is not equal to X. ** ** 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. ** ** 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 (175) static const YYACTIONTYPE yy_action[] = { /* 0 */ 187, 146, 7, 204, 38, 120, 145, 147, 148, 149, /* 10 */ 150, 151, 152, 153, 154, 155, 156, 157, 158, 159, /* 20 */ 160, 161, 162, 163, 164, 165, 146, 33, 190, 20, /* 30 */ 39, 145, 147, 148, 149, 150, 151, 152, 153, 154, /* 40 */ 155, 156, 157, 158, 159, 160, 161, 162, 163, 164, /* 50 */ 165, 146, 34, 190, 20, 204, 8, 147, 148, 149, /* 60 */ 150, 151, 152, 153, 154, 155, 156, 157, 158, 159, /* 70 */ 160, 161, 162, 163, 164, 165, 40, 167, 1, 171, /* 80 */ 173, 174, 175, 176, 177, 178, 179, 180, 172, 173, /* 90 */ 174, 175, 176, 177, 178, 179, 180, 170, 204, 41, /* 100 */ 189, 20, 208, 10, 27, 26, 25, 46, 32, 169, /* 110 */ 6, 205, 37, 204, 45, 48, 27, 26, 25, 46, /* 120 */ 32, 36, 198, 23, 37, 208, 208, 191, 42, 9, /* 130 */ 204, 196, 48, 11, 206, 207, 122, 204, 31, 199, /* 140 */ 11, 47, 138, 121, 14, 43, 44, 119, 35, 12, /* 150 */ 13, 28, 15, 182, 181, 130, 128, 124, 16, 3, /* 160 */ 200, 49, 29, 30, 17, 18, 19, 4, 2, 137, /* 170 */ 21, 22, 24, 168, 5, }; static const YYCODETYPE yy_lookahead[] = { /* 0 */ 39, 1, 2, 39, 40, 5, 6, 7, 8, 9, /* 10 */ 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, /* 20 */ 20, 21, 22, 23, 24, 25, 1, 37, 38, 39, /* 30 */ 39, 6, 7, 8, 9, 10, 11, 12, 13, 14, /* 40 */ 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, /* 50 */ 25, 1, 37, 38, 39, 39, 40, 7, 8, 9, /* 60 */ 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, /* 70 */ 20, 21, 22, 23, 24, 25, 39, 26, 27, 28, /* 80 */ 29, 30, 31, 32, 33, 34, 35, 36, 28, 29, /* 90 */ 30, 31, 32, 33, 34, 35, 36, 0, 39, 40, /* 100 */ 38, 39, 39, 39, 7, 8, 9, 10, 11, 0, /* 110 */ 47, 48, 15, 39, 40, 39, 7, 8, 9, 10, /* 120 */ 11, 45, 46, 12, 15, 39, 39, 39, 17, 18, /* 130 */ 39, 40, 39, 2, 48, 48, 5, 39, 40, 46, /* 140 */ 2, 24, 25, 5, 2, 39, 39, 5, 23, 39, /* 150 */ 22, 39, 39, 39, 39, 21, 20, 16, 13, 4, /* 160 */ 44, 43, 42, 41, 14, 13, 12, 4, 4, 25, /* 170 */ 14, 13, 3, 49, 4, 49, 49, 49, 49, 49, /* 180 */ 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, /* 190 */ 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, /* 200 */ 49, }; #define YY_SHIFT_COUNT (49) #define YY_SHIFT_MIN (0) #define YY_SHIFT_MAX (170) static const unsigned char yy_shift_ofst[] = { /* 0 */ 97, 109, 25, 50, 50, 50, 0, 25, 50, 50, /* 10 */ 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, /* 20 */ 50, 50, 50, 50, 50, 50, 50, 50, 125, 128, /* 30 */ 134, 136, 111, 131, 138, 117, 142, 141, 145, 155, /* 40 */ 150, 152, 154, 163, 156, 158, 164, 144, 169, 170, }; #define YY_REDUCE_COUNT (31) #define YY_REDUCE_MIN (-39) #define YY_REDUCE_MAX (122) static const signed char yy_reduce_ofst[] = { /* 0 */ 51, 60, 63, -10, 15, 76, 86, 87, -36, 16, /* 10 */ 59, 62, 74, 91, 93, 98, -39, -9, 37, 64, /* 20 */ 88, 106, 107, 110, 112, 113, 114, 115, 116, 118, /* 30 */ 120, 122, }; static const YYACTIONTYPE yy_default[] = { /* 0 */ 166, 166, 166, 166, 166, 166, 166, 166, 166, 166, /* 10 */ 166, 166, 166, 166, 166, 166, 166, 166, 166, 166, /* 20 */ 166, 166, 166, 166, 166, 166, 166, 166, 203, 197, /* 30 */ 195, 193, 166, 166, 166, 166, 166, 166, 166, 166, /* 40 */ 166, 166, 166, 166, 166, 166, 166, 166, 166, 166, }; /********** 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 */ #ifdef YYLOCATIONTYPE YYLOCATIONTYPE yyloc; /* Source location for this stack entry. ** Only present when %locations is active. */ #endif }; 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 bootARG_SDECL /* A place to hold %extra_argument */ bootCTX_SDECL /* A place to hold %extra_context */ yyStackEntry *yystackEnd; /* Last entry in the stack */ yyStackEntry *yystack; /* The parser stack */ yyStackEntry yystk0[YYSTACKDEPTH]; /* Initial stack space */ }; typedef struct yyParser yyParser; #include #include #include #ifndef NDEBUG #include 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: **
    **
  • A FILE* to which trace output should be written. ** If NULL, then tracing is turned off. **
  • A prefix string written at the beginning of every ** line of trace output. If NULL, then tracing is ** turned off. **
** ** Outputs: ** None. */ void bootTrace(FILE *TraceFILE, char *zTracePrompt){ yyTraceFILE = TraceFILE; yyTracePrompt = zTracePrompt; if( yyTraceFILE==0 ) yyTracePrompt = 0; else if( yyTracePrompt==0 ) yyTraceFILE = 0; } #endif /* NDEBUG */ #if defined(YYCOVERAGE) || !defined(NDEBUG) /* For tracing shifts, the names of all terminals and nonterminals ** are required. The following table supplies these names */ static const char *const yyTokenName[] = { /* 0 */ "$", /* 1 */ "ID", /* 2 */ "COMMA", /* 3 */ "EQUALS", /* 4 */ "LPAREN", /* 5 */ "RPAREN", /* 6 */ "NULLVAL", /* 7 */ "OPEN", /* 8 */ "XCLOSE", /* 9 */ "XCREATE", /* 10 */ "INSERT_TUPLE", /* 11 */ "XDECLARE", /* 12 */ "INDEX", /* 13 */ "ON", /* 14 */ "USING", /* 15 */ "XBUILD", /* 16 */ "INDICES", /* 17 */ "UNIQUE", /* 18 */ "XTOAST", /* 19 */ "OBJ_ID", /* 20 */ "XBOOTSTRAP", /* 21 */ "XSHARED_RELATION", /* 22 */ "XROWTYPE_OID", /* 23 */ "XFORCE", /* 24 */ "XNOT", /* 25 */ "XNULL", /* 26 */ "topLevel", /* 27 */ "boot_queries", /* 28 */ "boot_query", /* 29 */ "boot_openStmt", /* 30 */ "boot_closeStmt", /* 31 */ "boot_createStmt", /* 32 */ "boot_insertStmt", /* 33 */ "boot_declareIndexStmt", /* 34 */ "boot_declareUniqueIndexStmt", /* 35 */ "boot_declareToastStmt", /* 36 */ "boot_buildIndsStmt", /* 37 */ "boot_index_params", /* 38 */ "boot_index_param", /* 39 */ "boot_ident", /* 40 */ "oidspec", /* 41 */ "optbootstrap", /* 42 */ "optsharedrelation", /* 43 */ "optrowtypeoid", /* 44 */ "boot_column_nullness", /* 45 */ "boot_column_list", /* 46 */ "boot_column_def", /* 47 */ "boot_column_val_list", /* 48 */ "boot_column_val", }; #endif /* defined(YYCOVERAGE) || !defined(NDEBUG) */ #ifndef NDEBUG /* For tracing reduce actions, the names of all rules are required. */ static const char *const yyRuleName[] = { /* 0 */ "topLevel ::= boot_queries", /* 1 */ "topLevel ::=", /* 2 */ "boot_queries ::= boot_query", /* 3 */ "boot_queries ::= boot_queries boot_query", /* 4 */ "boot_query ::= boot_openStmt", /* 5 */ "boot_query ::= boot_closeStmt", /* 6 */ "boot_query ::= boot_createStmt", /* 7 */ "boot_query ::= boot_insertStmt", /* 8 */ "boot_query ::= boot_declareIndexStmt", /* 9 */ "boot_query ::= boot_declareUniqueIndexStmt", /* 10 */ "boot_query ::= boot_declareToastStmt", /* 11 */ "boot_query ::= boot_buildIndsStmt", /* 12 */ "boot_openStmt ::= OPEN boot_ident", /* 13 */ "boot_closeStmt ::= XCLOSE boot_ident", /* 14 */ "boot_createStmt ::= XCREATE boot_ident oidspec optbootstrap optsharedrelation optrowtypeoid LPAREN boot_column_list RPAREN", /* 15 */ "boot_insertStmt ::= INSERT_TUPLE LPAREN boot_column_val_list RPAREN", /* 16 */ "boot_declareIndexStmt ::= XDECLARE INDEX boot_ident oidspec ON boot_ident USING boot_ident LPAREN boot_index_params RPAREN", /* 17 */ "boot_declareUniqueIndexStmt ::= XDECLARE UNIQUE INDEX boot_ident oidspec ON boot_ident USING boot_ident LPAREN boot_index_params RPAREN", /* 18 */ "boot_declareToastStmt ::= XDECLARE XTOAST oidspec oidspec ON boot_ident", /* 19 */ "boot_buildIndsStmt ::= XBUILD INDICES", /* 20 */ "boot_index_params ::= boot_index_params COMMA boot_index_param", /* 21 */ "boot_index_params ::= boot_index_param", /* 22 */ "boot_index_param ::= boot_ident boot_ident", /* 23 */ "optbootstrap ::= XBOOTSTRAP", /* 24 */ "optbootstrap ::=", /* 25 */ "optsharedrelation ::= XSHARED_RELATION", /* 26 */ "optsharedrelation ::=", /* 27 */ "optrowtypeoid ::= XROWTYPE_OID oidspec", /* 28 */ "optrowtypeoid ::=", /* 29 */ "boot_column_list ::= boot_column_def", /* 30 */ "boot_column_list ::= boot_column_list COMMA boot_column_def", /* 31 */ "boot_column_def ::= boot_ident EQUALS boot_ident boot_column_nullness", /* 32 */ "boot_column_nullness ::= XFORCE XNOT XNULL", /* 33 */ "boot_column_nullness ::= XFORCE XNULL", /* 34 */ "boot_column_nullness ::=", /* 35 */ "oidspec ::= boot_ident", /* 36 */ "boot_column_val_list ::= boot_column_val", /* 37 */ "boot_column_val_list ::= boot_column_val_list boot_column_val", /* 38 */ "boot_column_val_list ::= boot_column_val_list COMMA boot_column_val", /* 39 */ "boot_column_val ::= boot_ident", /* 40 */ "boot_column_val ::= NULLVAL", /* 41 */ "boot_ident ::= ID", /* 42 */ "boot_ident ::= OPEN", /* 43 */ "boot_ident ::= XCLOSE", /* 44 */ "boot_ident ::= XCREATE", /* 45 */ "boot_ident ::= INSERT_TUPLE", /* 46 */ "boot_ident ::= XDECLARE", /* 47 */ "boot_ident ::= INDEX", /* 48 */ "boot_ident ::= ON", /* 49 */ "boot_ident ::= USING", /* 50 */ "boot_ident ::= XBUILD", /* 51 */ "boot_ident ::= INDICES", /* 52 */ "boot_ident ::= UNIQUE", /* 53 */ "boot_ident ::= XTOAST", /* 54 */ "boot_ident ::= OBJ_ID", /* 55 */ "boot_ident ::= XBOOTSTRAP", /* 56 */ "boot_ident ::= XSHARED_RELATION", /* 57 */ "boot_ident ::= XROWTYPE_OID", /* 58 */ "boot_ident ::= XFORCE", /* 59 */ "boot_ident ::= XNOT", /* 60 */ "boot_ident ::= XNULL", }; #endif /* NDEBUG */ #if YYGROWABLESTACK /* ** Try to increase the size of the parser stack. Return the number ** of errors. Return 0 on success. */ static int yyGrowStack(yyParser *p){ int oldSize = 1 + (int)(p->yystackEnd - p->yystack); int newSize; int idx; yyStackEntry *pNew; #ifdef YYSIZELIMIT int nLimit = YYSIZELIMIT(bootCTX(p)); #endif newSize = oldSize*2 + 100; #ifdef YYSIZELIMIT if( newSize>nLimit ){ newSize = nLimit; if( newSize<=oldSize ) return 1; } #endif idx = (int)(p->yytos - p->yystack); if( p->yystack==p->yystk0 ){ pNew = YYREALLOC(0, newSize*sizeof(pNew[0]), bootCTX(p)); if( pNew==0 ) return 1; memcpy(pNew, p->yystack, oldSize*sizeof(pNew[0])); }else{ pNew = YYREALLOC(p->yystack, newSize*sizeof(pNew[0]), bootCTX(p)); if( pNew==0 ) return 1; } p->yystack = pNew; p->yytos = &p->yystack[idx]; #ifndef NDEBUG if( yyTraceFILE ){ fprintf(yyTraceFILE,"%sStack grows from %d to %d entries.\n", yyTracePrompt, oldSize, newSize); } #endif p->yystackEnd = &p->yystack[newSize-1]; return 0; } #endif /* YYGROWABLESTACK */ #if !YYGROWABLESTACK /* For builds that do no have a growable stack, yyGrowStack always ** returns an error. */ # define yyGrowStack(X) 1 #endif /* Datatype of the argument to the memory allocated passed as the ** second argument to bootAlloc() 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 bootInit(void *yypRawParser bootCTX_PDECL){ yyParser *yypParser = (yyParser*)yypRawParser; bootCTX_STORE #ifdef YYTRACKMAXSTACKDEPTH yypParser->yyhwm = 0; #endif yypParser->yystack = yypParser->yystk0; yypParser->yystackEnd = &yypParser->yystack[YYSTACKDEPTH-1]; #ifndef YYNOERRORRECOVERY yypParser->yyerrcnt = -1; #endif yypParser->yytos = yypParser->yystack; yypParser->yystack[0].stateno = 0; yypParser->yystack[0].major = 0; } #ifndef boot_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 boot and bootFree. */ void *bootAlloc(void *(*mallocProc)(YYMALLOCARGTYPE) bootCTX_PDECL){ yyParser *yypParser; yypParser = (yyParser*)(*mallocProc)( (YYMALLOCARGTYPE)sizeof(yyParser) ); if( yypParser ){ bootCTX_STORE bootInit(yypParser bootCTX_PARAM); } return (void*)yypParser; } #endif /* boot_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 */ ){ bootARG_FETCH bootCTX_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 bootFinalize(void *p){ yyParser *pParser = (yyParser*)p; /* In-lined version of calling yy_pop_parser_stack() for each ** element left in the stack */ yyStackEntry *yytos = pParser->yytos; while( yytos>pParser->yystack ){ #ifndef NDEBUG if( yyTraceFILE ){ fprintf(yyTraceFILE,"%sPopping %s\n", yyTracePrompt, yyTokenName[yytos->major]); } #endif if( yytos->major>=YY_MIN_DSTRCTR ){ yy_destructor(pParser, yytos->major, &yytos->minor); } yytos--; } #if YYGROWABLESTACK if( pParser->yystack!=pParser->yystk0 ){ YYFREE(pParser->yystack, bootCTX(pParser)); } #endif } #ifndef boot_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 bootFree( void *p, /* The parser to be deleted */ void (*freeProc)(void*) /* Function used to reclaim memory */ ){ #ifndef YYPARSEFREENEVERNULL if( p==0 ) return; #endif bootFinalize(p); (*freeProc)(p); } #endif /* boot_ENGINEALWAYSONSTACK */ /* ** Return the peak depth of the stack for a parser. */ #ifdef YYTRACKMAXSTACKDEPTH int bootStackPeak(void *p){ yyParser *pParser = (yyParser*)p; return pParser->yyhwm; } #endif /* This array of booleans keeps track of the parser statement ** coverage. The element yycoverage[X][Y] is set when the parser ** is in state X and has a lookahead token Y. In a well-tested ** systems, every element of this matrix should end up being set. */ #if defined(YYCOVERAGE) static unsigned char yycoverage[YYNSTATE][YYNTOKEN]; #endif /* ** Write into out a description of every state/lookahead combination that ** ** (1) has not been used by the parser, and ** (2) is not a syntax error. ** ** Return the number of missed state/lookahead combinations. */ #if defined(YYCOVERAGE) int bootCoverage(FILE *out){ int stateno, iLookAhead, i; int nMissed = 0; for(stateno=0; statenoYY_MAX_SHIFT ) return stateno; #ifdef YYAOT /* Use the AOT-compiled switch-based lookup instead of table-driven */ return yy_find_shift_action_aot(stateno, (unsigned short)iLookAhead); #endif assert( stateno <= YY_SHIFT_COUNT ); #if defined(YYCOVERAGE) yycoverage[stateno][iLookAhead] = 1; #endif do{ i = yy_shift_ofst[stateno]; assert( i>=0 ); assert( i<=YY_ACTTAB_COUNT ); assert( i+YYNTOKEN<=(int)YY_NLOOKAHEAD ); assert( iLookAhead!=YYNOCODE ); assert( iLookAhead < YYNTOKEN ); i += iLookAhead; assert( i<(int)YY_NLOOKAHEAD ); if( yy_lookahead[i]!=iLookAhead ){ #ifdef YYFALLBACK YYCODETYPE iFallback; /* Fallback token */ assert( iLookAhead %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; assert( j<(int)(sizeof(yy_lookahead)/sizeof(yy_lookahead[0])) ); if( 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{ assert( i>=0 && i<(int)(sizeof(yy_action)/sizeof(yy_action[0])) ); return yy_action[i]; } }while(1); } /* ** Find the appropriate action for a parser given the non-terminal ** look-ahead token iLookAhead. */ static YYACTIONTYPE yy_find_reduce_action( YYACTIONTYPE 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( 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 && iyytos>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 ********************************************/ bootARG_STORE /* Suppress warning about unused %extra_argument var */ bootCTX_STORE } /* ** Print tracing information for a SHIFT action */ #ifndef NDEBUG static void yyTraceShift(yyParser *yypParser, int yyNewState, const char *zTag){ if( yyTraceFILE ){ if( yyNewStateyytos->major], yyNewState); }else{ fprintf(yyTraceFILE,"%s%s '%s', pending reduce %d\n", yyTracePrompt, zTag, yyTokenName[yypParser->yytos->major], yyNewState - YY_MIN_REDUCE); } } } #else # define yyTraceShift(X,Y,Z) #endif /* ** Perform a shift action. */ static void yy_shift( yyParser *yypParser, /* The parser to be shifted */ YYACTIONTYPE yyNewState, /* The new state to shift in */ YYCODETYPE yyMajor, /* The major token to shift in */ bootTOKENTYPE 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 yytos = yypParser->yytos; if( yytos>yypParser->yystackEnd ){ if( yyGrowStack(yypParser) ){ yypParser->yytos--; yyStackOverflow(yypParser); return; } yytos = yypParser->yytos; assert( yytos <= yypParser->yystackEnd ); } if( yyNewState > YY_MAX_SHIFT ){ yyNewState += YY_MIN_REDUCE - YY_MIN_SHIFTREDUCE; } yytos->stateno = yyNewState; yytos->major = yyMajor; yytos->minor.yy0 = yyMinor; yyTraceShift(yypParser, yyNewState, "Shift"); } /* For rule J, yyRuleInfoLhs[J] contains the symbol on the left-hand side ** of that rule */ static const YYCODETYPE yyRuleInfoLhs[] = { 26, /* (0) topLevel ::= boot_queries */ 26, /* (1) topLevel ::= */ 27, /* (2) boot_queries ::= boot_query */ 27, /* (3) boot_queries ::= boot_queries boot_query */ 28, /* (4) boot_query ::= boot_openStmt */ 28, /* (5) boot_query ::= boot_closeStmt */ 28, /* (6) boot_query ::= boot_createStmt */ 28, /* (7) boot_query ::= boot_insertStmt */ 28, /* (8) boot_query ::= boot_declareIndexStmt */ 28, /* (9) boot_query ::= boot_declareUniqueIndexStmt */ 28, /* (10) boot_query ::= boot_declareToastStmt */ 28, /* (11) boot_query ::= boot_buildIndsStmt */ 29, /* (12) boot_openStmt ::= OPEN boot_ident */ 30, /* (13) boot_closeStmt ::= XCLOSE boot_ident */ 31, /* (14) boot_createStmt ::= XCREATE boot_ident oidspec optbootstrap optsharedrelation optrowtypeoid LPAREN boot_column_list RPAREN */ 32, /* (15) boot_insertStmt ::= INSERT_TUPLE LPAREN boot_column_val_list RPAREN */ 33, /* (16) boot_declareIndexStmt ::= XDECLARE INDEX boot_ident oidspec ON boot_ident USING boot_ident LPAREN boot_index_params RPAREN */ 34, /* (17) boot_declareUniqueIndexStmt ::= XDECLARE UNIQUE INDEX boot_ident oidspec ON boot_ident USING boot_ident LPAREN boot_index_params RPAREN */ 35, /* (18) boot_declareToastStmt ::= XDECLARE XTOAST oidspec oidspec ON boot_ident */ 36, /* (19) boot_buildIndsStmt ::= XBUILD INDICES */ 37, /* (20) boot_index_params ::= boot_index_params COMMA boot_index_param */ 37, /* (21) boot_index_params ::= boot_index_param */ 38, /* (22) boot_index_param ::= boot_ident boot_ident */ 41, /* (23) optbootstrap ::= XBOOTSTRAP */ 41, /* (24) optbootstrap ::= */ 42, /* (25) optsharedrelation ::= XSHARED_RELATION */ 42, /* (26) optsharedrelation ::= */ 43, /* (27) optrowtypeoid ::= XROWTYPE_OID oidspec */ 43, /* (28) optrowtypeoid ::= */ 45, /* (29) boot_column_list ::= boot_column_def */ 45, /* (30) boot_column_list ::= boot_column_list COMMA boot_column_def */ 46, /* (31) boot_column_def ::= boot_ident EQUALS boot_ident boot_column_nullness */ 44, /* (32) boot_column_nullness ::= XFORCE XNOT XNULL */ 44, /* (33) boot_column_nullness ::= XFORCE XNULL */ 44, /* (34) boot_column_nullness ::= */ 40, /* (35) oidspec ::= boot_ident */ 47, /* (36) boot_column_val_list ::= boot_column_val */ 47, /* (37) boot_column_val_list ::= boot_column_val_list boot_column_val */ 47, /* (38) boot_column_val_list ::= boot_column_val_list COMMA boot_column_val */ 48, /* (39) boot_column_val ::= boot_ident */ 48, /* (40) boot_column_val ::= NULLVAL */ 39, /* (41) boot_ident ::= ID */ 39, /* (42) boot_ident ::= OPEN */ 39, /* (43) boot_ident ::= XCLOSE */ 39, /* (44) boot_ident ::= XCREATE */ 39, /* (45) boot_ident ::= INSERT_TUPLE */ 39, /* (46) boot_ident ::= XDECLARE */ 39, /* (47) boot_ident ::= INDEX */ 39, /* (48) boot_ident ::= ON */ 39, /* (49) boot_ident ::= USING */ 39, /* (50) boot_ident ::= XBUILD */ 39, /* (51) boot_ident ::= INDICES */ 39, /* (52) boot_ident ::= UNIQUE */ 39, /* (53) boot_ident ::= XTOAST */ 39, /* (54) boot_ident ::= OBJ_ID */ 39, /* (55) boot_ident ::= XBOOTSTRAP */ 39, /* (56) boot_ident ::= XSHARED_RELATION */ 39, /* (57) boot_ident ::= XROWTYPE_OID */ 39, /* (58) boot_ident ::= XFORCE */ 39, /* (59) boot_ident ::= XNOT */ 39, /* (60) boot_ident ::= XNULL */ }; /* For rule J, yyRuleInfoNRhs[J] contains the negative of the number ** of symbols on the right-hand side of that rule. */ static const signed char yyRuleInfoNRhs[] = { -1, /* (0) topLevel ::= boot_queries */ 0, /* (1) topLevel ::= */ -1, /* (2) boot_queries ::= boot_query */ -2, /* (3) boot_queries ::= boot_queries boot_query */ -1, /* (4) boot_query ::= boot_openStmt */ -1, /* (5) boot_query ::= boot_closeStmt */ -1, /* (6) boot_query ::= boot_createStmt */ -1, /* (7) boot_query ::= boot_insertStmt */ -1, /* (8) boot_query ::= boot_declareIndexStmt */ -1, /* (9) boot_query ::= boot_declareUniqueIndexStmt */ -1, /* (10) boot_query ::= boot_declareToastStmt */ -1, /* (11) boot_query ::= boot_buildIndsStmt */ -2, /* (12) boot_openStmt ::= OPEN boot_ident */ -2, /* (13) boot_closeStmt ::= XCLOSE boot_ident */ -9, /* (14) boot_createStmt ::= XCREATE boot_ident oidspec optbootstrap optsharedrelation optrowtypeoid LPAREN boot_column_list RPAREN */ -4, /* (15) boot_insertStmt ::= INSERT_TUPLE LPAREN boot_column_val_list RPAREN */ -11, /* (16) boot_declareIndexStmt ::= XDECLARE INDEX boot_ident oidspec ON boot_ident USING boot_ident LPAREN boot_index_params RPAREN */ -12, /* (17) boot_declareUniqueIndexStmt ::= XDECLARE UNIQUE INDEX boot_ident oidspec ON boot_ident USING boot_ident LPAREN boot_index_params RPAREN */ -6, /* (18) boot_declareToastStmt ::= XDECLARE XTOAST oidspec oidspec ON boot_ident */ -2, /* (19) boot_buildIndsStmt ::= XBUILD INDICES */ -3, /* (20) boot_index_params ::= boot_index_params COMMA boot_index_param */ -1, /* (21) boot_index_params ::= boot_index_param */ -2, /* (22) boot_index_param ::= boot_ident boot_ident */ -1, /* (23) optbootstrap ::= XBOOTSTRAP */ 0, /* (24) optbootstrap ::= */ -1, /* (25) optsharedrelation ::= XSHARED_RELATION */ 0, /* (26) optsharedrelation ::= */ -2, /* (27) optrowtypeoid ::= XROWTYPE_OID oidspec */ 0, /* (28) optrowtypeoid ::= */ -1, /* (29) boot_column_list ::= boot_column_def */ -3, /* (30) boot_column_list ::= boot_column_list COMMA boot_column_def */ -4, /* (31) boot_column_def ::= boot_ident EQUALS boot_ident boot_column_nullness */ -3, /* (32) boot_column_nullness ::= XFORCE XNOT XNULL */ -2, /* (33) boot_column_nullness ::= XFORCE XNULL */ 0, /* (34) boot_column_nullness ::= */ -1, /* (35) oidspec ::= boot_ident */ -1, /* (36) boot_column_val_list ::= boot_column_val */ -2, /* (37) boot_column_val_list ::= boot_column_val_list boot_column_val */ -3, /* (38) boot_column_val_list ::= boot_column_val_list COMMA boot_column_val */ -1, /* (39) boot_column_val ::= boot_ident */ -1, /* (40) boot_column_val ::= NULLVAL */ -1, /* (41) boot_ident ::= ID */ -1, /* (42) boot_ident ::= OPEN */ -1, /* (43) boot_ident ::= XCLOSE */ -1, /* (44) boot_ident ::= XCREATE */ -1, /* (45) boot_ident ::= INSERT_TUPLE */ -1, /* (46) boot_ident ::= XDECLARE */ -1, /* (47) boot_ident ::= INDEX */ -1, /* (48) boot_ident ::= ON */ -1, /* (49) boot_ident ::= USING */ -1, /* (50) boot_ident ::= XBUILD */ -1, /* (51) boot_ident ::= INDICES */ -1, /* (52) boot_ident ::= UNIQUE */ -1, /* (53) boot_ident ::= XTOAST */ -1, /* (54) boot_ident ::= OBJ_ID */ -1, /* (55) boot_ident ::= XBOOTSTRAP */ -1, /* (56) boot_ident ::= XSHARED_RELATION */ -1, /* (57) boot_ident ::= XROWTYPE_OID */ -1, /* (58) boot_ident ::= XFORCE */ -1, /* (59) boot_ident ::= XNOT */ -1, /* (60) boot_ident ::= XNULL */ }; static void yy_accept(yyParser*); /* Forward Declaration */ /* ** Perform a reduce action and the shift that must immediately ** follow the reduce. ** ** The yyLookahead and yyLookaheadToken parameters provide reduce actions ** access to the lookahead token (if any). The yyLookahead will be YYNOCODE ** if the lookahead token has already been consumed. As this procedure is ** only called from one place, optimizing compilers will in-line it, which ** means that the extra parameters have no performance impact. */ static YYACTIONTYPE yy_reduce( yyParser *yypParser, /* The parser */ unsigned int yyruleno, /* Number of the rule by which to reduce */ int yyLookahead, /* Lookahead token, or YYNOCODE if none */ bootTOKENTYPE yyLookaheadToken /* Value of the lookahead token */ bootCTX_PDECL /* %extra_context */ ){ int yygoto; /* The next state */ YYACTIONTYPE yyact; /* The next action */ yyStackEntry *yymsp; /* The top of the parser's stack */ int yysize; /* Amount to pop the stack */ bootARG_FETCH (void)yyLookahead; (void)yyLookaheadToken; yymsp = yypParser->yytos; switch( yyruleno ){ /* Beginning here are the reduction cases. A typical example ** follows: ** case 0: ** #line ** { ... } // User supplied code ** #line ** break; */ /********** Begin reduce actions **********************************************/ YYMINORTYPE yylhsminor; case 0: /* topLevel ::= boot_queries */ case 2: /* boot_queries ::= boot_query */ yytestcase(yyruleno==2); case 29: /* boot_column_list ::= boot_column_def */ yytestcase(yyruleno==29); case 36: /* boot_column_val_list ::= boot_column_val */ yytestcase(yyruleno==36); #line 141 "examples/bootstrap/boot_grammar.lime" { yylhsminor.yy32 = yymsp[0].minor.yy32; } #line 1170 "examples/bootstrap/boot_grammar.c" yymsp[0].minor.yy32 = yylhsminor.yy32; break; case 1: /* topLevel ::= */ #line 144 "examples/bootstrap/boot_grammar.lime" { yymsp[1].minor.yy32 = 0; } #line 1178 "examples/bootstrap/boot_grammar.c" break; case 3: /* boot_queries ::= boot_queries boot_query */ case 37: /* boot_column_val_list ::= boot_column_val_list boot_column_val */ yytestcase(yyruleno==37); #line 154 "examples/bootstrap/boot_grammar.lime" { yymsp[-1].minor.yy32 = yymsp[0].minor.yy32; } #line 1186 "examples/bootstrap/boot_grammar.c" break; case 4: /* boot_query ::= boot_openStmt */ case 5: /* boot_query ::= boot_closeStmt */ yytestcase(yyruleno==5); case 6: /* boot_query ::= boot_createStmt */ yytestcase(yyruleno==6); case 7: /* boot_query ::= boot_insertStmt */ yytestcase(yyruleno==7); case 8: /* boot_query ::= boot_declareIndexStmt */ yytestcase(yyruleno==8); case 9: /* boot_query ::= boot_declareUniqueIndexStmt */ yytestcase(yyruleno==9); case 10: /* boot_query ::= boot_declareToastStmt */ yytestcase(yyruleno==10); case 11: /* boot_query ::= boot_buildIndsStmt */ yytestcase(yyruleno==11); #line 161 "examples/bootstrap/boot_grammar.lime" { yylhsminor.yy32 = yymsp[0].minor.yy32; } #line 1198 "examples/bootstrap/boot_grammar.c" yymsp[0].minor.yy32 = yylhsminor.yy32; break; case 12: /* boot_openStmt ::= OPEN boot_ident */ #line 173 "examples/bootstrap/boot_grammar.lime" { boot_do_start(pstate); boot_openrel(pstate, yymsp[0].minor.yy29); boot_do_end(pstate); yymsp[-1].minor.yy32 = 0; } #line 1209 "examples/bootstrap/boot_grammar.c" break; case 13: /* boot_closeStmt ::= XCLOSE boot_ident */ #line 183 "examples/bootstrap/boot_grammar.lime" { boot_do_start(pstate); boot_closerel(pstate, yymsp[0].minor.yy29); boot_do_end(pstate); yymsp[-1].minor.yy32 = 0; } #line 1219 "examples/bootstrap/boot_grammar.c" break; case 14: /* boot_createStmt ::= XCREATE boot_ident oidspec optbootstrap optsharedrelation optrowtypeoid LPAREN boot_column_list RPAREN */ #line 200 "examples/bootstrap/boot_grammar.lime" { boot_do_create(pstate, yymsp[-7].minor.yy29, yymsp[-6].minor.yy21, yymsp[-5].minor.yy32, yymsp[-4].minor.yy32, yymsp[-3].minor.yy21); yymsp[-8].minor.yy32 = 0; } #line 1227 "examples/bootstrap/boot_grammar.c" break; case 15: /* boot_insertStmt ::= INSERT_TUPLE LPAREN boot_column_val_list RPAREN */ #line 208 "examples/bootstrap/boot_grammar.lime" { boot_do_insert(pstate); yymsp[-3].minor.yy32 = 0; } #line 1235 "examples/bootstrap/boot_grammar.c" break; case 16: /* boot_declareIndexStmt ::= XDECLARE INDEX boot_ident oidspec ON boot_ident USING boot_ident LPAREN boot_index_params RPAREN */ #line 217 "examples/bootstrap/boot_grammar.lime" { boot_do_declare_index(pstate, yymsp[-8].minor.yy29, yymsp[-7].minor.yy21, yymsp[-5].minor.yy29, yymsp[-3].minor.yy29, yymsp[-1].minor.yy68, 0 /* not unique */); yymsp[-10].minor.yy32 = 0; } #line 1243 "examples/bootstrap/boot_grammar.c" break; case 17: /* boot_declareUniqueIndexStmt ::= XDECLARE UNIQUE INDEX boot_ident oidspec ON boot_ident USING boot_ident LPAREN boot_index_params RPAREN */ #line 226 "examples/bootstrap/boot_grammar.lime" { boot_do_declare_index(pstate, yymsp[-8].minor.yy29, yymsp[-7].minor.yy21, yymsp[-5].minor.yy29, yymsp[-3].minor.yy29, yymsp[-1].minor.yy68, 1 /* unique */); yymsp[-11].minor.yy32 = 0; } #line 1251 "examples/bootstrap/boot_grammar.c" break; case 18: /* boot_declareToastStmt ::= XDECLARE XTOAST oidspec oidspec ON boot_ident */ #line 234 "examples/bootstrap/boot_grammar.lime" { boot_do_declare_toast(pstate, yymsp[0].minor.yy29, yymsp[-3].minor.yy21, yymsp[-2].minor.yy21); yymsp[-5].minor.yy32 = 0; } #line 1259 "examples/bootstrap/boot_grammar.c" break; case 19: /* boot_buildIndsStmt ::= XBUILD INDICES */ #line 242 "examples/bootstrap/boot_grammar.lime" { boot_do_build_indices(pstate); yymsp[-1].minor.yy32 = 0; } #line 1267 "examples/bootstrap/boot_grammar.c" break; case 20: /* boot_index_params ::= boot_index_params COMMA boot_index_param */ #line 250 "examples/bootstrap/boot_grammar.lime" { yylhsminor.yy68 = boot_index_param_list_append(pstate, yymsp[-2].minor.yy68, yymsp[0].minor.yy82); } #line 1274 "examples/bootstrap/boot_grammar.c" yymsp[-2].minor.yy68 = yylhsminor.yy68; break; case 21: /* boot_index_params ::= boot_index_param */ #line 253 "examples/bootstrap/boot_grammar.lime" { yylhsminor.yy68 = boot_index_param_list_create(pstate, yymsp[0].minor.yy82); } #line 1282 "examples/bootstrap/boot_grammar.c" yymsp[0].minor.yy68 = yylhsminor.yy68; break; case 22: /* boot_index_param ::= boot_ident boot_ident */ #line 257 "examples/bootstrap/boot_grammar.lime" { yylhsminor.yy82 = boot_make_index_param(pstate, yymsp[-1].minor.yy29, yymsp[0].minor.yy29); } #line 1290 "examples/bootstrap/boot_grammar.c" yymsp[-1].minor.yy82 = yylhsminor.yy82; break; case 23: /* optbootstrap ::= XBOOTSTRAP */ case 25: /* optsharedrelation ::= XSHARED_RELATION */ yytestcase(yyruleno==25); #line 264 "examples/bootstrap/boot_grammar.lime" { yymsp[0].minor.yy32 = 1; } #line 1297 "examples/bootstrap/boot_grammar.c" break; case 24: /* optbootstrap ::= */ case 26: /* optsharedrelation ::= */ yytestcase(yyruleno==26); #line 265 "examples/bootstrap/boot_grammar.lime" { yymsp[1].minor.yy32 = 0; } #line 1303 "examples/bootstrap/boot_grammar.c" break; case 27: /* optrowtypeoid ::= XROWTYPE_OID oidspec */ #line 270 "examples/bootstrap/boot_grammar.lime" { yymsp[-1].minor.yy21 = yymsp[0].minor.yy21; } #line 1308 "examples/bootstrap/boot_grammar.c" break; case 28: /* optrowtypeoid ::= */ #line 271 "examples/bootstrap/boot_grammar.lime" { yymsp[1].minor.yy21 = 0; /* InvalidOid */ } #line 1313 "examples/bootstrap/boot_grammar.c" break; case 30: /* boot_column_list ::= boot_column_list COMMA boot_column_def */ case 38: /* boot_column_val_list ::= boot_column_val_list COMMA boot_column_val */ yytestcase(yyruleno==38); #line 279 "examples/bootstrap/boot_grammar.lime" { yymsp[-2].minor.yy32 = yymsp[0].minor.yy32; } #line 1321 "examples/bootstrap/boot_grammar.c" break; case 31: /* boot_column_def ::= boot_ident EQUALS boot_ident boot_column_nullness */ #line 283 "examples/bootstrap/boot_grammar.lime" { boot_do_define_attr(pstate, yymsp[-3].minor.yy29, yymsp[-1].minor.yy29, yymsp[0].minor.yy32); yylhsminor.yy32 = 0; } #line 1329 "examples/bootstrap/boot_grammar.c" yymsp[-3].minor.yy32 = yylhsminor.yy32; break; case 32: /* boot_column_nullness ::= XFORCE XNOT XNULL */ #line 291 "examples/bootstrap/boot_grammar.lime" { yymsp[-2].minor.yy32 = BOOTCOL_NULL_FORCE_NOT_NULL; } #line 1335 "examples/bootstrap/boot_grammar.c" break; case 33: /* boot_column_nullness ::= XFORCE XNULL */ #line 292 "examples/bootstrap/boot_grammar.lime" { yymsp[-1].minor.yy32 = BOOTCOL_NULL_FORCE_NULL; } #line 1340 "examples/bootstrap/boot_grammar.c" break; case 34: /* boot_column_nullness ::= */ #line 293 "examples/bootstrap/boot_grammar.lime" { yymsp[1].minor.yy32 = BOOTCOL_NULL_AUTO; } #line 1345 "examples/bootstrap/boot_grammar.c" break; case 35: /* oidspec ::= boot_ident */ #line 298 "examples/bootstrap/boot_grammar.lime" { yylhsminor.yy21 = boot_atooid(yymsp[0].minor.yy29); } #line 1352 "examples/bootstrap/boot_grammar.c" yymsp[0].minor.yy21 = yylhsminor.yy21; break; case 39: /* boot_column_val ::= boot_ident */ #line 315 "examples/bootstrap/boot_grammar.lime" { boot_do_insert_one_value(pstate, yymsp[0].minor.yy29); yylhsminor.yy32 = 0; } #line 1361 "examples/bootstrap/boot_grammar.c" yymsp[0].minor.yy32 = yylhsminor.yy32; break; case 40: /* boot_column_val ::= NULLVAL */ #line 319 "examples/bootstrap/boot_grammar.lime" { boot_do_insert_one_null(pstate); yymsp[0].minor.yy32 = 0; } #line 1370 "examples/bootstrap/boot_grammar.c" break; case 41: /* boot_ident ::= ID */ #line 329 "examples/bootstrap/boot_grammar.lime" { yylhsminor.yy29 = yymsp[0].minor.yy0.str; } #line 1375 "examples/bootstrap/boot_grammar.c" yymsp[0].minor.yy29 = yylhsminor.yy29; break; case 42: /* boot_ident ::= OPEN */ case 43: /* boot_ident ::= XCLOSE */ yytestcase(yyruleno==43); case 44: /* boot_ident ::= XCREATE */ yytestcase(yyruleno==44); case 45: /* boot_ident ::= INSERT_TUPLE */ yytestcase(yyruleno==45); case 46: /* boot_ident ::= XDECLARE */ yytestcase(yyruleno==46); case 47: /* boot_ident ::= INDEX */ yytestcase(yyruleno==47); case 48: /* boot_ident ::= ON */ yytestcase(yyruleno==48); case 49: /* boot_ident ::= USING */ yytestcase(yyruleno==49); case 50: /* boot_ident ::= XBUILD */ yytestcase(yyruleno==50); case 51: /* boot_ident ::= INDICES */ yytestcase(yyruleno==51); case 52: /* boot_ident ::= UNIQUE */ yytestcase(yyruleno==52); case 53: /* boot_ident ::= XTOAST */ yytestcase(yyruleno==53); case 54: /* boot_ident ::= OBJ_ID */ yytestcase(yyruleno==54); case 55: /* boot_ident ::= XBOOTSTRAP */ yytestcase(yyruleno==55); case 56: /* boot_ident ::= XSHARED_RELATION */ yytestcase(yyruleno==56); case 57: /* boot_ident ::= XROWTYPE_OID */ yytestcase(yyruleno==57); case 58: /* boot_ident ::= XFORCE */ yytestcase(yyruleno==58); case 59: /* boot_ident ::= XNOT */ yytestcase(yyruleno==59); case 60: /* boot_ident ::= XNULL */ yytestcase(yyruleno==60); #line 330 "examples/bootstrap/boot_grammar.lime" { yylhsminor.yy29 = boot_pstrdup(pstate, yymsp[0].minor.yy0.kw); } #line 1399 "examples/bootstrap/boot_grammar.c" yymsp[0].minor.yy29 = yylhsminor.yy29; break; default: break; /********** End reduce actions ************************************************/ }; assert( yyrulenoYY_MAX_SHIFT && yyact<=YY_MAX_SHIFTREDUCE) ); /* It is not possible for a REDUCE to be followed by an error */ assert( yyact!=YY_ERROR_ACTION ); yymsp += yysize+1; yypParser->yytos = yymsp; yymsp->stateno = (YYACTIONTYPE)yyact; yymsp->major = (YYCODETYPE)yygoto; yyTraceShift(yypParser, yyact, "... then shift"); return yyact; } /* ** The following code executes when the parse fails */ #ifndef YYNOERRORRECOVERY static void yy_parse_failed( yyParser *yypParser /* The parser */ ){ bootARG_FETCH bootCTX_FETCH #ifndef NDEBUG if( yyTraceFILE ){ fprintf(yyTraceFILE,"%sFail!\n",yyTracePrompt); } #endif while( yypParser->yytos>yypParser->yystack ) yy_pop_parser_stack(yypParser); /* Here code is inserted which will be executed whenever the ** parser fails */ /************ Begin %parse_failure code ***************************************/ #line 55 "examples/bootstrap/boot_grammar.lime" boot_yyerror(pstate, "parse failure"); #line 1447 "examples/bootstrap/boot_grammar.c" /************ End %parse_failure code *****************************************/ bootARG_STORE /* Suppress warning about unused %extra_argument variable */ bootCTX_STORE } #endif /* YYNOERRORRECOVERY */ /* ** The following code executes when a syntax error first occurs. */ static void yy_syntax_error( yyParser *yypParser, /* The parser */ int yymajor, /* The major type of the error token */ bootTOKENTYPE yyminor /* The minor type of the error token */ #ifdef YYLOCATIONTYPE ,YYLOCATIONTYPE yyloc /* Source location of the error token */ #endif ){ bootARG_FETCH bootCTX_FETCH #define TOKEN yyminor #ifdef YYLOCATIONTYPE #define TOKEN_LOC yyloc #endif /************ Begin %syntax_error code ****************************************/ #line 51 "examples/bootstrap/boot_grammar.lime" boot_yyerror(pstate, "syntax error"); #line 1475 "examples/bootstrap/boot_grammar.c" /************ End %syntax_error code ******************************************/ bootARG_STORE /* Suppress warning about unused %extra_argument variable */ bootCTX_STORE } /* ** The following is executed when the parser accepts */ static void yy_accept( yyParser *yypParser /* The parser */ ){ bootARG_FETCH bootCTX_FETCH #ifndef NDEBUG if( yyTraceFILE ){ fprintf(yyTraceFILE,"%sAccept!\n",yyTracePrompt); } #endif #ifndef YYNOERRORRECOVERY yypParser->yyerrcnt = -1; #endif assert( yypParser->yytos==yypParser->yystack ); /* Here code is inserted which will be executed whenever the ** parser accepts */ /*********** Begin %parse_accept code *****************************************/ /*********** End %parse_accept code *******************************************/ bootARG_STORE /* Suppress warning about unused %extra_argument variable */ bootCTX_STORE } /* The main parser program. ** The first argument is a pointer to a structure obtained from ** "bootAlloc" which describes the current state of the parser. ** The second argument is the major token number. The third is ** the minor token. The fourth optional argument is whatever the ** user wants (and specified in the grammar) and is available for ** use by the action routines. ** ** Inputs: **
    **
  • A pointer to the parser (an opaque structure.) **
  • The major token number. **
  • The minor token number. **
  • An option argument of a grammar-specified type. **
** ** Outputs: ** None. */ /* Helper macro for calling yy_syntax_error with optional location argument */ #ifdef YYLOCATIONTYPE # define YY_SYNTAX_ERROR(P,M,m) \ yy_syntax_error(P,M,m, (P)->yytos > (P)->yystack ? (P)->yytos->yyloc \ : (YYLOCATIONTYPE){0,0,0,0,0}) #else # define YY_SYNTAX_ERROR(P,M,m) yy_syntax_error(P,M,m) #endif void boot( void *yyp, /* The parser */ int yymajor, /* The major token code number */ bootTOKENTYPE yyminor /* The value for the token */ bootARG_PDECL /* Optional %extra_argument parameter */ ){ YYMINORTYPE yyminorunion; YYACTIONTYPE yyact; /* The parser action. */ #if !defined(YYERRORSYMBOL) && !defined(YYNOERRORRECOVERY) int yyendofinput; /* True if we are at the end of input */ #endif #ifdef YYERRORSYMBOL int yyerrorhit = 0; /* True if yymajor has invoked an error */ #endif yyParser *yypParser = (yyParser*)yyp; /* The parser */ bootCTX_FETCH bootARG_STORE assert( yypParser->yytos!=0 ); #if !defined(YYERRORSYMBOL) && !defined(YYNOERRORRECOVERY) yyendofinput = (yymajor==0); #endif yyact = yypParser->yytos->stateno; #ifndef NDEBUG if( yyTraceFILE ){ if( yyact < YY_MIN_REDUCE ){ fprintf(yyTraceFILE,"%sInput '%s' in state %d\n", yyTracePrompt,yyTokenName[yymajor],yyact); }else{ fprintf(yyTraceFILE,"%sInput '%s' with pending reduce %d\n", yyTracePrompt,yyTokenName[yymajor],yyact-YY_MIN_REDUCE); } } #endif while(1){ /* Exit by "break" */ assert( yypParser->yytos>=yypParser->yystack ); assert( yyact==yypParser->yytos->stateno ); yyact = yy_find_shift_action((YYCODETYPE)yymajor,yyact); if( yyact >= YY_MIN_REDUCE ){ unsigned int yyruleno = yyact - YY_MIN_REDUCE; /* Reduce by this rule */ #ifndef NDEBUG assert( yyruleno<(int)(sizeof(yyRuleName)/sizeof(yyRuleName[0])) ); if( yyTraceFILE ){ int yysize = yyRuleInfoNRhs[yyruleno]; if( yysize ){ fprintf(yyTraceFILE, "%sReduce %d [%s]%s, pop back to state %d.\n", yyTracePrompt, yyruleno, yyRuleName[yyruleno], yyrulenoyytos[yysize].stateno); }else{ fprintf(yyTraceFILE, "%sReduce %d [%s]%s.\n", yyTracePrompt, yyruleno, yyRuleName[yyruleno], yyrulenoyytos - yypParser->yystack)>yypParser->yyhwm ){ yypParser->yyhwm++; assert( yypParser->yyhwm == (int)(yypParser->yytos - yypParser->yystack)); } #endif if( yypParser->yytos>=yypParser->yystackEnd ){ if( yyGrowStack(yypParser) ){ yyStackOverflow(yypParser); break; } } } yyact = yy_reduce(yypParser,yyruleno,yymajor,yyminor bootCTX_PARAM); }else if( yyact <= YY_MAX_SHIFTREDUCE ){ yy_shift(yypParser,yyact,(YYCODETYPE)yymajor,yyminor); #ifndef YYNOERRORRECOVERY yypParser->yyerrcnt--; #endif break; }else if( yyact==YY_ACCEPT_ACTION ){ yypParser->yytos--; yy_accept(yypParser); return; }else{ assert( yyact == YY_ERROR_ACTION ); yyminorunion.yy0 = yyminor; #ifdef YYERRORSYMBOL int yymx; #endif #ifndef NDEBUG if( yyTraceFILE ){ fprintf(yyTraceFILE,"%sSyntax Error!\n",yyTracePrompt); } #endif #ifdef YYERRORSYMBOL /* A syntax error has occurred. ** The response to an error depends upon whether or not the ** grammar defines an error token "ERROR". ** ** This is what we do if the grammar does define ERROR: ** ** * Call the %syntax_error function. ** ** * Begin popping the stack until we enter a state where ** it is legal to shift the error symbol, then shift ** the error symbol. ** ** * Set the error count to three. ** ** * Begin accepting and shifting new tokens. No new error ** processing will occur until three tokens have been ** shifted successfully. ** */ if( yypParser->yyerrcnt<0 ){ YY_SYNTAX_ERROR(yypParser,yymajor,yyminor); } yymx = yypParser->yytos->major; if( yymx==YYERRORSYMBOL || yyerrorhit ){ #ifndef NDEBUG if( yyTraceFILE ){ fprintf(yyTraceFILE,"%sDiscard input token %s\n", yyTracePrompt,yyTokenName[yymajor]); } #endif yy_destructor(yypParser, (YYCODETYPE)yymajor, &yyminorunion); yymajor = YYNOCODE; }else{ while( yypParser->yytos > yypParser->yystack ){ yyact = yy_find_reduce_action(yypParser->yytos->stateno, YYERRORSYMBOL); if( yyact<=YY_MAX_SHIFTREDUCE ) break; yy_pop_parser_stack(yypParser); } if( yypParser->yytos <= yypParser->yystack || yymajor==0 ){ yy_destructor(yypParser,(YYCODETYPE)yymajor,&yyminorunion); yy_parse_failed(yypParser); #ifndef YYNOERRORRECOVERY yypParser->yyerrcnt = -1; #endif yymajor = YYNOCODE; }else if( yymx!=YYERRORSYMBOL ){ yy_shift(yypParser,yyact,YYERRORSYMBOL,yyminor); } } yypParser->yyerrcnt = 3; yyerrorhit = 1; if( yymajor==YYNOCODE ) break; yyact = yypParser->yytos->stateno; #elif defined(YYNOERRORRECOVERY) /* If the YYNOERRORRECOVERY macro is defined, then do not attempt to ** do any kind of error recovery. Instead, simply invoke the syntax ** error routine and continue going as if nothing had happened. ** ** Applications can set this macro (for example inside %include) if ** they intend to abandon the parse upon the first syntax error seen. */ YY_SYNTAX_ERROR(yypParser,yymajor,yyminor); yy_destructor(yypParser,(YYCODETYPE)yymajor,&yyminorunion); break; #else /* YYERRORSYMBOL is not defined */ /* This is what we do if the grammar does not define ERROR: ** ** * Report an error message, and throw away the input token. ** ** * If the input token is $, then fail the parse. ** ** As before, subsequent error messages are suppressed until ** three input tokens have been successfully shifted. ** ** If YYERRORSYNC is defined, use panic-mode recovery: ** discard tokens until a synchronization token is found, ** then resume parsing from the current state. */ if( yypParser->yyerrcnt<=0 ){ YY_SYNTAX_ERROR(yypParser,yymajor,yyminor); } yypParser->yyerrcnt = 3; #ifdef YYERRORSYNC /* Panic-mode recovery: discard tokens until we find a sync token */ if( yymajor!=0 && (YYCODETYPE)yymajor<(YYCODETYPE)(sizeof(yy_is_sync_token)/sizeof(yy_is_sync_token[0])) && yy_is_sync_token[(YYCODETYPE)yymajor] ){ /* Current token IS a sync token -- resume parsing here */ break; } /* Not a sync token -- discard and continue */ yy_destructor(yypParser,(YYCODETYPE)yymajor,&yyminorunion); yymajor = YYNOCODE; break; #else /* !YYERRORSYNC */ yy_destructor(yypParser,(YYCODETYPE)yymajor,&yyminorunion); if( yyendofinput ){ yy_parse_failed(yypParser); #ifndef YYNOERRORRECOVERY yypParser->yyerrcnt = -1; #endif } break; #endif /* YYERRORSYNC */ #endif /* YYERRORSYMBOL */ } } #ifndef NDEBUG if( yyTraceFILE ){ yyStackEntry *i; char cDiv = '['; fprintf(yyTraceFILE,"%sReturn. Stack=",yyTracePrompt); for(i=&yypParser->yystack[1]; i<=yypParser->yytos; i++){ fprintf(yyTraceFILE,"%c%s", cDiv, yyTokenName[i->major]); cDiv = ' '; } fprintf(yyTraceFILE,"]\n"); } #endif return; } #ifdef YYLOCATIONTYPE /* ** Location-aware version of boot(). ** Same as boot() but also stores the source location for the shifted token. ** Use this entry point when the %locations directive is active. ** ** The location is stored on the parse stack alongside the token value. ** During reductions, a YYLOC(N) macro can access the location of the ** Nth RHS symbol, and the result location is computed by merging the ** locations of the first and last RHS symbols. */ void bootLoc( void *yyp, /* The parser */ int yymajor, /* The major token code number */ bootTOKENTYPE yyminor, /* The value for the token */ YYLOCATIONTYPE yyloc /* Source location of the token */ bootARG_PDECL /* Optional %extra_argument parameter */ ){ yyParser *yypParser = (yyParser*)yyp; /* Store the location for the next shift */ boot(yyp, yymajor, yyminor bootARG_PARAM); /* After boot shifts the token, patch the location on top of stack */ if( yypParser->yytos > yypParser->yystack ){ yypParser->yytos->yyloc = yyloc; } } #endif /* YYLOCATIONTYPE */ /* ** Return the fallback token corresponding to canonical token iToken, or ** 0 if iToken has no fallback. */ int bootFallback(int iToken){ #ifdef YYFALLBACK assert( iToken<(int)(sizeof(yyFallback)/sizeof(yyFallback[0])) ); return yyFallback[iToken]; #else (void)iToken; return 0; #endif } /* ** Return a heap-allocated string listing the tokens that would be ** valid in the current parser state. The caller must free() the ** returned string. Returns NULL if the parser is NULL or on ** allocation failure. ** ** The output is a comma-separated list like: "SELECT, INSERT, UPDATE". ** This is useful for producing human-readable error messages. */ char *bootExpectedTokens(void *yyp){ yyParser *yypParser = (yyParser*)yyp; if( yypParser==0 || yypParser->yytos==0 ) return 0; YYACTIONTYPE stateno = yypParser->yytos->stateno; char *buf = 0; size_t buf_len = 0; size_t buf_cap = 0; int first = 1; int i; for(i=0; i= 0 int j = i + yy_shift_ofst[stateno]; if( j>=0 && j buf_cap ){ size_t new_cap = (buf_cap == 0) ? 128 : buf_cap * 2; if( new_cap < needed ) new_cap = needed; char *tmp = (char*)realloc(buf, new_cap); if( tmp==0 ){ free(buf); return 0; } buf = tmp; buf_cap = new_cap; } if( !first ){ buf[buf_len++] = ','; buf[buf_len++] = ' '; } memcpy(buf + buf_len, name, nlen); buf_len += nlen; buf[buf_len] = 0; first = 0; } } return buf; }