1 /* A Bison parser, made by GNU Bison 3.0. */
3 /* Bison implementation for Yacc-like parsers in C
5 Copyright (C) 1984, 1989-1990, 2000-2013 Free Software Foundation, Inc.
7 This program is free software: you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation, either version 3 of the License, or
10 (at your option) any later version.
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with this program. If not, see <http://www.gnu.org/licenses/>. */
20 /* As a special exception, you may create a larger work that contains
21 part or all of the Bison parser skeleton and distribute that work
22 under terms of your choice, so long as that work isn't itself a
23 parser generator using the skeleton or a modified version thereof
24 as a parser skeleton. Alternatively, if you modify or redistribute
25 the parser skeleton itself, you may (at your option) remove this
26 special exception, which will cause the skeleton and the resulting
27 Bison output files to be licensed under the GNU General Public
28 License without this special exception.
30 This special exception was added by the Free Software Foundation in
31 version 2.2 of Bison. */
33 /* C LALR(1) parser skeleton written by Richard Stallman, by
34 simplifying the original so-called "semantic" parser. */
36 /* All symbols defined below should begin with yy or YY, to avoid
37 infringing on user name space. This should be done even for local
38 variables, as they might otherwise be expanded by user macros.
39 There are some unavoidable exceptions within include files to
40 define necessary library symbols; they are noted "INFRINGES ON
41 USER NAME SPACE" below. */
43 /* Identify Bison output. */
47 #define YYBISON_VERSION "3.0"
50 #define YYSKELETON_NAME "yacc.c"
62 /* Substitute the variable and function names. */
63 #define yyparse wql_parse
65 #define yyerror wql_error
66 #define yydebug wql_debug
67 #define yynerrs wql_nerrs
70 /* Copy the first part of user declarations. */
71 #line 1 "wql.y" /* yacc.c:339 */
75 * Copyright 2012 Hans Leidekker for CodeWeavers
77 * This library is free software; you can redistribute it and/or
78 * modify it under the terms of the GNU Lesser General Public
79 * License as published by the Free Software Foundation; either
80 * version 2.1 of the License, or (at your option) any later version.
82 * This library is distributed in the hope that it will be useful,
83 * but WITHOUT ANY WARRANTY; without even the implied warranty of
84 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
85 * Lesser General Public License for more details.
87 * You should have received a copy of the GNU Lesser General Public
88 * License along with this library; if not, write to the Free Software
89 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
98 #include "wbemprox_private.h"
100 #include "wine/list.h"
101 #include "wine/debug.h"
102 #include "wine/unicode.h"
104 WINE_DEFAULT_DEBUG_CHANNEL(wbemprox
);
122 static void *alloc_mem( struct parser
*parser
, UINT size
)
124 struct list
*mem
= heap_alloc( sizeof(struct list
) + size
);
125 list_add_tail( parser
->mem
, mem
);
129 static struct property
*alloc_property( struct parser
*parser
, const WCHAR
*class, const WCHAR
*name
)
131 struct property
*prop
= alloc_mem( parser
, sizeof(*prop
) );
141 static WCHAR
*get_string( struct parser
*parser
, const struct string
*str
)
143 const WCHAR
*p
= str
->data
;
147 if ((p
[0] == '\"' && p
[len
- 1] != '\"') ||
148 (p
[0] == '\'' && p
[len
- 1] != '\'')) return NULL
;
149 if ((p
[0] == '\"' && p
[len
- 1] == '\"') ||
150 (p
[0] == '\'' && p
[len
- 1] == '\''))
155 if (!(ret
= alloc_mem( parser
, (len
+ 1) * sizeof(WCHAR
) ))) return NULL
;
156 memcpy( ret
, p
, len
* sizeof(WCHAR
) );
161 static int get_int( struct parser
*parser
)
163 const WCHAR
*p
= &parser
->cmd
[parser
->idx
];
166 for (i
= 0; i
< parser
->len
; i
++)
168 if (p
[i
] < '0' || p
[i
] > '9')
170 ERR("should only be numbers here!\n");
173 ret
= (p
[i
] - '0') + ret
* 10;
178 static struct expr
*expr_complex( struct parser
*parser
, struct expr
*l
, UINT op
, struct expr
*r
)
180 struct expr
*e
= alloc_mem( parser
, sizeof(*e
) );
183 e
->type
= EXPR_COMPLEX
;
191 static struct expr
*expr_unary( struct parser
*parser
, struct expr
*l
, UINT op
)
193 struct expr
*e
= alloc_mem( parser
, sizeof(*e
) );
196 e
->type
= EXPR_UNARY
;
199 e
->u
.expr
.right
= NULL
;
204 static struct expr
*expr_ival( struct parser
*parser
, int val
)
206 struct expr
*e
= alloc_mem( parser
, sizeof *e
);
215 static struct expr
*expr_sval( struct parser
*parser
, const struct string
*str
)
217 struct expr
*e
= alloc_mem( parser
, sizeof *e
);
221 e
->u
.sval
= get_string( parser
, str
);
223 return NULL
; /* e will be freed by query destructor */
228 static struct expr
*expr_bval( struct parser
*parser
, int val
)
230 struct expr
*e
= alloc_mem( parser
, sizeof *e
);
239 static struct expr
*expr_propval( struct parser
*parser
, const struct property
*prop
)
241 struct expr
*e
= alloc_mem( parser
, sizeof *e
);
244 e
->type
= EXPR_PROPVAL
;
250 static int wql_error( struct parser
*parser
, const char *str
);
251 static int wql_lex( void *val
, struct parser
*parser
);
253 #define PARSER_BUBBLE_UP_VIEW( parser, result, current_view ) \
254 *parser->view = current_view; \
255 result = current_view
258 #line 259 "wql.tab.c" /* yacc.c:339 */
261 # if defined __cplusplus && 201103L <= __cplusplus
262 # define YY_NULL nullptr
268 /* Enabling verbose error messages. */
269 #ifdef YYERROR_VERBOSE
270 # undef YYERROR_VERBOSE
271 # define YYERROR_VERBOSE 1
273 # define YYERROR_VERBOSE 1
276 /* In a future release of Bison, this section will be replaced
277 by #include "wql.tab.h". */
278 #ifndef YY_WQL_E_REACTOSSYNC_GCC_DLL_WIN32_WBEMPROX_WQL_TAB_H_INCLUDED
279 # define YY_WQL_E_REACTOSSYNC_GCC_DLL_WIN32_WBEMPROX_WQL_TAB_H_INCLUDED
285 extern int wql_debug
;
326 #if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
327 typedef union YYSTYPE YYSTYPE
;
330 #line 194 "wql.y" /* yacc.c:355 */
334 struct property
*proplist
;
339 #line 340 "wql.tab.c" /* yacc.c:355 */
341 # define YYSTYPE_IS_TRIVIAL 1
342 # define YYSTYPE_IS_DECLARED 1
347 int wql_parse (struct parser
*ctx
);
349 #endif /* !YY_WQL_E_REACTOSSYNC_GCC_DLL_WIN32_WBEMPROX_WQL_TAB_H_INCLUDED */
351 /* Copy the second part of user declarations. */
353 #line 354 "wql.tab.c" /* yacc.c:358 */
360 typedef YYTYPE_UINT8 yytype_uint8
;
362 typedef unsigned char yytype_uint8
;
366 typedef YYTYPE_INT8 yytype_int8
;
368 typedef signed char yytype_int8
;
372 typedef YYTYPE_UINT16 yytype_uint16
;
374 typedef unsigned short int yytype_uint16
;
378 typedef YYTYPE_INT16 yytype_int16
;
380 typedef short int yytype_int16
;
384 # ifdef __SIZE_TYPE__
385 # define YYSIZE_T __SIZE_TYPE__
386 # elif defined size_t
387 # define YYSIZE_T size_t
388 # elif ! defined YYSIZE_T
389 # include <stddef.h> /* INFRINGES ON USER NAME SPACE */
390 # define YYSIZE_T size_t
392 # define YYSIZE_T unsigned int
396 #define YYSIZE_MAXIMUM ((YYSIZE_T) -1)
399 # if defined YYENABLE_NLS && YYENABLE_NLS
401 # include <libintl.h> /* INFRINGES ON USER NAME SPACE */
402 # define YY_(Msgid) dgettext ("bison-runtime", Msgid)
406 # define YY_(Msgid) Msgid
410 #ifndef __attribute__
411 /* This feature is available in gcc versions 2.5 and later. */
412 # if (! defined __GNUC__ || __GNUC__ < 2 \
413 || (__GNUC__ == 2 && __GNUC_MINOR__ < 5))
414 # define __attribute__(Spec) /* empty */
418 /* Suppress unused-variable warnings by "using" E. */
419 #if ! defined lint || defined __GNUC__
420 # define YYUSE(E) ((void) (E))
422 # define YYUSE(E) /* empty */
425 #if defined __GNUC__ && 407 <= __GNUC__ * 100 + __GNUC_MINOR__
426 /* Suppress an incorrect diagnostic about yylval being uninitialized. */
427 # define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN \
428 _Pragma ("GCC diagnostic push") \
429 _Pragma ("GCC diagnostic ignored \"-Wuninitialized\"")\
430 _Pragma ("GCC diagnostic ignored \"-Wmaybe-uninitialized\"")
431 # define YY_IGNORE_MAYBE_UNINITIALIZED_END \
432 _Pragma ("GCC diagnostic pop")
434 # define YY_INITIAL_VALUE(Value) Value
436 #ifndef YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
437 # define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
438 # define YY_IGNORE_MAYBE_UNINITIALIZED_END
440 #ifndef YY_INITIAL_VALUE
441 # define YY_INITIAL_VALUE(Value) /* Nothing. */
445 #if ! defined yyoverflow || YYERROR_VERBOSE
447 /* The parser invokes alloca or malloc; define the necessary symbols. */
449 # ifdef YYSTACK_USE_ALLOCA
450 # if YYSTACK_USE_ALLOCA
452 # define YYSTACK_ALLOC __builtin_alloca
453 # elif defined __BUILTIN_VA_ARG_INCR
454 # include <alloca.h> /* INFRINGES ON USER NAME SPACE */
456 # define YYSTACK_ALLOC __alloca
457 # elif defined _MSC_VER
458 # include <malloc.h> /* INFRINGES ON USER NAME SPACE */
459 # define alloca _alloca
461 # define YYSTACK_ALLOC alloca
462 # if ! defined _ALLOCA_H && ! defined EXIT_SUCCESS
463 # include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
464 /* Use EXIT_SUCCESS as a witness for stdlib.h. */
465 # ifndef EXIT_SUCCESS
466 # define EXIT_SUCCESS 0
473 # ifdef YYSTACK_ALLOC
474 /* Pacify GCC's 'empty if-body' warning. */
475 # define YYSTACK_FREE(Ptr) do { /* empty */; } while (0)
476 # ifndef YYSTACK_ALLOC_MAXIMUM
477 /* The OS might guarantee only one guard page at the bottom of the stack,
478 and a page size can be as small as 4096 bytes. So we cannot safely
479 invoke alloca (N) if N exceeds 4096. Use a slightly smaller number
480 to allow for a few compiler-allocated temporary stack slots. */
481 # define YYSTACK_ALLOC_MAXIMUM 4032 /* reasonable circa 2006 */
484 # define YYSTACK_ALLOC YYMALLOC
485 # define YYSTACK_FREE YYFREE
486 # ifndef YYSTACK_ALLOC_MAXIMUM
487 # define YYSTACK_ALLOC_MAXIMUM YYSIZE_MAXIMUM
489 # if (defined __cplusplus && ! defined EXIT_SUCCESS \
490 && ! ((defined YYMALLOC || defined malloc) \
491 && (defined YYFREE || defined free)))
492 # include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
493 # ifndef EXIT_SUCCESS
494 # define EXIT_SUCCESS 0
498 # define YYMALLOC malloc
499 # if ! defined malloc && ! defined EXIT_SUCCESS
500 void *malloc (YYSIZE_T
); /* INFRINGES ON USER NAME SPACE */
505 # if ! defined free && ! defined EXIT_SUCCESS
506 void free (void *); /* INFRINGES ON USER NAME SPACE */
510 #endif /* ! defined yyoverflow || YYERROR_VERBOSE */
513 #if (! defined yyoverflow \
514 && (! defined __cplusplus \
515 || (defined YYSTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL)))
517 /* A type that is properly aligned for any stack member. */
520 yytype_int16 yyss_alloc
;
524 /* The size of the maximum gap between one aligned stack and the next. */
525 # define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1)
527 /* The size of an array large to enough to hold all stacks, each with
529 # define YYSTACK_BYTES(N) \
530 ((N) * (sizeof (yytype_int16) + sizeof (YYSTYPE)) \
531 + YYSTACK_GAP_MAXIMUM)
533 # define YYCOPY_NEEDED 1
535 /* Relocate STACK from its old location to the new one. The
536 local variables YYSIZE and YYSTACKSIZE give the old and new number of
537 elements in the stack, and YYPTR gives the new location of the
538 stack. Advance YYPTR to a properly aligned location for the next
540 # define YYSTACK_RELOCATE(Stack_alloc, Stack) \
543 YYSIZE_T yynewbytes; \
544 YYCOPY (&yyptr->Stack_alloc, Stack, yysize); \
545 Stack = &yyptr->Stack_alloc; \
546 yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \
547 yyptr += yynewbytes / sizeof (*yyptr); \
553 #if defined YYCOPY_NEEDED && YYCOPY_NEEDED
554 /* Copy COUNT objects from SRC to DST. The source and destination do
557 # if defined __GNUC__ && 1 < __GNUC__
558 # define YYCOPY(Dst, Src, Count) \
559 __builtin_memcpy (Dst, Src, (Count) * sizeof (*(Src)))
561 # define YYCOPY(Dst, Src, Count) \
565 for (yyi = 0; yyi < (Count); yyi++) \
566 (Dst)[yyi] = (Src)[yyi]; \
571 #endif /* !YYCOPY_NEEDED */
573 /* YYFINAL -- State number of the termination state. */
575 /* YYLAST -- Last index in YYTABLE. */
578 /* YYNTOKENS -- Number of terminals. */
580 /* YYNNTS -- Number of nonterminals. */
582 /* YYNRULES -- Number of rules. */
584 /* YYNSTATES -- Number of states. */
587 /* YYTRANSLATE[YYX] -- Symbol number corresponding to YYX as returned
588 by yylex, with out-of-bounds checking. */
590 #define YYMAXUTOK 286
592 #define YYTRANSLATE(YYX) \
593 ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK)
595 /* YYTRANSLATE[TOKEN-NUM] -- Symbol number corresponding to TOKEN-NUM
596 as returned by yylex, without out-of-bounds checking. */
597 static const yytype_uint8 yytranslate
[] =
599 0, 2, 2, 2, 2, 2, 2, 2, 2, 2,
600 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
601 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
602 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
603 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
604 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
605 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
606 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
607 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
608 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
609 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
610 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
611 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
612 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
613 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
614 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
615 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
616 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
617 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
618 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
619 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
620 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
621 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
622 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
623 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
624 2, 2, 2, 2, 2, 2, 1, 2, 3, 4,
625 5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
626 15, 16, 17, 18, 19, 20, 21, 22, 23, 24,
627 25, 26, 27, 28, 29, 30, 31
631 /* YYRLINE[YYN] -- Source line where rule number YYN was defined. */
632 static const yytype_uint16 yyrline
[] =
634 0, 221, 221, 233, 245, 260, 261, 265, 272, 278,
635 287, 296, 303, 309, 315, 321, 327, 333, 339, 345,
636 351, 357, 363, 369, 375, 381, 387, 393, 399, 405,
637 411, 417, 423, 429, 435, 444, 453, 462, 468, 474,
642 #if YYDEBUG || YYERROR_VERBOSE || 1
643 /* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
644 First, the terminals, then, starting at YYNTOKENS, nonterminals. */
645 static const char *const yytname
[] =
647 "$end", "error", "$undefined", "TK_SELECT", "TK_FROM", "TK_STAR",
648 "TK_COMMA", "TK_DOT", "TK_IS", "TK_LP", "TK_RP", "TK_NULL", "TK_FALSE",
649 "TK_TRUE", "TK_INTEGER", "TK_WHERE", "TK_SPACE", "TK_MINUS",
650 "TK_ILLEGAL", "TK_BY", "TK_STRING", "TK_ID", "TK_OR", "TK_AND", "TK_NOT",
651 "TK_EQ", "TK_NE", "TK_LT", "TK_GT", "TK_LE", "TK_GE", "TK_LIKE",
652 "$accept", "select", "proplist", "prop", "id", "number", "expr",
653 "string_val", "prop_val", "const_val", YY_NULL
658 /* YYTOKNUM[NUM] -- (External) token number corresponding to the
659 (internal) symbol number NUM (which must be that of a token). */
660 static const yytype_uint16 yytoknum
[] =
662 0, 256, 257, 258, 259, 260, 261, 262, 263, 264,
663 265, 266, 267, 268, 269, 270, 271, 272, 273, 274,
664 275, 276, 277, 278, 279, 280, 281, 282, 283, 284,
669 #define YYPACT_NINF -23
671 #define yypact_value_is_default(Yystate) \
672 (!!((Yystate) == (-23)))
674 #define YYTABLE_NINF -1
676 #define yytable_value_is_error(Yytable_value) \
679 /* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
681 static const yytype_int8 yypact
[] =
683 -2, 10, 34, 14, -23, -23, 29, 48, 46, -23,
684 -23, 14, 11, 14, 42, -23, -23, 28, 28, -16,
685 -23, -23, -23, -23, 28, -23, -23, 22, -8, -22,
686 33, 14, 14, -23, 28, 28, 27, 50, 54, 59,
687 59, 59, 59, 39, 14, 14, 14, 14, 14, 14,
688 -23, -23, -23, 52, -23, -23, 58, -23, -23, -23,
689 -23, -23, -23, -23, -23, -23, -23, -23, -23, -23,
693 /* YYDEFACT[STATE-NUM] -- Default reduction number in state STATE-NUM.
694 Performed when YYTABLE does not specify something else to do. Zero
695 means the default is an error. */
696 static const yytype_uint8 yydefact
[] =
698 0, 0, 0, 0, 7, 10, 0, 5, 9, 1,
699 2, 0, 0, 0, 3, 6, 8, 0, 0, 0,
700 40, 39, 11, 38, 0, 36, 37, 4, 0, 0,
701 0, 0, 0, 15, 0, 0, 0, 0, 0, 0,
702 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
703 12, 32, 34, 14, 13, 29, 0, 31, 16, 33,
704 21, 18, 17, 19, 20, 35, 28, 22, 27, 24,
708 /* YYPGOTO[NTERM-NUM]. */
709 static const yytype_int8 yypgoto
[] =
711 -23, -23, 64, 1, 47, -23, 12, -23, -20, 43
714 /* YYDEFGOTO[NTERM-NUM]. */
715 static const yytype_int8 yydefgoto
[] =
717 -1, 2, 6, 25, 8, 26, 27, 66, 28, 29
720 /* YYTABLE[YYPACT[STATE-NUM]] -- What to do in state STATE-NUM. If
721 positive, shift that token. If negative, reduce the rule whose
722 number is the opposite. If YYTABLE_NINF, syntax error. */
723 static const yytype_uint8 yytable
[] =
725 36, 1, 7, 44, 45, 46, 47, 48, 49, 31,
726 32, 51, 52, 7, 3, 4, 4, 37, 38, 39,
727 40, 41, 42, 43, 67, 68, 69, 70, 71, 72,
728 30, 5, 5, 11, 9, 5, 33, 18, 55, 19,
729 20, 21, 22, 50, 34, 35, 53, 54, 23, 5,
730 10, 56, 24, 13, 12, 34, 35, 17, 14, 65,
731 16, 57, 20, 21, 22, 59, 20, 21, 22, 73,
732 23, 20, 21, 22, 23, 35, 15, 0, 0, 23,
733 58, 60, 61, 62, 63, 64
736 static const yytype_int8 yycheck
[] =
738 8, 3, 1, 25, 26, 27, 28, 29, 30, 25,
739 26, 31, 32, 12, 4, 5, 5, 25, 26, 27,
740 28, 29, 30, 31, 44, 45, 46, 47, 48, 49,
741 18, 21, 21, 4, 0, 21, 24, 9, 11, 11,
742 12, 13, 14, 10, 22, 23, 34, 35, 20, 21,
743 3, 24, 24, 7, 6, 22, 23, 15, 11, 20,
744 13, 11, 12, 13, 14, 11, 12, 13, 14, 11,
745 20, 12, 13, 14, 20, 23, 12, -1, -1, 20,
746 37, 38, 39, 40, 41, 42
749 /* YYSTOS[STATE-NUM] -- The (internal number of the) accessing
750 symbol of state STATE-NUM. */
751 static const yytype_uint8 yystos
[] =
753 0, 3, 33, 4, 5, 21, 34, 35, 36, 0,
754 36, 4, 6, 7, 36, 34, 36, 15, 9, 11,
755 12, 13, 14, 20, 24, 35, 37, 38, 40, 41,
756 38, 25, 26, 38, 22, 23, 8, 25, 26, 27,
757 28, 29, 30, 31, 25, 26, 27, 28, 29, 30,
758 10, 40, 40, 38, 38, 11, 24, 11, 41, 11,
759 41, 41, 41, 41, 41, 20, 39, 40, 40, 40,
763 /* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */
764 static const yytype_uint8 yyr1
[] =
766 0, 32, 33, 33, 33, 34, 34, 34, 35, 35,
767 36, 37, 38, 38, 38, 38, 38, 38, 38, 38,
768 38, 38, 38, 38, 38, 38, 38, 38, 38, 38,
769 38, 38, 38, 38, 38, 39, 40, 41, 41, 41,
773 /* YYR2[YYN] -- Number of symbols on the right hand side of rule YYN. */
774 static const yytype_uint8 yyr2
[] =
776 0, 2, 3, 4, 6, 1, 3, 1, 3, 1,
777 1, 1, 3, 3, 3, 2, 3, 3, 3, 3,
778 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
779 4, 3, 3, 3, 3, 1, 1, 1, 1, 1,
784 #define yyerrok (yyerrstatus = 0)
785 #define yyclearin (yychar = YYEMPTY)
789 #define YYACCEPT goto yyacceptlab
790 #define YYABORT goto yyabortlab
791 #define YYERROR goto yyerrorlab
794 #define YYRECOVERING() (!!yyerrstatus)
796 #define YYBACKUP(Token, Value) \
798 if (yychar == YYEMPTY) \
802 YYPOPSTACK (yylen); \
808 yyerror (ctx, YY_("syntax error: cannot back up")); \
813 /* Error token number */
815 #define YYERRCODE 256
819 /* Enable debugging if requested. */
823 # include <stdio.h> /* INFRINGES ON USER NAME SPACE */
824 # define YYFPRINTF fprintf
827 # define YYDPRINTF(Args) \
833 /* This macro is provided for backward compatibility. */
834 #ifndef YY_LOCATION_PRINT
835 # define YY_LOCATION_PRINT(File, Loc) ((void) 0)
839 # define YY_SYMBOL_PRINT(Title, Type, Value, Location) \
843 YYFPRINTF (stderr, "%s ", Title); \
844 yy_symbol_print (stderr, \
846 YYFPRINTF (stderr, "\n"); \
851 /*----------------------------------------.
852 | Print this symbol's value on YYOUTPUT. |
853 `----------------------------------------*/
856 yy_symbol_value_print (FILE *yyoutput
, int yytype
, YYSTYPE
const * const yyvaluep
, struct parser
*ctx
)
858 FILE *yyo
= yyoutput
;
864 if (yytype
< YYNTOKENS
)
865 YYPRINT (yyoutput
, yytoknum
[yytype
], *yyvaluep
);
871 /*--------------------------------.
872 | Print this symbol on YYOUTPUT. |
873 `--------------------------------*/
876 yy_symbol_print (FILE *yyoutput
, int yytype
, YYSTYPE
const * const yyvaluep
, struct parser
*ctx
)
878 YYFPRINTF (yyoutput
, "%s %s (",
879 yytype
< YYNTOKENS
? "token" : "nterm", yytname
[yytype
]);
881 yy_symbol_value_print (yyoutput
, yytype
, yyvaluep
, ctx
);
882 YYFPRINTF (yyoutput
, ")");
885 /*------------------------------------------------------------------.
886 | yy_stack_print -- Print the state stack from its BOTTOM up to its |
888 `------------------------------------------------------------------*/
891 yy_stack_print (yytype_int16
*yybottom
, yytype_int16
*yytop
)
893 YYFPRINTF (stderr
, "Stack now");
894 for (; yybottom
<= yytop
; yybottom
++)
896 int yybot
= *yybottom
;
897 YYFPRINTF (stderr
, " %d", yybot
);
899 YYFPRINTF (stderr
, "\n");
902 # define YY_STACK_PRINT(Bottom, Top) \
905 yy_stack_print ((Bottom), (Top)); \
909 /*------------------------------------------------.
910 | Report that the YYRULE is going to be reduced. |
911 `------------------------------------------------*/
914 yy_reduce_print (yytype_int16
*yyssp
, YYSTYPE
*yyvsp
, int yyrule
, struct parser
*ctx
)
916 unsigned long int yylno
= yyrline
[yyrule
];
917 int yynrhs
= yyr2
[yyrule
];
919 YYFPRINTF (stderr
, "Reducing stack by rule %d (line %lu):\n",
921 /* The symbols being reduced. */
922 for (yyi
= 0; yyi
< yynrhs
; yyi
++)
924 YYFPRINTF (stderr
, " $%d = ", yyi
+ 1);
925 yy_symbol_print (stderr
,
926 yystos
[yyssp
[yyi
+ 1 - yynrhs
]],
927 &(yyvsp
[(yyi
+ 1) - (yynrhs
)])
929 YYFPRINTF (stderr
, "\n");
933 # define YY_REDUCE_PRINT(Rule) \
936 yy_reduce_print (yyssp, yyvsp, Rule, ctx); \
939 /* Nonzero means print parse trace. It is left uninitialized so that
940 multiple parsers can coexist. */
943 # define YYDPRINTF(Args)
944 # define YY_SYMBOL_PRINT(Title, Type, Value, Location)
945 # define YY_STACK_PRINT(Bottom, Top)
946 # define YY_REDUCE_PRINT(Rule)
947 #endif /* !YYDEBUG */
950 /* YYINITDEPTH -- initial size of the parser's stacks. */
952 # define YYINITDEPTH 200
955 /* YYMAXDEPTH -- maximum size the stacks can grow to (effective only
956 if the built-in stack extension method is used).
958 Do not make this value too large; the results are undefined if
959 YYSTACK_ALLOC_MAXIMUM < YYSTACK_BYTES (YYMAXDEPTH)
960 evaluated with infinite-precision integer arithmetic. */
963 # define YYMAXDEPTH 10000
970 # if defined __GLIBC__ && defined _STRING_H
971 # define yystrlen strlen
973 /* Return the length of YYSTR. */
975 yystrlen (const char *yystr
)
978 for (yylen
= 0; yystr
[yylen
]; yylen
++)
986 # if defined __GLIBC__ && defined _STRING_H && defined _GNU_SOURCE
987 # define yystpcpy stpcpy
989 /* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in
992 yystpcpy (char *yydest
, const char *yysrc
)
995 const char *yys
= yysrc
;
997 while ((*yyd
++ = *yys
++) != '\0')
1006 /* Copy to YYRES the contents of YYSTR after stripping away unnecessary
1007 quotes and backslashes, so that it's suitable for yyerror. The
1008 heuristic is that double-quoting is unnecessary unless the string
1009 contains an apostrophe, a comma, or backslash (other than
1010 backslash-backslash). YYSTR is taken from yytname. If YYRES is
1011 null, do not copy; instead, return the length of what the result
1014 yytnamerr (char *yyres
, const char *yystr
)
1019 char const *yyp
= yystr
;
1026 goto do_not_strip_quotes
;
1030 goto do_not_strip_quotes
;
1043 do_not_strip_quotes
: ;
1047 return yystrlen (yystr
);
1049 return yystpcpy (yyres
, yystr
) - yyres
;
1053 /* Copy into *YYMSG, which is of size *YYMSG_ALLOC, an error message
1054 about the unexpected token YYTOKEN for the state stack whose top is
1057 Return 0 if *YYMSG was successfully written. Return 1 if *YYMSG is
1058 not large enough to hold the message. In that case, also set
1059 *YYMSG_ALLOC to the required number of bytes. Return 2 if the
1060 required number of bytes is too large to store. */
1062 yysyntax_error (YYSIZE_T
*yymsg_alloc
, char **yymsg
,
1063 yytype_int16
*yyssp
, int yytoken
)
1065 YYSIZE_T yysize0
= yytnamerr (YY_NULL
, yytname
[yytoken
]);
1066 YYSIZE_T yysize
= yysize0
;
1067 enum { YYERROR_VERBOSE_ARGS_MAXIMUM
= 5 };
1068 /* Internationalized format string. */
1069 const char *yyformat
= YY_NULL
;
1070 /* Arguments of yyformat. */
1071 char const *yyarg
[YYERROR_VERBOSE_ARGS_MAXIMUM
];
1072 /* Number of reported tokens (one for the "unexpected", one per
1076 /* There are many possibilities here to consider:
1077 - If this state is a consistent state with a default action, then
1078 the only way this function was invoked is if the default action
1079 is an error action. In that case, don't check for expected
1080 tokens because there are none.
1081 - The only way there can be no lookahead present (in yychar) is if
1082 this state is a consistent state with a default action. Thus,
1083 detecting the absence of a lookahead is sufficient to determine
1084 that there is no unexpected or expected token to report. In that
1085 case, just report a simple "syntax error".
1086 - Don't assume there isn't a lookahead just because this state is a
1087 consistent state with a default action. There might have been a
1088 previous inconsistent state, consistent state with a non-default
1089 action, or user semantic action that manipulated yychar.
1090 - Of course, the expected token list depends on states to have
1091 correct lookahead information, and it depends on the parser not
1092 to perform extra reductions after fetching a lookahead from the
1093 scanner and before detecting a syntax error. Thus, state merging
1094 (from LALR or IELR) and default reductions corrupt the expected
1095 token list. However, the list is correct for canonical LR with
1096 one exception: it will still contain any token that will not be
1097 accepted due to an error action in a later state.
1099 if (yytoken
!= YYEMPTY
)
1101 int yyn
= yypact
[*yyssp
];
1102 yyarg
[yycount
++] = yytname
[yytoken
];
1103 if (!yypact_value_is_default (yyn
))
1105 /* Start YYX at -YYN if negative to avoid negative indexes in
1106 YYCHECK. In other words, skip the first -YYN actions for
1107 this state because they are default actions. */
1108 int yyxbegin
= yyn
< 0 ? -yyn
: 0;
1109 /* Stay within bounds of both yycheck and yytname. */
1110 int yychecklim
= YYLAST
- yyn
+ 1;
1111 int yyxend
= yychecklim
< YYNTOKENS
? yychecklim
: YYNTOKENS
;
1114 for (yyx
= yyxbegin
; yyx
< yyxend
; ++yyx
)
1115 if (yycheck
[yyx
+ yyn
] == yyx
&& yyx
!= YYTERROR
1116 && !yytable_value_is_error (yytable
[yyx
+ yyn
]))
1118 if (yycount
== YYERROR_VERBOSE_ARGS_MAXIMUM
)
1124 yyarg
[yycount
++] = yytname
[yyx
];
1126 YYSIZE_T yysize1
= yysize
+ yytnamerr (YY_NULL
, yytname
[yyx
]);
1127 if (! (yysize
<= yysize1
1128 && yysize1
<= YYSTACK_ALLOC_MAXIMUM
))
1138 # define YYCASE_(N, S) \
1142 YYCASE_(0, YY_("syntax error"));
1143 YYCASE_(1, YY_("syntax error, unexpected %s"));
1144 YYCASE_(2, YY_("syntax error, unexpected %s, expecting %s"));
1145 YYCASE_(3, YY_("syntax error, unexpected %s, expecting %s or %s"));
1146 YYCASE_(4, YY_("syntax error, unexpected %s, expecting %s or %s or %s"));
1147 YYCASE_(5, YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s"));
1152 YYSIZE_T yysize1
= yysize
+ yystrlen (yyformat
);
1153 if (! (yysize
<= yysize1
&& yysize1
<= YYSTACK_ALLOC_MAXIMUM
))
1158 if (*yymsg_alloc
< yysize
)
1160 *yymsg_alloc
= 2 * yysize
;
1161 if (! (yysize
<= *yymsg_alloc
1162 && *yymsg_alloc
<= YYSTACK_ALLOC_MAXIMUM
))
1163 *yymsg_alloc
= YYSTACK_ALLOC_MAXIMUM
;
1167 /* Avoid sprintf, as that infringes on the user's name space.
1168 Don't have undefined behavior even if the translation
1169 produced a string with the wrong number of "%s"s. */
1173 while ((*yyp
= *yyformat
) != '\0')
1174 if (*yyp
== '%' && yyformat
[1] == 's' && yyi
< yycount
)
1176 yyp
+= yytnamerr (yyp
, yyarg
[yyi
++]);
1187 #endif /* YYERROR_VERBOSE */
1189 /*-----------------------------------------------.
1190 | Release the memory associated to this symbol. |
1191 `-----------------------------------------------*/
1194 yydestruct (const char *yymsg
, int yytype
, YYSTYPE
*yyvaluep
, struct parser
*ctx
)
1200 YY_SYMBOL_PRINT (yymsg
, yytype
, yyvaluep
, yylocationp
);
1202 YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
1204 YY_IGNORE_MAYBE_UNINITIALIZED_END
1215 yyparse (struct parser
*ctx
)
1217 /* The lookahead symbol. */
1221 /* The semantic value of the lookahead symbol. */
1222 /* Default value used for initialization, for pacifying older GCCs
1223 or non-GCC compilers. */
1224 YY_INITIAL_VALUE (static YYSTYPE yyval_default
;)
1225 YYSTYPE yylval
YY_INITIAL_VALUE (= yyval_default
);
1227 /* Number of syntax errors so far. */
1231 /* Number of tokens to shift before error messages enabled. */
1234 /* The stacks and their tools:
1235 'yyss': related to states.
1236 'yyvs': related to semantic values.
1238 Refer to the stacks through separate pointers, to allow yyoverflow
1239 to reallocate them elsewhere. */
1241 /* The state stack. */
1242 yytype_int16 yyssa
[YYINITDEPTH
];
1244 yytype_int16
*yyssp
;
1246 /* The semantic value stack. */
1247 YYSTYPE yyvsa
[YYINITDEPTH
];
1251 YYSIZE_T yystacksize
;
1255 /* Lookahead token as an internal (translated) token number. */
1257 /* The variables used to return semantic value and location from the
1262 /* Buffer for error messages, and its allocated size. */
1264 char *yymsg
= yymsgbuf
;
1265 YYSIZE_T yymsg_alloc
= sizeof yymsgbuf
;
1268 #define YYPOPSTACK(N) (yyvsp -= (N), yyssp -= (N))
1270 /* The number of symbols on the RHS of the reduced rule.
1271 Keep to zero when no symbol should be popped. */
1274 yyssp
= yyss
= yyssa
;
1275 yyvsp
= yyvs
= yyvsa
;
1276 yystacksize
= YYINITDEPTH
;
1278 YYDPRINTF ((stderr
, "Starting parse\n"));
1283 yychar
= YYEMPTY
; /* Cause a token to be read. */
1286 /*------------------------------------------------------------.
1287 | yynewstate -- Push a new state, which is found in yystate. |
1288 `------------------------------------------------------------*/
1290 /* In all cases, when you get here, the value and location stacks
1291 have just been pushed. So pushing a state here evens the stacks. */
1297 if (yyss
+ yystacksize
- 1 <= yyssp
)
1299 /* Get the current used size of the three stacks, in elements. */
1300 YYSIZE_T yysize
= yyssp
- yyss
+ 1;
1304 /* Give user a chance to reallocate the stack. Use copies of
1305 these so that the &'s don't force the real ones into
1307 YYSTYPE
*yyvs1
= yyvs
;
1308 yytype_int16
*yyss1
= yyss
;
1310 /* Each stack pointer address is followed by the size of the
1311 data in use in that stack, in bytes. This used to be a
1312 conditional around just the two extra args, but that might
1313 be undefined if yyoverflow is a macro. */
1314 yyoverflow (YY_("memory exhausted"),
1315 &yyss1
, yysize
* sizeof (*yyssp
),
1316 &yyvs1
, yysize
* sizeof (*yyvsp
),
1322 #else /* no yyoverflow */
1323 # ifndef YYSTACK_RELOCATE
1324 goto yyexhaustedlab
;
1326 /* Extend the stack our own way. */
1327 if (YYMAXDEPTH
<= yystacksize
)
1328 goto yyexhaustedlab
;
1330 if (YYMAXDEPTH
< yystacksize
)
1331 yystacksize
= YYMAXDEPTH
;
1334 yytype_int16
*yyss1
= yyss
;
1335 union yyalloc
*yyptr
=
1336 (union yyalloc
*) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize
));
1338 goto yyexhaustedlab
;
1339 YYSTACK_RELOCATE (yyss_alloc
, yyss
);
1340 YYSTACK_RELOCATE (yyvs_alloc
, yyvs
);
1341 # undef YYSTACK_RELOCATE
1343 YYSTACK_FREE (yyss1
);
1346 #endif /* no yyoverflow */
1348 yyssp
= yyss
+ yysize
- 1;
1349 yyvsp
= yyvs
+ yysize
- 1;
1351 YYDPRINTF ((stderr
, "Stack size increased to %lu\n",
1352 (unsigned long int) yystacksize
));
1354 if (yyss
+ yystacksize
- 1 <= yyssp
)
1358 YYDPRINTF ((stderr
, "Entering state %d\n", yystate
));
1360 if (yystate
== YYFINAL
)
1370 /* Do appropriate processing given the current state. Read a
1371 lookahead token if we need one and don't already have one. */
1373 /* First try to decide what to do without reference to lookahead token. */
1374 yyn
= yypact
[yystate
];
1375 if (yypact_value_is_default (yyn
))
1378 /* Not known => get a lookahead token if don't already have one. */
1380 /* YYCHAR is either YYEMPTY or YYEOF or a valid lookahead symbol. */
1381 if (yychar
== YYEMPTY
)
1383 YYDPRINTF ((stderr
, "Reading a token: "));
1384 yychar
= yylex (&yylval
, ctx
);
1387 if (yychar
<= YYEOF
)
1389 yychar
= yytoken
= YYEOF
;
1390 YYDPRINTF ((stderr
, "Now at end of input.\n"));
1394 yytoken
= YYTRANSLATE (yychar
);
1395 YY_SYMBOL_PRINT ("Next token is", yytoken
, &yylval
, &yylloc
);
1398 /* If the proper action on seeing token YYTOKEN is to reduce or to
1399 detect an error, take that action. */
1401 if (yyn
< 0 || YYLAST
< yyn
|| yycheck
[yyn
] != yytoken
)
1406 if (yytable_value_is_error (yyn
))
1412 /* Count tokens shifted since error; after three, turn off error
1417 /* Shift the lookahead token. */
1418 YY_SYMBOL_PRINT ("Shifting", yytoken
, &yylval
, &yylloc
);
1420 /* Discard the shifted token. */
1424 YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
1426 YY_IGNORE_MAYBE_UNINITIALIZED_END
1431 /*-----------------------------------------------------------.
1432 | yydefault -- do the default action for the current state. |
1433 `-----------------------------------------------------------*/
1435 yyn
= yydefact
[yystate
];
1441 /*-----------------------------.
1442 | yyreduce -- Do a reduction. |
1443 `-----------------------------*/
1445 /* yyn is the number of a rule to reduce with. */
1448 /* If YYLEN is nonzero, implement the default value of the action:
1451 Otherwise, the following line sets YYVAL to garbage.
1452 This behavior is undocumented and Bison
1453 users should not rely upon it. Assigning to YYVAL
1454 unconditionally makes the parser a bit smaller, and it avoids a
1455 GCC warning that YYVAL may be used uninitialized. */
1456 yyval
= yyvsp
[1-yylen
];
1459 YY_REDUCE_PRINT (yyn
);
1463 #line 222 "wql.y" /* yacc.c:1646 */
1466 struct parser
*parser
= ctx
;
1469 hr
= create_view( NULL
, (yyvsp
[0].string
), NULL
, &view
);
1473 PARSER_BUBBLE_UP_VIEW( parser
, (yyval
.view
), view
);
1475 #line 1476 "wql.tab.c" /* yacc.c:1646 */
1479 #line 234 "wql.y" /* yacc.c:1646 */
1482 struct parser
*parser
= ctx
;
1485 hr
= create_view( (yyvsp
[-2].proplist
), (yyvsp
[0].string
), NULL
, &view
);
1489 PARSER_BUBBLE_UP_VIEW( parser
, (yyval
.view
), view
);
1491 #line 1492 "wql.tab.c" /* yacc.c:1646 */
1495 #line 246 "wql.y" /* yacc.c:1646 */
1498 struct parser
*parser
= ctx
;
1501 hr
= create_view( (yyvsp
[-4].proplist
), (yyvsp
[-2].string
), (yyvsp
[0].expr
), &view
);
1505 PARSER_BUBBLE_UP_VIEW( parser
, (yyval
.view
), view
);
1507 #line 1508 "wql.tab.c" /* yacc.c:1646 */
1511 #line 262 "wql.y" /* yacc.c:1646 */
1513 (yyvsp
[-2].proplist
)->next
= (yyvsp
[0].proplist
);
1515 #line 1516 "wql.tab.c" /* yacc.c:1646 */
1519 #line 266 "wql.y" /* yacc.c:1646 */
1521 (yyval
.proplist
) = NULL
;
1523 #line 1524 "wql.tab.c" /* yacc.c:1646 */
1527 #line 273 "wql.y" /* yacc.c:1646 */
1529 (yyval
.proplist
) = alloc_property( ctx
, (yyvsp
[-2].string
), (yyvsp
[0].string
) );
1530 if (!(yyval
.proplist
))
1533 #line 1534 "wql.tab.c" /* yacc.c:1646 */
1537 #line 279 "wql.y" /* yacc.c:1646 */
1539 (yyval
.proplist
) = alloc_property( ctx
, NULL
, (yyvsp
[0].string
) );
1540 if (!(yyval
.proplist
))
1543 #line 1544 "wql.tab.c" /* yacc.c:1646 */
1547 #line 288 "wql.y" /* yacc.c:1646 */
1549 (yyval
.string
) = get_string( ctx
, &(yyvsp
[0].str
) );
1550 if (!(yyval
.string
))
1553 #line 1554 "wql.tab.c" /* yacc.c:1646 */
1557 #line 297 "wql.y" /* yacc.c:1646 */
1559 (yyval
.integer
) = get_int( ctx
);
1561 #line 1562 "wql.tab.c" /* yacc.c:1646 */
1565 #line 304 "wql.y" /* yacc.c:1646 */
1567 (yyval
.expr
) = (yyvsp
[-1].expr
);
1571 #line 1572 "wql.tab.c" /* yacc.c:1646 */
1575 #line 310 "wql.y" /* yacc.c:1646 */
1577 (yyval
.expr
) = expr_complex( ctx
, (yyvsp
[-2].expr
), OP_AND
, (yyvsp
[0].expr
) );
1581 #line 1582 "wql.tab.c" /* yacc.c:1646 */
1585 #line 316 "wql.y" /* yacc.c:1646 */
1587 (yyval
.expr
) = expr_complex( ctx
, (yyvsp
[-2].expr
), OP_OR
, (yyvsp
[0].expr
) );
1591 #line 1592 "wql.tab.c" /* yacc.c:1646 */
1595 #line 322 "wql.y" /* yacc.c:1646 */
1597 (yyval
.expr
) = expr_unary( ctx
, (yyvsp
[0].expr
), OP_NOT
);
1601 #line 1602 "wql.tab.c" /* yacc.c:1646 */
1605 #line 328 "wql.y" /* yacc.c:1646 */
1607 (yyval
.expr
) = expr_complex( ctx
, (yyvsp
[-2].expr
), OP_EQ
, (yyvsp
[0].expr
) );
1611 #line 1612 "wql.tab.c" /* yacc.c:1646 */
1615 #line 334 "wql.y" /* yacc.c:1646 */
1617 (yyval
.expr
) = expr_complex( ctx
, (yyvsp
[-2].expr
), OP_GT
, (yyvsp
[0].expr
) );
1621 #line 1622 "wql.tab.c" /* yacc.c:1646 */
1625 #line 340 "wql.y" /* yacc.c:1646 */
1627 (yyval
.expr
) = expr_complex( ctx
, (yyvsp
[-2].expr
), OP_LT
, (yyvsp
[0].expr
) );
1631 #line 1632 "wql.tab.c" /* yacc.c:1646 */
1635 #line 346 "wql.y" /* yacc.c:1646 */
1637 (yyval
.expr
) = expr_complex( ctx
, (yyvsp
[-2].expr
), OP_LE
, (yyvsp
[0].expr
) );
1641 #line 1642 "wql.tab.c" /* yacc.c:1646 */
1645 #line 352 "wql.y" /* yacc.c:1646 */
1647 (yyval
.expr
) = expr_complex( ctx
, (yyvsp
[-2].expr
), OP_GE
, (yyvsp
[0].expr
) );
1651 #line 1652 "wql.tab.c" /* yacc.c:1646 */
1655 #line 358 "wql.y" /* yacc.c:1646 */
1657 (yyval
.expr
) = expr_complex( ctx
, (yyvsp
[-2].expr
), OP_NE
, (yyvsp
[0].expr
) );
1661 #line 1662 "wql.tab.c" /* yacc.c:1646 */
1665 #line 364 "wql.y" /* yacc.c:1646 */
1667 (yyval
.expr
) = expr_complex( ctx
, (yyvsp
[-2].expr
), OP_EQ
, (yyvsp
[0].expr
) );
1671 #line 1672 "wql.tab.c" /* yacc.c:1646 */
1675 #line 370 "wql.y" /* yacc.c:1646 */
1677 (yyval
.expr
) = expr_complex( ctx
, (yyvsp
[-2].expr
), OP_GT
, (yyvsp
[0].expr
) );
1681 #line 1682 "wql.tab.c" /* yacc.c:1646 */
1685 #line 376 "wql.y" /* yacc.c:1646 */
1687 (yyval
.expr
) = expr_complex( ctx
, (yyvsp
[-2].expr
), OP_LT
, (yyvsp
[0].expr
) );
1691 #line 1692 "wql.tab.c" /* yacc.c:1646 */
1695 #line 382 "wql.y" /* yacc.c:1646 */
1697 (yyval
.expr
) = expr_complex( ctx
, (yyvsp
[-2].expr
), OP_LE
, (yyvsp
[0].expr
) );
1701 #line 1702 "wql.tab.c" /* yacc.c:1646 */
1705 #line 388 "wql.y" /* yacc.c:1646 */
1707 (yyval
.expr
) = expr_complex( ctx
, (yyvsp
[-2].expr
), OP_GE
, (yyvsp
[0].expr
) );
1711 #line 1712 "wql.tab.c" /* yacc.c:1646 */
1715 #line 394 "wql.y" /* yacc.c:1646 */
1717 (yyval
.expr
) = expr_complex( ctx
, (yyvsp
[-2].expr
), OP_NE
, (yyvsp
[0].expr
) );
1721 #line 1722 "wql.tab.c" /* yacc.c:1646 */
1725 #line 400 "wql.y" /* yacc.c:1646 */
1727 (yyval
.expr
) = expr_complex( ctx
, (yyvsp
[-2].expr
), OP_LIKE
, (yyvsp
[0].expr
) );
1731 #line 1732 "wql.tab.c" /* yacc.c:1646 */
1735 #line 406 "wql.y" /* yacc.c:1646 */
1737 (yyval
.expr
) = expr_unary( ctx
, (yyvsp
[-2].expr
), OP_ISNULL
);
1741 #line 1742 "wql.tab.c" /* yacc.c:1646 */
1745 #line 412 "wql.y" /* yacc.c:1646 */
1747 (yyval
.expr
) = expr_unary( ctx
, (yyvsp
[-3].expr
), OP_NOTNULL
);
1751 #line 1752 "wql.tab.c" /* yacc.c:1646 */
1755 #line 418 "wql.y" /* yacc.c:1646 */
1757 (yyval
.expr
) = expr_unary( ctx
, (yyvsp
[-2].expr
), OP_ISNULL
);
1761 #line 1762 "wql.tab.c" /* yacc.c:1646 */
1765 #line 424 "wql.y" /* yacc.c:1646 */
1767 (yyval
.expr
) = expr_unary( ctx
, (yyvsp
[0].expr
), OP_ISNULL
);
1771 #line 1772 "wql.tab.c" /* yacc.c:1646 */
1775 #line 430 "wql.y" /* yacc.c:1646 */
1777 (yyval
.expr
) = expr_unary( ctx
, (yyvsp
[-2].expr
), OP_NOTNULL
);
1781 #line 1782 "wql.tab.c" /* yacc.c:1646 */
1785 #line 436 "wql.y" /* yacc.c:1646 */
1787 (yyval
.expr
) = expr_unary( ctx
, (yyvsp
[0].expr
), OP_NOTNULL
);
1791 #line 1792 "wql.tab.c" /* yacc.c:1646 */
1795 #line 445 "wql.y" /* yacc.c:1646 */
1797 (yyval
.expr
) = expr_sval( ctx
, &(yyvsp
[0].str
) );
1801 #line 1802 "wql.tab.c" /* yacc.c:1646 */
1805 #line 454 "wql.y" /* yacc.c:1646 */
1807 (yyval
.expr
) = expr_propval( ctx
, (yyvsp
[0].proplist
) );
1811 #line 1812 "wql.tab.c" /* yacc.c:1646 */
1815 #line 463 "wql.y" /* yacc.c:1646 */
1817 (yyval
.expr
) = expr_ival( ctx
, (yyvsp
[0].integer
) );
1821 #line 1822 "wql.tab.c" /* yacc.c:1646 */
1825 #line 469 "wql.y" /* yacc.c:1646 */
1827 (yyval
.expr
) = expr_sval( ctx
, &(yyvsp
[0].str
) );
1831 #line 1832 "wql.tab.c" /* yacc.c:1646 */
1835 #line 475 "wql.y" /* yacc.c:1646 */
1837 (yyval
.expr
) = expr_bval( ctx
, -1 );
1841 #line 1842 "wql.tab.c" /* yacc.c:1646 */
1845 #line 481 "wql.y" /* yacc.c:1646 */
1847 (yyval
.expr
) = expr_bval( ctx
, 0 );
1851 #line 1852 "wql.tab.c" /* yacc.c:1646 */
1855 #line 1856 "wql.tab.c" /* yacc.c:1646 */
1858 /* User semantic actions sometimes alter yychar, and that requires
1859 that yytoken be updated with the new translation. We take the
1860 approach of translating immediately before every use of yytoken.
1861 One alternative is translating here after every semantic action,
1862 but that translation would be missed if the semantic action invokes
1863 YYABORT, YYACCEPT, or YYERROR immediately after altering yychar or
1864 if it invokes YYBACKUP. In the case of YYABORT or YYACCEPT, an
1865 incorrect destructor might then be invoked immediately. In the
1866 case of YYERROR or YYBACKUP, subsequent parser actions might lead
1867 to an incorrect destructor call or verbose syntax error message
1868 before the lookahead is translated. */
1869 YY_SYMBOL_PRINT ("-> $$ =", yyr1
[yyn
], &yyval
, &yyloc
);
1873 YY_STACK_PRINT (yyss
, yyssp
);
1877 /* Now 'shift' the result of the reduction. Determine what state
1878 that goes to, based on the state we popped back to and the rule
1879 number reduced by. */
1883 yystate
= yypgoto
[yyn
- YYNTOKENS
] + *yyssp
;
1884 if (0 <= yystate
&& yystate
<= YYLAST
&& yycheck
[yystate
] == *yyssp
)
1885 yystate
= yytable
[yystate
];
1887 yystate
= yydefgoto
[yyn
- YYNTOKENS
];
1892 /*--------------------------------------.
1893 | yyerrlab -- here on detecting error. |
1894 `--------------------------------------*/
1896 /* Make sure we have latest lookahead translation. See comments at
1897 user semantic actions for why this is necessary. */
1898 yytoken
= yychar
== YYEMPTY
? YYEMPTY
: YYTRANSLATE (yychar
);
1900 /* If not already recovering from an error, report this error. */
1904 #if ! YYERROR_VERBOSE
1905 yyerror (ctx
, YY_("syntax error"));
1907 # define YYSYNTAX_ERROR yysyntax_error (&yymsg_alloc, &yymsg, \
1910 char const *yymsgp
= YY_("syntax error");
1911 int yysyntax_error_status
;
1912 yysyntax_error_status
= YYSYNTAX_ERROR
;
1913 if (yysyntax_error_status
== 0)
1915 else if (yysyntax_error_status
== 1)
1917 if (yymsg
!= yymsgbuf
)
1918 YYSTACK_FREE (yymsg
);
1919 yymsg
= (char *) YYSTACK_ALLOC (yymsg_alloc
);
1923 yymsg_alloc
= sizeof yymsgbuf
;
1924 yysyntax_error_status
= 2;
1928 yysyntax_error_status
= YYSYNTAX_ERROR
;
1932 yyerror (ctx
, yymsgp
);
1933 if (yysyntax_error_status
== 2)
1934 goto yyexhaustedlab
;
1936 # undef YYSYNTAX_ERROR
1942 if (yyerrstatus
== 3)
1944 /* If just tried and failed to reuse lookahead token after an
1945 error, discard it. */
1947 if (yychar
<= YYEOF
)
1949 /* Return failure if at end of input. */
1950 if (yychar
== YYEOF
)
1955 yydestruct ("Error: discarding",
1956 yytoken
, &yylval
, ctx
);
1961 /* Else will try to reuse lookahead token after shifting the error
1966 /*---------------------------------------------------.
1967 | yyerrorlab -- error raised explicitly by YYERROR. |
1968 `---------------------------------------------------*/
1971 /* Pacify compilers like GCC when the user code never invokes
1972 YYERROR and the label yyerrorlab therefore never appears in user
1974 if (/*CONSTCOND*/ 0)
1977 /* Do not reclaim the symbols of the rule whose action triggered
1981 YY_STACK_PRINT (yyss
, yyssp
);
1986 /*-------------------------------------------------------------.
1987 | yyerrlab1 -- common code for both syntax error and YYERROR. |
1988 `-------------------------------------------------------------*/
1990 yyerrstatus
= 3; /* Each real token shifted decrements this. */
1994 yyn
= yypact
[yystate
];
1995 if (!yypact_value_is_default (yyn
))
1998 if (0 <= yyn
&& yyn
<= YYLAST
&& yycheck
[yyn
] == YYTERROR
)
2006 /* Pop the current state because it cannot handle the error token. */
2011 yydestruct ("Error: popping",
2012 yystos
[yystate
], yyvsp
, ctx
);
2015 YY_STACK_PRINT (yyss
, yyssp
);
2018 YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
2020 YY_IGNORE_MAYBE_UNINITIALIZED_END
2023 /* Shift the error token. */
2024 YY_SYMBOL_PRINT ("Shifting", yystos
[yyn
], yyvsp
, yylsp
);
2030 /*-------------------------------------.
2031 | yyacceptlab -- YYACCEPT comes here. |
2032 `-------------------------------------*/
2037 /*-----------------------------------.
2038 | yyabortlab -- YYABORT comes here. |
2039 `-----------------------------------*/
2044 #if !defined yyoverflow || YYERROR_VERBOSE
2045 /*-------------------------------------------------.
2046 | yyexhaustedlab -- memory exhaustion comes here. |
2047 `-------------------------------------------------*/
2049 yyerror (ctx
, YY_("memory exhausted"));
2055 if (yychar
!= YYEMPTY
)
2057 /* Make sure we have latest lookahead translation. See comments at
2058 user semantic actions for why this is necessary. */
2059 yytoken
= YYTRANSLATE (yychar
);
2060 yydestruct ("Cleanup: discarding lookahead",
2061 yytoken
, &yylval
, ctx
);
2063 /* Do not reclaim the symbols of the rule whose action triggered
2064 this YYABORT or YYACCEPT. */
2066 YY_STACK_PRINT (yyss
, yyssp
);
2067 while (yyssp
!= yyss
)
2069 yydestruct ("Cleanup: popping",
2070 yystos
[*yyssp
], yyvsp
, ctx
);
2075 YYSTACK_FREE (yyss
);
2078 if (yymsg
!= yymsgbuf
)
2079 YYSTACK_FREE (yymsg
);
2083 #line 488 "wql.y" /* yacc.c:1906 */
2086 HRESULT
parse_query( const WCHAR
*str
, struct view
**view
, struct list
*mem
)
2088 struct parser parser
;
2096 parser
.error
= WBEM_E_INVALID_QUERY
;
2100 ret
= wql_parse( &parser
);
2101 TRACE("wql_parse returned %d\n", ret
);
2106 destroy_view( *parser
.view
);
2107 *parser
.view
= NULL
;
2109 return parser
.error
;
2114 static const char id_char
[] =
2116 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2117 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2118 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0,
2119 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0,
2120 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
2121 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 1,
2122 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
2123 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0,
2124 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
2125 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
2126 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
2127 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
2128 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
2129 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
2130 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
2131 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
2141 #define MAX_TOKEN_LEN 6
2143 static const WCHAR andW
[] = {'A','N','D'};
2144 static const WCHAR byW
[] = {'B','Y'};
2145 static const WCHAR falseW
[] = {'F','A','L','S','E'};
2146 static const WCHAR fromW
[] = {'F','R','O','M'};
2147 static const WCHAR isW
[] = {'I','S'};
2148 static const WCHAR likeW
[] = {'L','I','K','E'};
2149 static const WCHAR notW
[] = {'N','O','T'};
2150 static const WCHAR nullW
[] = {'N','U','L','L'};
2151 static const WCHAR orW
[] = {'O','R'};
2152 static const WCHAR selectW
[] = {'S','E','L','E','C','T'};
2153 static const WCHAR trueW
[] = {'T','R','U','E'};
2154 static const WCHAR whereW
[] = {'W','H','E','R','E'};
2156 static const struct keyword keyword_table
[] =
2158 { andW
, SIZEOF(andW
), TK_AND
},
2159 { byW
, SIZEOF(byW
), TK_BY
},
2160 { falseW
, SIZEOF(falseW
), TK_FALSE
},
2161 { fromW
, SIZEOF(fromW
), TK_FROM
},
2162 { isW
, SIZEOF(isW
), TK_IS
},
2163 { likeW
, SIZEOF(likeW
), TK_LIKE
},
2164 { notW
, SIZEOF(notW
), TK_NOT
},
2165 { nullW
, SIZEOF(nullW
), TK_NULL
},
2166 { orW
, SIZEOF(orW
), TK_OR
},
2167 { selectW
, SIZEOF(selectW
), TK_SELECT
},
2168 { trueW
, SIZEOF(trueW
), TK_TRUE
},
2169 { whereW
, SIZEOF(whereW
), TK_WHERE
}
2172 static int cmp_keyword( const void *arg1
, const void *arg2
)
2174 const struct keyword
*key1
= arg1
, *key2
= arg2
;
2175 int len
= min( key1
->len
, key2
->len
);
2178 if ((ret
= memicmpW( key1
->name
, key2
->name
, len
))) return ret
;
2179 if (key1
->len
< key2
->len
) return -1;
2180 else if (key1
->len
> key2
->len
) return 1;
2184 static int keyword_type( const WCHAR
*str
, unsigned int len
)
2186 struct keyword key
, *ret
;
2188 if (len
> MAX_TOKEN_LEN
) return TK_ID
;
2193 ret
= bsearch( &key
, keyword_table
, SIZEOF(keyword_table
), sizeof(struct keyword
), cmp_keyword
);
2194 if (ret
) return ret
->type
;
2198 static int get_token( const WCHAR
*s
, int *token
)
2208 for (i
= 1; isspaceW( s
[i
] ); i
++) {}
2212 if (!s
[1]) return -1;
2233 else if (s
[1] == '>')
2257 *token
= TK_ILLEGAL
;
2270 for (i
= 1; s
[i
]; i
++)
2272 if (s
[i
] == s
[0]) break;
2278 if (!isdigitW( s
[1] ))
2284 case '0': case '1': case '2': case '3': case '4':
2285 case '5': case '6': case '7': case '8': case '9':
2286 *token
= TK_INTEGER
;
2287 for (i
= 1; isdigitW( s
[i
] ); i
++) {}
2290 if (!id_char
[*s
]) break;
2292 for (i
= 1; id_char
[s
[i
]]; i
++) {}
2293 *token
= keyword_type( s
, i
);
2296 *token
= TK_ILLEGAL
;
2300 static int wql_lex( void *p
, struct parser
*parser
)
2302 struct string
*str
= p
;
2306 parser
->idx
+= parser
->len
;
2307 if (!parser
->cmd
[parser
->idx
]) return 0;
2308 parser
->len
= get_token( &parser
->cmd
[parser
->idx
], &token
);
2309 if (!parser
->len
) break;
2311 str
->data
= &parser
->cmd
[parser
->idx
];
2312 str
->len
= parser
->len
;
2313 } while (token
== TK_SPACE
);
2317 static int wql_error( struct parser
*parser
, const char *str
)