/* This file is automatically generated by Lemon from input grammar ** source file "xpath.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 181 "xpath.lime" #include #include #include #include #include #include "xpath_internal.h" #include "xpath_helpers.h" #line 39 "xpath.c" /**************** End of %include directives **********************************/ /* These constants specify the various numeric values for terminal symbols. ***************** Begin token definitions *************************************/ #ifndef SLASH #define SLASH 1 #define DOUBLE_SLASH 2 #define DOT 3 #define DOUBLE_DOT 4 #define AT 5 #define COMMA 6 #define COLON_COLON 7 #define LPAREN 8 #define RPAREN 9 #define LBRACKET 10 #define RBRACKET 11 #define PLUS 12 #define MINUS 13 #define STAR 14 #define PIPE 15 #define EQUALS 16 #define NOT_EQUALS 17 #define LESS_THAN 18 #define LESS_EQUAL 19 #define GREATER_THAN 20 #define GREATER_EQUAL 21 #define DOLLAR 22 #define KW_OR 23 #define KW_AND 24 #define KW_DIV 25 #define KW_MOD 26 #define AXIS_ANCESTOR 27 #define AXIS_ANCESTOR_OR_SELF 28 #define AXIS_ATTRIBUTE 29 #define AXIS_CHILD 30 #define AXIS_DESCENDANT 31 #define AXIS_DESCENDANT_OR_SELF 32 #define AXIS_FOLLOWING 33 #define AXIS_FOLLOWING_SIBLING 34 #define AXIS_NAMESPACE 35 #define AXIS_PARENT 36 #define AXIS_PRECEDING 37 #define AXIS_PRECEDING_SIBLING 38 #define AXIS_SELF 39 #define NODE_TYPE_COMMENT 40 #define NODE_TYPE_TEXT 41 #define NODE_TYPE_PI 42 #define NODE_TYPE_NODE 43 #define LITERAL 44 #define NUMBER 45 #define NAME_TEST 46 #define FUNCTION_NAME 47 #define VARIABLE_REF 48 #define LONE_SLASH 49 #define UMINUS 50 #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. ** xpathParseTOKENTYPE 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 xpathParseTOKENTYPE. 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() ** xpathParseARG_SDECL A static variable declaration for the %extra_argument ** xpathParseARG_PDECL A parameter declaration for the %extra_argument ** xpathParseARG_PARAM Code to pass %extra_argument as a subroutine parameter ** xpathParseARG_STORE Code to store %extra_argument into yypParser ** xpathParseARG_FETCH Code to extract %extra_argument from yypParser ** xpathParseCTX_* As xpathParseARG_ 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 77 #define YYACTIONTYPE unsigned short int #define xpathParseTOKENTYPE XPathToken typedef union { int yyinit; xpathParseTOKENTYPE yy0; XPathAxisType yy25; XPathNodeList * yy34; XPathNode * yy106; } YYMINORTYPE; #ifndef YYSTACKDEPTH #define YYSTACKDEPTH 100 #endif #define xpathParseARG_SDECL XPathParseState *pstate; #define xpathParseARG_PDECL ,XPathParseState *pstate #define xpathParseARG_PARAM ,pstate #define xpathParseARG_FETCH XPathParseState *pstate=yypParser->pstate; #define xpathParseARG_STORE yypParser->pstate=pstate; #undef YYREALLOC #define YYREALLOC realloc #undef YYFREE #define YYFREE free #undef YYDYNSTACK #define YYDYNSTACK 0 #undef YYSIZELIMIT #define xpathParseCTX(P) 0 #define xpathParseCTX_SDECL #define xpathParseCTX_PDECL #define xpathParseCTX_PARAM #define xpathParseCTX_FETCH #define xpathParseCTX_STORE #undef YYERRORSYMBOL #undef YYERRSYMDT #undef YYFALLBACK #define YYNSTATE 70 #define YYNRULE 79 #define YYNRULE_WITH_ACTION 79 #define YYNTOKEN 51 #define YY_MAX_SHIFT 69 #define YY_MIN_SHIFTREDUCE 119 #define YY_MAX_SHIFTREDUCE 197 #define YY_ERROR_ACTION 198 #define YY_ACCEPT_ACTION 199 #define YY_NO_ACTION 200 #define YY_MIN_REDUCE 201 #define YY_MAX_REDUCE 279 #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 (552) static const YYACTIONTYPE yy_action[] = { /* 0 */ 31, 22, 21, 186, 187, 162, 231, 267, 3, 28, /* 10 */ 25, 24, 29, 16, 177, 38, 237, 26, 64, 30, /* 20 */ 8, 7, 242, 12, 11, 10, 9, 166, 175, 171, /* 30 */ 163, 164, 174, 169, 167, 172, 165, 170, 168, 173, /* 40 */ 63, 61, 59, 57, 190, 191, 176, 55, 188, 22, /* 50 */ 21, 186, 187, 162, 23, 20, 3, 42, 237, 26, /* 60 */ 64, 30, 177, 4, 242, 4, 189, 43, 237, 26, /* 70 */ 64, 30, 14, 13, 242, 166, 175, 171, 163, 164, /* 80 */ 174, 169, 167, 172, 165, 170, 168, 173, 63, 61, /* 90 */ 59, 57, 190, 191, 176, 55, 188, 278, 68, 65, /* 100 */ 47, 32, 40, 35, 218, 66, 224, 27, 226, 233, /* 110 */ 45, 237, 26, 64, 30, 183, 180, 242, 230, 274, /* 120 */ 54, 53, 2, 193, 182, 1, 56, 199, 69, 68, /* 130 */ 65, 47, 32, 40, 35, 218, 66, 224, 27, 226, /* 140 */ 233, 45, 237, 26, 64, 30, 181, 44, 242, 230, /* 150 */ 274, 58, 186, 187, 162, 48, 237, 26, 64, 30, /* 160 */ 18, 179, 242, 177, 239, 26, 64, 30, 60, 62, /* 170 */ 242, 17, 15, 178, 161, 6, 166, 175, 171, 163, /* 180 */ 164, 174, 169, 167, 172, 165, 170, 168, 173, 63, /* 190 */ 61, 59, 57, 177, 5, 176, 279, 68, 65, 47, /* 200 */ 32, 40, 35, 218, 66, 224, 27, 226, 233, 45, /* 210 */ 237, 26, 64, 30, 19, 201, 242, 230, 274, 63, /* 220 */ 61, 59, 57, 200, 200, 176, 200, 200, 200, 52, /* 230 */ 68, 65, 47, 32, 40, 35, 218, 66, 224, 27, /* 240 */ 226, 233, 45, 237, 26, 64, 30, 200, 200, 242, /* 250 */ 230, 274, 51, 68, 65, 47, 32, 40, 35, 218, /* 260 */ 66, 224, 27, 226, 233, 45, 237, 26, 64, 30, /* 270 */ 200, 200, 242, 230, 274, 238, 26, 64, 30, 200, /* 280 */ 200, 242, 200, 200, 67, 47, 32, 40, 35, 218, /* 290 */ 66, 224, 27, 226, 233, 45, 237, 26, 64, 30, /* 300 */ 200, 200, 242, 230, 274, 50, 32, 40, 35, 218, /* 310 */ 66, 224, 27, 226, 233, 45, 237, 26, 64, 30, /* 320 */ 200, 200, 242, 230, 274, 33, 40, 35, 218, 66, /* 330 */ 224, 27, 226, 233, 45, 237, 26, 64, 30, 200, /* 340 */ 200, 242, 230, 274, 34, 40, 35, 218, 66, 224, /* 350 */ 27, 226, 233, 45, 237, 26, 64, 30, 200, 200, /* 360 */ 242, 230, 274, 39, 35, 218, 66, 224, 27, 226, /* 370 */ 233, 45, 237, 26, 64, 30, 200, 200, 242, 230, /* 380 */ 274, 41, 35, 218, 66, 224, 27, 226, 233, 45, /* 390 */ 237, 26, 64, 30, 200, 200, 242, 230, 274, 46, /* 400 */ 35, 218, 66, 224, 27, 226, 233, 45, 237, 26, /* 410 */ 64, 30, 200, 200, 242, 230, 274, 200, 49, 35, /* 420 */ 218, 66, 224, 27, 226, 233, 45, 237, 26, 64, /* 430 */ 30, 200, 200, 242, 230, 274, 200, 36, 218, 66, /* 440 */ 224, 27, 226, 233, 45, 237, 26, 64, 30, 200, /* 450 */ 200, 242, 230, 274, 200, 37, 218, 66, 224, 27, /* 460 */ 226, 233, 45, 237, 26, 64, 30, 200, 200, 242, /* 470 */ 230, 274, 200, 200, 221, 66, 224, 27, 226, 233, /* 480 */ 45, 237, 26, 64, 30, 200, 200, 242, 230, 274, /* 490 */ 223, 66, 224, 27, 226, 233, 45, 237, 26, 64, /* 500 */ 30, 200, 200, 242, 230, 274, 220, 66, 224, 27, /* 510 */ 226, 233, 45, 237, 26, 64, 30, 200, 200, 242, /* 520 */ 230, 274, 219, 66, 224, 27, 226, 233, 45, 237, /* 530 */ 26, 64, 30, 200, 200, 242, 230, 274, 225, 27, /* 540 */ 226, 233, 45, 237, 26, 64, 30, 200, 200, 242, /* 550 */ 230, 274, }; static const YYCODETYPE yy_lookahead[] = { /* 0 */ 69, 1, 2, 3, 4, 5, 71, 71, 8, 70, /* 10 */ 1, 2, 70, 13, 14, 65, 66, 67, 68, 69, /* 20 */ 16, 17, 72, 18, 19, 20, 21, 27, 28, 29, /* 30 */ 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, /* 40 */ 40, 41, 42, 43, 44, 45, 46, 47, 48, 1, /* 50 */ 2, 3, 4, 5, 1, 2, 8, 65, 66, 67, /* 60 */ 68, 69, 14, 10, 72, 10, 9, 65, 66, 67, /* 70 */ 68, 69, 12, 13, 72, 27, 28, 29, 30, 31, /* 80 */ 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, /* 90 */ 42, 43, 44, 45, 46, 47, 48, 52, 53, 54, /* 100 */ 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, /* 110 */ 65, 66, 67, 68, 69, 11, 9, 72, 73, 74, /* 120 */ 75, 76, 6, 9, 9, 8, 8, 51, 52, 53, /* 130 */ 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, /* 140 */ 64, 65, 66, 67, 68, 69, 9, 8, 72, 73, /* 150 */ 74, 44, 3, 4, 5, 65, 66, 67, 68, 69, /* 160 */ 14, 9, 72, 14, 66, 67, 68, 69, 8, 8, /* 170 */ 72, 25, 26, 9, 7, 24, 27, 28, 29, 30, /* 180 */ 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, /* 190 */ 41, 42, 43, 14, 23, 46, 52, 53, 54, 55, /* 200 */ 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, /* 210 */ 66, 67, 68, 69, 15, 0, 72, 73, 74, 40, /* 220 */ 41, 42, 43, 77, 77, 46, 77, 77, 77, 52, /* 230 */ 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, /* 240 */ 63, 64, 65, 66, 67, 68, 69, 77, 77, 72, /* 250 */ 73, 74, 52, 53, 54, 55, 56, 57, 58, 59, /* 260 */ 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, /* 270 */ 77, 77, 72, 73, 74, 66, 67, 68, 69, 77, /* 280 */ 77, 72, 77, 77, 54, 55, 56, 57, 58, 59, /* 290 */ 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, /* 300 */ 77, 77, 72, 73, 74, 55, 56, 57, 58, 59, /* 310 */ 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, /* 320 */ 77, 77, 72, 73, 74, 56, 57, 58, 59, 60, /* 330 */ 61, 62, 63, 64, 65, 66, 67, 68, 69, 77, /* 340 */ 77, 72, 73, 74, 56, 57, 58, 59, 60, 61, /* 350 */ 62, 63, 64, 65, 66, 67, 68, 69, 77, 77, /* 360 */ 72, 73, 74, 57, 58, 59, 60, 61, 62, 63, /* 370 */ 64, 65, 66, 67, 68, 69, 77, 77, 72, 73, /* 380 */ 74, 57, 58, 59, 60, 61, 62, 63, 64, 65, /* 390 */ 66, 67, 68, 69, 77, 77, 72, 73, 74, 57, /* 400 */ 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, /* 410 */ 68, 69, 77, 77, 72, 73, 74, 77, 57, 58, /* 420 */ 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, /* 430 */ 69, 77, 77, 72, 73, 74, 77, 58, 59, 60, /* 440 */ 61, 62, 63, 64, 65, 66, 67, 68, 69, 77, /* 450 */ 77, 72, 73, 74, 77, 58, 59, 60, 61, 62, /* 460 */ 63, 64, 65, 66, 67, 68, 69, 77, 77, 72, /* 470 */ 73, 74, 77, 77, 59, 60, 61, 62, 63, 64, /* 480 */ 65, 66, 67, 68, 69, 77, 77, 72, 73, 74, /* 490 */ 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, /* 500 */ 69, 77, 77, 72, 73, 74, 59, 60, 61, 62, /* 510 */ 63, 64, 65, 66, 67, 68, 69, 77, 77, 72, /* 520 */ 73, 74, 59, 60, 61, 62, 63, 64, 65, 66, /* 530 */ 67, 68, 69, 77, 77, 72, 73, 74, 61, 62, /* 540 */ 63, 64, 65, 66, 67, 68, 69, 77, 77, 72, /* 550 */ 73, 74, 51, 51, 51, 51, 51, 51, 51, 51, /* 560 */ 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, /* 570 */ 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, /* 580 */ 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, /* 590 */ 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, /* 600 */ 51, 51, 51, }; #define YY_SHIFT_COUNT (69) #define YY_SHIFT_MIN (0) #define YY_SHIFT_MAX (215) static const unsigned short int yy_shift_ofst[] = { /* 0 */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 10 */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 48, /* 20 */ 149, 149, 149, 149, 149, 149, 179, 53, 55, 55, /* 30 */ 552, 552, 5, 5, 5, 146, 146, 146, 9, 60, /* 40 */ 60, 60, 9, 9, 107, 9, 60, 4, 9, 60, /* 50 */ 4, 104, 57, 116, 114, 117, 115, 118, 137, 139, /* 60 */ 152, 160, 164, 161, 167, 151, 199, 151, 171, 215, }; #define YY_REDUCE_COUNT (31) #define YY_REDUCE_MIN (-69) #define YY_REDUCE_MAX (477) static const short yy_reduce_ofst[] = { /* 0 */ 76, 45, 144, 177, 200, 230, 250, 269, 288, 306, /* 10 */ 324, 342, 361, 379, 397, 415, 431, 447, 463, 477, /* 20 */ -50, -8, 2, 90, 98, 209, -69, -65, -64, -64, /* 30 */ -61, -58, }; static const YYACTIONTYPE yy_default[] = { /* 0 */ 198, 276, 198, 198, 198, 198, 198, 198, 198, 198, /* 10 */ 198, 198, 198, 198, 198, 198, 198, 198, 198, 198, /* 20 */ 198, 198, 234, 198, 198, 198, 198, 227, 241, 240, /* 30 */ 266, 266, 207, 209, 208, 215, 217, 216, 229, 214, /* 40 */ 210, 213, 236, 235, 198, 232, 212, 205, 228, 211, /* 50 */ 206, 198, 198, 277, 198, 198, 198, 198, 198, 198, /* 60 */ 198, 198, 198, 198, 198, 203, 222, 204, 202, 198, }; /********** 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 xpathParseARG_SDECL /* A place to hold %extra_argument */ xpathParseCTX_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 xpathParseTrace(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 */ "SLASH", /* 2 */ "DOUBLE_SLASH", /* 3 */ "DOT", /* 4 */ "DOUBLE_DOT", /* 5 */ "AT", /* 6 */ "COMMA", /* 7 */ "COLON_COLON", /* 8 */ "LPAREN", /* 9 */ "RPAREN", /* 10 */ "LBRACKET", /* 11 */ "RBRACKET", /* 12 */ "PLUS", /* 13 */ "MINUS", /* 14 */ "STAR", /* 15 */ "PIPE", /* 16 */ "EQUALS", /* 17 */ "NOT_EQUALS", /* 18 */ "LESS_THAN", /* 19 */ "LESS_EQUAL", /* 20 */ "GREATER_THAN", /* 21 */ "GREATER_EQUAL", /* 22 */ "DOLLAR", /* 23 */ "KW_OR", /* 24 */ "KW_AND", /* 25 */ "KW_DIV", /* 26 */ "KW_MOD", /* 27 */ "AXIS_ANCESTOR", /* 28 */ "AXIS_ANCESTOR_OR_SELF", /* 29 */ "AXIS_ATTRIBUTE", /* 30 */ "AXIS_CHILD", /* 31 */ "AXIS_DESCENDANT", /* 32 */ "AXIS_DESCENDANT_OR_SELF", /* 33 */ "AXIS_FOLLOWING", /* 34 */ "AXIS_FOLLOWING_SIBLING", /* 35 */ "AXIS_NAMESPACE", /* 36 */ "AXIS_PARENT", /* 37 */ "AXIS_PRECEDING", /* 38 */ "AXIS_PRECEDING_SIBLING", /* 39 */ "AXIS_SELF", /* 40 */ "NODE_TYPE_COMMENT", /* 41 */ "NODE_TYPE_TEXT", /* 42 */ "NODE_TYPE_PI", /* 43 */ "NODE_TYPE_NODE", /* 44 */ "LITERAL", /* 45 */ "NUMBER", /* 46 */ "NAME_TEST", /* 47 */ "FUNCTION_NAME", /* 48 */ "VARIABLE_REF", /* 49 */ "LONE_SLASH", /* 50 */ "UMINUS", /* 51 */ "xpath_top", /* 52 */ "expr", /* 53 */ "or_expr", /* 54 */ "and_expr", /* 55 */ "equality_expr", /* 56 */ "relational_expr", /* 57 */ "additive_expr", /* 58 */ "multiplicative_expr", /* 59 */ "unary_expr", /* 60 */ "union_expr", /* 61 */ "path_expr", /* 62 */ "filter_expr", /* 63 */ "location_path", /* 64 */ "absolute_location_path", /* 65 */ "relative_location_path", /* 66 */ "step", /* 67 */ "axis_specifier", /* 68 */ "axis_name", /* 69 */ "node_test", /* 70 */ "predicate_list", /* 71 */ "predicate", /* 72 */ "abbreviated_step", /* 73 */ "primary_expr", /* 74 */ "function_call", /* 75 */ "argument_list", /* 76 */ "arguments", }; #endif /* defined(YYCOVERAGE) || !defined(NDEBUG) */ #ifndef NDEBUG /* For tracing reduce actions, the names of all rules are required. */ static const char *const yyRuleName[] = { /* 0 */ "xpath_top ::= expr", /* 1 */ "expr ::= or_expr", /* 2 */ "or_expr ::= and_expr", /* 3 */ "or_expr ::= or_expr KW_OR and_expr", /* 4 */ "and_expr ::= equality_expr", /* 5 */ "and_expr ::= and_expr KW_AND equality_expr", /* 6 */ "equality_expr ::= relational_expr", /* 7 */ "equality_expr ::= equality_expr EQUALS relational_expr", /* 8 */ "equality_expr ::= equality_expr NOT_EQUALS relational_expr", /* 9 */ "relational_expr ::= additive_expr", /* 10 */ "relational_expr ::= relational_expr LESS_THAN additive_expr", /* 11 */ "relational_expr ::= relational_expr LESS_EQUAL additive_expr", /* 12 */ "relational_expr ::= relational_expr GREATER_THAN additive_expr", /* 13 */ "relational_expr ::= relational_expr GREATER_EQUAL additive_expr", /* 14 */ "additive_expr ::= multiplicative_expr", /* 15 */ "additive_expr ::= additive_expr PLUS multiplicative_expr", /* 16 */ "additive_expr ::= additive_expr MINUS multiplicative_expr", /* 17 */ "multiplicative_expr ::= unary_expr", /* 18 */ "multiplicative_expr ::= multiplicative_expr STAR unary_expr", /* 19 */ "multiplicative_expr ::= multiplicative_expr KW_DIV unary_expr", /* 20 */ "multiplicative_expr ::= multiplicative_expr KW_MOD unary_expr", /* 21 */ "unary_expr ::= union_expr", /* 22 */ "unary_expr ::= MINUS unary_expr", /* 23 */ "union_expr ::= path_expr", /* 24 */ "union_expr ::= union_expr PIPE path_expr", /* 25 */ "path_expr ::= location_path", /* 26 */ "path_expr ::= filter_expr", /* 27 */ "path_expr ::= filter_expr SLASH relative_location_path", /* 28 */ "path_expr ::= filter_expr DOUBLE_SLASH relative_location_path", /* 29 */ "filter_expr ::= primary_expr", /* 30 */ "filter_expr ::= filter_expr predicate", /* 31 */ "location_path ::= relative_location_path", /* 32 */ "location_path ::= absolute_location_path", /* 33 */ "absolute_location_path ::= SLASH", /* 34 */ "absolute_location_path ::= SLASH relative_location_path", /* 35 */ "absolute_location_path ::= DOUBLE_SLASH relative_location_path", /* 36 */ "relative_location_path ::= step", /* 37 */ "relative_location_path ::= relative_location_path SLASH step", /* 38 */ "relative_location_path ::= relative_location_path DOUBLE_SLASH step", /* 39 */ "step ::= axis_specifier node_test predicate_list", /* 40 */ "step ::= node_test predicate_list", /* 41 */ "step ::= abbreviated_step", /* 42 */ "axis_specifier ::= axis_name COLON_COLON", /* 43 */ "axis_specifier ::= AT", /* 44 */ "axis_name ::= AXIS_CHILD", /* 45 */ "axis_name ::= AXIS_DESCENDANT", /* 46 */ "axis_name ::= AXIS_PARENT", /* 47 */ "axis_name ::= AXIS_ANCESTOR", /* 48 */ "axis_name ::= AXIS_FOLLOWING_SIBLING", /* 49 */ "axis_name ::= AXIS_PRECEDING_SIBLING", /* 50 */ "axis_name ::= AXIS_FOLLOWING", /* 51 */ "axis_name ::= AXIS_PRECEDING", /* 52 */ "axis_name ::= AXIS_ATTRIBUTE", /* 53 */ "axis_name ::= AXIS_NAMESPACE", /* 54 */ "axis_name ::= AXIS_SELF", /* 55 */ "axis_name ::= AXIS_DESCENDANT_OR_SELF", /* 56 */ "axis_name ::= AXIS_ANCESTOR_OR_SELF", /* 57 */ "node_test ::= NAME_TEST", /* 58 */ "node_test ::= STAR", /* 59 */ "node_test ::= NODE_TYPE_COMMENT LPAREN RPAREN", /* 60 */ "node_test ::= NODE_TYPE_TEXT LPAREN RPAREN", /* 61 */ "node_test ::= NODE_TYPE_PI LPAREN RPAREN", /* 62 */ "node_test ::= NODE_TYPE_PI LPAREN LITERAL RPAREN", /* 63 */ "node_test ::= NODE_TYPE_NODE LPAREN RPAREN", /* 64 */ "predicate ::= LBRACKET expr RBRACKET", /* 65 */ "predicate_list ::=", /* 66 */ "predicate_list ::= predicate_list predicate", /* 67 */ "abbreviated_step ::= DOT", /* 68 */ "abbreviated_step ::= DOUBLE_DOT", /* 69 */ "primary_expr ::= VARIABLE_REF", /* 70 */ "primary_expr ::= LPAREN expr RPAREN", /* 71 */ "primary_expr ::= LITERAL", /* 72 */ "primary_expr ::= NUMBER", /* 73 */ "primary_expr ::= function_call", /* 74 */ "function_call ::= FUNCTION_NAME LPAREN argument_list RPAREN", /* 75 */ "argument_list ::=", /* 76 */ "argument_list ::= arguments", /* 77 */ "arguments ::= expr", /* 78 */ "arguments ::= arguments COMMA expr", }; #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(xpathParseCTX(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]), xpathParseCTX(p)); if( pNew==0 ) return 1; memcpy(pNew, p->yystack, oldSize*sizeof(pNew[0])); }else{ pNew = YYREALLOC(p->yystack, newSize*sizeof(pNew[0]), xpathParseCTX(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 xpathParseAlloc() 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 xpathParseInit(void *yypRawParser xpathParseCTX_PDECL){ yyParser *yypParser = (yyParser*)yypRawParser; xpathParseCTX_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 xpathParse_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 xpathParse and xpathParseFree. */ void *xpathParseAlloc(void *(*mallocProc)(YYMALLOCARGTYPE) xpathParseCTX_PDECL){ yyParser *yypParser; yypParser = (yyParser*)(*mallocProc)( (YYMALLOCARGTYPE)sizeof(yyParser) ); if( yypParser ){ xpathParseCTX_STORE xpathParseInit(yypParser xpathParseCTX_PARAM); } return (void*)yypParser; } #endif /* xpathParse_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 */ ){ xpathParseARG_FETCH xpathParseCTX_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 xpathParseFinalize(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, xpathParseCTX(pParser)); } #endif } #ifndef xpathParse_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 xpathParseFree( void *p, /* The parser to be deleted */ void (*freeProc)(void*) /* Function used to reclaim memory */ ){ #ifndef YYPARSEFREENEVERNULL if( p==0 ) return; #endif xpathParseFinalize(p); (*freeProc)(p); } #endif /* xpathParse_ENGINEALWAYSONSTACK */ /* ** Return the peak depth of the stack for a parser. */ #ifdef YYTRACKMAXSTACKDEPTH int xpathParseStackPeak(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 xpathParseCoverage(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 ********************************************/ xpathParseARG_STORE /* Suppress warning about unused %extra_argument var */ xpathParseCTX_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 */ xpathParseTOKENTYPE 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[] = { 51, /* (0) xpath_top ::= expr */ 52, /* (1) expr ::= or_expr */ 53, /* (2) or_expr ::= and_expr */ 53, /* (3) or_expr ::= or_expr KW_OR and_expr */ 54, /* (4) and_expr ::= equality_expr */ 54, /* (5) and_expr ::= and_expr KW_AND equality_expr */ 55, /* (6) equality_expr ::= relational_expr */ 55, /* (7) equality_expr ::= equality_expr EQUALS relational_expr */ 55, /* (8) equality_expr ::= equality_expr NOT_EQUALS relational_expr */ 56, /* (9) relational_expr ::= additive_expr */ 56, /* (10) relational_expr ::= relational_expr LESS_THAN additive_expr */ 56, /* (11) relational_expr ::= relational_expr LESS_EQUAL additive_expr */ 56, /* (12) relational_expr ::= relational_expr GREATER_THAN additive_expr */ 56, /* (13) relational_expr ::= relational_expr GREATER_EQUAL additive_expr */ 57, /* (14) additive_expr ::= multiplicative_expr */ 57, /* (15) additive_expr ::= additive_expr PLUS multiplicative_expr */ 57, /* (16) additive_expr ::= additive_expr MINUS multiplicative_expr */ 58, /* (17) multiplicative_expr ::= unary_expr */ 58, /* (18) multiplicative_expr ::= multiplicative_expr STAR unary_expr */ 58, /* (19) multiplicative_expr ::= multiplicative_expr KW_DIV unary_expr */ 58, /* (20) multiplicative_expr ::= multiplicative_expr KW_MOD unary_expr */ 59, /* (21) unary_expr ::= union_expr */ 59, /* (22) unary_expr ::= MINUS unary_expr */ 60, /* (23) union_expr ::= path_expr */ 60, /* (24) union_expr ::= union_expr PIPE path_expr */ 61, /* (25) path_expr ::= location_path */ 61, /* (26) path_expr ::= filter_expr */ 61, /* (27) path_expr ::= filter_expr SLASH relative_location_path */ 61, /* (28) path_expr ::= filter_expr DOUBLE_SLASH relative_location_path */ 62, /* (29) filter_expr ::= primary_expr */ 62, /* (30) filter_expr ::= filter_expr predicate */ 63, /* (31) location_path ::= relative_location_path */ 63, /* (32) location_path ::= absolute_location_path */ 64, /* (33) absolute_location_path ::= SLASH */ 64, /* (34) absolute_location_path ::= SLASH relative_location_path */ 64, /* (35) absolute_location_path ::= DOUBLE_SLASH relative_location_path */ 65, /* (36) relative_location_path ::= step */ 65, /* (37) relative_location_path ::= relative_location_path SLASH step */ 65, /* (38) relative_location_path ::= relative_location_path DOUBLE_SLASH step */ 66, /* (39) step ::= axis_specifier node_test predicate_list */ 66, /* (40) step ::= node_test predicate_list */ 66, /* (41) step ::= abbreviated_step */ 67, /* (42) axis_specifier ::= axis_name COLON_COLON */ 67, /* (43) axis_specifier ::= AT */ 68, /* (44) axis_name ::= AXIS_CHILD */ 68, /* (45) axis_name ::= AXIS_DESCENDANT */ 68, /* (46) axis_name ::= AXIS_PARENT */ 68, /* (47) axis_name ::= AXIS_ANCESTOR */ 68, /* (48) axis_name ::= AXIS_FOLLOWING_SIBLING */ 68, /* (49) axis_name ::= AXIS_PRECEDING_SIBLING */ 68, /* (50) axis_name ::= AXIS_FOLLOWING */ 68, /* (51) axis_name ::= AXIS_PRECEDING */ 68, /* (52) axis_name ::= AXIS_ATTRIBUTE */ 68, /* (53) axis_name ::= AXIS_NAMESPACE */ 68, /* (54) axis_name ::= AXIS_SELF */ 68, /* (55) axis_name ::= AXIS_DESCENDANT_OR_SELF */ 68, /* (56) axis_name ::= AXIS_ANCESTOR_OR_SELF */ 69, /* (57) node_test ::= NAME_TEST */ 69, /* (58) node_test ::= STAR */ 69, /* (59) node_test ::= NODE_TYPE_COMMENT LPAREN RPAREN */ 69, /* (60) node_test ::= NODE_TYPE_TEXT LPAREN RPAREN */ 69, /* (61) node_test ::= NODE_TYPE_PI LPAREN RPAREN */ 69, /* (62) node_test ::= NODE_TYPE_PI LPAREN LITERAL RPAREN */ 69, /* (63) node_test ::= NODE_TYPE_NODE LPAREN RPAREN */ 71, /* (64) predicate ::= LBRACKET expr RBRACKET */ 70, /* (65) predicate_list ::= */ 70, /* (66) predicate_list ::= predicate_list predicate */ 72, /* (67) abbreviated_step ::= DOT */ 72, /* (68) abbreviated_step ::= DOUBLE_DOT */ 73, /* (69) primary_expr ::= VARIABLE_REF */ 73, /* (70) primary_expr ::= LPAREN expr RPAREN */ 73, /* (71) primary_expr ::= LITERAL */ 73, /* (72) primary_expr ::= NUMBER */ 73, /* (73) primary_expr ::= function_call */ 74, /* (74) function_call ::= FUNCTION_NAME LPAREN argument_list RPAREN */ 75, /* (75) argument_list ::= */ 75, /* (76) argument_list ::= arguments */ 76, /* (77) arguments ::= expr */ 76, /* (78) arguments ::= arguments COMMA expr */ }; /* 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) xpath_top ::= expr */ -1, /* (1) expr ::= or_expr */ -1, /* (2) or_expr ::= and_expr */ -3, /* (3) or_expr ::= or_expr KW_OR and_expr */ -1, /* (4) and_expr ::= equality_expr */ -3, /* (5) and_expr ::= and_expr KW_AND equality_expr */ -1, /* (6) equality_expr ::= relational_expr */ -3, /* (7) equality_expr ::= equality_expr EQUALS relational_expr */ -3, /* (8) equality_expr ::= equality_expr NOT_EQUALS relational_expr */ -1, /* (9) relational_expr ::= additive_expr */ -3, /* (10) relational_expr ::= relational_expr LESS_THAN additive_expr */ -3, /* (11) relational_expr ::= relational_expr LESS_EQUAL additive_expr */ -3, /* (12) relational_expr ::= relational_expr GREATER_THAN additive_expr */ -3, /* (13) relational_expr ::= relational_expr GREATER_EQUAL additive_expr */ -1, /* (14) additive_expr ::= multiplicative_expr */ -3, /* (15) additive_expr ::= additive_expr PLUS multiplicative_expr */ -3, /* (16) additive_expr ::= additive_expr MINUS multiplicative_expr */ -1, /* (17) multiplicative_expr ::= unary_expr */ -3, /* (18) multiplicative_expr ::= multiplicative_expr STAR unary_expr */ -3, /* (19) multiplicative_expr ::= multiplicative_expr KW_DIV unary_expr */ -3, /* (20) multiplicative_expr ::= multiplicative_expr KW_MOD unary_expr */ -1, /* (21) unary_expr ::= union_expr */ -2, /* (22) unary_expr ::= MINUS unary_expr */ -1, /* (23) union_expr ::= path_expr */ -3, /* (24) union_expr ::= union_expr PIPE path_expr */ -1, /* (25) path_expr ::= location_path */ -1, /* (26) path_expr ::= filter_expr */ -3, /* (27) path_expr ::= filter_expr SLASH relative_location_path */ -3, /* (28) path_expr ::= filter_expr DOUBLE_SLASH relative_location_path */ -1, /* (29) filter_expr ::= primary_expr */ -2, /* (30) filter_expr ::= filter_expr predicate */ -1, /* (31) location_path ::= relative_location_path */ -1, /* (32) location_path ::= absolute_location_path */ -1, /* (33) absolute_location_path ::= SLASH */ -2, /* (34) absolute_location_path ::= SLASH relative_location_path */ -2, /* (35) absolute_location_path ::= DOUBLE_SLASH relative_location_path */ -1, /* (36) relative_location_path ::= step */ -3, /* (37) relative_location_path ::= relative_location_path SLASH step */ -3, /* (38) relative_location_path ::= relative_location_path DOUBLE_SLASH step */ -3, /* (39) step ::= axis_specifier node_test predicate_list */ -2, /* (40) step ::= node_test predicate_list */ -1, /* (41) step ::= abbreviated_step */ -2, /* (42) axis_specifier ::= axis_name COLON_COLON */ -1, /* (43) axis_specifier ::= AT */ -1, /* (44) axis_name ::= AXIS_CHILD */ -1, /* (45) axis_name ::= AXIS_DESCENDANT */ -1, /* (46) axis_name ::= AXIS_PARENT */ -1, /* (47) axis_name ::= AXIS_ANCESTOR */ -1, /* (48) axis_name ::= AXIS_FOLLOWING_SIBLING */ -1, /* (49) axis_name ::= AXIS_PRECEDING_SIBLING */ -1, /* (50) axis_name ::= AXIS_FOLLOWING */ -1, /* (51) axis_name ::= AXIS_PRECEDING */ -1, /* (52) axis_name ::= AXIS_ATTRIBUTE */ -1, /* (53) axis_name ::= AXIS_NAMESPACE */ -1, /* (54) axis_name ::= AXIS_SELF */ -1, /* (55) axis_name ::= AXIS_DESCENDANT_OR_SELF */ -1, /* (56) axis_name ::= AXIS_ANCESTOR_OR_SELF */ -1, /* (57) node_test ::= NAME_TEST */ -1, /* (58) node_test ::= STAR */ -3, /* (59) node_test ::= NODE_TYPE_COMMENT LPAREN RPAREN */ -3, /* (60) node_test ::= NODE_TYPE_TEXT LPAREN RPAREN */ -3, /* (61) node_test ::= NODE_TYPE_PI LPAREN RPAREN */ -4, /* (62) node_test ::= NODE_TYPE_PI LPAREN LITERAL RPAREN */ -3, /* (63) node_test ::= NODE_TYPE_NODE LPAREN RPAREN */ -3, /* (64) predicate ::= LBRACKET expr RBRACKET */ 0, /* (65) predicate_list ::= */ -2, /* (66) predicate_list ::= predicate_list predicate */ -1, /* (67) abbreviated_step ::= DOT */ -1, /* (68) abbreviated_step ::= DOUBLE_DOT */ -1, /* (69) primary_expr ::= VARIABLE_REF */ -3, /* (70) primary_expr ::= LPAREN expr RPAREN */ -1, /* (71) primary_expr ::= LITERAL */ -1, /* (72) primary_expr ::= NUMBER */ -1, /* (73) primary_expr ::= function_call */ -4, /* (74) function_call ::= FUNCTION_NAME LPAREN argument_list RPAREN */ 0, /* (75) argument_list ::= */ -1, /* (76) argument_list ::= arguments */ -1, /* (77) arguments ::= expr */ -3, /* (78) arguments ::= arguments COMMA expr */ }; 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 */ xpathParseTOKENTYPE yyLookaheadToken /* Value of the lookahead token */ xpathParseCTX_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 */ xpathParseARG_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: /* xpath_top ::= expr */ #line 352 "xpath.lime" { yylhsminor.yy106 = yymsp[0].minor.yy106; pstate->result = yymsp[0].minor.yy106; } #line 1345 "xpath.c" yymsp[0].minor.yy106 = yylhsminor.yy106; break; case 1: /* expr ::= or_expr */ case 2: /* or_expr ::= and_expr */ yytestcase(yyruleno==2); case 4: /* and_expr ::= equality_expr */ yytestcase(yyruleno==4); case 6: /* equality_expr ::= relational_expr */ yytestcase(yyruleno==6); case 9: /* relational_expr ::= additive_expr */ yytestcase(yyruleno==9); case 14: /* additive_expr ::= multiplicative_expr */ yytestcase(yyruleno==14); case 17: /* multiplicative_expr ::= unary_expr */ yytestcase(yyruleno==17); case 21: /* unary_expr ::= union_expr */ yytestcase(yyruleno==21); case 23: /* union_expr ::= path_expr */ yytestcase(yyruleno==23); case 25: /* path_expr ::= location_path */ yytestcase(yyruleno==25); case 26: /* path_expr ::= filter_expr */ yytestcase(yyruleno==26); case 29: /* filter_expr ::= primary_expr */ yytestcase(yyruleno==29); case 31: /* location_path ::= relative_location_path */ yytestcase(yyruleno==31); case 32: /* location_path ::= absolute_location_path */ yytestcase(yyruleno==32); case 36: /* relative_location_path ::= step */ yytestcase(yyruleno==36); case 41: /* step ::= abbreviated_step */ yytestcase(yyruleno==41); case 73: /* primary_expr ::= function_call */ yytestcase(yyruleno==73); #line 358 "xpath.lime" { yylhsminor.yy106 = yymsp[0].minor.yy106; } #line 1367 "xpath.c" yymsp[0].minor.yy106 = yylhsminor.yy106; break; case 3: /* or_expr ::= or_expr KW_OR and_expr */ #line 363 "xpath.lime" { yylhsminor.yy106 = xpath_make_binary(XPATH_OP_OR, yymsp[-2].minor.yy106, yymsp[0].minor.yy106); } #line 1375 "xpath.c" yymsp[-2].minor.yy106 = yylhsminor.yy106; break; case 5: /* and_expr ::= and_expr KW_AND equality_expr */ #line 370 "xpath.lime" { yylhsminor.yy106 = xpath_make_binary(XPATH_OP_AND, yymsp[-2].minor.yy106, yymsp[0].minor.yy106); } #line 1383 "xpath.c" yymsp[-2].minor.yy106 = yylhsminor.yy106; break; case 7: /* equality_expr ::= equality_expr EQUALS relational_expr */ #line 377 "xpath.lime" { yylhsminor.yy106 = xpath_make_binary(XPATH_OP_EQ, yymsp[-2].minor.yy106, yymsp[0].minor.yy106); } #line 1391 "xpath.c" yymsp[-2].minor.yy106 = yylhsminor.yy106; break; case 8: /* equality_expr ::= equality_expr NOT_EQUALS relational_expr */ #line 381 "xpath.lime" { yylhsminor.yy106 = xpath_make_binary(XPATH_OP_NE, yymsp[-2].minor.yy106, yymsp[0].minor.yy106); } #line 1399 "xpath.c" yymsp[-2].minor.yy106 = yylhsminor.yy106; break; case 10: /* relational_expr ::= relational_expr LESS_THAN additive_expr */ #line 388 "xpath.lime" { yylhsminor.yy106 = xpath_make_binary(XPATH_OP_LT, yymsp[-2].minor.yy106, yymsp[0].minor.yy106); } #line 1407 "xpath.c" yymsp[-2].minor.yy106 = yylhsminor.yy106; break; case 11: /* relational_expr ::= relational_expr LESS_EQUAL additive_expr */ #line 392 "xpath.lime" { yylhsminor.yy106 = xpath_make_binary(XPATH_OP_LE, yymsp[-2].minor.yy106, yymsp[0].minor.yy106); } #line 1415 "xpath.c" yymsp[-2].minor.yy106 = yylhsminor.yy106; break; case 12: /* relational_expr ::= relational_expr GREATER_THAN additive_expr */ #line 396 "xpath.lime" { yylhsminor.yy106 = xpath_make_binary(XPATH_OP_GT, yymsp[-2].minor.yy106, yymsp[0].minor.yy106); } #line 1423 "xpath.c" yymsp[-2].minor.yy106 = yylhsminor.yy106; break; case 13: /* relational_expr ::= relational_expr GREATER_EQUAL additive_expr */ #line 400 "xpath.lime" { yylhsminor.yy106 = xpath_make_binary(XPATH_OP_GE, yymsp[-2].minor.yy106, yymsp[0].minor.yy106); } #line 1431 "xpath.c" yymsp[-2].minor.yy106 = yylhsminor.yy106; break; case 15: /* additive_expr ::= additive_expr PLUS multiplicative_expr */ #line 407 "xpath.lime" { yylhsminor.yy106 = xpath_make_binary(XPATH_OP_ADD, yymsp[-2].minor.yy106, yymsp[0].minor.yy106); } #line 1439 "xpath.c" yymsp[-2].minor.yy106 = yylhsminor.yy106; break; case 16: /* additive_expr ::= additive_expr MINUS multiplicative_expr */ #line 411 "xpath.lime" { yylhsminor.yy106 = xpath_make_binary(XPATH_OP_SUB, yymsp[-2].minor.yy106, yymsp[0].minor.yy106); } #line 1447 "xpath.c" yymsp[-2].minor.yy106 = yylhsminor.yy106; break; case 18: /* multiplicative_expr ::= multiplicative_expr STAR unary_expr */ #line 418 "xpath.lime" { yylhsminor.yy106 = xpath_make_binary(XPATH_OP_MUL, yymsp[-2].minor.yy106, yymsp[0].minor.yy106); } #line 1455 "xpath.c" yymsp[-2].minor.yy106 = yylhsminor.yy106; break; case 19: /* multiplicative_expr ::= multiplicative_expr KW_DIV unary_expr */ #line 422 "xpath.lime" { yylhsminor.yy106 = xpath_make_binary(XPATH_OP_DIV, yymsp[-2].minor.yy106, yymsp[0].minor.yy106); } #line 1463 "xpath.c" yymsp[-2].minor.yy106 = yylhsminor.yy106; break; case 20: /* multiplicative_expr ::= multiplicative_expr KW_MOD unary_expr */ #line 426 "xpath.lime" { yylhsminor.yy106 = xpath_make_binary(XPATH_OP_MOD, yymsp[-2].minor.yy106, yymsp[0].minor.yy106); } #line 1471 "xpath.c" yymsp[-2].minor.yy106 = yylhsminor.yy106; break; case 22: /* unary_expr ::= MINUS unary_expr */ #line 433 "xpath.lime" { yymsp[-1].minor.yy106 = xpath_make_unary(XPATH_OP_NEGATE, yymsp[0].minor.yy106); } #line 1479 "xpath.c" break; case 24: /* union_expr ::= union_expr PIPE path_expr */ #line 440 "xpath.lime" { yylhsminor.yy106 = xpath_make_binary(XPATH_OP_UNION, yymsp[-2].minor.yy106, yymsp[0].minor.yy106); } #line 1486 "xpath.c" yymsp[-2].minor.yy106 = yylhsminor.yy106; break; case 27: /* path_expr ::= filter_expr SLASH relative_location_path */ case 37: /* relative_location_path ::= relative_location_path SLASH step */ yytestcase(yyruleno==37); #line 453 "xpath.lime" { yylhsminor.yy106 = xpath_make_path(yymsp[-2].minor.yy106, yymsp[0].minor.yy106); } #line 1495 "xpath.c" yymsp[-2].minor.yy106 = yylhsminor.yy106; break; case 28: /* path_expr ::= filter_expr DOUBLE_SLASH relative_location_path */ #line 457 "xpath.lime" { /* * filter // relative => filter / descendant-or-self::node() / relative */ XPathNode *dsos = xpath_make_step(XPATH_AXIS_DESCENDANT_OR_SELF, xpath_make_node_type_test(XPATH_NODE_TYPE_NODE), NULL); XPathNode *expanded = xpath_make_path(dsos, yymsp[0].minor.yy106); yylhsminor.yy106 = xpath_make_path(yymsp[-2].minor.yy106, expanded); } #line 1510 "xpath.c" yymsp[-2].minor.yy106 = yylhsminor.yy106; break; case 30: /* filter_expr ::= filter_expr predicate */ #line 474 "xpath.lime" { yylhsminor.yy106 = xpath_make_filter(yymsp[-1].minor.yy106, yymsp[0].minor.yy106); } #line 1518 "xpath.c" yymsp[-1].minor.yy106 = yylhsminor.yy106; break; case 33: /* absolute_location_path ::= SLASH */ #line 497 "xpath.lime" { yymsp[0].minor.yy106 = xpath_make_root(); } #line 1526 "xpath.c" break; case 34: /* absolute_location_path ::= SLASH relative_location_path */ #line 501 "xpath.lime" { yymsp[-1].minor.yy106 = xpath_make_absolute_path(yymsp[0].minor.yy106); } #line 1533 "xpath.c" break; case 35: /* absolute_location_path ::= DOUBLE_SLASH relative_location_path */ #line 510 "xpath.lime" { XPathNode *dsos = xpath_make_step(XPATH_AXIS_DESCENDANT_OR_SELF, xpath_make_node_type_test(XPATH_NODE_TYPE_NODE), NULL); XPathNode *rel = xpath_make_path(dsos, yymsp[0].minor.yy106); yymsp[-1].minor.yy106 = xpath_make_absolute_path(rel); } #line 1544 "xpath.c" break; case 38: /* relative_location_path ::= relative_location_path DOUBLE_SLASH step */ #line 530 "xpath.lime" { XPathNode *dsos = xpath_make_step(XPATH_AXIS_DESCENDANT_OR_SELF, xpath_make_node_type_test(XPATH_NODE_TYPE_NODE), NULL); yylhsminor.yy106 = xpath_make_path(yymsp[-2].minor.yy106, xpath_make_path(dsos, yymsp[0].minor.yy106)); } #line 1554 "xpath.c" yymsp[-2].minor.yy106 = yylhsminor.yy106; break; case 39: /* step ::= axis_specifier node_test predicate_list */ #line 546 "xpath.lime" { yylhsminor.yy106 = xpath_make_step(yymsp[-2].minor.yy25, yymsp[-1].minor.yy106, yymsp[0].minor.yy106); } #line 1562 "xpath.c" yymsp[-2].minor.yy106 = yylhsminor.yy106; break; case 40: /* step ::= node_test predicate_list */ #line 557 "xpath.lime" { yylhsminor.yy106 = xpath_make_step(XPATH_AXIS_CHILD, yymsp[-1].minor.yy106, yymsp[0].minor.yy106); } #line 1570 "xpath.c" yymsp[-1].minor.yy106 = yylhsminor.yy106; break; case 42: /* axis_specifier ::= axis_name COLON_COLON */ #line 565 "xpath.lime" { yylhsminor.yy25 = yymsp[-1].minor.yy25; } #line 1576 "xpath.c" yymsp[-1].minor.yy25 = yylhsminor.yy25; break; case 43: /* axis_specifier ::= AT */ case 52: /* axis_name ::= AXIS_ATTRIBUTE */ yytestcase(yyruleno==52); #line 570 "xpath.lime" { yymsp[0].minor.yy25 = XPATH_AXIS_ATTRIBUTE; } #line 1583 "xpath.c" break; case 44: /* axis_name ::= AXIS_CHILD */ #line 585 "xpath.lime" { yymsp[0].minor.yy25 = XPATH_AXIS_CHILD; } #line 1588 "xpath.c" break; case 45: /* axis_name ::= AXIS_DESCENDANT */ #line 586 "xpath.lime" { yymsp[0].minor.yy25 = XPATH_AXIS_DESCENDANT; } #line 1593 "xpath.c" break; case 46: /* axis_name ::= AXIS_PARENT */ #line 587 "xpath.lime" { yymsp[0].minor.yy25 = XPATH_AXIS_PARENT; } #line 1598 "xpath.c" break; case 47: /* axis_name ::= AXIS_ANCESTOR */ #line 588 "xpath.lime" { yymsp[0].minor.yy25 = XPATH_AXIS_ANCESTOR; } #line 1603 "xpath.c" break; case 48: /* axis_name ::= AXIS_FOLLOWING_SIBLING */ #line 589 "xpath.lime" { yymsp[0].minor.yy25 = XPATH_AXIS_FOLLOWING_SIBLING; } #line 1608 "xpath.c" break; case 49: /* axis_name ::= AXIS_PRECEDING_SIBLING */ #line 590 "xpath.lime" { yymsp[0].minor.yy25 = XPATH_AXIS_PRECEDING_SIBLING; } #line 1613 "xpath.c" break; case 50: /* axis_name ::= AXIS_FOLLOWING */ #line 591 "xpath.lime" { yymsp[0].minor.yy25 = XPATH_AXIS_FOLLOWING; } #line 1618 "xpath.c" break; case 51: /* axis_name ::= AXIS_PRECEDING */ #line 592 "xpath.lime" { yymsp[0].minor.yy25 = XPATH_AXIS_PRECEDING; } #line 1623 "xpath.c" break; case 53: /* axis_name ::= AXIS_NAMESPACE */ #line 594 "xpath.lime" { yymsp[0].minor.yy25 = XPATH_AXIS_NAMESPACE; } #line 1628 "xpath.c" break; case 54: /* axis_name ::= AXIS_SELF */ #line 595 "xpath.lime" { yymsp[0].minor.yy25 = XPATH_AXIS_SELF; } #line 1633 "xpath.c" break; case 55: /* axis_name ::= AXIS_DESCENDANT_OR_SELF */ #line 596 "xpath.lime" { yymsp[0].minor.yy25 = XPATH_AXIS_DESCENDANT_OR_SELF; } #line 1638 "xpath.c" break; case 56: /* axis_name ::= AXIS_ANCESTOR_OR_SELF */ #line 597 "xpath.lime" { yymsp[0].minor.yy25 = XPATH_AXIS_ANCESTOR_OR_SELF; } #line 1643 "xpath.c" break; case 57: /* node_test ::= NAME_TEST */ #line 606 "xpath.lime" { yylhsminor.yy106 = xpath_make_name_test(yymsp[0].minor.yy0.str.val, yymsp[0].minor.yy0.str.len); } #line 1650 "xpath.c" yymsp[0].minor.yy106 = yylhsminor.yy106; break; case 58: /* node_test ::= STAR */ #line 610 "xpath.lime" { yymsp[0].minor.yy106 = xpath_make_name_test("*", 1); } #line 1658 "xpath.c" break; case 59: /* node_test ::= NODE_TYPE_COMMENT LPAREN RPAREN */ #line 614 "xpath.lime" { yymsp[-2].minor.yy106 = xpath_make_node_type_test(XPATH_NODE_TYPE_COMMENT); } #line 1665 "xpath.c" break; case 60: /* node_test ::= NODE_TYPE_TEXT LPAREN RPAREN */ #line 618 "xpath.lime" { yymsp[-2].minor.yy106 = xpath_make_node_type_test(XPATH_NODE_TYPE_TEXT); } #line 1672 "xpath.c" break; case 61: /* node_test ::= NODE_TYPE_PI LPAREN RPAREN */ #line 622 "xpath.lime" { yymsp[-2].minor.yy106 = xpath_make_node_type_test(XPATH_NODE_TYPE_PI); } #line 1679 "xpath.c" break; case 62: /* node_test ::= NODE_TYPE_PI LPAREN LITERAL RPAREN */ #line 626 "xpath.lime" { yymsp[-3].minor.yy106 = xpath_make_pi_test(yymsp[-1].minor.yy0.str.val, yymsp[-1].minor.yy0.str.len); } #line 1686 "xpath.c" break; case 63: /* node_test ::= NODE_TYPE_NODE LPAREN RPAREN */ #line 630 "xpath.lime" { yymsp[-2].minor.yy106 = xpath_make_node_type_test(XPATH_NODE_TYPE_NODE); } #line 1693 "xpath.c" break; case 64: /* predicate ::= LBRACKET expr RBRACKET */ case 70: /* primary_expr ::= LPAREN expr RPAREN */ yytestcase(yyruleno==70); #line 635 "xpath.lime" { yymsp[-2].minor.yy106 = yymsp[-1].minor.yy106; } #line 1699 "xpath.c" break; case 65: /* predicate_list ::= */ #line 638 "xpath.lime" { yymsp[1].minor.yy106 = NULL; } #line 1704 "xpath.c" break; case 66: /* predicate_list ::= predicate_list predicate */ #line 640 "xpath.lime" { yylhsminor.yy106 = xpath_append_predicate(yymsp[-1].minor.yy106, yymsp[0].minor.yy106); } #line 1711 "xpath.c" yymsp[-1].minor.yy106 = yylhsminor.yy106; break; case 67: /* abbreviated_step ::= DOT */ #line 649 "xpath.lime" { yymsp[0].minor.yy106 = xpath_make_step(XPATH_AXIS_SELF, xpath_make_node_type_test(XPATH_NODE_TYPE_NODE), NULL); } #line 1721 "xpath.c" break; case 68: /* abbreviated_step ::= DOUBLE_DOT */ #line 655 "xpath.lime" { yymsp[0].minor.yy106 = xpath_make_step(XPATH_AXIS_PARENT, xpath_make_node_type_test(XPATH_NODE_TYPE_NODE), NULL); } #line 1730 "xpath.c" break; case 69: /* primary_expr ::= VARIABLE_REF */ #line 662 "xpath.lime" { yylhsminor.yy106 = xpath_make_variable_ref(yymsp[0].minor.yy0.str.val, yymsp[0].minor.yy0.str.len); } #line 1737 "xpath.c" yymsp[0].minor.yy106 = yylhsminor.yy106; break; case 71: /* primary_expr ::= LITERAL */ #line 668 "xpath.lime" { yylhsminor.yy106 = xpath_make_literal(yymsp[0].minor.yy0.str.val, yymsp[0].minor.yy0.str.len); } #line 1745 "xpath.c" yymsp[0].minor.yy106 = yylhsminor.yy106; break; case 72: /* primary_expr ::= NUMBER */ #line 672 "xpath.lime" { yylhsminor.yy106 = xpath_make_number(yymsp[0].minor.yy0.numval); } #line 1753 "xpath.c" yymsp[0].minor.yy106 = yylhsminor.yy106; break; case 74: /* function_call ::= FUNCTION_NAME LPAREN argument_list RPAREN */ #line 692 "xpath.lime" { yylhsminor.yy106 = xpath_make_function_call(yymsp[-3].minor.yy0.str.val, yymsp[-3].minor.yy0.str.len, yymsp[-1].minor.yy34); } #line 1761 "xpath.c" yymsp[-3].minor.yy106 = yylhsminor.yy106; break; case 75: /* argument_list ::= */ #line 700 "xpath.lime" { yymsp[1].minor.yy34 = NULL; } #line 1767 "xpath.c" break; case 76: /* argument_list ::= arguments */ #line 702 "xpath.lime" { yylhsminor.yy34 = yymsp[0].minor.yy34; } #line 1772 "xpath.c" yymsp[0].minor.yy34 = yylhsminor.yy34; break; case 77: /* arguments ::= expr */ #line 704 "xpath.lime" { yylhsminor.yy34 = xpath_node_list_make1(yymsp[0].minor.yy106); } #line 1780 "xpath.c" yymsp[0].minor.yy34 = yylhsminor.yy34; break; case 78: /* arguments ::= arguments COMMA expr */ #line 708 "xpath.lime" { yylhsminor.yy34 = xpath_node_list_append(yymsp[-2].minor.yy34, yymsp[0].minor.yy106); } #line 1788 "xpath.c" yymsp[-2].minor.yy34 = yylhsminor.yy34; 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 */ ){ xpathParseARG_FETCH xpathParseCTX_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 201 "xpath.lime" pstate->error = 1; if (pstate->errMsg == NULL) { pstate->errMsg = "XPath parse failure"; } #line 1839 "xpath.c" /************ End %parse_failure code *****************************************/ xpathParseARG_STORE /* Suppress warning about unused %extra_argument variable */ xpathParseCTX_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 */ xpathParseTOKENTYPE yyminor /* The minor type of the error token */ ){ xpathParseARG_FETCH xpathParseCTX_FETCH #define TOKEN yyminor /************ Begin %syntax_error code ****************************************/ #line 194 "xpath.lime" pstate->error = 1; if (pstate->errMsg == NULL) { pstate->errMsg = "syntax error in XPath expression"; } #line 1864 "xpath.c" /************ End %syntax_error code ******************************************/ xpathParseARG_STORE /* Suppress warning about unused %extra_argument variable */ xpathParseCTX_STORE } /* ** The following is executed when the parser accepts */ static void yy_accept( yyParser *yypParser /* The parser */ ){ xpathParseARG_FETCH xpathParseCTX_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 *******************************************/ xpathParseARG_STORE /* Suppress warning about unused %extra_argument variable */ xpathParseCTX_STORE } /* The main parser program. ** The first argument is a pointer to a structure obtained from ** "xpathParseAlloc" 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 xpathParse( void *yyp, /* The parser */ int yymajor, /* The major token code number */ xpathParseTOKENTYPE yyminor /* The value for the token */ xpathParseARG_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 */ xpathParseCTX_FETCH xpathParseARG_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 xpathParseCTX_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 xpathParseFallback(int iToken){ #ifdef YYFALLBACK assert( iToken<(int)(sizeof(yyFallback)/sizeof(yyFallback[0])) ); return yyFallback[iToken]; #else (void)iToken; return 0; #endif }