/* This file is automatically generated by Lemon from input grammar ** source file "mongodb.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 58 "mongodb.lime" #include #include #include #include #include #include "mongodb_internal.h" #include "mongodb_helpers.h" #line 39 "mongodb.c" /**************** End of %include directives **********************************/ /* These constants specify the various numeric values for terminal symbols. ***************** Begin token definitions *************************************/ #ifndef LBRACE #define LBRACE 1 #define RBRACE 2 #define LBRACKET 3 #define RBRACKET 4 #define COLON 5 #define COMMA 6 #define LPAREN 7 #define RPAREN 8 #define DOT 9 #define STRING 10 #define INT_LIT 11 #define FLOAT_LIT 12 #define KW_TRUE 13 #define KW_FALSE 14 #define KW_NULL 15 #define IDENT 16 #define DOLLAR_IDENT 17 #define KW_DB 18 #define KW_FIND 19 #define KW_UPDATE 20 #define KW_AGGREGATE 21 #define KW_OBJECTID 22 #define OP_EQ 23 #define OP_NE 24 #define OP_GT 25 #define OP_GTE 26 #define OP_LT 27 #define OP_LTE 28 #define OP_IN 29 #define OP_NIN 30 #define OP_AND 31 #define OP_OR 32 #define OP_NOT 33 #define OP_NOR 34 #define OP_EXISTS 35 #define OP_TYPE 36 #define OP_REGEX 37 #define OP_OPTIONS 38 #define OP_MOD 39 #define OP_ALL 40 #define OP_ELEMMATCH 41 #define OP_SIZE 42 #define UP_SET 43 #define UP_UNSET 44 #define UP_INC 45 #define UP_MUL 46 #define UP_RENAME 47 #define UP_MIN 48 #define UP_MAX 49 #define UP_CURRENTDATE 50 #define UP_SETONINSERT 51 #define UP_PUSH 52 #define UP_PULL 53 #define UP_ADDTOSET 54 #define UP_POP 55 #define AGG_MATCH 56 #define AGG_GROUP 57 #define AGG_PROJECT 58 #define AGG_SORT 59 #define AGG_LIMIT 60 #define AGG_SKIP 61 #define AGG_UNWIND 62 #define AGG_LOOKUP 63 #define AGG_OUT 64 #define AGG_COUNT 65 #define AGG_SUM 66 #define AGG_AVG 67 #define AGG_FIRST 68 #define AGG_LAST 69 #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. ** mongodbParseTOKENTYPE 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 mongodbParseTOKENTYPE. 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() ** mongodbParseARG_SDECL A static variable declaration for the %extra_argument ** mongodbParseARG_PDECL A parameter declaration for the %extra_argument ** mongodbParseARG_PARAM Code to pass %extra_argument as a subroutine parameter ** mongodbParseARG_STORE Code to store %extra_argument into yypParser ** mongodbParseARG_FETCH Code to extract %extra_argument from yypParser ** mongodbParseCTX_* As mongodbParseARG_ 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 96 #define YYACTIONTYPE unsigned short int #define mongodbParseTOKENTYPE MdbToken typedef union { int yyinit; mongodbParseTOKENTYPE yy0; MdbNodeList * yy132; MdbNodeType yy140; MdbNode * yy148; MdbString yy191; } YYMINORTYPE; #ifndef YYSTACKDEPTH #define YYSTACKDEPTH 100 #endif #define mongodbParseARG_SDECL MdbParseState *pstate; #define mongodbParseARG_PDECL ,MdbParseState *pstate #define mongodbParseARG_PARAM ,pstate #define mongodbParseARG_FETCH MdbParseState *pstate=yypParser->pstate; #define mongodbParseARG_STORE yypParser->pstate=pstate; #undef YYREALLOC #define YYREALLOC realloc #undef YYFREE #define YYFREE free #undef YYDYNSTACK #define YYDYNSTACK 0 #undef YYSIZELIMIT #define mongodbParseCTX(P) 0 #define mongodbParseCTX_SDECL #define mongodbParseCTX_PDECL #define mongodbParseCTX_PARAM #define mongodbParseCTX_FETCH #define mongodbParseCTX_STORE #undef YYERRORSYMBOL #undef YYERRSYMDT #undef YYFALLBACK #define YYNSTATE 59 #define YYNRULE 98 #define YYNRULE_WITH_ACTION 98 #define YYNTOKEN 70 #define YY_MAX_SHIFT 58 #define YY_MIN_SHIFTREDUCE 152 #define YY_MAX_SHIFTREDUCE 249 #define YY_ERROR_ACTION 250 #define YY_ACCEPT_ACTION 251 #define YY_NO_ACTION 252 #define YY_MIN_REDUCE 253 #define YY_MAX_REDUCE 350 #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 (261) static const YYACTIONTYPE yy_action[] = { /* 0 */ 291, 54, 162, 28, 298, 292, 46, 47, 291, 3, /* 10 */ 175, 163, 346, 292, 1, 2, 176, 177, 178, 179, /* 20 */ 180, 181, 30, 200, 201, 202, 203, 204, 205, 206, /* 30 */ 207, 210, 211, 43, 212, 42, 41, 37, 183, 36, /* 40 */ 40, 39, 38, 221, 222, 223, 224, 225, 226, 227, /* 50 */ 228, 229, 230, 231, 232, 233, 235, 236, 237, 238, /* 60 */ 239, 240, 241, 242, 243, 244, 246, 247, 248, 249, /* 70 */ 175, 53, 32, 29, 31, 321, 176, 177, 178, 179, /* 80 */ 180, 181, 317, 200, 201, 202, 203, 204, 205, 206, /* 90 */ 207, 210, 211, 43, 212, 42, 41, 37, 183, 36, /* 100 */ 40, 39, 38, 221, 222, 223, 224, 225, 226, 227, /* 110 */ 228, 229, 230, 231, 232, 233, 235, 236, 237, 238, /* 120 */ 239, 240, 241, 242, 243, 244, 246, 247, 248, 249, /* 130 */ 27, 265, 51, 320, 310, 316, 261, 268, 45, 269, /* 140 */ 44, 270, 271, 272, 273, 35, 274, 34, 275, 33, /* 150 */ 266, 51, 1, 283, 3, 309, 268, 45, 269, 44, /* 160 */ 270, 271, 272, 273, 35, 274, 34, 275, 33, 55, /* 170 */ 23, 24, 283, 157, 1, 291, 3, 194, 52, 335, /* 180 */ 292, 14, 15, 184, 185, 186, 187, 188, 189, 1, /* 190 */ 192, 3, 291, 156, 16, 50, 319, 292, 184, 185, /* 200 */ 186, 187, 188, 189, 4, 192, 159, 5, 251, 58, /* 210 */ 50, 291, 158, 291, 57, 318, 292, 315, 292, 291, /* 220 */ 17, 291, 18, 314, 292, 300, 292, 6, 291, 7, /* 230 */ 56, 291, 299, 292, 19, 267, 292, 20, 8, 9, /* 240 */ 21, 22, 10, 195, 11, 252, 252, 252, 193, 49, /* 250 */ 12, 48, 155, 255, 254, 253, 25, 252, 252, 26, /* 260 */ 13, }; static const YYCODETYPE yy_lookahead[] = { /* 0 */ 71, 93, 2, 76, 75, 76, 77, 78, 71, 3, /* 10 */ 10, 2, 75, 76, 1, 6, 16, 17, 18, 19, /* 20 */ 20, 21, 71, 23, 24, 25, 26, 27, 28, 29, /* 30 */ 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, /* 40 */ 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, /* 50 */ 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, /* 60 */ 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, /* 70 */ 10, 19, 20, 21, 71, 71, 16, 17, 18, 19, /* 80 */ 20, 21, 71, 23, 24, 25, 26, 27, 28, 29, /* 90 */ 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, /* 100 */ 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, /* 110 */ 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, /* 120 */ 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, /* 130 */ 72, 73, 74, 76, 71, 76, 71, 79, 80, 81, /* 140 */ 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, /* 150 */ 73, 74, 1, 95, 3, 76, 79, 80, 81, 82, /* 160 */ 83, 84, 85, 86, 87, 88, 89, 90, 91, 18, /* 170 */ 6, 71, 95, 8, 1, 71, 3, 4, 94, 75, /* 180 */ 76, 7, 6, 10, 11, 12, 13, 14, 15, 1, /* 190 */ 17, 3, 71, 8, 7, 22, 75, 76, 10, 11, /* 200 */ 12, 13, 14, 15, 5, 17, 10, 5, 70, 71, /* 210 */ 22, 71, 16, 71, 76, 75, 76, 75, 76, 71, /* 220 */ 5, 71, 5, 75, 76, 75, 76, 5, 71, 5, /* 230 */ 92, 71, 75, 76, 5, 75, 76, 5, 5, 5, /* 240 */ 5, 5, 5, 4, 6, 96, 96, 96, 8, 7, /* 250 */ 5, 10, 8, 0, 0, 0, 7, 96, 96, 9, /* 260 */ 9, 96, 96, 96, 96, 96, 96, 96, 96, 96, /* 270 */ 96, 96, 96, 96, 96, 96, 96, 96, 96, 96, /* 280 */ 96, 96, 96, 96, 96, 96, 96, 96, 96, 96, /* 290 */ 96, 96, 96, 96, 96, 96, 96, 96, 96, 96, /* 300 */ 96, 96, 96, 96, 96, 96, 96, 96, 96, 96, /* 310 */ 96, 96, 96, 96, 96, 96, 96, 96, 96, 96, /* 320 */ 96, 96, 96, 96, 96, 96, 96, 96, 96, 96, /* 330 */ 96, }; #define YY_SHIFT_COUNT (58) #define YY_SHIFT_MIN (0) #define YY_SHIFT_MAX (255) static const unsigned short int yy_shift_ofst[] = { /* 0 */ 151, 0, 60, 173, 188, 188, 188, 188, 188, 188, /* 10 */ 188, 188, 188, 196, 6, 13, 13, 13, 6, 13, /* 20 */ 6, 13, 6, 13, 164, 13, 52, 9, 165, 174, /* 30 */ 185, 176, 187, 199, 202, 215, 217, 222, 224, 229, /* 40 */ 232, 233, 234, 235, 236, 237, 238, 239, 240, 241, /* 50 */ 242, 245, 244, 249, 250, 251, 253, 254, 255, }; #define YY_REDUCE_COUNT (25) #define YY_REDUCE_MIN (-92) #define YY_REDUCE_MAX (160) static const short yy_reduce_ofst[] = { /* 0 */ 138, 58, 77, -71, -63, 104, 121, 140, 142, 148, /* 10 */ 150, 157, 160, -92, -73, -49, 3, 4, 57, 11, /* 20 */ 59, 63, 79, 65, 84, 100, }; static const YYACTIONTYPE yy_default[] = { /* 0 */ 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, /* 10 */ 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, /* 20 */ 250, 250, 250, 250, 262, 250, 250, 250, 250, 250, /* 30 */ 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, /* 40 */ 250, 250, 250, 250, 250, 250, 297, 250, 250, 250, /* 50 */ 250, 250, 250, 250, 250, 250, 250, 250, 250, }; /********** End of lemon-generated parsing tables *****************************/ /* The next table maps tokens (terminal symbols) into fallback tokens. ** If a construct like the following: ** ** %fallback ID X Y Z. ** ** appears in the grammar, then ID becomes a fallback token for X, Y, ** and Z. Whenever one of the tokens X, Y, or Z is input to the parser ** but it does not parse, the type of the token is changed to ID and ** the parse is retried before an error is thrown. ** ** This feature can be used, for example, to cause some keywords in a language ** to revert to identifiers if they keyword does not apply in the context where ** it appears. */ #ifdef YYFALLBACK static const YYCODETYPE yyFallback[] = { }; #endif /* YYFALLBACK */ /* The following structure represents a single element of the ** parser's stack. Information stored includes: ** ** + The state number for the parser at this level of the stack. ** ** + The value of the token stored at this level of the stack. ** (In other words, the "major" token.) ** ** + The semantic value stored at this level of the stack. This is ** the information used by the action routines in the grammar. ** It is sometimes called the "minor" token. ** ** After the "shift" half of a SHIFTREDUCE action, the stateno field ** actually contains the reduce action for the second half of the ** SHIFTREDUCE. */ struct yyStackEntry { YYACTIONTYPE stateno; /* The state-number, or reduce action in SHIFTREDUCE */ YYCODETYPE major; /* The major token value. This is the code ** number for the token at this stack level */ YYMINORTYPE minor; /* The user-supplied minor token value. This ** is the value of the token */ }; typedef struct yyStackEntry yyStackEntry; /* The state of the parser is completely contained in an instance of ** the following structure */ struct yyParser { yyStackEntry *yytos; /* Pointer to top element of the stack */ #ifdef YYTRACKMAXSTACKDEPTH int yyhwm; /* High-water mark of the stack */ #endif #ifndef YYNOERRORRECOVERY int yyerrcnt; /* Shifts left before out of the error */ #endif mongodbParseARG_SDECL /* A place to hold %extra_argument */ mongodbParseCTX_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 #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 mongodbParseTrace(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 */ "LBRACE", /* 2 */ "RBRACE", /* 3 */ "LBRACKET", /* 4 */ "RBRACKET", /* 5 */ "COLON", /* 6 */ "COMMA", /* 7 */ "LPAREN", /* 8 */ "RPAREN", /* 9 */ "DOT", /* 10 */ "STRING", /* 11 */ "INT_LIT", /* 12 */ "FLOAT_LIT", /* 13 */ "KW_TRUE", /* 14 */ "KW_FALSE", /* 15 */ "KW_NULL", /* 16 */ "IDENT", /* 17 */ "DOLLAR_IDENT", /* 18 */ "KW_DB", /* 19 */ "KW_FIND", /* 20 */ "KW_UPDATE", /* 21 */ "KW_AGGREGATE", /* 22 */ "KW_OBJECTID", /* 23 */ "OP_EQ", /* 24 */ "OP_NE", /* 25 */ "OP_GT", /* 26 */ "OP_GTE", /* 27 */ "OP_LT", /* 28 */ "OP_LTE", /* 29 */ "OP_IN", /* 30 */ "OP_NIN", /* 31 */ "OP_AND", /* 32 */ "OP_OR", /* 33 */ "OP_NOT", /* 34 */ "OP_NOR", /* 35 */ "OP_EXISTS", /* 36 */ "OP_TYPE", /* 37 */ "OP_REGEX", /* 38 */ "OP_OPTIONS", /* 39 */ "OP_MOD", /* 40 */ "OP_ALL", /* 41 */ "OP_ELEMMATCH", /* 42 */ "OP_SIZE", /* 43 */ "UP_SET", /* 44 */ "UP_UNSET", /* 45 */ "UP_INC", /* 46 */ "UP_MUL", /* 47 */ "UP_RENAME", /* 48 */ "UP_MIN", /* 49 */ "UP_MAX", /* 50 */ "UP_CURRENTDATE", /* 51 */ "UP_SETONINSERT", /* 52 */ "UP_PUSH", /* 53 */ "UP_PULL", /* 54 */ "UP_ADDTOSET", /* 55 */ "UP_POP", /* 56 */ "AGG_MATCH", /* 57 */ "AGG_GROUP", /* 58 */ "AGG_PROJECT", /* 59 */ "AGG_SORT", /* 60 */ "AGG_LIMIT", /* 61 */ "AGG_SKIP", /* 62 */ "AGG_UNWIND", /* 63 */ "AGG_LOOKUP", /* 64 */ "AGG_OUT", /* 65 */ "AGG_COUNT", /* 66 */ "AGG_SUM", /* 67 */ "AGG_AVG", /* 68 */ "AGG_FIRST", /* 69 */ "AGG_LAST", /* 70 */ "input", /* 71 */ "document", /* 72 */ "pair_list", /* 73 */ "pair", /* 74 */ "key", /* 75 */ "value", /* 76 */ "array", /* 77 */ "value_list", /* 78 */ "opt_value_list", /* 79 */ "query_op_pair", /* 80 */ "comparison_op", /* 81 */ "logical_op_pair", /* 82 */ "logical_op", /* 83 */ "element_op_pair", /* 84 */ "array_op_pair", /* 85 */ "eval_op_pair", /* 86 */ "update_op_pair", /* 87 */ "update_op", /* 88 */ "agg_stage_pair", /* 89 */ "agg_stage_op", /* 90 */ "agg_expr_pair", /* 91 */ "agg_accum_op", /* 92 */ "shell_statement", /* 93 */ "collection_name", /* 94 */ "opt_projection", /* 95 */ "operator_key", }; #endif /* defined(YYCOVERAGE) || !defined(NDEBUG) */ #ifndef NDEBUG /* For tracing reduce actions, the names of all rules are required. */ static const char *const yyRuleName[] = { /* 0 */ "input ::= document", /* 1 */ "input ::= array", /* 2 */ "input ::= shell_statement", /* 3 */ "shell_statement ::= KW_DB DOT collection_name DOT KW_FIND LPAREN document opt_projection RPAREN", /* 4 */ "shell_statement ::= KW_DB DOT collection_name DOT KW_UPDATE LPAREN document COMMA document RPAREN", /* 5 */ "shell_statement ::= KW_DB DOT collection_name DOT KW_AGGREGATE LPAREN array RPAREN", /* 6 */ "collection_name ::= IDENT", /* 7 */ "collection_name ::= STRING", /* 8 */ "opt_projection ::= COMMA document", /* 9 */ "opt_projection ::=", /* 10 */ "document ::= LBRACE RBRACE", /* 11 */ "document ::= LBRACE pair_list RBRACE", /* 12 */ "pair_list ::= pair", /* 13 */ "pair_list ::= pair_list COMMA pair", /* 14 */ "pair ::= key COLON value", /* 15 */ "pair ::= query_op_pair", /* 16 */ "pair ::= logical_op_pair", /* 17 */ "pair ::= element_op_pair", /* 18 */ "pair ::= array_op_pair", /* 19 */ "pair ::= eval_op_pair", /* 20 */ "pair ::= update_op_pair", /* 21 */ "pair ::= agg_stage_pair", /* 22 */ "pair ::= agg_expr_pair", /* 23 */ "key ::= STRING", /* 24 */ "key ::= IDENT", /* 25 */ "key ::= DOLLAR_IDENT", /* 26 */ "key ::= KW_DB", /* 27 */ "key ::= KW_FIND", /* 28 */ "key ::= KW_UPDATE", /* 29 */ "key ::= KW_AGGREGATE", /* 30 */ "key ::= operator_key", /* 31 */ "operator_key ::= OP_OPTIONS", /* 32 */ "value ::= STRING", /* 33 */ "value ::= INT_LIT", /* 34 */ "value ::= FLOAT_LIT", /* 35 */ "value ::= KW_TRUE", /* 36 */ "value ::= KW_FALSE", /* 37 */ "value ::= KW_NULL", /* 38 */ "value ::= document", /* 39 */ "value ::= array", /* 40 */ "value ::= DOLLAR_IDENT", /* 41 */ "value ::= KW_OBJECTID LPAREN STRING RPAREN", /* 42 */ "array ::= LBRACKET RBRACKET", /* 43 */ "array ::= LBRACKET opt_value_list RBRACKET", /* 44 */ "opt_value_list ::= value_list", /* 45 */ "value_list ::= value", /* 46 */ "value_list ::= value_list COMMA value", /* 47 */ "query_op_pair ::= comparison_op COLON value", /* 48 */ "comparison_op ::= OP_EQ", /* 49 */ "comparison_op ::= OP_NE", /* 50 */ "comparison_op ::= OP_GT", /* 51 */ "comparison_op ::= OP_GTE", /* 52 */ "comparison_op ::= OP_LT", /* 53 */ "comparison_op ::= OP_LTE", /* 54 */ "comparison_op ::= OP_IN", /* 55 */ "comparison_op ::= OP_NIN", /* 56 */ "logical_op_pair ::= logical_op COLON array", /* 57 */ "logical_op_pair ::= OP_NOT COLON document", /* 58 */ "logical_op ::= OP_AND", /* 59 */ "logical_op ::= OP_OR", /* 60 */ "logical_op ::= OP_NOR", /* 61 */ "element_op_pair ::= OP_EXISTS COLON value", /* 62 */ "element_op_pair ::= OP_TYPE COLON value", /* 63 */ "array_op_pair ::= OP_ALL COLON array", /* 64 */ "array_op_pair ::= OP_ELEMMATCH COLON document", /* 65 */ "array_op_pair ::= OP_SIZE COLON value", /* 66 */ "eval_op_pair ::= OP_REGEX COLON value", /* 67 */ "eval_op_pair ::= OP_MOD COLON array", /* 68 */ "update_op_pair ::= update_op COLON document", /* 69 */ "update_op ::= UP_SET", /* 70 */ "update_op ::= UP_UNSET", /* 71 */ "update_op ::= UP_INC", /* 72 */ "update_op ::= UP_MUL", /* 73 */ "update_op ::= UP_RENAME", /* 74 */ "update_op ::= UP_MIN", /* 75 */ "update_op ::= UP_MAX", /* 76 */ "update_op ::= UP_CURRENTDATE", /* 77 */ "update_op ::= UP_SETONINSERT", /* 78 */ "update_op ::= UP_PUSH", /* 79 */ "update_op ::= UP_PULL", /* 80 */ "update_op ::= UP_ADDTOSET", /* 81 */ "update_op ::= UP_POP", /* 82 */ "agg_stage_pair ::= agg_stage_op COLON value", /* 83 */ "agg_stage_op ::= AGG_MATCH", /* 84 */ "agg_stage_op ::= AGG_GROUP", /* 85 */ "agg_stage_op ::= AGG_PROJECT", /* 86 */ "agg_stage_op ::= AGG_SORT", /* 87 */ "agg_stage_op ::= AGG_LIMIT", /* 88 */ "agg_stage_op ::= AGG_SKIP", /* 89 */ "agg_stage_op ::= AGG_UNWIND", /* 90 */ "agg_stage_op ::= AGG_LOOKUP", /* 91 */ "agg_stage_op ::= AGG_OUT", /* 92 */ "agg_stage_op ::= AGG_COUNT", /* 93 */ "agg_expr_pair ::= agg_accum_op COLON value", /* 94 */ "agg_accum_op ::= AGG_SUM", /* 95 */ "agg_accum_op ::= AGG_AVG", /* 96 */ "agg_accum_op ::= AGG_FIRST", /* 97 */ "agg_accum_op ::= AGG_LAST", }; #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(mongodbParseCTX(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]), mongodbParseCTX(p)); if( pNew==0 ) return 1; memcpy(pNew, p->yystack, oldSize*sizeof(pNew[0])); }else{ pNew = YYREALLOC(p->yystack, newSize*sizeof(pNew[0]), mongodbParseCTX(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 mongodbParseAlloc() 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 mongodbParseInit(void *yypRawParser mongodbParseCTX_PDECL){ yyParser *yypParser = (yyParser*)yypRawParser; mongodbParseCTX_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 mongodbParse_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 mongodbParse and mongodbParseFree. */ void *mongodbParseAlloc(void *(*mallocProc)(YYMALLOCARGTYPE) mongodbParseCTX_PDECL){ yyParser *yypParser; yypParser = (yyParser*)(*mallocProc)( (YYMALLOCARGTYPE)sizeof(yyParser) ); if( yypParser ){ mongodbParseCTX_STORE mongodbParseInit(yypParser mongodbParseCTX_PARAM); } return (void*)yypParser; } #endif /* mongodbParse_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 */ ){ mongodbParseARG_FETCH mongodbParseCTX_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 mongodbParseFinalize(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, mongodbParseCTX(pParser)); } #endif } #ifndef mongodbParse_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 mongodbParseFree( void *p, /* The parser to be deleted */ void (*freeProc)(void*) /* Function used to reclaim memory */ ){ #ifndef YYPARSEFREENEVERNULL if( p==0 ) return; #endif mongodbParseFinalize(p); (*freeProc)(p); } #endif /* mongodbParse_ENGINEALWAYSONSTACK */ /* ** Return the peak depth of the stack for a parser. */ #ifdef YYTRACKMAXSTACKDEPTH int mongodbParseStackPeak(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 mongodbParseCoverage(FILE *out){ int stateno, iLookAhead, i; int nMissed = 0; for(stateno=0; statenoYY_MAX_SHIFT ) return stateno; 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 ********************************************/ mongodbParseARG_STORE /* Suppress warning about unused %extra_argument var */ mongodbParseCTX_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 */ mongodbParseTOKENTYPE 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[] = { 70, /* (0) input ::= document */ 70, /* (1) input ::= array */ 70, /* (2) input ::= shell_statement */ 92, /* (3) shell_statement ::= KW_DB DOT collection_name DOT KW_FIND LPAREN document opt_projection RPAREN */ 92, /* (4) shell_statement ::= KW_DB DOT collection_name DOT KW_UPDATE LPAREN document COMMA document RPAREN */ 92, /* (5) shell_statement ::= KW_DB DOT collection_name DOT KW_AGGREGATE LPAREN array RPAREN */ 93, /* (6) collection_name ::= IDENT */ 93, /* (7) collection_name ::= STRING */ 94, /* (8) opt_projection ::= COMMA document */ 94, /* (9) opt_projection ::= */ 71, /* (10) document ::= LBRACE RBRACE */ 71, /* (11) document ::= LBRACE pair_list RBRACE */ 72, /* (12) pair_list ::= pair */ 72, /* (13) pair_list ::= pair_list COMMA pair */ 73, /* (14) pair ::= key COLON value */ 73, /* (15) pair ::= query_op_pair */ 73, /* (16) pair ::= logical_op_pair */ 73, /* (17) pair ::= element_op_pair */ 73, /* (18) pair ::= array_op_pair */ 73, /* (19) pair ::= eval_op_pair */ 73, /* (20) pair ::= update_op_pair */ 73, /* (21) pair ::= agg_stage_pair */ 73, /* (22) pair ::= agg_expr_pair */ 74, /* (23) key ::= STRING */ 74, /* (24) key ::= IDENT */ 74, /* (25) key ::= DOLLAR_IDENT */ 74, /* (26) key ::= KW_DB */ 74, /* (27) key ::= KW_FIND */ 74, /* (28) key ::= KW_UPDATE */ 74, /* (29) key ::= KW_AGGREGATE */ 74, /* (30) key ::= operator_key */ 95, /* (31) operator_key ::= OP_OPTIONS */ 75, /* (32) value ::= STRING */ 75, /* (33) value ::= INT_LIT */ 75, /* (34) value ::= FLOAT_LIT */ 75, /* (35) value ::= KW_TRUE */ 75, /* (36) value ::= KW_FALSE */ 75, /* (37) value ::= KW_NULL */ 75, /* (38) value ::= document */ 75, /* (39) value ::= array */ 75, /* (40) value ::= DOLLAR_IDENT */ 75, /* (41) value ::= KW_OBJECTID LPAREN STRING RPAREN */ 76, /* (42) array ::= LBRACKET RBRACKET */ 76, /* (43) array ::= LBRACKET opt_value_list RBRACKET */ 78, /* (44) opt_value_list ::= value_list */ 77, /* (45) value_list ::= value */ 77, /* (46) value_list ::= value_list COMMA value */ 79, /* (47) query_op_pair ::= comparison_op COLON value */ 80, /* (48) comparison_op ::= OP_EQ */ 80, /* (49) comparison_op ::= OP_NE */ 80, /* (50) comparison_op ::= OP_GT */ 80, /* (51) comparison_op ::= OP_GTE */ 80, /* (52) comparison_op ::= OP_LT */ 80, /* (53) comparison_op ::= OP_LTE */ 80, /* (54) comparison_op ::= OP_IN */ 80, /* (55) comparison_op ::= OP_NIN */ 81, /* (56) logical_op_pair ::= logical_op COLON array */ 81, /* (57) logical_op_pair ::= OP_NOT COLON document */ 82, /* (58) logical_op ::= OP_AND */ 82, /* (59) logical_op ::= OP_OR */ 82, /* (60) logical_op ::= OP_NOR */ 83, /* (61) element_op_pair ::= OP_EXISTS COLON value */ 83, /* (62) element_op_pair ::= OP_TYPE COLON value */ 84, /* (63) array_op_pair ::= OP_ALL COLON array */ 84, /* (64) array_op_pair ::= OP_ELEMMATCH COLON document */ 84, /* (65) array_op_pair ::= OP_SIZE COLON value */ 85, /* (66) eval_op_pair ::= OP_REGEX COLON value */ 85, /* (67) eval_op_pair ::= OP_MOD COLON array */ 86, /* (68) update_op_pair ::= update_op COLON document */ 87, /* (69) update_op ::= UP_SET */ 87, /* (70) update_op ::= UP_UNSET */ 87, /* (71) update_op ::= UP_INC */ 87, /* (72) update_op ::= UP_MUL */ 87, /* (73) update_op ::= UP_RENAME */ 87, /* (74) update_op ::= UP_MIN */ 87, /* (75) update_op ::= UP_MAX */ 87, /* (76) update_op ::= UP_CURRENTDATE */ 87, /* (77) update_op ::= UP_SETONINSERT */ 87, /* (78) update_op ::= UP_PUSH */ 87, /* (79) update_op ::= UP_PULL */ 87, /* (80) update_op ::= UP_ADDTOSET */ 87, /* (81) update_op ::= UP_POP */ 88, /* (82) agg_stage_pair ::= agg_stage_op COLON value */ 89, /* (83) agg_stage_op ::= AGG_MATCH */ 89, /* (84) agg_stage_op ::= AGG_GROUP */ 89, /* (85) agg_stage_op ::= AGG_PROJECT */ 89, /* (86) agg_stage_op ::= AGG_SORT */ 89, /* (87) agg_stage_op ::= AGG_LIMIT */ 89, /* (88) agg_stage_op ::= AGG_SKIP */ 89, /* (89) agg_stage_op ::= AGG_UNWIND */ 89, /* (90) agg_stage_op ::= AGG_LOOKUP */ 89, /* (91) agg_stage_op ::= AGG_OUT */ 89, /* (92) agg_stage_op ::= AGG_COUNT */ 90, /* (93) agg_expr_pair ::= agg_accum_op COLON value */ 91, /* (94) agg_accum_op ::= AGG_SUM */ 91, /* (95) agg_accum_op ::= AGG_AVG */ 91, /* (96) agg_accum_op ::= AGG_FIRST */ 91, /* (97) agg_accum_op ::= AGG_LAST */ }; /* 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) input ::= document */ -1, /* (1) input ::= array */ -1, /* (2) input ::= shell_statement */ -9, /* (3) shell_statement ::= KW_DB DOT collection_name DOT KW_FIND LPAREN document opt_projection RPAREN */ -10, /* (4) shell_statement ::= KW_DB DOT collection_name DOT KW_UPDATE LPAREN document COMMA document RPAREN */ -8, /* (5) shell_statement ::= KW_DB DOT collection_name DOT KW_AGGREGATE LPAREN array RPAREN */ -1, /* (6) collection_name ::= IDENT */ -1, /* (7) collection_name ::= STRING */ -2, /* (8) opt_projection ::= COMMA document */ 0, /* (9) opt_projection ::= */ -2, /* (10) document ::= LBRACE RBRACE */ -3, /* (11) document ::= LBRACE pair_list RBRACE */ -1, /* (12) pair_list ::= pair */ -3, /* (13) pair_list ::= pair_list COMMA pair */ -3, /* (14) pair ::= key COLON value */ -1, /* (15) pair ::= query_op_pair */ -1, /* (16) pair ::= logical_op_pair */ -1, /* (17) pair ::= element_op_pair */ -1, /* (18) pair ::= array_op_pair */ -1, /* (19) pair ::= eval_op_pair */ -1, /* (20) pair ::= update_op_pair */ -1, /* (21) pair ::= agg_stage_pair */ -1, /* (22) pair ::= agg_expr_pair */ -1, /* (23) key ::= STRING */ -1, /* (24) key ::= IDENT */ -1, /* (25) key ::= DOLLAR_IDENT */ -1, /* (26) key ::= KW_DB */ -1, /* (27) key ::= KW_FIND */ -1, /* (28) key ::= KW_UPDATE */ -1, /* (29) key ::= KW_AGGREGATE */ -1, /* (30) key ::= operator_key */ -1, /* (31) operator_key ::= OP_OPTIONS */ -1, /* (32) value ::= STRING */ -1, /* (33) value ::= INT_LIT */ -1, /* (34) value ::= FLOAT_LIT */ -1, /* (35) value ::= KW_TRUE */ -1, /* (36) value ::= KW_FALSE */ -1, /* (37) value ::= KW_NULL */ -1, /* (38) value ::= document */ -1, /* (39) value ::= array */ -1, /* (40) value ::= DOLLAR_IDENT */ -4, /* (41) value ::= KW_OBJECTID LPAREN STRING RPAREN */ -2, /* (42) array ::= LBRACKET RBRACKET */ -3, /* (43) array ::= LBRACKET opt_value_list RBRACKET */ -1, /* (44) opt_value_list ::= value_list */ -1, /* (45) value_list ::= value */ -3, /* (46) value_list ::= value_list COMMA value */ -3, /* (47) query_op_pair ::= comparison_op COLON value */ -1, /* (48) comparison_op ::= OP_EQ */ -1, /* (49) comparison_op ::= OP_NE */ -1, /* (50) comparison_op ::= OP_GT */ -1, /* (51) comparison_op ::= OP_GTE */ -1, /* (52) comparison_op ::= OP_LT */ -1, /* (53) comparison_op ::= OP_LTE */ -1, /* (54) comparison_op ::= OP_IN */ -1, /* (55) comparison_op ::= OP_NIN */ -3, /* (56) logical_op_pair ::= logical_op COLON array */ -3, /* (57) logical_op_pair ::= OP_NOT COLON document */ -1, /* (58) logical_op ::= OP_AND */ -1, /* (59) logical_op ::= OP_OR */ -1, /* (60) logical_op ::= OP_NOR */ -3, /* (61) element_op_pair ::= OP_EXISTS COLON value */ -3, /* (62) element_op_pair ::= OP_TYPE COLON value */ -3, /* (63) array_op_pair ::= OP_ALL COLON array */ -3, /* (64) array_op_pair ::= OP_ELEMMATCH COLON document */ -3, /* (65) array_op_pair ::= OP_SIZE COLON value */ -3, /* (66) eval_op_pair ::= OP_REGEX COLON value */ -3, /* (67) eval_op_pair ::= OP_MOD COLON array */ -3, /* (68) update_op_pair ::= update_op COLON document */ -1, /* (69) update_op ::= UP_SET */ -1, /* (70) update_op ::= UP_UNSET */ -1, /* (71) update_op ::= UP_INC */ -1, /* (72) update_op ::= UP_MUL */ -1, /* (73) update_op ::= UP_RENAME */ -1, /* (74) update_op ::= UP_MIN */ -1, /* (75) update_op ::= UP_MAX */ -1, /* (76) update_op ::= UP_CURRENTDATE */ -1, /* (77) update_op ::= UP_SETONINSERT */ -1, /* (78) update_op ::= UP_PUSH */ -1, /* (79) update_op ::= UP_PULL */ -1, /* (80) update_op ::= UP_ADDTOSET */ -1, /* (81) update_op ::= UP_POP */ -3, /* (82) agg_stage_pair ::= agg_stage_op COLON value */ -1, /* (83) agg_stage_op ::= AGG_MATCH */ -1, /* (84) agg_stage_op ::= AGG_GROUP */ -1, /* (85) agg_stage_op ::= AGG_PROJECT */ -1, /* (86) agg_stage_op ::= AGG_SORT */ -1, /* (87) agg_stage_op ::= AGG_LIMIT */ -1, /* (88) agg_stage_op ::= AGG_SKIP */ -1, /* (89) agg_stage_op ::= AGG_UNWIND */ -1, /* (90) agg_stage_op ::= AGG_LOOKUP */ -1, /* (91) agg_stage_op ::= AGG_OUT */ -1, /* (92) agg_stage_op ::= AGG_COUNT */ -3, /* (93) agg_expr_pair ::= agg_accum_op COLON value */ -1, /* (94) agg_accum_op ::= AGG_SUM */ -1, /* (95) agg_accum_op ::= AGG_AVG */ -1, /* (96) agg_accum_op ::= AGG_FIRST */ -1, /* (97) agg_accum_op ::= AGG_LAST */ }; 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 */ mongodbParseTOKENTYPE yyLookaheadToken /* Value of the lookahead token */ mongodbParseCTX_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 */ mongodbParseARG_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: /* input ::= document */ case 1: /* input ::= array */ yytestcase(yyruleno==1); case 2: /* input ::= shell_statement */ yytestcase(yyruleno==2); #line 243 "mongodb.lime" { yylhsminor.yy148 = yymsp[0].minor.yy148; pstate->result = yylhsminor.yy148; } #line 1384 "mongodb.c" yymsp[0].minor.yy148 = yylhsminor.yy148; break; case 3: /* shell_statement ::= KW_DB DOT collection_name DOT KW_FIND LPAREN document opt_projection RPAREN */ #line 264 "mongodb.lime" { yymsp[-8].minor.yy148 = mdb_make_find(yymsp[-2].minor.yy148, yymsp[-1].minor.yy148); } #line 1392 "mongodb.c" break; case 4: /* shell_statement ::= KW_DB DOT collection_name DOT KW_UPDATE LPAREN document COMMA document RPAREN */ #line 268 "mongodb.lime" { yymsp[-9].minor.yy148 = mdb_make_update(yymsp[-3].minor.yy148, yymsp[-1].minor.yy148); } #line 1399 "mongodb.c" break; case 5: /* shell_statement ::= KW_DB DOT collection_name DOT KW_AGGREGATE LPAREN array RPAREN */ #line 272 "mongodb.lime" { yymsp[-7].minor.yy148 = mdb_make_aggregate(yymsp[-1].minor.yy148); } #line 1406 "mongodb.c" break; case 6: /* collection_name ::= IDENT */ case 7: /* collection_name ::= STRING */ yytestcase(yyruleno==7); case 23: /* key ::= STRING */ yytestcase(yyruleno==23); case 24: /* key ::= IDENT */ yytestcase(yyruleno==24); case 25: /* key ::= DOLLAR_IDENT */ yytestcase(yyruleno==25); case 26: /* key ::= KW_DB */ yytestcase(yyruleno==26); case 27: /* key ::= KW_FIND */ yytestcase(yyruleno==27); case 28: /* key ::= KW_UPDATE */ yytestcase(yyruleno==28); case 29: /* key ::= KW_AGGREGATE */ yytestcase(yyruleno==29); case 31: /* operator_key ::= OP_OPTIONS */ yytestcase(yyruleno==31); #line 276 "mongodb.lime" { yylhsminor.yy191 = yymsp[0].minor.yy0.str; } #line 1420 "mongodb.c" yymsp[0].minor.yy191 = yylhsminor.yy191; break; case 8: /* opt_projection ::= COMMA document */ #line 279 "mongodb.lime" { yymsp[-1].minor.yy148 = yymsp[0].minor.yy148; } #line 1426 "mongodb.c" break; case 9: /* opt_projection ::= */ #line 280 "mongodb.lime" { yymsp[1].minor.yy148 = NULL; } #line 1431 "mongodb.c" break; case 10: /* document ::= LBRACE RBRACE */ #line 286 "mongodb.lime" { yymsp[-1].minor.yy148 = mdb_make_document(NULL); } #line 1438 "mongodb.c" break; case 11: /* document ::= LBRACE pair_list RBRACE */ #line 290 "mongodb.lime" { yymsp[-2].minor.yy148 = mdb_make_document(yymsp[-1].minor.yy132); } #line 1445 "mongodb.c" break; case 12: /* pair_list ::= pair */ case 45: /* value_list ::= value */ yytestcase(yyruleno==45); #line 294 "mongodb.lime" { yylhsminor.yy132 = mdb_list_make1(yymsp[0].minor.yy148); } #line 1453 "mongodb.c" yymsp[0].minor.yy132 = yylhsminor.yy132; break; case 13: /* pair_list ::= pair_list COMMA pair */ case 46: /* value_list ::= value_list COMMA value */ yytestcase(yyruleno==46); #line 298 "mongodb.lime" { yylhsminor.yy132 = mdb_list_append(yymsp[-2].minor.yy132, yymsp[0].minor.yy148); } #line 1462 "mongodb.c" yymsp[-2].minor.yy132 = yylhsminor.yy132; break; case 14: /* pair ::= key COLON value */ #line 306 "mongodb.lime" { yylhsminor.yy148 = mdb_make_pair(&yymsp[-2].minor.yy191, yymsp[0].minor.yy148); } #line 1470 "mongodb.c" yymsp[-2].minor.yy148 = yylhsminor.yy148; break; case 15: /* pair ::= query_op_pair */ case 16: /* pair ::= logical_op_pair */ yytestcase(yyruleno==16); case 17: /* pair ::= element_op_pair */ yytestcase(yyruleno==17); case 18: /* pair ::= array_op_pair */ yytestcase(yyruleno==18); case 19: /* pair ::= eval_op_pair */ yytestcase(yyruleno==19); case 20: /* pair ::= update_op_pair */ yytestcase(yyruleno==20); case 21: /* pair ::= agg_stage_pair */ yytestcase(yyruleno==21); case 22: /* pair ::= agg_expr_pair */ yytestcase(yyruleno==22); case 38: /* value ::= document */ yytestcase(yyruleno==38); case 39: /* value ::= array */ yytestcase(yyruleno==39); #line 310 "mongodb.lime" { yylhsminor.yy148 = yymsp[0].minor.yy148; } #line 1485 "mongodb.c" yymsp[0].minor.yy148 = yylhsminor.yy148; break; case 30: /* key ::= operator_key */ #line 335 "mongodb.lime" { yylhsminor.yy191 = yymsp[0].minor.yy191; } #line 1491 "mongodb.c" yymsp[0].minor.yy191 = yylhsminor.yy191; break; case 32: /* value ::= STRING */ #line 342 "mongodb.lime" { yylhsminor.yy148 = mdb_make_string(&yymsp[0].minor.yy0.str); } #line 1497 "mongodb.c" yymsp[0].minor.yy148 = yylhsminor.yy148; break; case 33: /* value ::= INT_LIT */ #line 343 "mongodb.lime" { yylhsminor.yy148 = mdb_make_int(yymsp[0].minor.yy0.ival); } #line 1503 "mongodb.c" yymsp[0].minor.yy148 = yylhsminor.yy148; break; case 34: /* value ::= FLOAT_LIT */ #line 344 "mongodb.lime" { yylhsminor.yy148 = mdb_make_double(yymsp[0].minor.yy0.dval); } #line 1509 "mongodb.c" yymsp[0].minor.yy148 = yylhsminor.yy148; break; case 35: /* value ::= KW_TRUE */ #line 345 "mongodb.lime" { yymsp[0].minor.yy148 = mdb_make_bool(true); } #line 1515 "mongodb.c" break; case 36: /* value ::= KW_FALSE */ #line 346 "mongodb.lime" { yymsp[0].minor.yy148 = mdb_make_bool(false); } #line 1520 "mongodb.c" break; case 37: /* value ::= KW_NULL */ #line 347 "mongodb.lime" { yymsp[0].minor.yy148 = mdb_make_null(); } #line 1525 "mongodb.c" break; case 40: /* value ::= DOLLAR_IDENT */ #line 350 "mongodb.lime" { yylhsminor.yy148 = mdb_make_field_path(&yymsp[0].minor.yy0.str); } #line 1530 "mongodb.c" yymsp[0].minor.yy148 = yylhsminor.yy148; break; case 41: /* value ::= KW_OBJECTID LPAREN STRING RPAREN */ #line 351 "mongodb.lime" { yymsp[-3].minor.yy148 = mdb_make_object_id(&yymsp[-1].minor.yy0.str); } #line 1536 "mongodb.c" break; case 42: /* array ::= LBRACKET RBRACKET */ #line 357 "mongodb.lime" { yymsp[-1].minor.yy148 = mdb_make_array(NULL); } #line 1543 "mongodb.c" break; case 43: /* array ::= LBRACKET opt_value_list RBRACKET */ #line 361 "mongodb.lime" { yymsp[-2].minor.yy148 = mdb_make_array(yymsp[-1].minor.yy132); } #line 1550 "mongodb.c" break; case 44: /* opt_value_list ::= value_list */ #line 365 "mongodb.lime" { yylhsminor.yy132 = yymsp[0].minor.yy132; } #line 1555 "mongodb.c" yymsp[0].minor.yy132 = yylhsminor.yy132; break; case 47: /* query_op_pair ::= comparison_op COLON value */ #line 384 "mongodb.lime" { yylhsminor.yy148 = mdb_make_query_op(yymsp[-2].minor.yy140, NULL, yymsp[0].minor.yy148); } #line 1563 "mongodb.c" yymsp[-2].minor.yy148 = yylhsminor.yy148; break; case 48: /* comparison_op ::= OP_EQ */ #line 388 "mongodb.lime" { yymsp[0].minor.yy140 = MDB_OP_EQ; } #line 1569 "mongodb.c" break; case 49: /* comparison_op ::= OP_NE */ #line 389 "mongodb.lime" { yymsp[0].minor.yy140 = MDB_OP_NE; } #line 1574 "mongodb.c" break; case 50: /* comparison_op ::= OP_GT */ #line 390 "mongodb.lime" { yymsp[0].minor.yy140 = MDB_OP_GT; } #line 1579 "mongodb.c" break; case 51: /* comparison_op ::= OP_GTE */ #line 391 "mongodb.lime" { yymsp[0].minor.yy140 = MDB_OP_GTE; } #line 1584 "mongodb.c" break; case 52: /* comparison_op ::= OP_LT */ #line 392 "mongodb.lime" { yymsp[0].minor.yy140 = MDB_OP_LT; } #line 1589 "mongodb.c" break; case 53: /* comparison_op ::= OP_LTE */ #line 393 "mongodb.lime" { yymsp[0].minor.yy140 = MDB_OP_LTE; } #line 1594 "mongodb.c" break; case 54: /* comparison_op ::= OP_IN */ #line 394 "mongodb.lime" { yymsp[0].minor.yy140 = MDB_OP_IN; } #line 1599 "mongodb.c" break; case 55: /* comparison_op ::= OP_NIN */ #line 395 "mongodb.lime" { yymsp[0].minor.yy140 = MDB_OP_NIN; } #line 1604 "mongodb.c" break; case 56: /* logical_op_pair ::= logical_op COLON array */ #line 403 "mongodb.lime" { yylhsminor.yy148 = mdb_make_logical_op(yymsp[-2].minor.yy140, yymsp[0].minor.yy148); } #line 1611 "mongodb.c" yymsp[-2].minor.yy148 = yylhsminor.yy148; break; case 57: /* logical_op_pair ::= OP_NOT COLON document */ #line 407 "mongodb.lime" { yymsp[-2].minor.yy148 = mdb_make_logical_op(MDB_OP_NOT, yymsp[0].minor.yy148); } #line 1619 "mongodb.c" break; case 58: /* logical_op ::= OP_AND */ #line 411 "mongodb.lime" { yymsp[0].minor.yy140 = MDB_OP_AND; } #line 1624 "mongodb.c" break; case 59: /* logical_op ::= OP_OR */ #line 412 "mongodb.lime" { yymsp[0].minor.yy140 = MDB_OP_OR; } #line 1629 "mongodb.c" break; case 60: /* logical_op ::= OP_NOR */ #line 413 "mongodb.lime" { yymsp[0].minor.yy140 = MDB_OP_NOR; } #line 1634 "mongodb.c" break; case 61: /* element_op_pair ::= OP_EXISTS COLON value */ #line 419 "mongodb.lime" { yymsp[-2].minor.yy148 = mdb_make_query_op(MDB_OP_EXISTS, NULL, yymsp[0].minor.yy148); } #line 1641 "mongodb.c" break; case 62: /* element_op_pair ::= OP_TYPE COLON value */ #line 423 "mongodb.lime" { yymsp[-2].minor.yy148 = mdb_make_query_op(MDB_OP_TYPE, NULL, yymsp[0].minor.yy148); } #line 1648 "mongodb.c" break; case 63: /* array_op_pair ::= OP_ALL COLON array */ #line 432 "mongodb.lime" { yymsp[-2].minor.yy148 = mdb_make_query_op(MDB_OP_ALL, NULL, yymsp[0].minor.yy148); } #line 1655 "mongodb.c" break; case 64: /* array_op_pair ::= OP_ELEMMATCH COLON document */ #line 436 "mongodb.lime" { yymsp[-2].minor.yy148 = mdb_make_query_op(MDB_OP_ELEMMATCH, NULL, yymsp[0].minor.yy148); } #line 1662 "mongodb.c" break; case 65: /* array_op_pair ::= OP_SIZE COLON value */ #line 440 "mongodb.lime" { yymsp[-2].minor.yy148 = mdb_make_query_op(MDB_OP_SIZE, NULL, yymsp[0].minor.yy148); } #line 1669 "mongodb.c" break; case 66: /* eval_op_pair ::= OP_REGEX COLON value */ #line 449 "mongodb.lime" { yymsp[-2].minor.yy148 = mdb_make_query_op(MDB_OP_REGEX, NULL, yymsp[0].minor.yy148); } #line 1676 "mongodb.c" break; case 67: /* eval_op_pair ::= OP_MOD COLON array */ #line 453 "mongodb.lime" { yymsp[-2].minor.yy148 = mdb_make_query_op(MDB_OP_MOD, NULL, yymsp[0].minor.yy148); } #line 1683 "mongodb.c" break; case 68: /* update_op_pair ::= update_op COLON document */ #line 463 "mongodb.lime" { yylhsminor.yy148 = mdb_make_update_op(yymsp[-2].minor.yy140, yymsp[0].minor.yy148); } #line 1690 "mongodb.c" yymsp[-2].minor.yy148 = yylhsminor.yy148; break; case 69: /* update_op ::= UP_SET */ #line 467 "mongodb.lime" { yymsp[0].minor.yy140 = MDB_UP_SET; } #line 1696 "mongodb.c" break; case 70: /* update_op ::= UP_UNSET */ #line 468 "mongodb.lime" { yymsp[0].minor.yy140 = MDB_UP_UNSET; } #line 1701 "mongodb.c" break; case 71: /* update_op ::= UP_INC */ #line 469 "mongodb.lime" { yymsp[0].minor.yy140 = MDB_UP_INC; } #line 1706 "mongodb.c" break; case 72: /* update_op ::= UP_MUL */ #line 470 "mongodb.lime" { yymsp[0].minor.yy140 = MDB_UP_MUL; } #line 1711 "mongodb.c" break; case 73: /* update_op ::= UP_RENAME */ #line 471 "mongodb.lime" { yymsp[0].minor.yy140 = MDB_UP_RENAME; } #line 1716 "mongodb.c" break; case 74: /* update_op ::= UP_MIN */ #line 472 "mongodb.lime" { yymsp[0].minor.yy140 = MDB_UP_MIN; } #line 1721 "mongodb.c" break; case 75: /* update_op ::= UP_MAX */ #line 473 "mongodb.lime" { yymsp[0].minor.yy140 = MDB_UP_MAX; } #line 1726 "mongodb.c" break; case 76: /* update_op ::= UP_CURRENTDATE */ #line 474 "mongodb.lime" { yymsp[0].minor.yy140 = MDB_UP_CURRENTDATE; } #line 1731 "mongodb.c" break; case 77: /* update_op ::= UP_SETONINSERT */ #line 475 "mongodb.lime" { yymsp[0].minor.yy140 = MDB_UP_SETONDISERT; } #line 1736 "mongodb.c" break; case 78: /* update_op ::= UP_PUSH */ #line 476 "mongodb.lime" { yymsp[0].minor.yy140 = MDB_UP_PUSH; } #line 1741 "mongodb.c" break; case 79: /* update_op ::= UP_PULL */ #line 477 "mongodb.lime" { yymsp[0].minor.yy140 = MDB_UP_PULL; } #line 1746 "mongodb.c" break; case 80: /* update_op ::= UP_ADDTOSET */ #line 478 "mongodb.lime" { yymsp[0].minor.yy140 = MDB_UP_ADDTOSET; } #line 1751 "mongodb.c" break; case 81: /* update_op ::= UP_POP */ #line 479 "mongodb.lime" { yymsp[0].minor.yy140 = MDB_UP_POP; } #line 1756 "mongodb.c" break; case 82: /* agg_stage_pair ::= agg_stage_op COLON value */ #line 488 "mongodb.lime" { yylhsminor.yy148 = mdb_make_agg_stage(yymsp[-2].minor.yy140, yymsp[0].minor.yy148); } #line 1763 "mongodb.c" yymsp[-2].minor.yy148 = yylhsminor.yy148; break; case 83: /* agg_stage_op ::= AGG_MATCH */ #line 492 "mongodb.lime" { yymsp[0].minor.yy140 = MDB_AGG_MATCH; } #line 1769 "mongodb.c" break; case 84: /* agg_stage_op ::= AGG_GROUP */ #line 493 "mongodb.lime" { yymsp[0].minor.yy140 = MDB_AGG_GROUP; } #line 1774 "mongodb.c" break; case 85: /* agg_stage_op ::= AGG_PROJECT */ #line 494 "mongodb.lime" { yymsp[0].minor.yy140 = MDB_AGG_PROJECT; } #line 1779 "mongodb.c" break; case 86: /* agg_stage_op ::= AGG_SORT */ #line 495 "mongodb.lime" { yymsp[0].minor.yy140 = MDB_AGG_SORT; } #line 1784 "mongodb.c" break; case 87: /* agg_stage_op ::= AGG_LIMIT */ #line 496 "mongodb.lime" { yymsp[0].minor.yy140 = MDB_AGG_LIMIT; } #line 1789 "mongodb.c" break; case 88: /* agg_stage_op ::= AGG_SKIP */ #line 497 "mongodb.lime" { yymsp[0].minor.yy140 = MDB_AGG_SKIP; } #line 1794 "mongodb.c" break; case 89: /* agg_stage_op ::= AGG_UNWIND */ #line 498 "mongodb.lime" { yymsp[0].minor.yy140 = MDB_AGG_UNWIND; } #line 1799 "mongodb.c" break; case 90: /* agg_stage_op ::= AGG_LOOKUP */ #line 499 "mongodb.lime" { yymsp[0].minor.yy140 = MDB_AGG_LOOKUP; } #line 1804 "mongodb.c" break; case 91: /* agg_stage_op ::= AGG_OUT */ #line 500 "mongodb.lime" { yymsp[0].minor.yy140 = MDB_AGG_OUT; } #line 1809 "mongodb.c" break; case 92: /* agg_stage_op ::= AGG_COUNT */ #line 501 "mongodb.lime" { yymsp[0].minor.yy140 = MDB_AGG_COUNT; } #line 1814 "mongodb.c" break; case 93: /* agg_expr_pair ::= agg_accum_op COLON value */ #line 510 "mongodb.lime" { yylhsminor.yy148 = mdb_make_agg_expr(yymsp[-2].minor.yy140, yymsp[0].minor.yy148); } #line 1821 "mongodb.c" yymsp[-2].minor.yy148 = yylhsminor.yy148; break; case 94: /* agg_accum_op ::= AGG_SUM */ #line 514 "mongodb.lime" { yymsp[0].minor.yy140 = MDB_AGG_SUM; } #line 1827 "mongodb.c" break; case 95: /* agg_accum_op ::= AGG_AVG */ #line 515 "mongodb.lime" { yymsp[0].minor.yy140 = MDB_AGG_AVG; } #line 1832 "mongodb.c" break; case 96: /* agg_accum_op ::= AGG_FIRST */ #line 516 "mongodb.lime" { yymsp[0].minor.yy140 = MDB_AGG_FIRST; } #line 1837 "mongodb.c" break; case 97: /* agg_accum_op ::= AGG_LAST */ #line 517 "mongodb.lime" { yymsp[0].minor.yy140 = MDB_AGG_LAST; } #line 1842 "mongodb.c" 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 */ ){ mongodbParseARG_FETCH mongodbParseCTX_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 93 "mongodb.lime" pstate->error = 1; if (pstate->errMsg == NULL) { pstate->errMsg = "MongoDB query parse failure"; } #line 1892 "mongodb.c" /************ End %parse_failure code *****************************************/ mongodbParseARG_STORE /* Suppress warning about unused %extra_argument variable */ mongodbParseCTX_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 */ mongodbParseTOKENTYPE yyminor /* The minor type of the error token */ ){ mongodbParseARG_FETCH mongodbParseCTX_FETCH #define TOKEN yyminor /************ Begin %syntax_error code ****************************************/ #line 86 "mongodb.lime" pstate->error = 1; if (pstate->errMsg == NULL) { pstate->errMsg = "syntax error in MongoDB query"; } #line 1917 "mongodb.c" /************ End %syntax_error code ******************************************/ mongodbParseARG_STORE /* Suppress warning about unused %extra_argument variable */ mongodbParseCTX_STORE } /* ** The following is executed when the parser accepts */ static void yy_accept( yyParser *yypParser /* The parser */ ){ mongodbParseARG_FETCH mongodbParseCTX_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 *******************************************/ mongodbParseARG_STORE /* Suppress warning about unused %extra_argument variable */ mongodbParseCTX_STORE } /* The main parser program. ** The first argument is a pointer to a structure obtained from ** "mongodbParseAlloc" 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. */ void mongodbParse( void *yyp, /* The parser */ int yymajor, /* The major token code number */ mongodbParseTOKENTYPE yyminor /* The value for the token */ mongodbParseARG_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 */ mongodbParseCTX_FETCH mongodbParseARG_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 mongodbParseCTX_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( yypParser->yyerrcnt<=0 ){ yy_syntax_error(yypParser,yymajor, yyminor); } yypParser->yyerrcnt = 3; yy_destructor(yypParser,(YYCODETYPE)yymajor,&yyminorunion); if( yyendofinput ){ yy_parse_failed(yypParser); #ifndef YYNOERRORRECOVERY yypParser->yyerrcnt = -1; #endif } break; #endif } } #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; } /* ** Return the fallback token corresponding to canonical token iToken, or ** 0 if iToken has no fallback. */ int mongodbParseFallback(int iToken){ #ifdef YYFALLBACK assert( iToken<(int)(sizeof(yyFallback)/sizeof(yyFallback[0])) ); return yyFallback[iToken]; #else (void)iToken; return 0; #endif }