1 /* A Bison parser, made by GNU Bison 3.0.2. */
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.2"
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
92 #include "wbemprox_private.h"
110 static void *alloc_mem( struct parser
*parser
, UINT size
)
112 struct list
*mem
= heap_alloc( sizeof(struct list
) + size
);
113 list_add_tail( parser
->mem
, mem
);
117 static struct property
*alloc_property( struct parser
*parser
, const WCHAR
*class, const WCHAR
*name
)
119 struct property
*prop
= alloc_mem( parser
, sizeof(*prop
) );
129 static WCHAR
*get_string( struct parser
*parser
, const struct string
*str
)
131 const WCHAR
*p
= str
->data
;
135 if ((p
[0] == '\"' && p
[len
- 1] != '\"') ||
136 (p
[0] == '\'' && p
[len
- 1] != '\'')) return NULL
;
137 if ((p
[0] == '\"' && p
[len
- 1] == '\"') ||
138 (p
[0] == '\'' && p
[len
- 1] == '\''))
143 if (!(ret
= alloc_mem( parser
, (len
+ 1) * sizeof(WCHAR
) ))) return NULL
;
144 memcpy( ret
, p
, len
* sizeof(WCHAR
) );
149 static int get_int( struct parser
*parser
)
151 const WCHAR
*p
= &parser
->cmd
[parser
->idx
];
154 for (i
= 0; i
< parser
->len
; i
++)
156 if (p
[i
] < '0' || p
[i
] > '9')
158 ERR("should only be numbers here!\n");
161 ret
= (p
[i
] - '0') + ret
* 10;
166 static struct expr
*expr_complex( struct parser
*parser
, struct expr
*l
, UINT op
, struct expr
*r
)
168 struct expr
*e
= alloc_mem( parser
, sizeof(*e
) );
171 e
->type
= EXPR_COMPLEX
;
179 static struct expr
*expr_unary( struct parser
*parser
, struct expr
*l
, UINT op
)
181 struct expr
*e
= alloc_mem( parser
, sizeof(*e
) );
184 e
->type
= EXPR_UNARY
;
187 e
->u
.expr
.right
= NULL
;
192 static struct expr
*expr_ival( struct parser
*parser
, int val
)
194 struct expr
*e
= alloc_mem( parser
, sizeof *e
);
203 static struct expr
*expr_sval( struct parser
*parser
, const struct string
*str
)
205 struct expr
*e
= alloc_mem( parser
, sizeof *e
);
209 e
->u
.sval
= get_string( parser
, str
);
211 return NULL
; /* e will be freed by query destructor */
216 static struct expr
*expr_bval( struct parser
*parser
, int val
)
218 struct expr
*e
= alloc_mem( parser
, sizeof *e
);
227 static struct expr
*expr_propval( struct parser
*parser
, const struct property
*prop
)
229 struct expr
*e
= alloc_mem( parser
, sizeof *e
);
232 e
->type
= EXPR_PROPVAL
;
238 static int wql_error( struct parser
*parser
, const char *str
);
239 static int wql_lex( void *val
, struct parser
*parser
);
241 #define PARSER_BUBBLE_UP_VIEW( parser, result, current_view ) \
242 *parser->view = current_view; \
243 result = current_view
246 #line 259 "wql.tab.c" /* yacc.c:339 */
249 # if defined __cplusplus && 201103L <= __cplusplus
250 # define YY_NULLPTR nullptr
252 # define YY_NULLPTR 0
256 /* Enabling verbose error messages. */
257 #ifdef YYERROR_VERBOSE
258 # undef YYERROR_VERBOSE
259 # define YYERROR_VERBOSE 1
261 # define YYERROR_VERBOSE 1
270 extern int wql_debug
;
311 #if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
312 typedef union YYSTYPE YYSTYPE
;
315 #line 194 "wql.y" /* yacc.c:355 */
319 struct property
*proplist
;
324 #line 337 "wql.tab.c" /* yacc.c:355 */
326 # define YYSTYPE_IS_TRIVIAL 1
327 # define YYSTYPE_IS_DECLARED 1
332 int wql_parse (struct parser
*ctx
);
336 /* Copy the second part of user declarations. */
338 #line 351 "wql.tab.c" /* yacc.c:358 */
345 typedef YYTYPE_UINT8 yytype_uint8
;
347 typedef unsigned char yytype_uint8
;
351 typedef YYTYPE_INT8 yytype_int8
;
353 typedef signed char yytype_int8
;
357 typedef YYTYPE_UINT16 yytype_uint16
;
359 typedef unsigned short int yytype_uint16
;
363 typedef YYTYPE_INT16 yytype_int16
;
365 typedef short int yytype_int16
;
369 # ifdef __SIZE_TYPE__
370 # define YYSIZE_T __SIZE_TYPE__
371 # elif defined size_t
372 # define YYSIZE_T size_t
373 # elif ! defined YYSIZE_T
374 # include <stddef.h> /* INFRINGES ON USER NAME SPACE */
375 # define YYSIZE_T size_t
377 # define YYSIZE_T unsigned int
381 #define YYSIZE_MAXIMUM ((YYSIZE_T) -1)
384 # if defined YYENABLE_NLS && YYENABLE_NLS
386 # include <libintl.h> /* INFRINGES ON USER NAME SPACE */
387 # define YY_(Msgid) dgettext ("bison-runtime", Msgid)
391 # define YY_(Msgid) Msgid
396 # if (defined __GNUC__ \
397 && (2 < __GNUC__ || (__GNUC__ == 2 && 96 <= __GNUC_MINOR__))) \
398 || defined __SUNPRO_C && 0x5110 <= __SUNPRO_C
399 # define YY_ATTRIBUTE(Spec) __attribute__(Spec)
401 # define YY_ATTRIBUTE(Spec) /* empty */
405 #ifndef YY_ATTRIBUTE_PURE
406 # define YY_ATTRIBUTE_PURE YY_ATTRIBUTE ((__pure__))
409 #ifndef YY_ATTRIBUTE_UNUSED
410 # define YY_ATTRIBUTE_UNUSED YY_ATTRIBUTE ((__unused__))
413 #if !defined _Noreturn \
414 && (!defined __STDC_VERSION__ || __STDC_VERSION__ < 201112)
415 # if defined _MSC_VER && 1200 <= _MSC_VER
416 # define _Noreturn __declspec (noreturn)
418 # define _Noreturn YY_ATTRIBUTE ((__noreturn__))
422 /* Suppress unused-variable warnings by "using" E. */
423 #if ! defined lint || defined __GNUC__
424 # define YYUSE(E) ((void) (E))
426 # define YYUSE(E) /* empty */
429 #if defined __GNUC__ && 407 <= __GNUC__ * 100 + __GNUC_MINOR__
430 /* Suppress an incorrect diagnostic about yylval being uninitialized. */
431 # define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN \
432 _Pragma ("GCC diagnostic push") \
433 _Pragma ("GCC diagnostic ignored \"-Wuninitialized\"")\
434 _Pragma ("GCC diagnostic ignored \"-Wmaybe-uninitialized\"")
435 # define YY_IGNORE_MAYBE_UNINITIALIZED_END \
436 _Pragma ("GCC diagnostic pop")
438 # define YY_INITIAL_VALUE(Value) Value
440 #ifndef YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
441 # define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
442 # define YY_IGNORE_MAYBE_UNINITIALIZED_END
444 #ifndef YY_INITIAL_VALUE
445 # define YY_INITIAL_VALUE(Value) /* Nothing. */
449 #if ! defined yyoverflow || YYERROR_VERBOSE
451 /* The parser invokes alloca or malloc; define the necessary symbols. */
453 # ifdef YYSTACK_USE_ALLOCA
454 # if YYSTACK_USE_ALLOCA
456 # define YYSTACK_ALLOC __builtin_alloca
457 # elif defined __BUILTIN_VA_ARG_INCR
458 # include <alloca.h> /* INFRINGES ON USER NAME SPACE */
460 # define YYSTACK_ALLOC __alloca
461 # elif defined _MSC_VER
462 # include <malloc.h> /* INFRINGES ON USER NAME SPACE */
463 # define alloca _alloca
465 # define YYSTACK_ALLOC alloca
466 # if ! defined _ALLOCA_H && ! defined EXIT_SUCCESS
467 # include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
468 /* Use EXIT_SUCCESS as a witness for stdlib.h. */
469 # ifndef EXIT_SUCCESS
470 # define EXIT_SUCCESS 0
477 # ifdef YYSTACK_ALLOC
478 /* Pacify GCC's 'empty if-body' warning. */
479 # define YYSTACK_FREE(Ptr) do { /* empty */; } while (0)
480 # ifndef YYSTACK_ALLOC_MAXIMUM
481 /* The OS might guarantee only one guard page at the bottom of the stack,
482 and a page size can be as small as 4096 bytes. So we cannot safely
483 invoke alloca (N) if N exceeds 4096. Use a slightly smaller number
484 to allow for a few compiler-allocated temporary stack slots. */
485 # define YYSTACK_ALLOC_MAXIMUM 4032 /* reasonable circa 2006 */
488 # define YYSTACK_ALLOC YYMALLOC
489 # define YYSTACK_FREE YYFREE
490 # ifndef YYSTACK_ALLOC_MAXIMUM
491 # define YYSTACK_ALLOC_MAXIMUM YYSIZE_MAXIMUM
493 # if (defined __cplusplus && ! defined EXIT_SUCCESS \
494 && ! ((defined YYMALLOC || defined malloc) \
495 && (defined YYFREE || defined free)))
496 # include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
497 # ifndef EXIT_SUCCESS
498 # define EXIT_SUCCESS 0
502 # define YYMALLOC malloc
503 # if ! defined malloc && ! defined EXIT_SUCCESS
504 void *malloc (YYSIZE_T
); /* INFRINGES ON USER NAME SPACE */
509 # if ! defined free && ! defined EXIT_SUCCESS
510 void free (void *); /* INFRINGES ON USER NAME SPACE */
514 #endif /* ! defined yyoverflow || YYERROR_VERBOSE */
517 #if (! defined yyoverflow \
518 && (! defined __cplusplus \
519 || (defined YYSTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL)))
521 /* A type that is properly aligned for any stack member. */
524 yytype_int16 yyss_alloc
;
528 /* The size of the maximum gap between one aligned stack and the next. */
529 # define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1)
531 /* The size of an array large to enough to hold all stacks, each with
533 # define YYSTACK_BYTES(N) \
534 ((N) * (sizeof (yytype_int16) + sizeof (YYSTYPE)) \
535 + YYSTACK_GAP_MAXIMUM)
537 # define YYCOPY_NEEDED 1
539 /* Relocate STACK from its old location to the new one. The
540 local variables YYSIZE and YYSTACKSIZE give the old and new number of
541 elements in the stack, and YYPTR gives the new location of the
542 stack. Advance YYPTR to a properly aligned location for the next
544 # define YYSTACK_RELOCATE(Stack_alloc, Stack) \
547 YYSIZE_T yynewbytes; \
548 YYCOPY (&yyptr->Stack_alloc, Stack, yysize); \
549 Stack = &yyptr->Stack_alloc; \
550 yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \
551 yyptr += yynewbytes / sizeof (*yyptr); \
557 #if defined YYCOPY_NEEDED && YYCOPY_NEEDED
558 /* Copy COUNT objects from SRC to DST. The source and destination do
561 # if defined __GNUC__ && 1 < __GNUC__
562 # define YYCOPY(Dst, Src, Count) \
563 __builtin_memcpy (Dst, Src, (Count) * sizeof (*(Src)))
565 # define YYCOPY(Dst, Src, Count) \
569 for (yyi = 0; yyi < (Count); yyi++) \
570 (Dst)[yyi] = (Src)[yyi]; \
575 #endif /* !YYCOPY_NEEDED */
577 /* YYFINAL -- State number of the termination state. */
579 /* YYLAST -- Last index in YYTABLE. */
582 /* YYNTOKENS -- Number of terminals. */
584 /* YYNNTS -- Number of nonterminals. */
586 /* YYNRULES -- Number of rules. */
588 /* YYNSTATES -- Number of states. */
591 /* YYTRANSLATE[YYX] -- Symbol number corresponding to YYX as returned
592 by yylex, with out-of-bounds checking. */
594 #define YYMAXUTOK 286
596 #define YYTRANSLATE(YYX) \
597 ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK)
599 /* YYTRANSLATE[TOKEN-NUM] -- Symbol number corresponding to TOKEN-NUM
600 as returned by yylex, without out-of-bounds checking. */
601 static const yytype_uint8 yytranslate
[] =
603 0, 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, 2, 2, 2, 2,
625 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
626 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
627 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
628 2, 2, 2, 2, 2, 2, 1, 2, 3, 4,
629 5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
630 15, 16, 17, 18, 19, 20, 21, 22, 23, 24,
631 25, 26, 27, 28, 29, 30, 31
635 /* YYRLINE[YYN] -- Source line where rule number YYN was defined. */
636 static const yytype_uint16 yyrline
[] =
638 0, 221, 221, 233, 245, 260, 261, 265, 272, 278,
639 287, 296, 303, 309, 315, 321, 327, 333, 339, 345,
640 351, 357, 363, 369, 375, 381, 387, 393, 399, 405,
641 411, 420, 429, 438, 444, 450, 456
645 #if YYDEBUG || YYERROR_VERBOSE || 1
646 /* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
647 First, the terminals, then, starting at YYNTOKENS, nonterminals. */
648 static const char *const yytname
[] =
650 "$end", "error", "$undefined", "TK_SELECT", "TK_FROM", "TK_STAR",
651 "TK_COMMA", "TK_DOT", "TK_IS", "TK_LP", "TK_RP", "TK_NULL", "TK_FALSE",
652 "TK_TRUE", "TK_INTEGER", "TK_WHERE", "TK_SPACE", "TK_MINUS",
653 "TK_ILLEGAL", "TK_BY", "TK_STRING", "TK_ID", "TK_OR", "TK_AND", "TK_NOT",
654 "TK_EQ", "TK_NE", "TK_LT", "TK_GT", "TK_LE", "TK_GE", "TK_LIKE",
655 "$accept", "select", "proplist", "prop", "id", "number", "expr",
656 "string_val", "prop_val", "const_val", YY_NULLPTR
661 /* YYTOKNUM[NUM] -- (External) token number corresponding to the
662 (internal) symbol number NUM (which must be that of a token). */
663 static const yytype_uint16 yytoknum
[] =
665 0, 256, 257, 258, 259, 260, 261, 262, 263, 264,
666 265, 266, 267, 268, 269, 270, 271, 272, 273, 274,
667 275, 276, 277, 278, 279, 280, 281, 282, 283, 284,
672 #define YYPACT_NINF -18
674 #define yypact_value_is_default(Yystate) \
675 (!!((Yystate) == (-18)))
677 #define YYTABLE_NINF -1
679 #define yytable_value_is_error(Yytable_value) \
682 /* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
684 static const yytype_int8 yypact
[] =
686 7, 3, 12, -5, -18, -18, 24, 29, 35, -18,
687 -18, -5, 4, -5, 21, -18, -18, 17, 17, -18,
688 -18, -18, -18, 17, -18, -18, 11, -8, 25, 22,
689 -18, 17, 17, 16, -9, -9, -9, -9, -9, -9,
690 23, -5, -5, -5, -5, -5, -5, -18, 45, -18,
691 -18, 37, -18, -18, -18, -18, -18, -18, -18, -18,
692 -18, -18, -18, -18, -18, -18, -18
695 /* YYDEFACT[STATE-NUM] -- Default reduction number in state STATE-NUM.
696 Performed when YYTABLE does not specify something else to do. Zero
697 means the default is an error. */
698 static const yytype_uint8 yydefact
[] =
700 0, 0, 0, 0, 7, 10, 0, 5, 9, 1,
701 2, 0, 0, 0, 3, 6, 8, 0, 0, 36,
702 35, 11, 34, 0, 32, 33, 4, 0, 0, 0,
703 15, 0, 0, 0, 0, 0, 0, 0, 0, 0,
704 0, 0, 0, 0, 0, 0, 0, 12, 14, 13,
705 29, 0, 16, 21, 18, 17, 19, 20, 31, 28,
706 22, 27, 24, 23, 25, 26, 30
709 /* YYPGOTO[NTERM-NUM]. */
710 static const yytype_int8 yypgoto
[] =
712 -18, -18, 34, 1, 36, -18, -17, -18, 15, 28
715 /* YYDEFGOTO[NTERM-NUM]. */
716 static const yytype_int8 yydefgoto
[] =
718 -1, 2, 6, 24, 8, 25, 26, 59, 27, 28
721 /* YYTABLE[YYPACT[STATE-NUM]] -- What to do in state STATE-NUM. If
722 positive, shift that token. If negative, reduce the rule whose
723 number is the opposite. If YYTABLE_NINF, syntax error. */
724 static const yytype_uint8 yytable
[] =
726 33, 29, 7, 19, 20, 21, 30, 3, 4, 4,
727 1, 22, 9, 7, 48, 49, 5, 34, 35, 36,
728 37, 38, 39, 40, 5, 5, 18, 50, 11, 19,
729 20, 21, 47, 31, 32, 12, 17, 22, 5, 10,
730 51, 23, 13, 58, 31, 32, 15, 14, 66, 16,
731 41, 42, 43, 44, 45, 46, 60, 61, 62, 63,
732 64, 65, 52, 53, 54, 55, 56, 57, 32
735 static const yytype_uint8 yycheck
[] =
737 8, 18, 1, 12, 13, 14, 23, 4, 5, 5,
738 3, 20, 0, 12, 31, 32, 21, 25, 26, 27,
739 28, 29, 30, 31, 21, 21, 9, 11, 4, 12,
740 13, 14, 10, 22, 23, 6, 15, 20, 21, 3,
741 24, 24, 7, 20, 22, 23, 12, 11, 11, 13,
742 25, 26, 27, 28, 29, 30, 41, 42, 43, 44,
743 45, 46, 34, 35, 36, 37, 38, 39, 23
746 /* YYSTOS[STATE-NUM] -- The (internal number of the) accessing
747 symbol of state STATE-NUM. */
748 static const yytype_uint8 yystos
[] =
750 0, 3, 33, 4, 5, 21, 34, 35, 36, 0,
751 36, 4, 6, 7, 36, 34, 36, 15, 9, 12,
752 13, 14, 20, 24, 35, 37, 38, 40, 41, 38,
753 38, 22, 23, 8, 25, 26, 27, 28, 29, 30,
754 31, 25, 26, 27, 28, 29, 30, 10, 38, 38,
755 11, 24, 41, 41, 41, 41, 41, 41, 20, 39,
756 40, 40, 40, 40, 40, 40, 11
759 /* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */
760 static const yytype_uint8 yyr1
[] =
762 0, 32, 33, 33, 33, 34, 34, 34, 35, 35,
763 36, 37, 38, 38, 38, 38, 38, 38, 38, 38,
764 38, 38, 38, 38, 38, 38, 38, 38, 38, 38,
765 38, 39, 40, 41, 41, 41, 41
768 /* YYR2[YYN] -- Number of symbols on the right hand side of rule YYN. */
769 static const yytype_uint8 yyr2
[] =
771 0, 2, 3, 4, 6, 1, 3, 1, 3, 1,
772 1, 1, 3, 3, 3, 2, 3, 3, 3, 3,
773 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
778 #define yyerrok (yyerrstatus = 0)
779 #define yyclearin (yychar = YYEMPTY)
783 #define YYACCEPT goto yyacceptlab
784 #define YYABORT goto yyabortlab
785 #define YYERROR goto yyerrorlab
788 #define YYRECOVERING() (!!yyerrstatus)
790 #define YYBACKUP(Token, Value) \
792 if (yychar == YYEMPTY) \
796 YYPOPSTACK (yylen); \
802 yyerror (ctx, YY_("syntax error: cannot back up")); \
807 /* Error token number */
809 #define YYERRCODE 256
813 /* Enable debugging if requested. */
817 # include <stdio.h> /* INFRINGES ON USER NAME SPACE */
818 # define YYFPRINTF fprintf
821 # define YYDPRINTF(Args) \
827 /* This macro is provided for backward compatibility. */
828 #ifndef YY_LOCATION_PRINT
829 # define YY_LOCATION_PRINT(File, Loc) ((void) 0)
833 # define YY_SYMBOL_PRINT(Title, Type, Value, Location) \
837 YYFPRINTF (stderr, "%s ", Title); \
838 yy_symbol_print (stderr, \
840 YYFPRINTF (stderr, "\n"); \
845 /*----------------------------------------.
846 | Print this symbol's value on YYOUTPUT. |
847 `----------------------------------------*/
850 yy_symbol_value_print (FILE *yyoutput
, int yytype
, YYSTYPE
const * const yyvaluep
, struct parser
*ctx
)
852 FILE *yyo
= yyoutput
;
858 if (yytype
< YYNTOKENS
)
859 YYPRINT (yyoutput
, yytoknum
[yytype
], *yyvaluep
);
865 /*--------------------------------.
866 | Print this symbol on YYOUTPUT. |
867 `--------------------------------*/
870 yy_symbol_print (FILE *yyoutput
, int yytype
, YYSTYPE
const * const yyvaluep
, struct parser
*ctx
)
872 YYFPRINTF (yyoutput
, "%s %s (",
873 yytype
< YYNTOKENS
? "token" : "nterm", yytname
[yytype
]);
875 yy_symbol_value_print (yyoutput
, yytype
, yyvaluep
, ctx
);
876 YYFPRINTF (yyoutput
, ")");
879 /*------------------------------------------------------------------.
880 | yy_stack_print -- Print the state stack from its BOTTOM up to its |
882 `------------------------------------------------------------------*/
885 yy_stack_print (yytype_int16
*yybottom
, yytype_int16
*yytop
)
887 YYFPRINTF (stderr
, "Stack now");
888 for (; yybottom
<= yytop
; yybottom
++)
890 int yybot
= *yybottom
;
891 YYFPRINTF (stderr
, " %d", yybot
);
893 YYFPRINTF (stderr
, "\n");
896 # define YY_STACK_PRINT(Bottom, Top) \
899 yy_stack_print ((Bottom), (Top)); \
903 /*------------------------------------------------.
904 | Report that the YYRULE is going to be reduced. |
905 `------------------------------------------------*/
908 yy_reduce_print (yytype_int16
*yyssp
, YYSTYPE
*yyvsp
, int yyrule
, struct parser
*ctx
)
910 unsigned long int yylno
= yyrline
[yyrule
];
911 int yynrhs
= yyr2
[yyrule
];
913 YYFPRINTF (stderr
, "Reducing stack by rule %d (line %lu):\n",
915 /* The symbols being reduced. */
916 for (yyi
= 0; yyi
< yynrhs
; yyi
++)
918 YYFPRINTF (stderr
, " $%d = ", yyi
+ 1);
919 yy_symbol_print (stderr
,
920 yystos
[yyssp
[yyi
+ 1 - yynrhs
]],
921 &(yyvsp
[(yyi
+ 1) - (yynrhs
)])
923 YYFPRINTF (stderr
, "\n");
927 # define YY_REDUCE_PRINT(Rule) \
930 yy_reduce_print (yyssp, yyvsp, Rule, ctx); \
933 /* Nonzero means print parse trace. It is left uninitialized so that
934 multiple parsers can coexist. */
937 # define YYDPRINTF(Args)
938 # define YY_SYMBOL_PRINT(Title, Type, Value, Location)
939 # define YY_STACK_PRINT(Bottom, Top)
940 # define YY_REDUCE_PRINT(Rule)
941 #endif /* !YYDEBUG */
944 /* YYINITDEPTH -- initial size of the parser's stacks. */
946 # define YYINITDEPTH 200
949 /* YYMAXDEPTH -- maximum size the stacks can grow to (effective only
950 if the built-in stack extension method is used).
952 Do not make this value too large; the results are undefined if
953 YYSTACK_ALLOC_MAXIMUM < YYSTACK_BYTES (YYMAXDEPTH)
954 evaluated with infinite-precision integer arithmetic. */
957 # define YYMAXDEPTH 10000
964 # if defined __GLIBC__ && defined _STRING_H
965 # define yystrlen strlen
967 /* Return the length of YYSTR. */
969 yystrlen (const char *yystr
)
972 for (yylen
= 0; yystr
[yylen
]; yylen
++)
980 # if defined __GLIBC__ && defined _STRING_H && defined _GNU_SOURCE
981 # define yystpcpy stpcpy
983 /* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in
986 yystpcpy (char *yydest
, const char *yysrc
)
989 const char *yys
= yysrc
;
991 while ((*yyd
++ = *yys
++) != '\0')
1000 /* Copy to YYRES the contents of YYSTR after stripping away unnecessary
1001 quotes and backslashes, so that it's suitable for yyerror. The
1002 heuristic is that double-quoting is unnecessary unless the string
1003 contains an apostrophe, a comma, or backslash (other than
1004 backslash-backslash). YYSTR is taken from yytname. If YYRES is
1005 null, do not copy; instead, return the length of what the result
1008 yytnamerr (char *yyres
, const char *yystr
)
1013 char const *yyp
= yystr
;
1020 goto do_not_strip_quotes
;
1024 goto do_not_strip_quotes
;
1037 do_not_strip_quotes
: ;
1041 return yystrlen (yystr
);
1043 return yystpcpy (yyres
, yystr
) - yyres
;
1047 /* Copy into *YYMSG, which is of size *YYMSG_ALLOC, an error message
1048 about the unexpected token YYTOKEN for the state stack whose top is
1051 Return 0 if *YYMSG was successfully written. Return 1 if *YYMSG is
1052 not large enough to hold the message. In that case, also set
1053 *YYMSG_ALLOC to the required number of bytes. Return 2 if the
1054 required number of bytes is too large to store. */
1056 yysyntax_error (YYSIZE_T
*yymsg_alloc
, char **yymsg
,
1057 yytype_int16
*yyssp
, int yytoken
)
1059 YYSIZE_T yysize0
= yytnamerr (YY_NULLPTR
, yytname
[yytoken
]);
1060 YYSIZE_T yysize
= yysize0
;
1061 enum { YYERROR_VERBOSE_ARGS_MAXIMUM
= 5 };
1062 /* Internationalized format string. */
1063 const char *yyformat
= YY_NULLPTR
;
1064 /* Arguments of yyformat. */
1065 char const *yyarg
[YYERROR_VERBOSE_ARGS_MAXIMUM
];
1066 /* Number of reported tokens (one for the "unexpected", one per
1070 /* There are many possibilities here to consider:
1071 - If this state is a consistent state with a default action, then
1072 the only way this function was invoked is if the default action
1073 is an error action. In that case, don't check for expected
1074 tokens because there are none.
1075 - The only way there can be no lookahead present (in yychar) is if
1076 this state is a consistent state with a default action. Thus,
1077 detecting the absence of a lookahead is sufficient to determine
1078 that there is no unexpected or expected token to report. In that
1079 case, just report a simple "syntax error".
1080 - Don't assume there isn't a lookahead just because this state is a
1081 consistent state with a default action. There might have been a
1082 previous inconsistent state, consistent state with a non-default
1083 action, or user semantic action that manipulated yychar.
1084 - Of course, the expected token list depends on states to have
1085 correct lookahead information, and it depends on the parser not
1086 to perform extra reductions after fetching a lookahead from the
1087 scanner and before detecting a syntax error. Thus, state merging
1088 (from LALR or IELR) and default reductions corrupt the expected
1089 token list. However, the list is correct for canonical LR with
1090 one exception: it will still contain any token that will not be
1091 accepted due to an error action in a later state.
1093 if (yytoken
!= YYEMPTY
)
1095 int yyn
= yypact
[*yyssp
];
1096 yyarg
[yycount
++] = yytname
[yytoken
];
1097 if (!yypact_value_is_default (yyn
))
1099 /* Start YYX at -YYN if negative to avoid negative indexes in
1100 YYCHECK. In other words, skip the first -YYN actions for
1101 this state because they are default actions. */
1102 int yyxbegin
= yyn
< 0 ? -yyn
: 0;
1103 /* Stay within bounds of both yycheck and yytname. */
1104 int yychecklim
= YYLAST
- yyn
+ 1;
1105 int yyxend
= yychecklim
< YYNTOKENS
? yychecklim
: YYNTOKENS
;
1108 for (yyx
= yyxbegin
; yyx
< yyxend
; ++yyx
)
1109 if (yycheck
[yyx
+ yyn
] == yyx
&& yyx
!= YYTERROR
1110 && !yytable_value_is_error (yytable
[yyx
+ yyn
]))
1112 if (yycount
== YYERROR_VERBOSE_ARGS_MAXIMUM
)
1118 yyarg
[yycount
++] = yytname
[yyx
];
1120 YYSIZE_T yysize1
= yysize
+ yytnamerr (YY_NULLPTR
, yytname
[yyx
]);
1121 if (! (yysize
<= yysize1
1122 && yysize1
<= YYSTACK_ALLOC_MAXIMUM
))
1132 # define YYCASE_(N, S) \
1136 YYCASE_(0, YY_("syntax error"));
1137 YYCASE_(1, YY_("syntax error, unexpected %s"));
1138 YYCASE_(2, YY_("syntax error, unexpected %s, expecting %s"));
1139 YYCASE_(3, YY_("syntax error, unexpected %s, expecting %s or %s"));
1140 YYCASE_(4, YY_("syntax error, unexpected %s, expecting %s or %s or %s"));
1141 YYCASE_(5, YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s"));
1146 YYSIZE_T yysize1
= yysize
+ yystrlen (yyformat
);
1147 if (! (yysize
<= yysize1
&& yysize1
<= YYSTACK_ALLOC_MAXIMUM
))
1152 if (*yymsg_alloc
< yysize
)
1154 *yymsg_alloc
= 2 * yysize
;
1155 if (! (yysize
<= *yymsg_alloc
1156 && *yymsg_alloc
<= YYSTACK_ALLOC_MAXIMUM
))
1157 *yymsg_alloc
= YYSTACK_ALLOC_MAXIMUM
;
1161 /* Avoid sprintf, as that infringes on the user's name space.
1162 Don't have undefined behavior even if the translation
1163 produced a string with the wrong number of "%s"s. */
1167 while ((*yyp
= *yyformat
) != '\0')
1168 if (*yyp
== '%' && yyformat
[1] == 's' && yyi
< yycount
)
1170 yyp
+= yytnamerr (yyp
, yyarg
[yyi
++]);
1181 #endif /* YYERROR_VERBOSE */
1183 /*-----------------------------------------------.
1184 | Release the memory associated to this symbol. |
1185 `-----------------------------------------------*/
1188 yydestruct (const char *yymsg
, int yytype
, YYSTYPE
*yyvaluep
, struct parser
*ctx
)
1194 YY_SYMBOL_PRINT (yymsg
, yytype
, yyvaluep
, yylocationp
);
1196 YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
1198 YY_IGNORE_MAYBE_UNINITIALIZED_END
1209 yyparse (struct parser
*ctx
)
1211 /* The lookahead symbol. */
1215 /* The semantic value of the lookahead symbol. */
1216 /* Default value used for initialization, for pacifying older GCCs
1217 or non-GCC compilers. */
1218 YY_INITIAL_VALUE (static YYSTYPE yyval_default
;)
1219 YYSTYPE yylval
YY_INITIAL_VALUE (= yyval_default
);
1221 /* Number of syntax errors so far. */
1225 /* Number of tokens to shift before error messages enabled. */
1228 /* The stacks and their tools:
1229 'yyss': related to states.
1230 'yyvs': related to semantic values.
1232 Refer to the stacks through separate pointers, to allow yyoverflow
1233 to reallocate them elsewhere. */
1235 /* The state stack. */
1236 yytype_int16 yyssa
[YYINITDEPTH
];
1238 yytype_int16
*yyssp
;
1240 /* The semantic value stack. */
1241 YYSTYPE yyvsa
[YYINITDEPTH
];
1245 YYSIZE_T yystacksize
;
1249 /* Lookahead token as an internal (translated) token number. */
1251 /* The variables used to return semantic value and location from the
1256 /* Buffer for error messages, and its allocated size. */
1258 char *yymsg
= yymsgbuf
;
1259 YYSIZE_T yymsg_alloc
= sizeof yymsgbuf
;
1262 #define YYPOPSTACK(N) (yyvsp -= (N), yyssp -= (N))
1264 /* The number of symbols on the RHS of the reduced rule.
1265 Keep to zero when no symbol should be popped. */
1268 yyssp
= yyss
= yyssa
;
1269 yyvsp
= yyvs
= yyvsa
;
1270 yystacksize
= YYINITDEPTH
;
1272 YYDPRINTF ((stderr
, "Starting parse\n"));
1277 yychar
= YYEMPTY
; /* Cause a token to be read. */
1280 /*------------------------------------------------------------.
1281 | yynewstate -- Push a new state, which is found in yystate. |
1282 `------------------------------------------------------------*/
1284 /* In all cases, when you get here, the value and location stacks
1285 have just been pushed. So pushing a state here evens the stacks. */
1291 if (yyss
+ yystacksize
- 1 <= yyssp
)
1293 /* Get the current used size of the three stacks, in elements. */
1294 YYSIZE_T yysize
= yyssp
- yyss
+ 1;
1298 /* Give user a chance to reallocate the stack. Use copies of
1299 these so that the &'s don't force the real ones into
1301 YYSTYPE
*yyvs1
= yyvs
;
1302 yytype_int16
*yyss1
= yyss
;
1304 /* Each stack pointer address is followed by the size of the
1305 data in use in that stack, in bytes. This used to be a
1306 conditional around just the two extra args, but that might
1307 be undefined if yyoverflow is a macro. */
1308 yyoverflow (YY_("memory exhausted"),
1309 &yyss1
, yysize
* sizeof (*yyssp
),
1310 &yyvs1
, yysize
* sizeof (*yyvsp
),
1316 #else /* no yyoverflow */
1317 # ifndef YYSTACK_RELOCATE
1318 goto yyexhaustedlab
;
1320 /* Extend the stack our own way. */
1321 if (YYMAXDEPTH
<= yystacksize
)
1322 goto yyexhaustedlab
;
1324 if (YYMAXDEPTH
< yystacksize
)
1325 yystacksize
= YYMAXDEPTH
;
1328 yytype_int16
*yyss1
= yyss
;
1329 union yyalloc
*yyptr
=
1330 (union yyalloc
*) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize
));
1332 goto yyexhaustedlab
;
1333 YYSTACK_RELOCATE (yyss_alloc
, yyss
);
1334 YYSTACK_RELOCATE (yyvs_alloc
, yyvs
);
1335 # undef YYSTACK_RELOCATE
1337 YYSTACK_FREE (yyss1
);
1340 #endif /* no yyoverflow */
1342 yyssp
= yyss
+ yysize
- 1;
1343 yyvsp
= yyvs
+ yysize
- 1;
1345 YYDPRINTF ((stderr
, "Stack size increased to %lu\n",
1346 (unsigned long int) yystacksize
));
1348 if (yyss
+ yystacksize
- 1 <= yyssp
)
1352 YYDPRINTF ((stderr
, "Entering state %d\n", yystate
));
1354 if (yystate
== YYFINAL
)
1364 /* Do appropriate processing given the current state. Read a
1365 lookahead token if we need one and don't already have one. */
1367 /* First try to decide what to do without reference to lookahead token. */
1368 yyn
= yypact
[yystate
];
1369 if (yypact_value_is_default (yyn
))
1372 /* Not known => get a lookahead token if don't already have one. */
1374 /* YYCHAR is either YYEMPTY or YYEOF or a valid lookahead symbol. */
1375 if (yychar
== YYEMPTY
)
1377 YYDPRINTF ((stderr
, "Reading a token: "));
1378 yychar
= yylex (&yylval
, ctx
);
1381 if (yychar
<= YYEOF
)
1383 yychar
= yytoken
= YYEOF
;
1384 YYDPRINTF ((stderr
, "Now at end of input.\n"));
1388 yytoken
= YYTRANSLATE (yychar
);
1389 YY_SYMBOL_PRINT ("Next token is", yytoken
, &yylval
, &yylloc
);
1392 /* If the proper action on seeing token YYTOKEN is to reduce or to
1393 detect an error, take that action. */
1395 if (yyn
< 0 || YYLAST
< yyn
|| yycheck
[yyn
] != yytoken
)
1400 if (yytable_value_is_error (yyn
))
1406 /* Count tokens shifted since error; after three, turn off error
1411 /* Shift the lookahead token. */
1412 YY_SYMBOL_PRINT ("Shifting", yytoken
, &yylval
, &yylloc
);
1414 /* Discard the shifted token. */
1418 YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
1420 YY_IGNORE_MAYBE_UNINITIALIZED_END
1425 /*-----------------------------------------------------------.
1426 | yydefault -- do the default action for the current state. |
1427 `-----------------------------------------------------------*/
1429 yyn
= yydefact
[yystate
];
1435 /*-----------------------------.
1436 | yyreduce -- Do a reduction. |
1437 `-----------------------------*/
1439 /* yyn is the number of a rule to reduce with. */
1442 /* If YYLEN is nonzero, implement the default value of the action:
1445 Otherwise, the following line sets YYVAL to garbage.
1446 This behavior is undocumented and Bison
1447 users should not rely upon it. Assigning to YYVAL
1448 unconditionally makes the parser a bit smaller, and it avoids a
1449 GCC warning that YYVAL may be used uninitialized. */
1450 yyval
= yyvsp
[1-yylen
];
1453 YY_REDUCE_PRINT (yyn
);
1457 #line 222 "wql.y" /* yacc.c:1646 */
1460 struct parser
*parser
= ctx
;
1463 hr
= create_view( NULL
, (yyvsp
[0].string
), NULL
, &view
);
1467 PARSER_BUBBLE_UP_VIEW( parser
, (yyval
.view
), view
);
1469 #line 1482 "wql.tab.c" /* yacc.c:1646 */
1473 #line 234 "wql.y" /* yacc.c:1646 */
1476 struct parser
*parser
= ctx
;
1479 hr
= create_view( (yyvsp
[-2].proplist
), (yyvsp
[0].string
), NULL
, &view
);
1483 PARSER_BUBBLE_UP_VIEW( parser
, (yyval
.view
), view
);
1485 #line 1498 "wql.tab.c" /* yacc.c:1646 */
1489 #line 246 "wql.y" /* yacc.c:1646 */
1492 struct parser
*parser
= ctx
;
1495 hr
= create_view( (yyvsp
[-4].proplist
), (yyvsp
[-2].string
), (yyvsp
[0].expr
), &view
);
1499 PARSER_BUBBLE_UP_VIEW( parser
, (yyval
.view
), view
);
1501 #line 1514 "wql.tab.c" /* yacc.c:1646 */
1505 #line 262 "wql.y" /* yacc.c:1646 */
1507 (yyvsp
[-2].proplist
)->next
= (yyvsp
[0].proplist
);
1509 #line 1522 "wql.tab.c" /* yacc.c:1646 */
1513 #line 266 "wql.y" /* yacc.c:1646 */
1515 (yyval
.proplist
) = NULL
;
1517 #line 1530 "wql.tab.c" /* yacc.c:1646 */
1521 #line 273 "wql.y" /* yacc.c:1646 */
1523 (yyval
.proplist
) = alloc_property( ctx
, (yyvsp
[-2].string
), (yyvsp
[0].string
) );
1524 if (!(yyval
.proplist
))
1527 #line 1540 "wql.tab.c" /* yacc.c:1646 */
1531 #line 279 "wql.y" /* yacc.c:1646 */
1533 (yyval
.proplist
) = alloc_property( ctx
, NULL
, (yyvsp
[0].string
) );
1534 if (!(yyval
.proplist
))
1537 #line 1550 "wql.tab.c" /* yacc.c:1646 */
1541 #line 288 "wql.y" /* yacc.c:1646 */
1543 (yyval
.string
) = get_string( ctx
, &(yyvsp
[0].str
) );
1544 if (!(yyval
.string
))
1547 #line 1560 "wql.tab.c" /* yacc.c:1646 */
1551 #line 297 "wql.y" /* yacc.c:1646 */
1553 (yyval
.integer
) = get_int( ctx
);
1555 #line 1568 "wql.tab.c" /* yacc.c:1646 */
1559 #line 304 "wql.y" /* yacc.c:1646 */
1561 (yyval
.expr
) = (yyvsp
[-1].expr
);
1565 #line 1578 "wql.tab.c" /* yacc.c:1646 */
1569 #line 310 "wql.y" /* yacc.c:1646 */
1571 (yyval
.expr
) = expr_complex( ctx
, (yyvsp
[-2].expr
), OP_AND
, (yyvsp
[0].expr
) );
1575 #line 1588 "wql.tab.c" /* yacc.c:1646 */
1579 #line 316 "wql.y" /* yacc.c:1646 */
1581 (yyval
.expr
) = expr_complex( ctx
, (yyvsp
[-2].expr
), OP_OR
, (yyvsp
[0].expr
) );
1585 #line 1598 "wql.tab.c" /* yacc.c:1646 */
1589 #line 322 "wql.y" /* yacc.c:1646 */
1591 (yyval
.expr
) = expr_unary( ctx
, (yyvsp
[0].expr
), OP_NOT
);
1595 #line 1608 "wql.tab.c" /* yacc.c:1646 */
1599 #line 328 "wql.y" /* yacc.c:1646 */
1601 (yyval
.expr
) = expr_complex( ctx
, (yyvsp
[-2].expr
), OP_EQ
, (yyvsp
[0].expr
) );
1605 #line 1618 "wql.tab.c" /* yacc.c:1646 */
1609 #line 334 "wql.y" /* yacc.c:1646 */
1611 (yyval
.expr
) = expr_complex( ctx
, (yyvsp
[-2].expr
), OP_GT
, (yyvsp
[0].expr
) );
1615 #line 1628 "wql.tab.c" /* yacc.c:1646 */
1619 #line 340 "wql.y" /* yacc.c:1646 */
1621 (yyval
.expr
) = expr_complex( ctx
, (yyvsp
[-2].expr
), OP_LT
, (yyvsp
[0].expr
) );
1625 #line 1638 "wql.tab.c" /* yacc.c:1646 */
1629 #line 346 "wql.y" /* yacc.c:1646 */
1631 (yyval
.expr
) = expr_complex( ctx
, (yyvsp
[-2].expr
), OP_LE
, (yyvsp
[0].expr
) );
1635 #line 1648 "wql.tab.c" /* yacc.c:1646 */
1639 #line 352 "wql.y" /* yacc.c:1646 */
1641 (yyval
.expr
) = expr_complex( ctx
, (yyvsp
[-2].expr
), OP_GE
, (yyvsp
[0].expr
) );
1645 #line 1658 "wql.tab.c" /* yacc.c:1646 */
1649 #line 358 "wql.y" /* yacc.c:1646 */
1651 (yyval
.expr
) = expr_complex( ctx
, (yyvsp
[-2].expr
), OP_NE
, (yyvsp
[0].expr
) );
1655 #line 1668 "wql.tab.c" /* yacc.c:1646 */
1659 #line 364 "wql.y" /* yacc.c:1646 */
1661 (yyval
.expr
) = expr_complex( ctx
, (yyvsp
[-2].expr
), OP_EQ
, (yyvsp
[0].expr
) );
1665 #line 1678 "wql.tab.c" /* yacc.c:1646 */
1669 #line 370 "wql.y" /* yacc.c:1646 */
1671 (yyval
.expr
) = expr_complex( ctx
, (yyvsp
[-2].expr
), OP_GT
, (yyvsp
[0].expr
) );
1675 #line 1688 "wql.tab.c" /* yacc.c:1646 */
1679 #line 376 "wql.y" /* yacc.c:1646 */
1681 (yyval
.expr
) = expr_complex( ctx
, (yyvsp
[-2].expr
), OP_LT
, (yyvsp
[0].expr
) );
1685 #line 1698 "wql.tab.c" /* yacc.c:1646 */
1689 #line 382 "wql.y" /* yacc.c:1646 */
1691 (yyval
.expr
) = expr_complex( ctx
, (yyvsp
[-2].expr
), OP_LE
, (yyvsp
[0].expr
) );
1695 #line 1708 "wql.tab.c" /* yacc.c:1646 */
1699 #line 388 "wql.y" /* yacc.c:1646 */
1701 (yyval
.expr
) = expr_complex( ctx
, (yyvsp
[-2].expr
), OP_GE
, (yyvsp
[0].expr
) );
1705 #line 1718 "wql.tab.c" /* yacc.c:1646 */
1709 #line 394 "wql.y" /* yacc.c:1646 */
1711 (yyval
.expr
) = expr_complex( ctx
, (yyvsp
[-2].expr
), OP_NE
, (yyvsp
[0].expr
) );
1715 #line 1728 "wql.tab.c" /* yacc.c:1646 */
1719 #line 400 "wql.y" /* yacc.c:1646 */
1721 (yyval
.expr
) = expr_complex( ctx
, (yyvsp
[-2].expr
), OP_LIKE
, (yyvsp
[0].expr
) );
1725 #line 1738 "wql.tab.c" /* yacc.c:1646 */
1729 #line 406 "wql.y" /* yacc.c:1646 */
1731 (yyval
.expr
) = expr_unary( ctx
, (yyvsp
[-2].expr
), OP_ISNULL
);
1735 #line 1748 "wql.tab.c" /* yacc.c:1646 */
1739 #line 412 "wql.y" /* yacc.c:1646 */
1741 (yyval
.expr
) = expr_unary( ctx
, (yyvsp
[-3].expr
), OP_NOTNULL
);
1745 #line 1758 "wql.tab.c" /* yacc.c:1646 */
1749 #line 421 "wql.y" /* yacc.c:1646 */
1751 (yyval
.expr
) = expr_sval( ctx
, &(yyvsp
[0].str
) );
1755 #line 1768 "wql.tab.c" /* yacc.c:1646 */
1759 #line 430 "wql.y" /* yacc.c:1646 */
1761 (yyval
.expr
) = expr_propval( ctx
, (yyvsp
[0].proplist
) );
1765 #line 1778 "wql.tab.c" /* yacc.c:1646 */
1769 #line 439 "wql.y" /* yacc.c:1646 */
1771 (yyval
.expr
) = expr_ival( ctx
, (yyvsp
[0].integer
) );
1775 #line 1788 "wql.tab.c" /* yacc.c:1646 */
1779 #line 445 "wql.y" /* yacc.c:1646 */
1781 (yyval
.expr
) = expr_sval( ctx
, &(yyvsp
[0].str
) );
1785 #line 1798 "wql.tab.c" /* yacc.c:1646 */
1789 #line 451 "wql.y" /* yacc.c:1646 */
1791 (yyval
.expr
) = expr_bval( ctx
, -1 );
1795 #line 1808 "wql.tab.c" /* yacc.c:1646 */
1799 #line 457 "wql.y" /* yacc.c:1646 */
1801 (yyval
.expr
) = expr_bval( ctx
, 0 );
1805 #line 1818 "wql.tab.c" /* yacc.c:1646 */
1809 #line 1822 "wql.tab.c" /* yacc.c:1646 */
1812 /* User semantic actions sometimes alter yychar, and that requires
1813 that yytoken be updated with the new translation. We take the
1814 approach of translating immediately before every use of yytoken.
1815 One alternative is translating here after every semantic action,
1816 but that translation would be missed if the semantic action invokes
1817 YYABORT, YYACCEPT, or YYERROR immediately after altering yychar or
1818 if it invokes YYBACKUP. In the case of YYABORT or YYACCEPT, an
1819 incorrect destructor might then be invoked immediately. In the
1820 case of YYERROR or YYBACKUP, subsequent parser actions might lead
1821 to an incorrect destructor call or verbose syntax error message
1822 before the lookahead is translated. */
1823 YY_SYMBOL_PRINT ("-> $$ =", yyr1
[yyn
], &yyval
, &yyloc
);
1827 YY_STACK_PRINT (yyss
, yyssp
);
1831 /* Now 'shift' the result of the reduction. Determine what state
1832 that goes to, based on the state we popped back to and the rule
1833 number reduced by. */
1837 yystate
= yypgoto
[yyn
- YYNTOKENS
] + *yyssp
;
1838 if (0 <= yystate
&& yystate
<= YYLAST
&& yycheck
[yystate
] == *yyssp
)
1839 yystate
= yytable
[yystate
];
1841 yystate
= yydefgoto
[yyn
- YYNTOKENS
];
1846 /*--------------------------------------.
1847 | yyerrlab -- here on detecting error. |
1848 `--------------------------------------*/
1850 /* Make sure we have latest lookahead translation. See comments at
1851 user semantic actions for why this is necessary. */
1852 yytoken
= yychar
== YYEMPTY
? YYEMPTY
: YYTRANSLATE (yychar
);
1854 /* If not already recovering from an error, report this error. */
1858 #if ! YYERROR_VERBOSE
1859 yyerror (ctx
, YY_("syntax error"));
1861 # define YYSYNTAX_ERROR yysyntax_error (&yymsg_alloc, &yymsg, \
1864 char const *yymsgp
= YY_("syntax error");
1865 int yysyntax_error_status
;
1866 yysyntax_error_status
= YYSYNTAX_ERROR
;
1867 if (yysyntax_error_status
== 0)
1869 else if (yysyntax_error_status
== 1)
1871 if (yymsg
!= yymsgbuf
)
1872 YYSTACK_FREE (yymsg
);
1873 yymsg
= (char *) YYSTACK_ALLOC (yymsg_alloc
);
1877 yymsg_alloc
= sizeof yymsgbuf
;
1878 yysyntax_error_status
= 2;
1882 yysyntax_error_status
= YYSYNTAX_ERROR
;
1886 yyerror (ctx
, yymsgp
);
1887 if (yysyntax_error_status
== 2)
1888 goto yyexhaustedlab
;
1890 # undef YYSYNTAX_ERROR
1896 if (yyerrstatus
== 3)
1898 /* If just tried and failed to reuse lookahead token after an
1899 error, discard it. */
1901 if (yychar
<= YYEOF
)
1903 /* Return failure if at end of input. */
1904 if (yychar
== YYEOF
)
1909 yydestruct ("Error: discarding",
1910 yytoken
, &yylval
, ctx
);
1915 /* Else will try to reuse lookahead token after shifting the error
1920 /*---------------------------------------------------.
1921 | yyerrorlab -- error raised explicitly by YYERROR. |
1922 `---------------------------------------------------*/
1925 /* Pacify compilers like GCC when the user code never invokes
1926 YYERROR and the label yyerrorlab therefore never appears in user
1928 if (/*CONSTCOND*/ 0)
1931 /* Do not reclaim the symbols of the rule whose action triggered
1935 YY_STACK_PRINT (yyss
, yyssp
);
1940 /*-------------------------------------------------------------.
1941 | yyerrlab1 -- common code for both syntax error and YYERROR. |
1942 `-------------------------------------------------------------*/
1944 yyerrstatus
= 3; /* Each real token shifted decrements this. */
1948 yyn
= yypact
[yystate
];
1949 if (!yypact_value_is_default (yyn
))
1952 if (0 <= yyn
&& yyn
<= YYLAST
&& yycheck
[yyn
] == YYTERROR
)
1960 /* Pop the current state because it cannot handle the error token. */
1965 yydestruct ("Error: popping",
1966 yystos
[yystate
], yyvsp
, ctx
);
1969 YY_STACK_PRINT (yyss
, yyssp
);
1972 YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
1974 YY_IGNORE_MAYBE_UNINITIALIZED_END
1977 /* Shift the error token. */
1978 YY_SYMBOL_PRINT ("Shifting", yystos
[yyn
], yyvsp
, yylsp
);
1984 /*-------------------------------------.
1985 | yyacceptlab -- YYACCEPT comes here. |
1986 `-------------------------------------*/
1991 /*-----------------------------------.
1992 | yyabortlab -- YYABORT comes here. |
1993 `-----------------------------------*/
1998 #if !defined yyoverflow || YYERROR_VERBOSE
1999 /*-------------------------------------------------.
2000 | yyexhaustedlab -- memory exhaustion comes here. |
2001 `-------------------------------------------------*/
2003 yyerror (ctx
, YY_("memory exhausted"));
2009 if (yychar
!= YYEMPTY
)
2011 /* Make sure we have latest lookahead translation. See comments at
2012 user semantic actions for why this is necessary. */
2013 yytoken
= YYTRANSLATE (yychar
);
2014 yydestruct ("Cleanup: discarding lookahead",
2015 yytoken
, &yylval
, ctx
);
2017 /* Do not reclaim the symbols of the rule whose action triggered
2018 this YYABORT or YYACCEPT. */
2020 YY_STACK_PRINT (yyss
, yyssp
);
2021 while (yyssp
!= yyss
)
2023 yydestruct ("Cleanup: popping",
2024 yystos
[*yyssp
], yyvsp
, ctx
);
2029 YYSTACK_FREE (yyss
);
2032 if (yymsg
!= yymsgbuf
)
2033 YYSTACK_FREE (yymsg
);
2037 #line 464 "wql.y" /* yacc.c:1906 */
2040 HRESULT
parse_query( const WCHAR
*str
, struct view
**view
, struct list
*mem
)
2042 struct parser parser
;
2050 parser
.error
= WBEM_E_INVALID_QUERY
;
2054 ret
= wql_parse( &parser
);
2055 TRACE("wql_parse returned %d\n", ret
);
2060 destroy_view( *parser
.view
);
2061 *parser
.view
= NULL
;
2063 return parser
.error
;
2068 static const char id_char
[] =
2070 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2071 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2072 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0,
2073 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0,
2074 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
2075 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 1,
2076 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
2077 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0,
2078 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
2079 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
2080 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
2081 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
2082 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
2083 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
2084 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
2085 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
2095 #define MAX_TOKEN_LEN 6
2097 static const WCHAR andW
[] = {'A','N','D'};
2098 static const WCHAR byW
[] = {'B','Y'};
2099 static const WCHAR falseW
[] = {'F','A','L','S','E'};
2100 static const WCHAR fromW
[] = {'F','R','O','M'};
2101 static const WCHAR isW
[] = {'I','S'};
2102 static const WCHAR likeW
[] = {'L','I','K','E'};
2103 static const WCHAR notW
[] = {'N','O','T'};
2104 static const WCHAR nullW
[] = {'N','U','L','L'};
2105 static const WCHAR orW
[] = {'O','R'};
2106 static const WCHAR selectW
[] = {'S','E','L','E','C','T'};
2107 static const WCHAR trueW
[] = {'T','R','U','E'};
2108 static const WCHAR whereW
[] = {'W','H','E','R','E'};
2110 static const struct keyword keyword_table
[] =
2112 { andW
, SIZEOF(andW
), TK_AND
},
2113 { byW
, SIZEOF(byW
), TK_BY
},
2114 { falseW
, SIZEOF(falseW
), TK_FALSE
},
2115 { fromW
, SIZEOF(fromW
), TK_FROM
},
2116 { isW
, SIZEOF(isW
), TK_IS
},
2117 { likeW
, SIZEOF(likeW
), TK_LIKE
},
2118 { notW
, SIZEOF(notW
), TK_NOT
},
2119 { nullW
, SIZEOF(nullW
), TK_NULL
},
2120 { orW
, SIZEOF(orW
), TK_OR
},
2121 { selectW
, SIZEOF(selectW
), TK_SELECT
},
2122 { trueW
, SIZEOF(trueW
), TK_TRUE
},
2123 { whereW
, SIZEOF(whereW
), TK_WHERE
}
2126 static int cmp_keyword( const void *arg1
, const void *arg2
)
2128 const struct keyword
*key1
= arg1
, *key2
= arg2
;
2129 int len
= min( key1
->len
, key2
->len
);
2132 if ((ret
= memicmpW( key1
->name
, key2
->name
, len
))) return ret
;
2133 if (key1
->len
< key2
->len
) return -1;
2134 else if (key1
->len
> key2
->len
) return 1;
2138 static int keyword_type( const WCHAR
*str
, unsigned int len
)
2140 struct keyword key
, *ret
;
2142 if (len
> MAX_TOKEN_LEN
) return TK_ID
;
2147 ret
= bsearch( &key
, keyword_table
, SIZEOF(keyword_table
), sizeof(struct keyword
), cmp_keyword
);
2148 if (ret
) return ret
->type
;
2152 static int get_token( const WCHAR
*s
, int *token
)
2161 for (i
= 1; isspaceW( s
[i
] ); i
++) {}
2165 if (!s
[1]) return -1;
2186 else if (s
[1] == '>')
2210 *token
= TK_ILLEGAL
;
2224 for (i
= 1; s
[i
]; i
++)
2226 if (s
[i
] == s
[0]) break;
2233 if (!isdigitW( s
[1] ))
2239 case '0': case '1': case '2': case '3': case '4':
2240 case '5': case '6': case '7': case '8': case '9':
2241 *token
= TK_INTEGER
;
2242 for (i
= 1; isdigitW( s
[i
] ); i
++) {}
2245 if (!id_char
[*s
]) break;
2247 for (i
= 1; id_char
[s
[i
]]; i
++) {}
2248 *token
= keyword_type( s
, i
);
2251 *token
= TK_ILLEGAL
;
2255 static int wql_lex( void *p
, struct parser
*parser
)
2257 struct string
*str
= p
;
2261 parser
->idx
+= parser
->len
;
2262 if (!parser
->cmd
[parser
->idx
]) return 0;
2263 parser
->len
= get_token( &parser
->cmd
[parser
->idx
], &token
);
2264 if (!parser
->len
) break;
2266 str
->data
= &parser
->cmd
[parser
->idx
];
2267 str
->len
= parser
->len
;
2268 } while (token
== TK_SPACE
);
2272 static int wql_error( struct parser
*parser
, const char *str
)