/* This file is automatically generated by Lemon from input grammar ** source file "examples/jsonpath/jsonpath_gram.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 18 "examples/jsonpath/jsonpath_gram.lime" #include #include #include #include #include #include "jsonpath_internal.h" #include "jsonpath_helpers.h" #line 39 "examples/jsonpath/jsonpath_gram.c" /**************** End of %include directives **********************************/ /* These constants specify the various numeric values for terminal symbols. ***************** Begin token definitions *************************************/ #ifndef TO_P #define TO_P 1 #define NULL_P 2 #define TRUE_P 3 #define FALSE_P 4 #define IS_P 5 #define UNKNOWN_P 6 #define EXISTS_P 7 #define IDENT_P 8 #define STRING_P 9 #define NUMERIC_P 10 #define INT_P 11 #define VARIABLE_P 12 #define OR_P 13 #define AND_P 14 #define NOT_P 15 #define LESS_P 16 #define LESSEQUAL_P 17 #define EQUAL_P 18 #define NOTEQUAL_P 19 #define GREATEREQUAL_P 20 #define GREATER_P 21 #define ANY_P 22 #define STRICT_P 23 #define LAX_P 24 #define LAST_P 25 #define STARTS_P 26 #define WITH_P 27 #define LIKE_REGEX_P 28 #define FLAG_P 29 #define ABS_P 30 #define SIZE_P 31 #define TYPE_P 32 #define FLOOR_P 33 #define DOUBLE_P 34 #define CEILING_P 35 #define KEYVALUE_P 36 #define DATETIME_P 37 #define BIGINT_P 38 #define BOOLEAN_P 39 #define DATE_P 40 #define DECIMAL_P 41 #define INTEGER_P 42 #define NUMBER_P 43 #define STRINGFUNC_P 44 #define TIME_P 45 #define TIME_TZ_P 46 #define TIMESTAMP_P 47 #define TIMESTAMP_TZ_P 48 #define DOLLAR 49 #define AT 50 #define DOT 51 #define LBRACKET 52 #define RBRACKET 53 #define LBRACE 54 #define RBRACE 55 #define LPAREN 56 #define RPAREN 57 #define QUESTION 58 #define COMMA 59 #define STAR 60 #define COLON 61 #define PLUS 62 #define MINUS 63 #define SLASH 64 #define PERCENT 65 #define UMINUS 66 #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. ** jsonpathParseTOKENTYPE 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 jsonpathParseTOKENTYPE. 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() ** jsonpathParseARG_SDECL A static variable declaration for the %extra_argument ** jsonpathParseARG_PDECL A parameter declaration for the %extra_argument ** jsonpathParseARG_PARAM Code to pass %extra_argument as a subroutine parameter ** jsonpathParseARG_STORE Code to store %extra_argument into yypParser ** jsonpathParseARG_FETCH Code to extract %extra_argument from yypParser ** jsonpathParseCTX_* As jsonpathParseARG_ 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 94 #define YYACTIONTYPE unsigned short int #define jsonpathParseTOKENTYPE JsonPathToken typedef union { int yyinit; jsonpathParseTOKENTYPE yy0; JsonPathString yy23; JsonPathParseItem * yy60; int yy92; JsonPathList * yy106; JsonPathItemType yy117; JsonPathParseResult * yy188; } YYMINORTYPE; #ifndef YYSTACKDEPTH #define YYSTACKDEPTH 100 #endif #define jsonpathParseARG_SDECL JsonPathParseState *pstate; #define jsonpathParseARG_PDECL ,JsonPathParseState *pstate #define jsonpathParseARG_PARAM ,pstate #define jsonpathParseARG_FETCH JsonPathParseState *pstate=yypParser->pstate; #define jsonpathParseARG_STORE yypParser->pstate=pstate; #undef YYREALLOC #define YYREALLOC realloc #undef YYFREE #define YYFREE free #undef YYDYNSTACK #define YYDYNSTACK 0 #undef YYSIZELIMIT #define jsonpathParseCTX(P) 0 #define jsonpathParseCTX_SDECL #define jsonpathParseCTX_PDECL #define jsonpathParseCTX_PARAM #define jsonpathParseCTX_FETCH #define jsonpathParseCTX_STORE #undef YYERRORSYMBOL #undef YYERRSYMDT #undef YYFALLBACK #define YYNSTATE 94 #define YYNRULE 135 #define YYNRULE_WITH_ACTION 135 #define YYNTOKEN 67 #define YY_MAX_SHIFT 93 #define YY_MIN_SHIFTREDUCE 178 #define YY_MAX_SHIFTREDUCE 312 #define YY_ERROR_ACTION 313 #define YY_ACCEPT_ACTION 314 #define YY_NO_ACTION 315 #define YY_MIN_REDUCE 316 #define YY_MAX_REDUCE 450 #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 (332) static const YYACTIONTYPE yy_action[] = { /* 0 */ 20, 267, 268, 269, 270, 271, 272, 273, 265, 266, /* 10 */ 93, 314, 349, 1, 338, 49, 58, 353, 25, 33, /* 20 */ 397, 73, 91, 274, 275, 284, 285, 286, 287, 288, /* 30 */ 72, 71, 70, 69, 68, 67, 66, 82, 65, 64, /* 40 */ 63, 87, 62, 61, 60, 80, 78, 76, 74, 186, /* 50 */ 187, 188, 379, 37, 58, 355, 185, 189, 190, 191, /* 60 */ 240, 349, 35, 338, 45, 2, 353, 25, 32, 392, /* 70 */ 83, 86, 214, 349, 258, 186, 187, 188, 353, 25, /* 80 */ 39, 369, 185, 189, 190, 191, 349, 261, 338, 53, /* 90 */ 15, 353, 25, 32, 13, 12, 212, 213, 214, 349, /* 100 */ 344, 338, 340, 6, 353, 25, 32, 237, 379, 16, /* 110 */ 14, 354, 3, 4, 194, 196, 192, 193, 197, 195, /* 120 */ 234, 11, 212, 213, 57, 349, 56, 338, 46, 7, /* 130 */ 353, 25, 32, 52, 235, 16, 14, 349, 379, 338, /* 140 */ 48, 356, 353, 25, 31, 317, 349, 209, 338, 44, /* 150 */ 210, 353, 25, 31, 393, 24, 23, 342, 15, 232, /* 160 */ 19, 17, 13, 12, 186, 187, 188, 90, 182, 183, /* 170 */ 349, 185, 189, 190, 191, 353, 25, 39, 368, 50, /* 180 */ 15, 4, 19, 17, 13, 12, 380, 214, 194, 196, /* 190 */ 192, 193, 197, 195, 51, 377, 402, 89, 57, 233, /* 200 */ 56, 199, 208, 251, 15, 9, 19, 17, 13, 12, /* 210 */ 349, 212, 213, 397, 75, 353, 25, 41, 7, 54, /* 220 */ 10, 8, 3, 4, 16, 14, 15, 59, 19, 17, /* 230 */ 13, 12, 15, 349, 19, 17, 13, 12, 353, 25, /* 240 */ 365, 349, 92, 55, 349, 36, 353, 25, 364, 353, /* 250 */ 25, 360, 18, 349, 85, 84, 349, 5, 353, 25, /* 260 */ 363, 353, 25, 359, 349, 34, 198, 349, 450, 353, /* 270 */ 25, 47, 353, 25, 40, 349, 3, 4, 349, 449, /* 280 */ 353, 25, 43, 353, 25, 42, 3, 4, 10, 8, /* 290 */ 250, 397, 77, 249, 448, 59, 447, 397, 79, 446, /* 300 */ 400, 81, 3, 4, 445, 444, 443, 442, 441, 440, /* 310 */ 439, 438, 26, 27, 253, 248, 28, 252, 247, 246, /* 320 */ 244, 29, 21, 30, 38, 245, 243, 88, 205, 238, /* 330 */ 22, 316, }; static const YYCODETYPE yy_lookahead[] = { /* 0 */ 71, 1, 2, 3, 4, 5, 6, 7, 8, 9, /* 10 */ 68, 67, 70, 69, 72, 73, 7, 75, 76, 77, /* 20 */ 87, 88, 22, 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, 2, /* 50 */ 3, 4, 80, 1, 7, 83, 9, 10, 11, 12, /* 60 */ 60, 70, 15, 72, 73, 56, 75, 76, 77, 84, /* 70 */ 85, 86, 25, 70, 11, 2, 3, 4, 75, 76, /* 80 */ 77, 78, 9, 10, 11, 12, 70, 9, 72, 73, /* 90 */ 60, 75, 76, 77, 64, 65, 49, 50, 25, 70, /* 100 */ 74, 72, 73, 56, 75, 76, 77, 55, 80, 62, /* 110 */ 63, 83, 13, 14, 16, 17, 18, 19, 20, 21, /* 120 */ 11, 1, 49, 50, 26, 70, 28, 72, 73, 56, /* 130 */ 75, 76, 77, 60, 25, 62, 63, 70, 80, 72, /* 140 */ 73, 83, 75, 76, 77, 0, 70, 9, 72, 73, /* 150 */ 12, 75, 76, 77, 84, 57, 57, 72, 60, 53, /* 160 */ 62, 63, 64, 65, 2, 3, 4, 81, 23, 24, /* 170 */ 70, 9, 10, 11, 12, 75, 76, 77, 78, 79, /* 180 */ 60, 14, 62, 63, 64, 65, 82, 25, 16, 17, /* 190 */ 18, 19, 20, 21, 81, 91, 92, 93, 26, 53, /* 200 */ 28, 57, 9, 11, 60, 59, 62, 63, 64, 65, /* 210 */ 70, 49, 50, 87, 88, 75, 76, 77, 56, 29, /* 220 */ 51, 52, 13, 14, 62, 63, 60, 58, 62, 63, /* 230 */ 64, 65, 60, 70, 62, 63, 64, 65, 75, 76, /* 240 */ 77, 70, 5, 9, 70, 27, 75, 76, 77, 75, /* 250 */ 76, 77, 56, 70, 62, 63, 70, 56, 75, 76, /* 260 */ 77, 75, 76, 77, 70, 59, 57, 70, 56, 75, /* 270 */ 76, 77, 75, 76, 77, 70, 13, 14, 70, 56, /* 280 */ 75, 76, 77, 75, 76, 77, 13, 14, 51, 52, /* 290 */ 57, 87, 88, 57, 56, 58, 56, 87, 88, 56, /* 300 */ 89, 90, 13, 14, 56, 56, 56, 56, 56, 56, /* 310 */ 56, 56, 56, 56, 11, 57, 56, 11, 57, 57, /* 320 */ 57, 56, 56, 56, 54, 57, 57, 56, 6, 55, /* 330 */ 57, 0, 94, 94, 94, 94, 94, 94, 94, 94, /* 340 */ 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, /* 350 */ 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, /* 360 */ 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, /* 370 */ 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, /* 380 */ 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, /* 390 */ 94, 94, 94, 94, 94, 94, 94, 94, 94, }; #define YY_SHIFT_COUNT (93) #define YY_SHIFT_MIN (0) #define YY_SHIFT_MAX (331) static const unsigned short int yy_shift_ofst[] = { /* 0 */ 145, 47, 47, 47, 47, 47, 47, 47, 73, 162, /* 10 */ 0, 162, 162, 162, 162, 162, 162, 162, 162, 162, /* 20 */ 162, 192, 237, 169, 169, 169, 63, 63, 63, 63, /* 30 */ 78, 98, 172, 172, 192, 9, 138, 109, 109, 120, /* 40 */ 144, 166, 166, 30, 99, 209, 263, 30, 273, 289, /* 50 */ 146, 52, 106, 167, 193, 190, 234, 218, 196, 201, /* 60 */ 212, 223, 238, 240, 243, 248, 249, 250, 251, 252, /* 70 */ 253, 254, 255, 233, 256, 236, 257, 258, 260, 261, /* 80 */ 265, 262, 267, 206, 303, 306, 268, 266, 269, 271, /* 90 */ 274, 270, 322, 331, }; #define YY_REDUCE_COUNT (38) #define YY_REDUCE_MIN (-71) #define YY_REDUCE_MAX (211) static const short yy_reduce_ofst[] = { /* 0 */ -56, -58, -9, 16, 29, 55, 67, 76, 100, 3, /* 10 */ 104, 140, 163, 171, 174, 183, 186, 194, 197, 205, /* 20 */ 208, -15, -28, -28, 28, 58, -67, 126, 204, 210, /* 30 */ 211, -71, -71, -71, 70, 85, 26, 86, 113, }; static const YYACTIONTYPE yy_default[] = { /* 0 */ 322, 313, 313, 313, 313, 313, 313, 313, 313, 313, /* 10 */ 313, 313, 313, 313, 313, 313, 313, 313, 313, 313, /* 20 */ 313, 395, 336, 313, 358, 357, 398, 398, 398, 398, /* 30 */ 401, 313, 313, 318, 313, 313, 313, 313, 313, 366, /* 40 */ 313, 367, 339, 361, 313, 313, 313, 362, 313, 319, /* 50 */ 313, 313, 313, 341, 313, 345, 313, 313, 313, 313, /* 60 */ 433, 432, 431, 429, 428, 427, 421, 419, 418, 417, /* 70 */ 416, 415, 414, 313, 437, 313, 436, 313, 435, 313, /* 80 */ 434, 313, 420, 394, 313, 313, 313, 430, 313, 313, /* 90 */ 313, 374, 313, 313, }; /********** 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 jsonpathParseARG_SDECL /* A place to hold %extra_argument */ jsonpathParseCTX_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 jsonpathParseTrace(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 */ "TO_P", /* 2 */ "NULL_P", /* 3 */ "TRUE_P", /* 4 */ "FALSE_P", /* 5 */ "IS_P", /* 6 */ "UNKNOWN_P", /* 7 */ "EXISTS_P", /* 8 */ "IDENT_P", /* 9 */ "STRING_P", /* 10 */ "NUMERIC_P", /* 11 */ "INT_P", /* 12 */ "VARIABLE_P", /* 13 */ "OR_P", /* 14 */ "AND_P", /* 15 */ "NOT_P", /* 16 */ "LESS_P", /* 17 */ "LESSEQUAL_P", /* 18 */ "EQUAL_P", /* 19 */ "NOTEQUAL_P", /* 20 */ "GREATEREQUAL_P", /* 21 */ "GREATER_P", /* 22 */ "ANY_P", /* 23 */ "STRICT_P", /* 24 */ "LAX_P", /* 25 */ "LAST_P", /* 26 */ "STARTS_P", /* 27 */ "WITH_P", /* 28 */ "LIKE_REGEX_P", /* 29 */ "FLAG_P", /* 30 */ "ABS_P", /* 31 */ "SIZE_P", /* 32 */ "TYPE_P", /* 33 */ "FLOOR_P", /* 34 */ "DOUBLE_P", /* 35 */ "CEILING_P", /* 36 */ "KEYVALUE_P", /* 37 */ "DATETIME_P", /* 38 */ "BIGINT_P", /* 39 */ "BOOLEAN_P", /* 40 */ "DATE_P", /* 41 */ "DECIMAL_P", /* 42 */ "INTEGER_P", /* 43 */ "NUMBER_P", /* 44 */ "STRINGFUNC_P", /* 45 */ "TIME_P", /* 46 */ "TIME_TZ_P", /* 47 */ "TIMESTAMP_P", /* 48 */ "TIMESTAMP_TZ_P", /* 49 */ "DOLLAR", /* 50 */ "AT", /* 51 */ "DOT", /* 52 */ "LBRACKET", /* 53 */ "RBRACKET", /* 54 */ "LBRACE", /* 55 */ "RBRACE", /* 56 */ "LPAREN", /* 57 */ "RPAREN", /* 58 */ "QUESTION", /* 59 */ "COMMA", /* 60 */ "STAR", /* 61 */ "COLON", /* 62 */ "PLUS", /* 63 */ "MINUS", /* 64 */ "SLASH", /* 65 */ "PERCENT", /* 66 */ "UMINUS", /* 67 */ "result", /* 68 */ "expr_or_predicate", /* 69 */ "mode", /* 70 */ "scalar_value", /* 71 */ "comp_op", /* 72 */ "delimited_predicate", /* 73 */ "predicate", /* 74 */ "starts_with_initial", /* 75 */ "path_primary", /* 76 */ "accessor_expr", /* 77 */ "expr", /* 78 */ "index_elem", /* 79 */ "index_list", /* 80 */ "array_accessor", /* 81 */ "any_level", /* 82 */ "any_path", /* 83 */ "accessor_op", /* 84 */ "csv_elem", /* 85 */ "csv_list", /* 86 */ "opt_csv_list", /* 87 */ "datetime_precision", /* 88 */ "opt_datetime_precision", /* 89 */ "datetime_template", /* 90 */ "opt_datetime_template", /* 91 */ "key", /* 92 */ "key_name", /* 93 */ "method", }; #endif /* defined(YYCOVERAGE) || !defined(NDEBUG) */ #ifndef NDEBUG /* For tracing reduce actions, the names of all rules are required. */ static const char *const yyRuleName[] = { /* 0 */ "result ::= mode expr_or_predicate", /* 1 */ "result ::=", /* 2 */ "expr_or_predicate ::= expr", /* 3 */ "expr_or_predicate ::= predicate", /* 4 */ "mode ::= STRICT_P", /* 5 */ "mode ::= LAX_P", /* 6 */ "mode ::=", /* 7 */ "scalar_value ::= STRING_P", /* 8 */ "scalar_value ::= NULL_P", /* 9 */ "scalar_value ::= TRUE_P", /* 10 */ "scalar_value ::= FALSE_P", /* 11 */ "scalar_value ::= NUMERIC_P", /* 12 */ "scalar_value ::= INT_P", /* 13 */ "scalar_value ::= VARIABLE_P", /* 14 */ "comp_op ::= EQUAL_P", /* 15 */ "comp_op ::= NOTEQUAL_P", /* 16 */ "comp_op ::= LESS_P", /* 17 */ "comp_op ::= GREATER_P", /* 18 */ "comp_op ::= LESSEQUAL_P", /* 19 */ "comp_op ::= GREATEREQUAL_P", /* 20 */ "delimited_predicate ::= LPAREN predicate RPAREN", /* 21 */ "delimited_predicate ::= EXISTS_P LPAREN expr RPAREN", /* 22 */ "predicate ::= delimited_predicate", /* 23 */ "predicate ::= expr comp_op expr", /* 24 */ "predicate ::= predicate AND_P predicate", /* 25 */ "predicate ::= predicate OR_P predicate", /* 26 */ "predicate ::= NOT_P delimited_predicate", /* 27 */ "predicate ::= LPAREN predicate RPAREN IS_P UNKNOWN_P", /* 28 */ "predicate ::= expr STARTS_P WITH_P starts_with_initial", /* 29 */ "predicate ::= expr LIKE_REGEX_P STRING_P", /* 30 */ "predicate ::= expr LIKE_REGEX_P STRING_P FLAG_P STRING_P", /* 31 */ "starts_with_initial ::= STRING_P", /* 32 */ "starts_with_initial ::= VARIABLE_P", /* 33 */ "path_primary ::= scalar_value", /* 34 */ "path_primary ::= DOLLAR", /* 35 */ "path_primary ::= AT", /* 36 */ "path_primary ::= LAST_P", /* 37 */ "accessor_expr ::= path_primary", /* 38 */ "accessor_expr ::= LPAREN expr RPAREN accessor_op", /* 39 */ "accessor_expr ::= LPAREN predicate RPAREN accessor_op", /* 40 */ "accessor_expr ::= accessor_expr accessor_op", /* 41 */ "expr ::= accessor_expr", /* 42 */ "expr ::= LPAREN expr RPAREN", /* 43 */ "expr ::= PLUS expr", /* 44 */ "expr ::= MINUS expr", /* 45 */ "expr ::= expr PLUS expr", /* 46 */ "expr ::= expr MINUS expr", /* 47 */ "expr ::= expr STAR expr", /* 48 */ "expr ::= expr SLASH expr", /* 49 */ "expr ::= expr PERCENT expr", /* 50 */ "index_elem ::= expr", /* 51 */ "index_elem ::= expr TO_P expr", /* 52 */ "index_list ::= index_elem", /* 53 */ "index_list ::= index_list COMMA index_elem", /* 54 */ "array_accessor ::= LBRACKET STAR RBRACKET", /* 55 */ "array_accessor ::= LBRACKET index_list RBRACKET", /* 56 */ "any_level ::= INT_P", /* 57 */ "any_level ::= LAST_P", /* 58 */ "any_path ::= ANY_P", /* 59 */ "any_path ::= ANY_P LBRACE any_level RBRACE", /* 60 */ "any_path ::= ANY_P LBRACE any_level TO_P any_level RBRACE", /* 61 */ "accessor_op ::= DOT key", /* 62 */ "accessor_op ::= DOT STAR", /* 63 */ "accessor_op ::= array_accessor", /* 64 */ "accessor_op ::= DOT any_path", /* 65 */ "accessor_op ::= DOT method LPAREN RPAREN", /* 66 */ "accessor_op ::= QUESTION LPAREN predicate RPAREN", /* 67 */ "accessor_op ::= DOT DECIMAL_P LPAREN opt_csv_list RPAREN", /* 68 */ "accessor_op ::= DOT DATETIME_P LPAREN opt_datetime_template RPAREN", /* 69 */ "accessor_op ::= DOT TIME_P LPAREN opt_datetime_precision RPAREN", /* 70 */ "accessor_op ::= DOT TIME_TZ_P LPAREN opt_datetime_precision RPAREN", /* 71 */ "accessor_op ::= DOT TIMESTAMP_P LPAREN opt_datetime_precision RPAREN", /* 72 */ "accessor_op ::= DOT TIMESTAMP_TZ_P LPAREN opt_datetime_precision RPAREN", /* 73 */ "csv_elem ::= INT_P", /* 74 */ "csv_elem ::= PLUS INT_P", /* 75 */ "csv_elem ::= MINUS INT_P", /* 76 */ "csv_list ::= csv_elem", /* 77 */ "csv_list ::= csv_list COMMA csv_elem", /* 78 */ "opt_csv_list ::= csv_list", /* 79 */ "opt_csv_list ::=", /* 80 */ "datetime_precision ::= INT_P", /* 81 */ "opt_datetime_precision ::= datetime_precision", /* 82 */ "opt_datetime_precision ::=", /* 83 */ "datetime_template ::= STRING_P", /* 84 */ "opt_datetime_template ::= datetime_template", /* 85 */ "opt_datetime_template ::=", /* 86 */ "key ::= key_name", /* 87 */ "key_name ::= IDENT_P", /* 88 */ "key_name ::= STRING_P", /* 89 */ "key_name ::= TO_P", /* 90 */ "key_name ::= NULL_P", /* 91 */ "key_name ::= TRUE_P", /* 92 */ "key_name ::= FALSE_P", /* 93 */ "key_name ::= IS_P", /* 94 */ "key_name ::= UNKNOWN_P", /* 95 */ "key_name ::= EXISTS_P", /* 96 */ "key_name ::= STRICT_P", /* 97 */ "key_name ::= LAX_P", /* 98 */ "key_name ::= ABS_P", /* 99 */ "key_name ::= SIZE_P", /* 100 */ "key_name ::= TYPE_P", /* 101 */ "key_name ::= FLOOR_P", /* 102 */ "key_name ::= DOUBLE_P", /* 103 */ "key_name ::= CEILING_P", /* 104 */ "key_name ::= DATETIME_P", /* 105 */ "key_name ::= KEYVALUE_P", /* 106 */ "key_name ::= LAST_P", /* 107 */ "key_name ::= STARTS_P", /* 108 */ "key_name ::= WITH_P", /* 109 */ "key_name ::= LIKE_REGEX_P", /* 110 */ "key_name ::= FLAG_P", /* 111 */ "key_name ::= BIGINT_P", /* 112 */ "key_name ::= BOOLEAN_P", /* 113 */ "key_name ::= DATE_P", /* 114 */ "key_name ::= DECIMAL_P", /* 115 */ "key_name ::= INTEGER_P", /* 116 */ "key_name ::= NUMBER_P", /* 117 */ "key_name ::= STRINGFUNC_P", /* 118 */ "key_name ::= TIME_P", /* 119 */ "key_name ::= TIME_TZ_P", /* 120 */ "key_name ::= TIMESTAMP_P", /* 121 */ "key_name ::= TIMESTAMP_TZ_P", /* 122 */ "method ::= ABS_P", /* 123 */ "method ::= SIZE_P", /* 124 */ "method ::= TYPE_P", /* 125 */ "method ::= FLOOR_P", /* 126 */ "method ::= DOUBLE_P", /* 127 */ "method ::= CEILING_P", /* 128 */ "method ::= KEYVALUE_P", /* 129 */ "method ::= BIGINT_P", /* 130 */ "method ::= BOOLEAN_P", /* 131 */ "method ::= DATE_P", /* 132 */ "method ::= INTEGER_P", /* 133 */ "method ::= NUMBER_P", /* 134 */ "method ::= STRINGFUNC_P", }; #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(jsonpathParseCTX(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]), jsonpathParseCTX(p)); if( pNew==0 ) return 1; memcpy(pNew, p->yystack, oldSize*sizeof(pNew[0])); }else{ pNew = YYREALLOC(p->yystack, newSize*sizeof(pNew[0]), jsonpathParseCTX(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 jsonpathParseAlloc() 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 jsonpathParseInit(void *yypRawParser jsonpathParseCTX_PDECL){ yyParser *yypParser = (yyParser*)yypRawParser; jsonpathParseCTX_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 jsonpathParse_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 jsonpathParse and jsonpathParseFree. */ void *jsonpathParseAlloc(void *(*mallocProc)(YYMALLOCARGTYPE) jsonpathParseCTX_PDECL){ yyParser *yypParser; yypParser = (yyParser*)(*mallocProc)( (YYMALLOCARGTYPE)sizeof(yyParser) ); if( yypParser ){ jsonpathParseCTX_STORE jsonpathParseInit(yypParser jsonpathParseCTX_PARAM); } return (void*)yypParser; } #endif /* jsonpathParse_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 */ ){ jsonpathParseARG_FETCH jsonpathParseCTX_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 jsonpathParseFinalize(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, jsonpathParseCTX(pParser)); } #endif } #ifndef jsonpathParse_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 jsonpathParseFree( void *p, /* The parser to be deleted */ void (*freeProc)(void*) /* Function used to reclaim memory */ ){ #ifndef YYPARSEFREENEVERNULL if( p==0 ) return; #endif jsonpathParseFinalize(p); (*freeProc)(p); } #endif /* jsonpathParse_ENGINEALWAYSONSTACK */ /* ** Return the peak depth of the stack for a parser. */ #ifdef YYTRACKMAXSTACKDEPTH int jsonpathParseStackPeak(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 jsonpathParseCoverage(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 ********************************************/ jsonpathParseARG_STORE /* Suppress warning about unused %extra_argument var */ jsonpathParseCTX_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 */ jsonpathParseTOKENTYPE 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[] = { 67, /* (0) result ::= mode expr_or_predicate */ 67, /* (1) result ::= */ 68, /* (2) expr_or_predicate ::= expr */ 68, /* (3) expr_or_predicate ::= predicate */ 69, /* (4) mode ::= STRICT_P */ 69, /* (5) mode ::= LAX_P */ 69, /* (6) mode ::= */ 70, /* (7) scalar_value ::= STRING_P */ 70, /* (8) scalar_value ::= NULL_P */ 70, /* (9) scalar_value ::= TRUE_P */ 70, /* (10) scalar_value ::= FALSE_P */ 70, /* (11) scalar_value ::= NUMERIC_P */ 70, /* (12) scalar_value ::= INT_P */ 70, /* (13) scalar_value ::= VARIABLE_P */ 71, /* (14) comp_op ::= EQUAL_P */ 71, /* (15) comp_op ::= NOTEQUAL_P */ 71, /* (16) comp_op ::= LESS_P */ 71, /* (17) comp_op ::= GREATER_P */ 71, /* (18) comp_op ::= LESSEQUAL_P */ 71, /* (19) comp_op ::= GREATEREQUAL_P */ 72, /* (20) delimited_predicate ::= LPAREN predicate RPAREN */ 72, /* (21) delimited_predicate ::= EXISTS_P LPAREN expr RPAREN */ 73, /* (22) predicate ::= delimited_predicate */ 73, /* (23) predicate ::= expr comp_op expr */ 73, /* (24) predicate ::= predicate AND_P predicate */ 73, /* (25) predicate ::= predicate OR_P predicate */ 73, /* (26) predicate ::= NOT_P delimited_predicate */ 73, /* (27) predicate ::= LPAREN predicate RPAREN IS_P UNKNOWN_P */ 73, /* (28) predicate ::= expr STARTS_P WITH_P starts_with_initial */ 73, /* (29) predicate ::= expr LIKE_REGEX_P STRING_P */ 73, /* (30) predicate ::= expr LIKE_REGEX_P STRING_P FLAG_P STRING_P */ 74, /* (31) starts_with_initial ::= STRING_P */ 74, /* (32) starts_with_initial ::= VARIABLE_P */ 75, /* (33) path_primary ::= scalar_value */ 75, /* (34) path_primary ::= DOLLAR */ 75, /* (35) path_primary ::= AT */ 75, /* (36) path_primary ::= LAST_P */ 76, /* (37) accessor_expr ::= path_primary */ 76, /* (38) accessor_expr ::= LPAREN expr RPAREN accessor_op */ 76, /* (39) accessor_expr ::= LPAREN predicate RPAREN accessor_op */ 76, /* (40) accessor_expr ::= accessor_expr accessor_op */ 77, /* (41) expr ::= accessor_expr */ 77, /* (42) expr ::= LPAREN expr RPAREN */ 77, /* (43) expr ::= PLUS expr */ 77, /* (44) expr ::= MINUS expr */ 77, /* (45) expr ::= expr PLUS expr */ 77, /* (46) expr ::= expr MINUS expr */ 77, /* (47) expr ::= expr STAR expr */ 77, /* (48) expr ::= expr SLASH expr */ 77, /* (49) expr ::= expr PERCENT expr */ 78, /* (50) index_elem ::= expr */ 78, /* (51) index_elem ::= expr TO_P expr */ 79, /* (52) index_list ::= index_elem */ 79, /* (53) index_list ::= index_list COMMA index_elem */ 80, /* (54) array_accessor ::= LBRACKET STAR RBRACKET */ 80, /* (55) array_accessor ::= LBRACKET index_list RBRACKET */ 81, /* (56) any_level ::= INT_P */ 81, /* (57) any_level ::= LAST_P */ 82, /* (58) any_path ::= ANY_P */ 82, /* (59) any_path ::= ANY_P LBRACE any_level RBRACE */ 82, /* (60) any_path ::= ANY_P LBRACE any_level TO_P any_level RBRACE */ 83, /* (61) accessor_op ::= DOT key */ 83, /* (62) accessor_op ::= DOT STAR */ 83, /* (63) accessor_op ::= array_accessor */ 83, /* (64) accessor_op ::= DOT any_path */ 83, /* (65) accessor_op ::= DOT method LPAREN RPAREN */ 83, /* (66) accessor_op ::= QUESTION LPAREN predicate RPAREN */ 83, /* (67) accessor_op ::= DOT DECIMAL_P LPAREN opt_csv_list RPAREN */ 83, /* (68) accessor_op ::= DOT DATETIME_P LPAREN opt_datetime_template RPAREN */ 83, /* (69) accessor_op ::= DOT TIME_P LPAREN opt_datetime_precision RPAREN */ 83, /* (70) accessor_op ::= DOT TIME_TZ_P LPAREN opt_datetime_precision RPAREN */ 83, /* (71) accessor_op ::= DOT TIMESTAMP_P LPAREN opt_datetime_precision RPAREN */ 83, /* (72) accessor_op ::= DOT TIMESTAMP_TZ_P LPAREN opt_datetime_precision RPAREN */ 84, /* (73) csv_elem ::= INT_P */ 84, /* (74) csv_elem ::= PLUS INT_P */ 84, /* (75) csv_elem ::= MINUS INT_P */ 85, /* (76) csv_list ::= csv_elem */ 85, /* (77) csv_list ::= csv_list COMMA csv_elem */ 86, /* (78) opt_csv_list ::= csv_list */ 86, /* (79) opt_csv_list ::= */ 87, /* (80) datetime_precision ::= INT_P */ 88, /* (81) opt_datetime_precision ::= datetime_precision */ 88, /* (82) opt_datetime_precision ::= */ 89, /* (83) datetime_template ::= STRING_P */ 90, /* (84) opt_datetime_template ::= datetime_template */ 90, /* (85) opt_datetime_template ::= */ 91, /* (86) key ::= key_name */ 92, /* (87) key_name ::= IDENT_P */ 92, /* (88) key_name ::= STRING_P */ 92, /* (89) key_name ::= TO_P */ 92, /* (90) key_name ::= NULL_P */ 92, /* (91) key_name ::= TRUE_P */ 92, /* (92) key_name ::= FALSE_P */ 92, /* (93) key_name ::= IS_P */ 92, /* (94) key_name ::= UNKNOWN_P */ 92, /* (95) key_name ::= EXISTS_P */ 92, /* (96) key_name ::= STRICT_P */ 92, /* (97) key_name ::= LAX_P */ 92, /* (98) key_name ::= ABS_P */ 92, /* (99) key_name ::= SIZE_P */ 92, /* (100) key_name ::= TYPE_P */ 92, /* (101) key_name ::= FLOOR_P */ 92, /* (102) key_name ::= DOUBLE_P */ 92, /* (103) key_name ::= CEILING_P */ 92, /* (104) key_name ::= DATETIME_P */ 92, /* (105) key_name ::= KEYVALUE_P */ 92, /* (106) key_name ::= LAST_P */ 92, /* (107) key_name ::= STARTS_P */ 92, /* (108) key_name ::= WITH_P */ 92, /* (109) key_name ::= LIKE_REGEX_P */ 92, /* (110) key_name ::= FLAG_P */ 92, /* (111) key_name ::= BIGINT_P */ 92, /* (112) key_name ::= BOOLEAN_P */ 92, /* (113) key_name ::= DATE_P */ 92, /* (114) key_name ::= DECIMAL_P */ 92, /* (115) key_name ::= INTEGER_P */ 92, /* (116) key_name ::= NUMBER_P */ 92, /* (117) key_name ::= STRINGFUNC_P */ 92, /* (118) key_name ::= TIME_P */ 92, /* (119) key_name ::= TIME_TZ_P */ 92, /* (120) key_name ::= TIMESTAMP_P */ 92, /* (121) key_name ::= TIMESTAMP_TZ_P */ 93, /* (122) method ::= ABS_P */ 93, /* (123) method ::= SIZE_P */ 93, /* (124) method ::= TYPE_P */ 93, /* (125) method ::= FLOOR_P */ 93, /* (126) method ::= DOUBLE_P */ 93, /* (127) method ::= CEILING_P */ 93, /* (128) method ::= KEYVALUE_P */ 93, /* (129) method ::= BIGINT_P */ 93, /* (130) method ::= BOOLEAN_P */ 93, /* (131) method ::= DATE_P */ 93, /* (132) method ::= INTEGER_P */ 93, /* (133) method ::= NUMBER_P */ 93, /* (134) method ::= STRINGFUNC_P */ }; /* 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[] = { -2, /* (0) result ::= mode expr_or_predicate */ 0, /* (1) result ::= */ -1, /* (2) expr_or_predicate ::= expr */ -1, /* (3) expr_or_predicate ::= predicate */ -1, /* (4) mode ::= STRICT_P */ -1, /* (5) mode ::= LAX_P */ 0, /* (6) mode ::= */ -1, /* (7) scalar_value ::= STRING_P */ -1, /* (8) scalar_value ::= NULL_P */ -1, /* (9) scalar_value ::= TRUE_P */ -1, /* (10) scalar_value ::= FALSE_P */ -1, /* (11) scalar_value ::= NUMERIC_P */ -1, /* (12) scalar_value ::= INT_P */ -1, /* (13) scalar_value ::= VARIABLE_P */ -1, /* (14) comp_op ::= EQUAL_P */ -1, /* (15) comp_op ::= NOTEQUAL_P */ -1, /* (16) comp_op ::= LESS_P */ -1, /* (17) comp_op ::= GREATER_P */ -1, /* (18) comp_op ::= LESSEQUAL_P */ -1, /* (19) comp_op ::= GREATEREQUAL_P */ -3, /* (20) delimited_predicate ::= LPAREN predicate RPAREN */ -4, /* (21) delimited_predicate ::= EXISTS_P LPAREN expr RPAREN */ -1, /* (22) predicate ::= delimited_predicate */ -3, /* (23) predicate ::= expr comp_op expr */ -3, /* (24) predicate ::= predicate AND_P predicate */ -3, /* (25) predicate ::= predicate OR_P predicate */ -2, /* (26) predicate ::= NOT_P delimited_predicate */ -5, /* (27) predicate ::= LPAREN predicate RPAREN IS_P UNKNOWN_P */ -4, /* (28) predicate ::= expr STARTS_P WITH_P starts_with_initial */ -3, /* (29) predicate ::= expr LIKE_REGEX_P STRING_P */ -5, /* (30) predicate ::= expr LIKE_REGEX_P STRING_P FLAG_P STRING_P */ -1, /* (31) starts_with_initial ::= STRING_P */ -1, /* (32) starts_with_initial ::= VARIABLE_P */ -1, /* (33) path_primary ::= scalar_value */ -1, /* (34) path_primary ::= DOLLAR */ -1, /* (35) path_primary ::= AT */ -1, /* (36) path_primary ::= LAST_P */ -1, /* (37) accessor_expr ::= path_primary */ -4, /* (38) accessor_expr ::= LPAREN expr RPAREN accessor_op */ -4, /* (39) accessor_expr ::= LPAREN predicate RPAREN accessor_op */ -2, /* (40) accessor_expr ::= accessor_expr accessor_op */ -1, /* (41) expr ::= accessor_expr */ -3, /* (42) expr ::= LPAREN expr RPAREN */ -2, /* (43) expr ::= PLUS expr */ -2, /* (44) expr ::= MINUS expr */ -3, /* (45) expr ::= expr PLUS expr */ -3, /* (46) expr ::= expr MINUS expr */ -3, /* (47) expr ::= expr STAR expr */ -3, /* (48) expr ::= expr SLASH expr */ -3, /* (49) expr ::= expr PERCENT expr */ -1, /* (50) index_elem ::= expr */ -3, /* (51) index_elem ::= expr TO_P expr */ -1, /* (52) index_list ::= index_elem */ -3, /* (53) index_list ::= index_list COMMA index_elem */ -3, /* (54) array_accessor ::= LBRACKET STAR RBRACKET */ -3, /* (55) array_accessor ::= LBRACKET index_list RBRACKET */ -1, /* (56) any_level ::= INT_P */ -1, /* (57) any_level ::= LAST_P */ -1, /* (58) any_path ::= ANY_P */ -4, /* (59) any_path ::= ANY_P LBRACE any_level RBRACE */ -6, /* (60) any_path ::= ANY_P LBRACE any_level TO_P any_level RBRACE */ -2, /* (61) accessor_op ::= DOT key */ -2, /* (62) accessor_op ::= DOT STAR */ -1, /* (63) accessor_op ::= array_accessor */ -2, /* (64) accessor_op ::= DOT any_path */ -4, /* (65) accessor_op ::= DOT method LPAREN RPAREN */ -4, /* (66) accessor_op ::= QUESTION LPAREN predicate RPAREN */ -5, /* (67) accessor_op ::= DOT DECIMAL_P LPAREN opt_csv_list RPAREN */ -5, /* (68) accessor_op ::= DOT DATETIME_P LPAREN opt_datetime_template RPAREN */ -5, /* (69) accessor_op ::= DOT TIME_P LPAREN opt_datetime_precision RPAREN */ -5, /* (70) accessor_op ::= DOT TIME_TZ_P LPAREN opt_datetime_precision RPAREN */ -5, /* (71) accessor_op ::= DOT TIMESTAMP_P LPAREN opt_datetime_precision RPAREN */ -5, /* (72) accessor_op ::= DOT TIMESTAMP_TZ_P LPAREN opt_datetime_precision RPAREN */ -1, /* (73) csv_elem ::= INT_P */ -2, /* (74) csv_elem ::= PLUS INT_P */ -2, /* (75) csv_elem ::= MINUS INT_P */ -1, /* (76) csv_list ::= csv_elem */ -3, /* (77) csv_list ::= csv_list COMMA csv_elem */ -1, /* (78) opt_csv_list ::= csv_list */ 0, /* (79) opt_csv_list ::= */ -1, /* (80) datetime_precision ::= INT_P */ -1, /* (81) opt_datetime_precision ::= datetime_precision */ 0, /* (82) opt_datetime_precision ::= */ -1, /* (83) datetime_template ::= STRING_P */ -1, /* (84) opt_datetime_template ::= datetime_template */ 0, /* (85) opt_datetime_template ::= */ -1, /* (86) key ::= key_name */ -1, /* (87) key_name ::= IDENT_P */ -1, /* (88) key_name ::= STRING_P */ -1, /* (89) key_name ::= TO_P */ -1, /* (90) key_name ::= NULL_P */ -1, /* (91) key_name ::= TRUE_P */ -1, /* (92) key_name ::= FALSE_P */ -1, /* (93) key_name ::= IS_P */ -1, /* (94) key_name ::= UNKNOWN_P */ -1, /* (95) key_name ::= EXISTS_P */ -1, /* (96) key_name ::= STRICT_P */ -1, /* (97) key_name ::= LAX_P */ -1, /* (98) key_name ::= ABS_P */ -1, /* (99) key_name ::= SIZE_P */ -1, /* (100) key_name ::= TYPE_P */ -1, /* (101) key_name ::= FLOOR_P */ -1, /* (102) key_name ::= DOUBLE_P */ -1, /* (103) key_name ::= CEILING_P */ -1, /* (104) key_name ::= DATETIME_P */ -1, /* (105) key_name ::= KEYVALUE_P */ -1, /* (106) key_name ::= LAST_P */ -1, /* (107) key_name ::= STARTS_P */ -1, /* (108) key_name ::= WITH_P */ -1, /* (109) key_name ::= LIKE_REGEX_P */ -1, /* (110) key_name ::= FLAG_P */ -1, /* (111) key_name ::= BIGINT_P */ -1, /* (112) key_name ::= BOOLEAN_P */ -1, /* (113) key_name ::= DATE_P */ -1, /* (114) key_name ::= DECIMAL_P */ -1, /* (115) key_name ::= INTEGER_P */ -1, /* (116) key_name ::= NUMBER_P */ -1, /* (117) key_name ::= STRINGFUNC_P */ -1, /* (118) key_name ::= TIME_P */ -1, /* (119) key_name ::= TIME_TZ_P */ -1, /* (120) key_name ::= TIMESTAMP_P */ -1, /* (121) key_name ::= TIMESTAMP_TZ_P */ -1, /* (122) method ::= ABS_P */ -1, /* (123) method ::= SIZE_P */ -1, /* (124) method ::= TYPE_P */ -1, /* (125) method ::= FLOOR_P */ -1, /* (126) method ::= DOUBLE_P */ -1, /* (127) method ::= CEILING_P */ -1, /* (128) method ::= KEYVALUE_P */ -1, /* (129) method ::= BIGINT_P */ -1, /* (130) method ::= BOOLEAN_P */ -1, /* (131) method ::= DATE_P */ -1, /* (132) method ::= INTEGER_P */ -1, /* (133) method ::= NUMBER_P */ -1, /* (134) method ::= STRINGFUNC_P */ }; 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 */ jsonpathParseTOKENTYPE yyLookaheadToken /* Value of the lookahead token */ jsonpathParseCTX_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 */ jsonpathParseARG_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: /* result ::= mode expr_or_predicate */ #line 198 "examples/jsonpath/jsonpath_gram.lime" { yylhsminor.yy188 = (JsonPathParseResult *)malloc(sizeof(JsonPathParseResult)); yylhsminor.yy188->expr = yymsp[0].minor.yy60; yylhsminor.yy188->lax = yymsp[-1].minor.yy92; pstate->result = yylhsminor.yy188; } #line 1530 "examples/jsonpath/jsonpath_gram.c" yymsp[-1].minor.yy188 = yylhsminor.yy188; break; case 1: /* result ::= */ #line 205 "examples/jsonpath/jsonpath_gram.lime" { yymsp[1].minor.yy188 = NULL; pstate->result = NULL; } #line 1539 "examples/jsonpath/jsonpath_gram.c" break; case 2: /* expr_or_predicate ::= expr */ case 3: /* expr_or_predicate ::= predicate */ yytestcase(yyruleno==3); case 22: /* predicate ::= delimited_predicate */ yytestcase(yyruleno==22); case 33: /* path_primary ::= scalar_value */ yytestcase(yyruleno==33); case 63: /* accessor_op ::= array_accessor */ yytestcase(yyruleno==63); case 81: /* opt_datetime_precision ::= datetime_precision */ yytestcase(yyruleno==81); case 84: /* opt_datetime_template ::= datetime_template */ yytestcase(yyruleno==84); #line 211 "examples/jsonpath/jsonpath_gram.lime" { yylhsminor.yy60 = yymsp[0].minor.yy60; } #line 1550 "examples/jsonpath/jsonpath_gram.c" yymsp[0].minor.yy60 = yylhsminor.yy60; break; case 4: /* mode ::= STRICT_P */ #line 216 "examples/jsonpath/jsonpath_gram.lime" { yymsp[0].minor.yy92 = 0; } #line 1556 "examples/jsonpath/jsonpath_gram.c" break; case 5: /* mode ::= LAX_P */ #line 218 "examples/jsonpath/jsonpath_gram.lime" { yymsp[0].minor.yy92 = 1; } #line 1561 "examples/jsonpath/jsonpath_gram.c" break; case 6: /* mode ::= */ #line 220 "examples/jsonpath/jsonpath_gram.lime" { yymsp[1].minor.yy92 = 1; } #line 1566 "examples/jsonpath/jsonpath_gram.c" break; case 7: /* scalar_value ::= STRING_P */ case 31: /* starts_with_initial ::= STRING_P */ yytestcase(yyruleno==31); case 83: /* datetime_template ::= STRING_P */ yytestcase(yyruleno==83); #line 223 "examples/jsonpath/jsonpath_gram.lime" { yylhsminor.yy60 = makeItemString(&yymsp[0].minor.yy0.str); } #line 1573 "examples/jsonpath/jsonpath_gram.c" yymsp[0].minor.yy60 = yylhsminor.yy60; break; case 8: /* scalar_value ::= NULL_P */ #line 225 "examples/jsonpath/jsonpath_gram.lime" { yymsp[0].minor.yy60 = makeItemString(NULL); } #line 1579 "examples/jsonpath/jsonpath_gram.c" break; case 9: /* scalar_value ::= TRUE_P */ #line 227 "examples/jsonpath/jsonpath_gram.lime" { yymsp[0].minor.yy60 = makeItemBool(true); } #line 1584 "examples/jsonpath/jsonpath_gram.c" break; case 10: /* scalar_value ::= FALSE_P */ #line 229 "examples/jsonpath/jsonpath_gram.lime" { yymsp[0].minor.yy60 = makeItemBool(false); } #line 1589 "examples/jsonpath/jsonpath_gram.c" break; case 11: /* scalar_value ::= NUMERIC_P */ case 12: /* scalar_value ::= INT_P */ yytestcase(yyruleno==12); case 80: /* datetime_precision ::= INT_P */ yytestcase(yyruleno==80); #line 231 "examples/jsonpath/jsonpath_gram.lime" { yylhsminor.yy60 = makeItemNumeric(&yymsp[0].minor.yy0.str); } #line 1596 "examples/jsonpath/jsonpath_gram.c" yymsp[0].minor.yy60 = yylhsminor.yy60; break; case 13: /* scalar_value ::= VARIABLE_P */ case 32: /* starts_with_initial ::= VARIABLE_P */ yytestcase(yyruleno==32); #line 235 "examples/jsonpath/jsonpath_gram.lime" { yylhsminor.yy60 = makeItemVariable(&yymsp[0].minor.yy0.str); } #line 1603 "examples/jsonpath/jsonpath_gram.c" yymsp[0].minor.yy60 = yylhsminor.yy60; break; case 14: /* comp_op ::= EQUAL_P */ #line 238 "examples/jsonpath/jsonpath_gram.lime" { yymsp[0].minor.yy117 = jpiEqual; } #line 1609 "examples/jsonpath/jsonpath_gram.c" break; case 15: /* comp_op ::= NOTEQUAL_P */ #line 240 "examples/jsonpath/jsonpath_gram.lime" { yymsp[0].minor.yy117 = jpiNotEqual; } #line 1614 "examples/jsonpath/jsonpath_gram.c" break; case 16: /* comp_op ::= LESS_P */ #line 242 "examples/jsonpath/jsonpath_gram.lime" { yymsp[0].minor.yy117 = jpiLess; } #line 1619 "examples/jsonpath/jsonpath_gram.c" break; case 17: /* comp_op ::= GREATER_P */ #line 244 "examples/jsonpath/jsonpath_gram.lime" { yymsp[0].minor.yy117 = jpiGreater; } #line 1624 "examples/jsonpath/jsonpath_gram.c" break; case 18: /* comp_op ::= LESSEQUAL_P */ #line 246 "examples/jsonpath/jsonpath_gram.lime" { yymsp[0].minor.yy117 = jpiLessOrEqual; } #line 1629 "examples/jsonpath/jsonpath_gram.c" break; case 19: /* comp_op ::= GREATEREQUAL_P */ #line 248 "examples/jsonpath/jsonpath_gram.lime" { yymsp[0].minor.yy117 = jpiGreaterOrEqual; } #line 1634 "examples/jsonpath/jsonpath_gram.c" break; case 20: /* delimited_predicate ::= LPAREN predicate RPAREN */ case 42: /* expr ::= LPAREN expr RPAREN */ yytestcase(yyruleno==42); #line 251 "examples/jsonpath/jsonpath_gram.lime" { yymsp[-2].minor.yy60 = yymsp[-1].minor.yy60; } #line 1640 "examples/jsonpath/jsonpath_gram.c" break; case 21: /* delimited_predicate ::= EXISTS_P LPAREN expr RPAREN */ #line 253 "examples/jsonpath/jsonpath_gram.lime" { yymsp[-3].minor.yy60 = makeItemUnary(jpiExists, yymsp[-1].minor.yy60); } #line 1647 "examples/jsonpath/jsonpath_gram.c" break; case 23: /* predicate ::= expr comp_op expr */ #line 260 "examples/jsonpath/jsonpath_gram.lime" { yylhsminor.yy60 = makeItemBinary(yymsp[-1].minor.yy117, yymsp[-2].minor.yy60, yymsp[0].minor.yy60); } #line 1654 "examples/jsonpath/jsonpath_gram.c" yymsp[-2].minor.yy60 = yylhsminor.yy60; break; case 24: /* predicate ::= predicate AND_P predicate */ #line 264 "examples/jsonpath/jsonpath_gram.lime" { yylhsminor.yy60 = makeItemBinary(jpiAnd, yymsp[-2].minor.yy60, yymsp[0].minor.yy60); } #line 1662 "examples/jsonpath/jsonpath_gram.c" yymsp[-2].minor.yy60 = yylhsminor.yy60; break; case 25: /* predicate ::= predicate OR_P predicate */ #line 268 "examples/jsonpath/jsonpath_gram.lime" { yylhsminor.yy60 = makeItemBinary(jpiOr, yymsp[-2].minor.yy60, yymsp[0].minor.yy60); } #line 1670 "examples/jsonpath/jsonpath_gram.c" yymsp[-2].minor.yy60 = yylhsminor.yy60; break; case 26: /* predicate ::= NOT_P delimited_predicate */ #line 272 "examples/jsonpath/jsonpath_gram.lime" { yymsp[-1].minor.yy60 = makeItemUnary(jpiNot, yymsp[0].minor.yy60); } #line 1678 "examples/jsonpath/jsonpath_gram.c" break; case 27: /* predicate ::= LPAREN predicate RPAREN IS_P UNKNOWN_P */ #line 276 "examples/jsonpath/jsonpath_gram.lime" { yymsp[-4].minor.yy60 = makeItemUnary(jpiIsUnknown, yymsp[-3].minor.yy60); } #line 1685 "examples/jsonpath/jsonpath_gram.c" break; case 28: /* predicate ::= expr STARTS_P WITH_P starts_with_initial */ #line 280 "examples/jsonpath/jsonpath_gram.lime" { yylhsminor.yy60 = makeItemBinary(jpiStartsWith, yymsp[-3].minor.yy60, yymsp[0].minor.yy60); } #line 1692 "examples/jsonpath/jsonpath_gram.c" yymsp[-3].minor.yy60 = yylhsminor.yy60; break; case 29: /* predicate ::= expr LIKE_REGEX_P STRING_P */ #line 284 "examples/jsonpath/jsonpath_gram.lime" { JsonPathParseItem *jppitem; char *errMsg = NULL; if (!makeItemLikeRegex(yymsp[-2].minor.yy60, &yymsp[0].minor.yy0.str, NULL, &jppitem, &errMsg)) { pstate->error = 1; pstate->errMsg = errMsg ? errMsg : "invalid LIKE_REGEX"; } yylhsminor.yy60 = jppitem; } #line 1706 "examples/jsonpath/jsonpath_gram.c" yymsp[-2].minor.yy60 = yylhsminor.yy60; break; case 30: /* predicate ::= expr LIKE_REGEX_P STRING_P FLAG_P STRING_P */ #line 294 "examples/jsonpath/jsonpath_gram.lime" { JsonPathParseItem *jppitem; char *errMsg = NULL; if (!makeItemLikeRegex(yymsp[-4].minor.yy60, &yymsp[-2].minor.yy0.str, &yymsp[0].minor.yy0.str, &jppitem, &errMsg)) { pstate->error = 1; pstate->errMsg = errMsg ? errMsg : "invalid LIKE_REGEX with flags"; } yylhsminor.yy60 = jppitem; } #line 1720 "examples/jsonpath/jsonpath_gram.c" yymsp[-4].minor.yy60 = yylhsminor.yy60; break; case 34: /* path_primary ::= DOLLAR */ #line 312 "examples/jsonpath/jsonpath_gram.lime" { yymsp[0].minor.yy60 = makeItemType(jpiRoot); } #line 1726 "examples/jsonpath/jsonpath_gram.c" break; case 35: /* path_primary ::= AT */ #line 314 "examples/jsonpath/jsonpath_gram.lime" { yymsp[0].minor.yy60 = makeItemType(jpiCurrent); } #line 1731 "examples/jsonpath/jsonpath_gram.c" break; case 36: /* path_primary ::= LAST_P */ #line 316 "examples/jsonpath/jsonpath_gram.lime" { yymsp[0].minor.yy60 = makeItemType(jpiLast); } #line 1736 "examples/jsonpath/jsonpath_gram.c" break; case 37: /* accessor_expr ::= path_primary */ #line 319 "examples/jsonpath/jsonpath_gram.lime" { yylhsminor.yy106 = jp_list_make1(yymsp[0].minor.yy60); } #line 1743 "examples/jsonpath/jsonpath_gram.c" yymsp[0].minor.yy106 = yylhsminor.yy106; break; case 38: /* accessor_expr ::= LPAREN expr RPAREN accessor_op */ case 39: /* accessor_expr ::= LPAREN predicate RPAREN accessor_op */ yytestcase(yyruleno==39); #line 323 "examples/jsonpath/jsonpath_gram.lime" { yymsp[-3].minor.yy106 = jp_list_make2(yymsp[-2].minor.yy60, yymsp[0].minor.yy60); } #line 1752 "examples/jsonpath/jsonpath_gram.c" break; case 40: /* accessor_expr ::= accessor_expr accessor_op */ #line 331 "examples/jsonpath/jsonpath_gram.lime" { yylhsminor.yy106 = jp_list_append(yymsp[-1].minor.yy106, yymsp[0].minor.yy60); } #line 1759 "examples/jsonpath/jsonpath_gram.c" yymsp[-1].minor.yy106 = yylhsminor.yy106; break; case 41: /* expr ::= accessor_expr */ #line 336 "examples/jsonpath/jsonpath_gram.lime" { yylhsminor.yy60 = makeItemList(yymsp[0].minor.yy106); } #line 1765 "examples/jsonpath/jsonpath_gram.c" yymsp[0].minor.yy60 = yylhsminor.yy60; break; case 43: /* expr ::= PLUS expr */ #line 340 "examples/jsonpath/jsonpath_gram.lime" { yymsp[-1].minor.yy60 = makeItemUnary(jpiPlus, yymsp[0].minor.yy60); } #line 1771 "examples/jsonpath/jsonpath_gram.c" break; case 44: /* expr ::= MINUS expr */ #line 342 "examples/jsonpath/jsonpath_gram.lime" { yymsp[-1].minor.yy60 = makeItemUnary(jpiMinus, yymsp[0].minor.yy60); } #line 1776 "examples/jsonpath/jsonpath_gram.c" break; case 45: /* expr ::= expr PLUS expr */ #line 344 "examples/jsonpath/jsonpath_gram.lime" { yylhsminor.yy60 = makeItemBinary(jpiAdd, yymsp[-2].minor.yy60, yymsp[0].minor.yy60); } #line 1781 "examples/jsonpath/jsonpath_gram.c" yymsp[-2].minor.yy60 = yylhsminor.yy60; break; case 46: /* expr ::= expr MINUS expr */ #line 346 "examples/jsonpath/jsonpath_gram.lime" { yylhsminor.yy60 = makeItemBinary(jpiSub, yymsp[-2].minor.yy60, yymsp[0].minor.yy60); } #line 1787 "examples/jsonpath/jsonpath_gram.c" yymsp[-2].minor.yy60 = yylhsminor.yy60; break; case 47: /* expr ::= expr STAR expr */ #line 348 "examples/jsonpath/jsonpath_gram.lime" { yylhsminor.yy60 = makeItemBinary(jpiMul, yymsp[-2].minor.yy60, yymsp[0].minor.yy60); } #line 1793 "examples/jsonpath/jsonpath_gram.c" yymsp[-2].minor.yy60 = yylhsminor.yy60; break; case 48: /* expr ::= expr SLASH expr */ #line 350 "examples/jsonpath/jsonpath_gram.lime" { yylhsminor.yy60 = makeItemBinary(jpiDiv, yymsp[-2].minor.yy60, yymsp[0].minor.yy60); } #line 1799 "examples/jsonpath/jsonpath_gram.c" yymsp[-2].minor.yy60 = yylhsminor.yy60; break; case 49: /* expr ::= expr PERCENT expr */ #line 352 "examples/jsonpath/jsonpath_gram.lime" { yylhsminor.yy60 = makeItemBinary(jpiMod, yymsp[-2].minor.yy60, yymsp[0].minor.yy60); } #line 1805 "examples/jsonpath/jsonpath_gram.c" yymsp[-2].minor.yy60 = yylhsminor.yy60; break; case 50: /* index_elem ::= expr */ #line 355 "examples/jsonpath/jsonpath_gram.lime" { yylhsminor.yy60 = makeItemBinary(jpiSubscript, yymsp[0].minor.yy60, NULL); } #line 1813 "examples/jsonpath/jsonpath_gram.c" yymsp[0].minor.yy60 = yylhsminor.yy60; break; case 51: /* index_elem ::= expr TO_P expr */ #line 359 "examples/jsonpath/jsonpath_gram.lime" { yylhsminor.yy60 = makeItemBinary(jpiSubscript, yymsp[-2].minor.yy60, yymsp[0].minor.yy60); } #line 1821 "examples/jsonpath/jsonpath_gram.c" yymsp[-2].minor.yy60 = yylhsminor.yy60; break; case 52: /* index_list ::= index_elem */ case 76: /* csv_list ::= csv_elem */ yytestcase(yyruleno==76); #line 364 "examples/jsonpath/jsonpath_gram.lime" { yylhsminor.yy106 = jp_list_make1(yymsp[0].minor.yy60); } #line 1828 "examples/jsonpath/jsonpath_gram.c" yymsp[0].minor.yy106 = yylhsminor.yy106; break; case 53: /* index_list ::= index_list COMMA index_elem */ case 77: /* csv_list ::= csv_list COMMA csv_elem */ yytestcase(yyruleno==77); #line 366 "examples/jsonpath/jsonpath_gram.lime" { yylhsminor.yy106 = jp_list_append(yymsp[-2].minor.yy106, yymsp[0].minor.yy60); } #line 1837 "examples/jsonpath/jsonpath_gram.c" yymsp[-2].minor.yy106 = yylhsminor.yy106; break; case 54: /* array_accessor ::= LBRACKET STAR RBRACKET */ #line 371 "examples/jsonpath/jsonpath_gram.lime" { yymsp[-2].minor.yy60 = makeItemType(jpiAnyArray); } #line 1845 "examples/jsonpath/jsonpath_gram.c" break; case 55: /* array_accessor ::= LBRACKET index_list RBRACKET */ #line 375 "examples/jsonpath/jsonpath_gram.lime" { yymsp[-2].minor.yy60 = makeIndexArray(yymsp[-1].minor.yy106); } #line 1852 "examples/jsonpath/jsonpath_gram.c" break; case 56: /* any_level ::= INT_P */ #line 380 "examples/jsonpath/jsonpath_gram.lime" { yylhsminor.yy92 = jp_strtoint32(yymsp[0].minor.yy0.str.val); } #line 1857 "examples/jsonpath/jsonpath_gram.c" yymsp[0].minor.yy92 = yylhsminor.yy92; break; case 57: /* any_level ::= LAST_P */ #line 382 "examples/jsonpath/jsonpath_gram.lime" { yymsp[0].minor.yy92 = -1; } #line 1863 "examples/jsonpath/jsonpath_gram.c" break; case 58: /* any_path ::= ANY_P */ #line 385 "examples/jsonpath/jsonpath_gram.lime" { yymsp[0].minor.yy60 = makeAny(0, -1); } #line 1868 "examples/jsonpath/jsonpath_gram.c" break; case 59: /* any_path ::= ANY_P LBRACE any_level RBRACE */ #line 387 "examples/jsonpath/jsonpath_gram.lime" { yymsp[-3].minor.yy60 = makeAny(yymsp[-1].minor.yy92, yymsp[-1].minor.yy92); } #line 1875 "examples/jsonpath/jsonpath_gram.c" break; case 60: /* any_path ::= ANY_P LBRACE any_level TO_P any_level RBRACE */ #line 391 "examples/jsonpath/jsonpath_gram.lime" { yymsp[-5].minor.yy60 = makeAny(yymsp[-3].minor.yy92, yymsp[-1].minor.yy92); } #line 1882 "examples/jsonpath/jsonpath_gram.c" break; case 61: /* accessor_op ::= DOT key */ case 64: /* accessor_op ::= DOT any_path */ yytestcase(yyruleno==64); #line 396 "examples/jsonpath/jsonpath_gram.lime" { yymsp[-1].minor.yy60 = yymsp[0].minor.yy60; } #line 1888 "examples/jsonpath/jsonpath_gram.c" break; case 62: /* accessor_op ::= DOT STAR */ #line 398 "examples/jsonpath/jsonpath_gram.lime" { yymsp[-1].minor.yy60 = makeItemType(jpiAnyKey); } #line 1893 "examples/jsonpath/jsonpath_gram.c" break; case 65: /* accessor_op ::= DOT method LPAREN RPAREN */ #line 404 "examples/jsonpath/jsonpath_gram.lime" { yymsp[-3].minor.yy60 = makeItemType(yymsp[-2].minor.yy117); } #line 1900 "examples/jsonpath/jsonpath_gram.c" break; case 66: /* accessor_op ::= QUESTION LPAREN predicate RPAREN */ #line 408 "examples/jsonpath/jsonpath_gram.lime" { yymsp[-3].minor.yy60 = makeItemUnary(jpiFilter, yymsp[-1].minor.yy60); } #line 1907 "examples/jsonpath/jsonpath_gram.c" break; case 67: /* accessor_op ::= DOT DECIMAL_P LPAREN opt_csv_list RPAREN */ #line 412 "examples/jsonpath/jsonpath_gram.lime" { int len = jp_list_length(yymsp[-1].minor.yy106); if (len == 0) yymsp[-4].minor.yy60 = makeItemBinary(jpiDecimal, NULL, NULL); else if (len == 1) yymsp[-4].minor.yy60 = makeItemBinary(jpiDecimal, (JsonPathParseItem *)jp_list_first(yymsp[-1].minor.yy106), NULL); else if (len == 2) yymsp[-4].minor.yy60 = makeItemBinary(jpiDecimal, (JsonPathParseItem *)jp_list_first(yymsp[-1].minor.yy106), (JsonPathParseItem *)jp_list_second(yymsp[-1].minor.yy106)); else { pstate->error = 1; pstate->errMsg = ".decimal() can only have an optional precision[,scale]."; yymsp[-4].minor.yy60 = NULL; } } #line 1927 "examples/jsonpath/jsonpath_gram.c" break; case 68: /* accessor_op ::= DOT DATETIME_P LPAREN opt_datetime_template RPAREN */ #line 429 "examples/jsonpath/jsonpath_gram.lime" { yymsp[-4].minor.yy60 = makeItemUnary(jpiDatetime, yymsp[-1].minor.yy60); } #line 1934 "examples/jsonpath/jsonpath_gram.c" break; case 69: /* accessor_op ::= DOT TIME_P LPAREN opt_datetime_precision RPAREN */ #line 433 "examples/jsonpath/jsonpath_gram.lime" { yymsp[-4].minor.yy60 = makeItemUnary(jpiTime, yymsp[-1].minor.yy60); } #line 1941 "examples/jsonpath/jsonpath_gram.c" break; case 70: /* accessor_op ::= DOT TIME_TZ_P LPAREN opt_datetime_precision RPAREN */ #line 437 "examples/jsonpath/jsonpath_gram.lime" { yymsp[-4].minor.yy60 = makeItemUnary(jpiTimeTz, yymsp[-1].minor.yy60); } #line 1948 "examples/jsonpath/jsonpath_gram.c" break; case 71: /* accessor_op ::= DOT TIMESTAMP_P LPAREN opt_datetime_precision RPAREN */ #line 441 "examples/jsonpath/jsonpath_gram.lime" { yymsp[-4].minor.yy60 = makeItemUnary(jpiTimestamp, yymsp[-1].minor.yy60); } #line 1955 "examples/jsonpath/jsonpath_gram.c" break; case 72: /* accessor_op ::= DOT TIMESTAMP_TZ_P LPAREN opt_datetime_precision RPAREN */ #line 445 "examples/jsonpath/jsonpath_gram.lime" { yymsp[-4].minor.yy60 = makeItemUnary(jpiTimestampTz, yymsp[-1].minor.yy60); } #line 1962 "examples/jsonpath/jsonpath_gram.c" break; case 73: /* csv_elem ::= INT_P */ #line 450 "examples/jsonpath/jsonpath_gram.lime" { yylhsminor.yy60 = makeItemNumeric(&yymsp[0].minor.yy0.str); } #line 1969 "examples/jsonpath/jsonpath_gram.c" yymsp[0].minor.yy60 = yylhsminor.yy60; break; case 74: /* csv_elem ::= PLUS INT_P */ #line 454 "examples/jsonpath/jsonpath_gram.lime" { yymsp[-1].minor.yy60 = makeItemUnary(jpiPlus, makeItemNumeric(&yymsp[0].minor.yy0.str)); } #line 1977 "examples/jsonpath/jsonpath_gram.c" break; case 75: /* csv_elem ::= MINUS INT_P */ #line 458 "examples/jsonpath/jsonpath_gram.lime" { yymsp[-1].minor.yy60 = makeItemUnary(jpiMinus, makeItemNumeric(&yymsp[0].minor.yy0.str)); } #line 1984 "examples/jsonpath/jsonpath_gram.c" break; case 78: /* opt_csv_list ::= csv_list */ #line 470 "examples/jsonpath/jsonpath_gram.lime" { yylhsminor.yy106 = yymsp[0].minor.yy106; } #line 1989 "examples/jsonpath/jsonpath_gram.c" yymsp[0].minor.yy106 = yylhsminor.yy106; break; case 79: /* opt_csv_list ::= */ #line 472 "examples/jsonpath/jsonpath_gram.lime" { yymsp[1].minor.yy106 = NULL; } #line 1995 "examples/jsonpath/jsonpath_gram.c" break; case 82: /* opt_datetime_precision ::= */ case 85: /* opt_datetime_template ::= */ yytestcase(yyruleno==85); #line 480 "examples/jsonpath/jsonpath_gram.lime" { yymsp[1].minor.yy60 = NULL; } #line 2001 "examples/jsonpath/jsonpath_gram.c" break; case 86: /* key ::= key_name */ #line 491 "examples/jsonpath/jsonpath_gram.lime" { yylhsminor.yy60 = makeItemKey(&yymsp[0].minor.yy23); } #line 2006 "examples/jsonpath/jsonpath_gram.c" yymsp[0].minor.yy60 = yylhsminor.yy60; break; case 87: /* key_name ::= IDENT_P */ case 88: /* key_name ::= STRING_P */ yytestcase(yyruleno==88); case 89: /* key_name ::= TO_P */ yytestcase(yyruleno==89); case 90: /* key_name ::= NULL_P */ yytestcase(yyruleno==90); case 91: /* key_name ::= TRUE_P */ yytestcase(yyruleno==91); case 92: /* key_name ::= FALSE_P */ yytestcase(yyruleno==92); case 93: /* key_name ::= IS_P */ yytestcase(yyruleno==93); case 94: /* key_name ::= UNKNOWN_P */ yytestcase(yyruleno==94); case 95: /* key_name ::= EXISTS_P */ yytestcase(yyruleno==95); case 96: /* key_name ::= STRICT_P */ yytestcase(yyruleno==96); case 97: /* key_name ::= LAX_P */ yytestcase(yyruleno==97); case 98: /* key_name ::= ABS_P */ yytestcase(yyruleno==98); case 99: /* key_name ::= SIZE_P */ yytestcase(yyruleno==99); case 100: /* key_name ::= TYPE_P */ yytestcase(yyruleno==100); case 101: /* key_name ::= FLOOR_P */ yytestcase(yyruleno==101); case 102: /* key_name ::= DOUBLE_P */ yytestcase(yyruleno==102); case 103: /* key_name ::= CEILING_P */ yytestcase(yyruleno==103); case 104: /* key_name ::= DATETIME_P */ yytestcase(yyruleno==104); case 105: /* key_name ::= KEYVALUE_P */ yytestcase(yyruleno==105); case 106: /* key_name ::= LAST_P */ yytestcase(yyruleno==106); case 107: /* key_name ::= STARTS_P */ yytestcase(yyruleno==107); case 108: /* key_name ::= WITH_P */ yytestcase(yyruleno==108); case 109: /* key_name ::= LIKE_REGEX_P */ yytestcase(yyruleno==109); case 110: /* key_name ::= FLAG_P */ yytestcase(yyruleno==110); case 111: /* key_name ::= BIGINT_P */ yytestcase(yyruleno==111); case 112: /* key_name ::= BOOLEAN_P */ yytestcase(yyruleno==112); case 113: /* key_name ::= DATE_P */ yytestcase(yyruleno==113); case 114: /* key_name ::= DECIMAL_P */ yytestcase(yyruleno==114); case 115: /* key_name ::= INTEGER_P */ yytestcase(yyruleno==115); case 116: /* key_name ::= NUMBER_P */ yytestcase(yyruleno==116); case 117: /* key_name ::= STRINGFUNC_P */ yytestcase(yyruleno==117); case 118: /* key_name ::= TIME_P */ yytestcase(yyruleno==118); case 119: /* key_name ::= TIME_TZ_P */ yytestcase(yyruleno==119); case 120: /* key_name ::= TIMESTAMP_P */ yytestcase(yyruleno==120); case 121: /* key_name ::= TIMESTAMP_TZ_P */ yytestcase(yyruleno==121); #line 496 "examples/jsonpath/jsonpath_gram.lime" { yylhsminor.yy23 = yymsp[0].minor.yy0.str; } #line 2046 "examples/jsonpath/jsonpath_gram.c" yymsp[0].minor.yy23 = yylhsminor.yy23; break; case 122: /* method ::= ABS_P */ #line 533 "examples/jsonpath/jsonpath_gram.lime" { yymsp[0].minor.yy117 = jpiAbs; } #line 2052 "examples/jsonpath/jsonpath_gram.c" break; case 123: /* method ::= SIZE_P */ #line 534 "examples/jsonpath/jsonpath_gram.lime" { yymsp[0].minor.yy117 = jpiSize; } #line 2057 "examples/jsonpath/jsonpath_gram.c" break; case 124: /* method ::= TYPE_P */ #line 535 "examples/jsonpath/jsonpath_gram.lime" { yymsp[0].minor.yy117 = jpiType; } #line 2062 "examples/jsonpath/jsonpath_gram.c" break; case 125: /* method ::= FLOOR_P */ #line 536 "examples/jsonpath/jsonpath_gram.lime" { yymsp[0].minor.yy117 = jpiFloor; } #line 2067 "examples/jsonpath/jsonpath_gram.c" break; case 126: /* method ::= DOUBLE_P */ #line 537 "examples/jsonpath/jsonpath_gram.lime" { yymsp[0].minor.yy117 = jpiDouble; } #line 2072 "examples/jsonpath/jsonpath_gram.c" break; case 127: /* method ::= CEILING_P */ #line 538 "examples/jsonpath/jsonpath_gram.lime" { yymsp[0].minor.yy117 = jpiCeiling; } #line 2077 "examples/jsonpath/jsonpath_gram.c" break; case 128: /* method ::= KEYVALUE_P */ #line 539 "examples/jsonpath/jsonpath_gram.lime" { yymsp[0].minor.yy117 = jpiKeyValue; } #line 2082 "examples/jsonpath/jsonpath_gram.c" break; case 129: /* method ::= BIGINT_P */ #line 540 "examples/jsonpath/jsonpath_gram.lime" { yymsp[0].minor.yy117 = jpiBigint; } #line 2087 "examples/jsonpath/jsonpath_gram.c" break; case 130: /* method ::= BOOLEAN_P */ #line 541 "examples/jsonpath/jsonpath_gram.lime" { yymsp[0].minor.yy117 = jpiBoolean; } #line 2092 "examples/jsonpath/jsonpath_gram.c" break; case 131: /* method ::= DATE_P */ #line 542 "examples/jsonpath/jsonpath_gram.lime" { yymsp[0].minor.yy117 = jpiDate; } #line 2097 "examples/jsonpath/jsonpath_gram.c" break; case 132: /* method ::= INTEGER_P */ #line 543 "examples/jsonpath/jsonpath_gram.lime" { yymsp[0].minor.yy117 = jpiInteger; } #line 2102 "examples/jsonpath/jsonpath_gram.c" break; case 133: /* method ::= NUMBER_P */ #line 544 "examples/jsonpath/jsonpath_gram.lime" { yymsp[0].minor.yy117 = jpiNumber; } #line 2107 "examples/jsonpath/jsonpath_gram.c" break; case 134: /* method ::= STRINGFUNC_P */ #line 545 "examples/jsonpath/jsonpath_gram.lime" { yymsp[0].minor.yy117 = jpiStringFunc; } #line 2112 "examples/jsonpath/jsonpath_gram.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 */ ){ jsonpathParseARG_FETCH jsonpathParseCTX_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/jsonpath/jsonpath_gram.lime" pstate->error = 1; if (pstate->errMsg == NULL) { pstate->errMsg = "jsonpath parse failure"; } #line 2162 "examples/jsonpath/jsonpath_gram.c" /************ End %parse_failure code *****************************************/ jsonpathParseARG_STORE /* Suppress warning about unused %extra_argument variable */ jsonpathParseCTX_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 */ jsonpathParseTOKENTYPE yyminor /* The minor type of the error token */ #ifdef YYLOCATIONTYPE ,YYLOCATIONTYPE yyloc /* Source location of the error token */ #endif ){ jsonpathParseARG_FETCH jsonpathParseCTX_FETCH #define TOKEN yyminor #ifdef YYLOCATIONTYPE #define TOKEN_LOC yyloc #endif /************ Begin %syntax_error code ****************************************/ #line 48 "examples/jsonpath/jsonpath_gram.lime" pstate->error = 1; if (pstate->errMsg == NULL) { pstate->errMsg = "syntax error in jsonpath"; } #line 2193 "examples/jsonpath/jsonpath_gram.c" /************ End %syntax_error code ******************************************/ jsonpathParseARG_STORE /* Suppress warning about unused %extra_argument variable */ jsonpathParseCTX_STORE } /* ** The following is executed when the parser accepts */ static void yy_accept( yyParser *yypParser /* The parser */ ){ jsonpathParseARG_FETCH jsonpathParseCTX_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 *******************************************/ jsonpathParseARG_STORE /* Suppress warning about unused %extra_argument variable */ jsonpathParseCTX_STORE } /* The main parser program. ** The first argument is a pointer to a structure obtained from ** "jsonpathParseAlloc" 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 jsonpathParse( void *yyp, /* The parser */ int yymajor, /* The major token code number */ jsonpathParseTOKENTYPE yyminor /* The value for the token */ jsonpathParseARG_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 */ jsonpathParseCTX_FETCH jsonpathParseARG_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 jsonpathParseCTX_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 jsonpathParse(). ** Same as jsonpathParse() 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 jsonpathParseLoc( void *yyp, /* The parser */ int yymajor, /* The major token code number */ jsonpathParseTOKENTYPE yyminor, /* The value for the token */ YYLOCATIONTYPE yyloc /* Source location of the token */ jsonpathParseARG_PDECL /* Optional %extra_argument parameter */ ){ yyParser *yypParser = (yyParser*)yyp; /* Store the location for the next shift */ jsonpathParse(yyp, yymajor, yyminor jsonpathParseARG_PARAM); /* After jsonpathParse 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 jsonpathParseFallback(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 *jsonpathParseExpectedTokens(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; }