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 cond_parse
64 #define yylex cond_lex
65 #define yyerror cond_error
66 #define yydebug cond_debug
67 #define yynerrs cond_nerrs
70 /* Copy the first part of user declarations. */
71 #line 1 "cond.y" /* yacc.c:339 */
75 * Implementation of the Microsoft Installer (msi.dll)
77 * Copyright 2003 Mike McCormack for CodeWeavers
79 * This library is free software; you can redistribute it and/or
80 * modify it under the terms of the GNU Lesser General Public
81 * License as published by the Free Software Foundation; either
82 * version 2.1 of the License, or (at your option) any later version.
84 * This library is distributed in the hope that it will be useful,
85 * but WITHOUT ANY WARRANTY; without even the implied warranty of
86 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
87 * Lesser General Public License for more details.
89 * You should have received a copy of the GNU Lesser General Public
90 * License along with this library; if not, write to the Free Software
91 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
106 #include "msiquery.h"
111 #include "msiserver.h"
112 #include "wine/debug.h"
113 #include "wine/unicode.h"
114 #include "wine/list.h"
116 WINE_DEFAULT_DEBUG_CHANNEL(msi
);
118 typedef struct tag_yyinput
144 static LPWSTR
COND_GetString( COND_input
*info
, const struct cond_str
*str
);
145 static LPWSTR
COND_GetLiteral( COND_input
*info
, const struct cond_str
*str
);
146 static int cond_lex( void *COND_lval
, COND_input
*info
);
147 static int cond_error( COND_input
*info
, const char *str
);
149 static void *cond_alloc( COND_input
*cond
, unsigned int sz
);
150 static void *cond_track_mem( COND_input
*cond
, void *ptr
, unsigned int sz
);
151 static void cond_free( void *ptr
);
153 static INT
compare_int( INT a
, INT
operator, INT b
);
154 static INT
compare_string( LPCWSTR a
, INT
operator, LPCWSTR b
, BOOL convert
);
156 static BOOL
num_from_prop( LPCWSTR p
, INT
*val
)
158 INT ret
= 0, sign
= 1;
171 if( *p
< '0' || *p
> '9' )
173 ret
= ret
*10 + (*p
- '0');
180 static void value_free( struct value val
)
182 if (val
.type
!= VALUE_INTEGER
)
183 cond_free( val
.u
.string
);
187 #line 188 "cond.tab.c" /* yacc.c:339 */
190 # if defined __cplusplus && 201103L <= __cplusplus
191 # define YY_NULL nullptr
197 /* Enabling verbose error messages. */
198 #ifdef YYERROR_VERBOSE
199 # undef YYERROR_VERBOSE
200 # define YYERROR_VERBOSE 1
202 # define YYERROR_VERBOSE 0
205 /* In a future release of Bison, this section will be replaced
206 by #include "cond.tab.h". */
207 #ifndef YY_COND_E_REACTOSSYNC_GCC_DLL_WIN32_MSI_COND_TAB_H_INCLUDED
208 # define YY_COND_E_REACTOSSYNC_GCC_DLL_WIN32_MSI_COND_TAB_H_INCLUDED
214 extern int cond_debug
;
264 #if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
265 typedef union YYSTYPE YYSTYPE
;
268 #line 122 "cond.y" /* yacc.c:355 */
276 #line 277 "cond.tab.c" /* yacc.c:355 */
278 # define YYSTYPE_IS_TRIVIAL 1
279 # define YYSTYPE_IS_DECLARED 1
284 int cond_parse (COND_input
*info
);
286 #endif /* !YY_COND_E_REACTOSSYNC_GCC_DLL_WIN32_MSI_COND_TAB_H_INCLUDED */
288 /* Copy the second part of user declarations. */
290 #line 291 "cond.tab.c" /* yacc.c:358 */
297 typedef YYTYPE_UINT8 yytype_uint8
;
299 typedef unsigned char yytype_uint8
;
303 typedef YYTYPE_INT8 yytype_int8
;
305 typedef signed char yytype_int8
;
309 typedef YYTYPE_UINT16 yytype_uint16
;
311 typedef unsigned short int yytype_uint16
;
315 typedef YYTYPE_INT16 yytype_int16
;
317 typedef short int yytype_int16
;
321 # ifdef __SIZE_TYPE__
322 # define YYSIZE_T __SIZE_TYPE__
323 # elif defined size_t
324 # define YYSIZE_T size_t
325 # elif ! defined YYSIZE_T
326 # include <stddef.h> /* INFRINGES ON USER NAME SPACE */
327 # define YYSIZE_T size_t
329 # define YYSIZE_T unsigned int
333 #define YYSIZE_MAXIMUM ((YYSIZE_T) -1)
336 # if defined YYENABLE_NLS && YYENABLE_NLS
338 # include <libintl.h> /* INFRINGES ON USER NAME SPACE */
339 # define YY_(Msgid) dgettext ("bison-runtime", Msgid)
343 # define YY_(Msgid) Msgid
347 #ifndef __attribute__
348 /* This feature is available in gcc versions 2.5 and later. */
349 # if (! defined __GNUC__ || __GNUC__ < 2 \
350 || (__GNUC__ == 2 && __GNUC_MINOR__ < 5))
351 # define __attribute__(Spec) /* empty */
355 /* Suppress unused-variable warnings by "using" E. */
356 #if ! defined lint || defined __GNUC__
357 # define YYUSE(E) ((void) (E))
359 # define YYUSE(E) /* empty */
362 #if defined __GNUC__ && 407 <= __GNUC__ * 100 + __GNUC_MINOR__
363 /* Suppress an incorrect diagnostic about yylval being uninitialized. */
364 # define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN \
365 _Pragma ("GCC diagnostic push") \
366 _Pragma ("GCC diagnostic ignored \"-Wuninitialized\"")\
367 _Pragma ("GCC diagnostic ignored \"-Wmaybe-uninitialized\"")
368 # define YY_IGNORE_MAYBE_UNINITIALIZED_END \
369 _Pragma ("GCC diagnostic pop")
371 # define YY_INITIAL_VALUE(Value) Value
373 #ifndef YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
374 # define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
375 # define YY_IGNORE_MAYBE_UNINITIALIZED_END
377 #ifndef YY_INITIAL_VALUE
378 # define YY_INITIAL_VALUE(Value) /* Nothing. */
382 #if ! defined yyoverflow || YYERROR_VERBOSE
384 /* The parser invokes alloca or malloc; define the necessary symbols. */
386 # ifdef YYSTACK_USE_ALLOCA
387 # if YYSTACK_USE_ALLOCA
389 # define YYSTACK_ALLOC __builtin_alloca
390 # elif defined __BUILTIN_VA_ARG_INCR
391 # include <alloca.h> /* INFRINGES ON USER NAME SPACE */
393 # define YYSTACK_ALLOC __alloca
394 # elif defined _MSC_VER
395 # include <malloc.h> /* INFRINGES ON USER NAME SPACE */
396 # define alloca _alloca
398 # define YYSTACK_ALLOC alloca
399 # if ! defined _ALLOCA_H && ! defined EXIT_SUCCESS
400 # include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
401 /* Use EXIT_SUCCESS as a witness for stdlib.h. */
402 # ifndef EXIT_SUCCESS
403 # define EXIT_SUCCESS 0
410 # ifdef YYSTACK_ALLOC
411 /* Pacify GCC's 'empty if-body' warning. */
412 # define YYSTACK_FREE(Ptr) do { /* empty */; } while (0)
413 # ifndef YYSTACK_ALLOC_MAXIMUM
414 /* The OS might guarantee only one guard page at the bottom of the stack,
415 and a page size can be as small as 4096 bytes. So we cannot safely
416 invoke alloca (N) if N exceeds 4096. Use a slightly smaller number
417 to allow for a few compiler-allocated temporary stack slots. */
418 # define YYSTACK_ALLOC_MAXIMUM 4032 /* reasonable circa 2006 */
421 # define YYSTACK_ALLOC YYMALLOC
422 # define YYSTACK_FREE YYFREE
423 # ifndef YYSTACK_ALLOC_MAXIMUM
424 # define YYSTACK_ALLOC_MAXIMUM YYSIZE_MAXIMUM
426 # if (defined __cplusplus && ! defined EXIT_SUCCESS \
427 && ! ((defined YYMALLOC || defined malloc) \
428 && (defined YYFREE || defined free)))
429 # include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
430 # ifndef EXIT_SUCCESS
431 # define EXIT_SUCCESS 0
435 # define YYMALLOC malloc
436 # if ! defined malloc && ! defined EXIT_SUCCESS
437 void *malloc (YYSIZE_T
); /* INFRINGES ON USER NAME SPACE */
442 # if ! defined free && ! defined EXIT_SUCCESS
443 void free (void *); /* INFRINGES ON USER NAME SPACE */
447 #endif /* ! defined yyoverflow || YYERROR_VERBOSE */
450 #if (! defined yyoverflow \
451 && (! defined __cplusplus \
452 || (defined YYSTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL)))
454 /* A type that is properly aligned for any stack member. */
457 yytype_int16 yyss_alloc
;
461 /* The size of the maximum gap between one aligned stack and the next. */
462 # define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1)
464 /* The size of an array large to enough to hold all stacks, each with
466 # define YYSTACK_BYTES(N) \
467 ((N) * (sizeof (yytype_int16) + sizeof (YYSTYPE)) \
468 + YYSTACK_GAP_MAXIMUM)
470 # define YYCOPY_NEEDED 1
472 /* Relocate STACK from its old location to the new one. The
473 local variables YYSIZE and YYSTACKSIZE give the old and new number of
474 elements in the stack, and YYPTR gives the new location of the
475 stack. Advance YYPTR to a properly aligned location for the next
477 # define YYSTACK_RELOCATE(Stack_alloc, Stack) \
480 YYSIZE_T yynewbytes; \
481 YYCOPY (&yyptr->Stack_alloc, Stack, yysize); \
482 Stack = &yyptr->Stack_alloc; \
483 yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \
484 yyptr += yynewbytes / sizeof (*yyptr); \
490 #if defined YYCOPY_NEEDED && YYCOPY_NEEDED
491 /* Copy COUNT objects from SRC to DST. The source and destination do
494 # if defined __GNUC__ && 1 < __GNUC__
495 # define YYCOPY(Dst, Src, Count) \
496 __builtin_memcpy (Dst, Src, (Count) * sizeof (*(Src)))
498 # define YYCOPY(Dst, Src, Count) \
502 for (yyi = 0; yyi < (Count); yyi++) \
503 (Dst)[yyi] = (Src)[yyi]; \
508 #endif /* !YYCOPY_NEEDED */
510 /* YYFINAL -- State number of the termination state. */
512 /* YYLAST -- Last index in YYTABLE. */
515 /* YYNTOKENS -- Number of terminals. */
517 /* YYNNTS -- Number of nonterminals. */
519 /* YYNRULES -- Number of rules. */
521 /* YYNSTATES -- Number of states. */
524 /* YYTRANSLATE[YYX] -- Symbol number corresponding to YYX as returned
525 by yylex, with out-of-bounds checking. */
527 #define YYMAXUTOK 295
529 #define YYTRANSLATE(YYX) \
530 ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK)
532 /* YYTRANSLATE[TOKEN-NUM] -- Symbol number corresponding to TOKEN-NUM
533 as returned by yylex, without out-of-bounds checking. */
534 static const yytype_uint8 yytranslate
[] =
536 0, 2, 2, 2, 2, 2, 2, 2, 2, 2,
537 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
538 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
539 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
540 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
541 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
542 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
543 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
544 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
545 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
546 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
547 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
548 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
549 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
550 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
551 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
552 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
553 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
554 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
555 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
556 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
557 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
558 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
559 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
560 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
561 2, 2, 2, 2, 2, 2, 1, 2, 3, 4,
562 5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
563 15, 16, 17, 18, 19, 20, 21, 22, 23, 24,
564 25, 26, 27, 28, 29, 30, 31, 32, 33, 34,
565 35, 36, 37, 38, 39, 40
569 /* YYRLINE[YYN] -- Source line where rule number YYN was defined. */
570 static const yytype_uint16 yyrline
[] =
572 0, 149, 149, 155, 162, 166, 170, 174, 178, 185,
573 189, 196, 200, 208, 243, 251, 252, 253, 254, 255,
574 256, 257, 258, 259, 260, 261, 262, 263, 264, 265,
575 266, 267, 268, 272, 286, 301, 309, 319, 336, 353,
580 #if YYDEBUG || YYERROR_VERBOSE || 0
581 /* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
582 First, the terminals, then, starting at YYNTOKENS, nonterminals. */
583 static const char *const yytname
[] =
585 "$end", "error", "$undefined", "COND_SPACE", "COND_EOF", "COND_OR",
586 "COND_AND", "COND_NOT", "COND_XOR", "COND_IMP", "COND_EQV", "COND_LT",
587 "COND_GT", "COND_EQ", "COND_NE", "COND_GE", "COND_LE", "COND_ILT",
588 "COND_IGT", "COND_IEQ", "COND_INE", "COND_IGE", "COND_ILE", "COND_LPAR",
589 "COND_RPAR", "COND_TILDA", "COND_SS", "COND_ISS", "COND_ILHS",
590 "COND_IRHS", "COND_LHS", "COND_RHS", "COND_PERCENT", "COND_DOLLARS",
591 "COND_QUESTION", "COND_AMPER", "COND_EXCLAM", "COND_IDENT",
592 "COND_NUMBER", "COND_LITER", "COND_ERROR", "$accept", "condition",
593 "expression", "boolean_term", "boolean_factor", "operator", "value",
594 "identifier", YY_NULL
599 /* YYTOKNUM[NUM] -- (External) token number corresponding to the
600 (internal) symbol number NUM (which must be that of a token). */
601 static const yytype_uint16 yytoknum
[] =
603 0, 256, 257, 258, 259, 260, 261, 262, 263, 264,
604 265, 266, 267, 268, 269, 270, 271, 272, 273, 274,
605 275, 276, 277, 278, 279, 280, 281, 282, 283, 284,
606 285, 286, 287, 288, 289, 290, 291, 292, 293, 294,
611 #define YYPACT_NINF -45
613 #define yypact_value_is_default(Yystate) \
614 (!!((Yystate) == (-45)))
616 #define YYTABLE_NINF -1
618 #define yytable_value_is_error(Yytable_value) \
621 /* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
623 static const yytype_int8 yypact
[] =
625 -7, -7, -7, -36, -36, -36, -36, -36, -45, -45,
626 -45, 2, 5, 3, -45, 23, -45, -45, -2, -45,
627 -45, -45, -45, -45, -45, -7, -7, -7, -7, -7,
628 -45, -45, -45, -45, -45, -45, -45, -45, -45, -45,
629 -45, -45, -45, -45, -45, -45, -45, -45, 24, -45,
633 /* YYDEFACT[STATE-NUM] -- Default reduction number in state STATE-NUM.
634 Performed when YYTABLE does not specify something else to do. Zero
635 means the default is an error. */
636 static const yytype_uint8 yydefact
[] =
638 3, 0, 0, 0, 0, 0, 0, 0, 41, 36,
639 35, 0, 2, 4, 9, 12, 33, 11, 0, 34,
640 37, 38, 39, 40, 1, 0, 0, 0, 0, 0,
641 17, 18, 15, 16, 20, 19, 24, 25, 22, 23,
642 27, 26, 21, 28, 31, 32, 29, 30, 0, 14,
646 /* YYPGOTO[NTERM-NUM]. */
647 static const yytype_int8 yypgoto
[] =
649 -45, -45, 9, 39, 4, -45, -44, 14
652 /* YYDEFGOTO[NTERM-NUM]. */
653 static const yytype_int8 yydefgoto
[] =
655 -1, 11, 12, 13, 14, 48, 15, 16
658 /* YYTABLE[YYPACT[STATE-NUM]] -- What to do in state STATE-NUM. If
659 positive, shift that token. If negative, reduce the rule whose
660 number is the opposite. If YYTABLE_NINF, syntax error. */
661 static const yytype_uint8 yytable
[] =
663 1, 8, 24, 25, 55, 17, 26, 27, 28, 29,
664 25, 18, 0, 26, 27, 28, 2, 19, 20, 21,
665 22, 23, 49, 0, 0, 3, 4, 5, 6, 7,
666 8, 9, 10, 54, 30, 31, 32, 33, 34, 35,
667 36, 37, 38, 39, 40, 41, 0, 0, 0, 42,
668 43, 44, 45, 46, 47, 0, 3, 4, 5, 6,
669 7, 8, 9, 10, 50, 51, 52, 53
672 static const yytype_int8 yycheck
[] =
674 7, 37, 0, 5, 48, 1, 8, 9, 10, 6,
675 5, 2, -1, 8, 9, 10, 23, 3, 4, 5,
676 6, 7, 24, -1, -1, 32, 33, 34, 35, 36,
677 37, 38, 39, 29, 11, 12, 13, 14, 15, 16,
678 17, 18, 19, 20, 21, 22, -1, -1, -1, 26,
679 27, 28, 29, 30, 31, -1, 32, 33, 34, 35,
680 36, 37, 38, 39, 25, 26, 27, 28
683 /* YYSTOS[STATE-NUM] -- The (internal number of the) accessing
684 symbol of state STATE-NUM. */
685 static const yytype_uint8 yystos
[] =
687 0, 7, 23, 32, 33, 34, 35, 36, 37, 38,
688 39, 42, 43, 44, 45, 47, 48, 45, 43, 48,
689 48, 48, 48, 48, 0, 5, 8, 9, 10, 6,
690 11, 12, 13, 14, 15, 16, 17, 18, 19, 20,
691 21, 22, 26, 27, 28, 29, 30, 31, 46, 24,
692 44, 44, 44, 44, 45, 47
695 /* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */
696 static const yytype_uint8 yyr1
[] =
698 0, 41, 42, 42, 43, 43, 43, 43, 43, 44,
699 44, 45, 45, 45, 45, 46, 46, 46, 46, 46,
700 46, 46, 46, 46, 46, 46, 46, 46, 46, 46,
701 46, 46, 46, 47, 47, 47, 47, 47, 47, 47,
705 /* YYR2[YYN] -- Number of symbols on the right hand side of rule YYN. */
706 static const yytype_uint8 yyr2
[] =
708 0, 2, 1, 0, 1, 3, 3, 3, 3, 1,
709 3, 2, 1, 3, 3, 1, 1, 1, 1, 1,
710 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
711 1, 1, 1, 1, 2, 1, 1, 2, 2, 2,
716 #define yyerrok (yyerrstatus = 0)
717 #define yyclearin (yychar = YYEMPTY)
721 #define YYACCEPT goto yyacceptlab
722 #define YYABORT goto yyabortlab
723 #define YYERROR goto yyerrorlab
726 #define YYRECOVERING() (!!yyerrstatus)
728 #define YYBACKUP(Token, Value) \
730 if (yychar == YYEMPTY) \
734 YYPOPSTACK (yylen); \
740 yyerror (info, YY_("syntax error: cannot back up")); \
745 /* Error token number */
747 #define YYERRCODE 256
751 /* Enable debugging if requested. */
755 # include <stdio.h> /* INFRINGES ON USER NAME SPACE */
756 # define YYFPRINTF fprintf
759 # define YYDPRINTF(Args) \
765 /* This macro is provided for backward compatibility. */
766 #ifndef YY_LOCATION_PRINT
767 # define YY_LOCATION_PRINT(File, Loc) ((void) 0)
771 # define YY_SYMBOL_PRINT(Title, Type, Value, Location) \
775 YYFPRINTF (stderr, "%s ", Title); \
776 yy_symbol_print (stderr, \
777 Type, Value, info); \
778 YYFPRINTF (stderr, "\n"); \
783 /*----------------------------------------.
784 | Print this symbol's value on YYOUTPUT. |
785 `----------------------------------------*/
788 yy_symbol_value_print (FILE *yyoutput
, int yytype
, YYSTYPE
const * const yyvaluep
, COND_input
*info
)
790 FILE *yyo
= yyoutput
;
796 if (yytype
< YYNTOKENS
)
797 YYPRINT (yyoutput
, yytoknum
[yytype
], *yyvaluep
);
803 /*--------------------------------.
804 | Print this symbol on YYOUTPUT. |
805 `--------------------------------*/
808 yy_symbol_print (FILE *yyoutput
, int yytype
, YYSTYPE
const * const yyvaluep
, COND_input
*info
)
810 YYFPRINTF (yyoutput
, "%s %s (",
811 yytype
< YYNTOKENS
? "token" : "nterm", yytname
[yytype
]);
813 yy_symbol_value_print (yyoutput
, yytype
, yyvaluep
, info
);
814 YYFPRINTF (yyoutput
, ")");
817 /*------------------------------------------------------------------.
818 | yy_stack_print -- Print the state stack from its BOTTOM up to its |
820 `------------------------------------------------------------------*/
823 yy_stack_print (yytype_int16
*yybottom
, yytype_int16
*yytop
)
825 YYFPRINTF (stderr
, "Stack now");
826 for (; yybottom
<= yytop
; yybottom
++)
828 int yybot
= *yybottom
;
829 YYFPRINTF (stderr
, " %d", yybot
);
831 YYFPRINTF (stderr
, "\n");
834 # define YY_STACK_PRINT(Bottom, Top) \
837 yy_stack_print ((Bottom), (Top)); \
841 /*------------------------------------------------.
842 | Report that the YYRULE is going to be reduced. |
843 `------------------------------------------------*/
846 yy_reduce_print (yytype_int16
*yyssp
, YYSTYPE
*yyvsp
, int yyrule
, COND_input
*info
)
848 unsigned long int yylno
= yyrline
[yyrule
];
849 int yynrhs
= yyr2
[yyrule
];
851 YYFPRINTF (stderr
, "Reducing stack by rule %d (line %lu):\n",
853 /* The symbols being reduced. */
854 for (yyi
= 0; yyi
< yynrhs
; yyi
++)
856 YYFPRINTF (stderr
, " $%d = ", yyi
+ 1);
857 yy_symbol_print (stderr
,
858 yystos
[yyssp
[yyi
+ 1 - yynrhs
]],
859 &(yyvsp
[(yyi
+ 1) - (yynrhs
)])
861 YYFPRINTF (stderr
, "\n");
865 # define YY_REDUCE_PRINT(Rule) \
868 yy_reduce_print (yyssp, yyvsp, Rule, info); \
871 /* Nonzero means print parse trace. It is left uninitialized so that
872 multiple parsers can coexist. */
875 # define YYDPRINTF(Args)
876 # define YY_SYMBOL_PRINT(Title, Type, Value, Location)
877 # define YY_STACK_PRINT(Bottom, Top)
878 # define YY_REDUCE_PRINT(Rule)
879 #endif /* !YYDEBUG */
882 /* YYINITDEPTH -- initial size of the parser's stacks. */
884 # define YYINITDEPTH 200
887 /* YYMAXDEPTH -- maximum size the stacks can grow to (effective only
888 if the built-in stack extension method is used).
890 Do not make this value too large; the results are undefined if
891 YYSTACK_ALLOC_MAXIMUM < YYSTACK_BYTES (YYMAXDEPTH)
892 evaluated with infinite-precision integer arithmetic. */
895 # define YYMAXDEPTH 10000
902 # if defined __GLIBC__ && defined _STRING_H
903 # define yystrlen strlen
905 /* Return the length of YYSTR. */
907 yystrlen (const char *yystr
)
910 for (yylen
= 0; yystr
[yylen
]; yylen
++)
918 # if defined __GLIBC__ && defined _STRING_H && defined _GNU_SOURCE
919 # define yystpcpy stpcpy
921 /* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in
924 yystpcpy (char *yydest
, const char *yysrc
)
927 const char *yys
= yysrc
;
929 while ((*yyd
++ = *yys
++) != '\0')
938 /* Copy to YYRES the contents of YYSTR after stripping away unnecessary
939 quotes and backslashes, so that it's suitable for yyerror. The
940 heuristic is that double-quoting is unnecessary unless the string
941 contains an apostrophe, a comma, or backslash (other than
942 backslash-backslash). YYSTR is taken from yytname. If YYRES is
943 null, do not copy; instead, return the length of what the result
946 yytnamerr (char *yyres
, const char *yystr
)
951 char const *yyp
= yystr
;
958 goto do_not_strip_quotes
;
962 goto do_not_strip_quotes
;
975 do_not_strip_quotes
: ;
979 return yystrlen (yystr
);
981 return yystpcpy (yyres
, yystr
) - yyres
;
985 /* Copy into *YYMSG, which is of size *YYMSG_ALLOC, an error message
986 about the unexpected token YYTOKEN for the state stack whose top is
989 Return 0 if *YYMSG was successfully written. Return 1 if *YYMSG is
990 not large enough to hold the message. In that case, also set
991 *YYMSG_ALLOC to the required number of bytes. Return 2 if the
992 required number of bytes is too large to store. */
994 yysyntax_error (YYSIZE_T
*yymsg_alloc
, char **yymsg
,
995 yytype_int16
*yyssp
, int yytoken
)
997 YYSIZE_T yysize0
= yytnamerr (YY_NULL
, yytname
[yytoken
]);
998 YYSIZE_T yysize
= yysize0
;
999 enum { YYERROR_VERBOSE_ARGS_MAXIMUM
= 5 };
1000 /* Internationalized format string. */
1001 const char *yyformat
= YY_NULL
;
1002 /* Arguments of yyformat. */
1003 char const *yyarg
[YYERROR_VERBOSE_ARGS_MAXIMUM
];
1004 /* Number of reported tokens (one for the "unexpected", one per
1008 /* There are many possibilities here to consider:
1009 - If this state is a consistent state with a default action, then
1010 the only way this function was invoked is if the default action
1011 is an error action. In that case, don't check for expected
1012 tokens because there are none.
1013 - The only way there can be no lookahead present (in yychar) is if
1014 this state is a consistent state with a default action. Thus,
1015 detecting the absence of a lookahead is sufficient to determine
1016 that there is no unexpected or expected token to report. In that
1017 case, just report a simple "syntax error".
1018 - Don't assume there isn't a lookahead just because this state is a
1019 consistent state with a default action. There might have been a
1020 previous inconsistent state, consistent state with a non-default
1021 action, or user semantic action that manipulated yychar.
1022 - Of course, the expected token list depends on states to have
1023 correct lookahead information, and it depends on the parser not
1024 to perform extra reductions after fetching a lookahead from the
1025 scanner and before detecting a syntax error. Thus, state merging
1026 (from LALR or IELR) and default reductions corrupt the expected
1027 token list. However, the list is correct for canonical LR with
1028 one exception: it will still contain any token that will not be
1029 accepted due to an error action in a later state.
1031 if (yytoken
!= YYEMPTY
)
1033 int yyn
= yypact
[*yyssp
];
1034 yyarg
[yycount
++] = yytname
[yytoken
];
1035 if (!yypact_value_is_default (yyn
))
1037 /* Start YYX at -YYN if negative to avoid negative indexes in
1038 YYCHECK. In other words, skip the first -YYN actions for
1039 this state because they are default actions. */
1040 int yyxbegin
= yyn
< 0 ? -yyn
: 0;
1041 /* Stay within bounds of both yycheck and yytname. */
1042 int yychecklim
= YYLAST
- yyn
+ 1;
1043 int yyxend
= yychecklim
< YYNTOKENS
? yychecklim
: YYNTOKENS
;
1046 for (yyx
= yyxbegin
; yyx
< yyxend
; ++yyx
)
1047 if (yycheck
[yyx
+ yyn
] == yyx
&& yyx
!= YYTERROR
1048 && !yytable_value_is_error (yytable
[yyx
+ yyn
]))
1050 if (yycount
== YYERROR_VERBOSE_ARGS_MAXIMUM
)
1056 yyarg
[yycount
++] = yytname
[yyx
];
1058 YYSIZE_T yysize1
= yysize
+ yytnamerr (YY_NULL
, yytname
[yyx
]);
1059 if (! (yysize
<= yysize1
1060 && yysize1
<= YYSTACK_ALLOC_MAXIMUM
))
1070 # define YYCASE_(N, S) \
1074 YYCASE_(0, YY_("syntax error"));
1075 YYCASE_(1, YY_("syntax error, unexpected %s"));
1076 YYCASE_(2, YY_("syntax error, unexpected %s, expecting %s"));
1077 YYCASE_(3, YY_("syntax error, unexpected %s, expecting %s or %s"));
1078 YYCASE_(4, YY_("syntax error, unexpected %s, expecting %s or %s or %s"));
1079 YYCASE_(5, YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s"));
1084 YYSIZE_T yysize1
= yysize
+ yystrlen (yyformat
);
1085 if (! (yysize
<= yysize1
&& yysize1
<= YYSTACK_ALLOC_MAXIMUM
))
1090 if (*yymsg_alloc
< yysize
)
1092 *yymsg_alloc
= 2 * yysize
;
1093 if (! (yysize
<= *yymsg_alloc
1094 && *yymsg_alloc
<= YYSTACK_ALLOC_MAXIMUM
))
1095 *yymsg_alloc
= YYSTACK_ALLOC_MAXIMUM
;
1099 /* Avoid sprintf, as that infringes on the user's name space.
1100 Don't have undefined behavior even if the translation
1101 produced a string with the wrong number of "%s"s. */
1105 while ((*yyp
= *yyformat
) != '\0')
1106 if (*yyp
== '%' && yyformat
[1] == 's' && yyi
< yycount
)
1108 yyp
+= yytnamerr (yyp
, yyarg
[yyi
++]);
1119 #endif /* YYERROR_VERBOSE */
1121 /*-----------------------------------------------.
1122 | Release the memory associated to this symbol. |
1123 `-----------------------------------------------*/
1126 yydestruct (const char *yymsg
, int yytype
, YYSTYPE
*yyvaluep
, COND_input
*info
)
1132 YY_SYMBOL_PRINT (yymsg
, yytype
, yyvaluep
, yylocationp
);
1134 YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
1136 YY_IGNORE_MAYBE_UNINITIALIZED_END
1147 yyparse (COND_input
*info
)
1149 /* The lookahead symbol. */
1153 /* The semantic value of the lookahead symbol. */
1154 /* Default value used for initialization, for pacifying older GCCs
1155 or non-GCC compilers. */
1156 YY_INITIAL_VALUE (static YYSTYPE yyval_default
;)
1157 YYSTYPE yylval
YY_INITIAL_VALUE (= yyval_default
);
1159 /* Number of syntax errors so far. */
1163 /* Number of tokens to shift before error messages enabled. */
1166 /* The stacks and their tools:
1167 'yyss': related to states.
1168 'yyvs': related to semantic values.
1170 Refer to the stacks through separate pointers, to allow yyoverflow
1171 to reallocate them elsewhere. */
1173 /* The state stack. */
1174 yytype_int16 yyssa
[YYINITDEPTH
];
1176 yytype_int16
*yyssp
;
1178 /* The semantic value stack. */
1179 YYSTYPE yyvsa
[YYINITDEPTH
];
1183 YYSIZE_T yystacksize
;
1187 /* Lookahead token as an internal (translated) token number. */
1189 /* The variables used to return semantic value and location from the
1194 /* Buffer for error messages, and its allocated size. */
1196 char *yymsg
= yymsgbuf
;
1197 YYSIZE_T yymsg_alloc
= sizeof yymsgbuf
;
1200 #define YYPOPSTACK(N) (yyvsp -= (N), yyssp -= (N))
1202 /* The number of symbols on the RHS of the reduced rule.
1203 Keep to zero when no symbol should be popped. */
1206 yyssp
= yyss
= yyssa
;
1207 yyvsp
= yyvs
= yyvsa
;
1208 yystacksize
= YYINITDEPTH
;
1210 YYDPRINTF ((stderr
, "Starting parse\n"));
1215 yychar
= YYEMPTY
; /* Cause a token to be read. */
1218 /*------------------------------------------------------------.
1219 | yynewstate -- Push a new state, which is found in yystate. |
1220 `------------------------------------------------------------*/
1222 /* In all cases, when you get here, the value and location stacks
1223 have just been pushed. So pushing a state here evens the stacks. */
1229 if (yyss
+ yystacksize
- 1 <= yyssp
)
1231 /* Get the current used size of the three stacks, in elements. */
1232 YYSIZE_T yysize
= yyssp
- yyss
+ 1;
1236 /* Give user a chance to reallocate the stack. Use copies of
1237 these so that the &'s don't force the real ones into
1239 YYSTYPE
*yyvs1
= yyvs
;
1240 yytype_int16
*yyss1
= yyss
;
1242 /* Each stack pointer address is followed by the size of the
1243 data in use in that stack, in bytes. This used to be a
1244 conditional around just the two extra args, but that might
1245 be undefined if yyoverflow is a macro. */
1246 yyoverflow (YY_("memory exhausted"),
1247 &yyss1
, yysize
* sizeof (*yyssp
),
1248 &yyvs1
, yysize
* sizeof (*yyvsp
),
1254 #else /* no yyoverflow */
1255 # ifndef YYSTACK_RELOCATE
1256 goto yyexhaustedlab
;
1258 /* Extend the stack our own way. */
1259 if (YYMAXDEPTH
<= yystacksize
)
1260 goto yyexhaustedlab
;
1262 if (YYMAXDEPTH
< yystacksize
)
1263 yystacksize
= YYMAXDEPTH
;
1266 yytype_int16
*yyss1
= yyss
;
1267 union yyalloc
*yyptr
=
1268 (union yyalloc
*) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize
));
1270 goto yyexhaustedlab
;
1271 YYSTACK_RELOCATE (yyss_alloc
, yyss
);
1272 YYSTACK_RELOCATE (yyvs_alloc
, yyvs
);
1273 # undef YYSTACK_RELOCATE
1275 YYSTACK_FREE (yyss1
);
1278 #endif /* no yyoverflow */
1280 yyssp
= yyss
+ yysize
- 1;
1281 yyvsp
= yyvs
+ yysize
- 1;
1283 YYDPRINTF ((stderr
, "Stack size increased to %lu\n",
1284 (unsigned long int) yystacksize
));
1286 if (yyss
+ yystacksize
- 1 <= yyssp
)
1290 YYDPRINTF ((stderr
, "Entering state %d\n", yystate
));
1292 if (yystate
== YYFINAL
)
1302 /* Do appropriate processing given the current state. Read a
1303 lookahead token if we need one and don't already have one. */
1305 /* First try to decide what to do without reference to lookahead token. */
1306 yyn
= yypact
[yystate
];
1307 if (yypact_value_is_default (yyn
))
1310 /* Not known => get a lookahead token if don't already have one. */
1312 /* YYCHAR is either YYEMPTY or YYEOF or a valid lookahead symbol. */
1313 if (yychar
== YYEMPTY
)
1315 YYDPRINTF ((stderr
, "Reading a token: "));
1316 yychar
= yylex (&yylval
, info
);
1319 if (yychar
<= YYEOF
)
1321 yychar
= yytoken
= YYEOF
;
1322 YYDPRINTF ((stderr
, "Now at end of input.\n"));
1326 yytoken
= YYTRANSLATE (yychar
);
1327 YY_SYMBOL_PRINT ("Next token is", yytoken
, &yylval
, &yylloc
);
1330 /* If the proper action on seeing token YYTOKEN is to reduce or to
1331 detect an error, take that action. */
1333 if (yyn
< 0 || YYLAST
< yyn
|| yycheck
[yyn
] != yytoken
)
1338 if (yytable_value_is_error (yyn
))
1344 /* Count tokens shifted since error; after three, turn off error
1349 /* Shift the lookahead token. */
1350 YY_SYMBOL_PRINT ("Shifting", yytoken
, &yylval
, &yylloc
);
1352 /* Discard the shifted token. */
1356 YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
1358 YY_IGNORE_MAYBE_UNINITIALIZED_END
1363 /*-----------------------------------------------------------.
1364 | yydefault -- do the default action for the current state. |
1365 `-----------------------------------------------------------*/
1367 yyn
= yydefact
[yystate
];
1373 /*-----------------------------.
1374 | yyreduce -- Do a reduction. |
1375 `-----------------------------*/
1377 /* yyn is the number of a rule to reduce with. */
1380 /* If YYLEN is nonzero, implement the default value of the action:
1383 Otherwise, the following line sets YYVAL to garbage.
1384 This behavior is undocumented and Bison
1385 users should not rely upon it. Assigning to YYVAL
1386 unconditionally makes the parser a bit smaller, and it avoids a
1387 GCC warning that YYVAL may be used uninitialized. */
1388 yyval
= yyvsp
[1-yylen
];
1391 YY_REDUCE_PRINT (yyn
);
1395 #line 150 "cond.y" /* yacc.c:1646 */
1397 COND_input
* cond
= (COND_input
*) info
;
1398 cond
->result
= (yyvsp
[0].bool);
1400 #line 1401 "cond.tab.c" /* yacc.c:1646 */
1404 #line 155 "cond.y" /* yacc.c:1646 */
1406 COND_input
* cond
= (COND_input
*) info
;
1407 cond
->result
= MSICONDITION_NONE
;
1409 #line 1410 "cond.tab.c" /* yacc.c:1646 */
1413 #line 163 "cond.y" /* yacc.c:1646 */
1415 (yyval
.bool) = (yyvsp
[0].bool);
1417 #line 1418 "cond.tab.c" /* yacc.c:1646 */
1421 #line 167 "cond.y" /* yacc.c:1646 */
1423 (yyval
.bool) = (yyvsp
[-2].bool) || (yyvsp
[0].bool);
1425 #line 1426 "cond.tab.c" /* yacc.c:1646 */
1429 #line 171 "cond.y" /* yacc.c:1646 */
1431 (yyval
.bool) = !(yyvsp
[-2].bool) || (yyvsp
[0].bool);
1433 #line 1434 "cond.tab.c" /* yacc.c:1646 */
1437 #line 175 "cond.y" /* yacc.c:1646 */
1439 (yyval
.bool) = ( (yyvsp
[-2].bool) || (yyvsp
[0].bool) ) && !( (yyvsp
[-2].bool) && (yyvsp
[0].bool) );
1441 #line 1442 "cond.tab.c" /* yacc.c:1646 */
1445 #line 179 "cond.y" /* yacc.c:1646 */
1447 (yyval
.bool) = ( (yyvsp
[-2].bool) && (yyvsp
[0].bool) ) || ( !(yyvsp
[-2].bool) && !(yyvsp
[0].bool) );
1449 #line 1450 "cond.tab.c" /* yacc.c:1646 */
1453 #line 186 "cond.y" /* yacc.c:1646 */
1455 (yyval
.bool) = (yyvsp
[0].bool);
1457 #line 1458 "cond.tab.c" /* yacc.c:1646 */
1461 #line 190 "cond.y" /* yacc.c:1646 */
1463 (yyval
.bool) = (yyvsp
[-2].bool) && (yyvsp
[0].bool);
1465 #line 1466 "cond.tab.c" /* yacc.c:1646 */
1469 #line 197 "cond.y" /* yacc.c:1646 */
1471 (yyval
.bool) = !(yyvsp
[0].bool);
1473 #line 1474 "cond.tab.c" /* yacc.c:1646 */
1477 #line 201 "cond.y" /* yacc.c:1646 */
1479 if ((yyvsp
[0].value
).type
== VALUE_INTEGER
)
1480 (yyval
.bool) = (yyvsp
[0].value
).u
.integer
? 1 : 0;
1482 (yyval
.bool) = (yyvsp
[0].value
).u
.string
&& (yyvsp
[0].value
).u
.string
[0];
1483 value_free( (yyvsp
[0].value
) );
1485 #line 1486 "cond.tab.c" /* yacc.c:1646 */
1489 #line 209 "cond.y" /* yacc.c:1646 */
1491 if ((yyvsp
[-2].value
).type
== VALUE_INTEGER
&& (yyvsp
[0].value
).type
== VALUE_INTEGER
)
1493 (yyval
.bool) = compare_int((yyvsp
[-2].value
).u
.integer
, (yyvsp
[-1].operator), (yyvsp
[0].value
).u
.integer
);
1495 else if ((yyvsp
[-2].value
).type
!= VALUE_INTEGER
&& (yyvsp
[0].value
).type
!= VALUE_INTEGER
)
1497 (yyval
.bool) = compare_string((yyvsp
[-2].value
).u
.string
, (yyvsp
[-1].operator), (yyvsp
[0].value
).u
.string
,
1498 (yyvsp
[-2].value
).type
== VALUE_SYMBOL
|| (yyvsp
[0].value
).type
== VALUE_SYMBOL
);
1500 else if ((yyvsp
[-2].value
).type
== VALUE_LITERAL
|| (yyvsp
[0].value
).type
== VALUE_LITERAL
)
1502 (yyval
.bool) = FALSE
;
1504 else if ((yyvsp
[-2].value
).type
== VALUE_SYMBOL
) /* symbol operator integer */
1507 if (num_from_prop( (yyvsp
[-2].value
).u
.string
, &num
))
1508 (yyval
.bool) = compare_int( num
, (yyvsp
[-1].operator), (yyvsp
[0].value
).u
.integer
);
1510 (yyval
.bool) = ((yyvsp
[-1].operator) == COND_NE
|| (yyvsp
[-1].operator) == COND_INE
);
1512 else /* integer operator symbol */
1515 if (num_from_prop( (yyvsp
[0].value
).u
.string
, &num
))
1516 (yyval
.bool) = compare_int( (yyvsp
[-2].value
).u
.integer
, (yyvsp
[-1].operator), num
);
1518 (yyval
.bool) = ((yyvsp
[-1].operator) == COND_NE
|| (yyvsp
[-1].operator) == COND_INE
);
1521 value_free( (yyvsp
[-2].value
) );
1522 value_free( (yyvsp
[0].value
) );
1524 #line 1525 "cond.tab.c" /* yacc.c:1646 */
1528 #line 244 "cond.y" /* yacc.c:1646 */
1530 (yyval
.bool) = (yyvsp
[-1].bool);
1532 #line 1533 "cond.tab.c" /* yacc.c:1646 */
1536 #line 251 "cond.y" /* yacc.c:1646 */
1537 { (yyval
.operator) = COND_EQ
; }
1538 #line 1539 "cond.tab.c" /* yacc.c:1646 */
1542 #line 252 "cond.y" /* yacc.c:1646 */
1543 { (yyval
.operator) = COND_NE
; }
1544 #line 1545 "cond.tab.c" /* yacc.c:1646 */
1548 #line 253 "cond.y" /* yacc.c:1646 */
1549 { (yyval
.operator) = COND_LT
; }
1550 #line 1551 "cond.tab.c" /* yacc.c:1646 */
1554 #line 254 "cond.y" /* yacc.c:1646 */
1555 { (yyval
.operator) = COND_GT
; }
1556 #line 1557 "cond.tab.c" /* yacc.c:1646 */
1560 #line 255 "cond.y" /* yacc.c:1646 */
1561 { (yyval
.operator) = COND_LE
; }
1562 #line 1563 "cond.tab.c" /* yacc.c:1646 */
1566 #line 256 "cond.y" /* yacc.c:1646 */
1567 { (yyval
.operator) = COND_GE
; }
1568 #line 1569 "cond.tab.c" /* yacc.c:1646 */
1572 #line 257 "cond.y" /* yacc.c:1646 */
1573 { (yyval
.operator) = COND_SS
; }
1574 #line 1575 "cond.tab.c" /* yacc.c:1646 */
1578 #line 258 "cond.y" /* yacc.c:1646 */
1579 { (yyval
.operator) = COND_IEQ
; }
1580 #line 1581 "cond.tab.c" /* yacc.c:1646 */
1584 #line 259 "cond.y" /* yacc.c:1646 */
1585 { (yyval
.operator) = COND_INE
; }
1586 #line 1587 "cond.tab.c" /* yacc.c:1646 */
1590 #line 260 "cond.y" /* yacc.c:1646 */
1591 { (yyval
.operator) = COND_ILT
; }
1592 #line 1593 "cond.tab.c" /* yacc.c:1646 */
1596 #line 261 "cond.y" /* yacc.c:1646 */
1597 { (yyval
.operator) = COND_IGT
; }
1598 #line 1599 "cond.tab.c" /* yacc.c:1646 */
1602 #line 262 "cond.y" /* yacc.c:1646 */
1603 { (yyval
.operator) = COND_ILE
; }
1604 #line 1605 "cond.tab.c" /* yacc.c:1646 */
1608 #line 263 "cond.y" /* yacc.c:1646 */
1609 { (yyval
.operator) = COND_IGE
; }
1610 #line 1611 "cond.tab.c" /* yacc.c:1646 */
1614 #line 264 "cond.y" /* yacc.c:1646 */
1615 { (yyval
.operator) = COND_ISS
; }
1616 #line 1617 "cond.tab.c" /* yacc.c:1646 */
1620 #line 265 "cond.y" /* yacc.c:1646 */
1621 { (yyval
.operator) = COND_LHS
; }
1622 #line 1623 "cond.tab.c" /* yacc.c:1646 */
1626 #line 266 "cond.y" /* yacc.c:1646 */
1627 { (yyval
.operator) = COND_RHS
; }
1628 #line 1629 "cond.tab.c" /* yacc.c:1646 */
1632 #line 267 "cond.y" /* yacc.c:1646 */
1633 { (yyval
.operator) = COND_ILHS
; }
1634 #line 1635 "cond.tab.c" /* yacc.c:1646 */
1638 #line 268 "cond.y" /* yacc.c:1646 */
1639 { (yyval
.operator) = COND_IRHS
; }
1640 #line 1641 "cond.tab.c" /* yacc.c:1646 */
1644 #line 273 "cond.y" /* yacc.c:1646 */
1646 COND_input
* cond
= (COND_input
*) info
;
1649 (yyval
.value
).type
= VALUE_SYMBOL
;
1650 (yyval
.value
).u
.string
= msi_dup_property( cond
->package
->db
, (yyvsp
[0].identifier
) );
1651 if ((yyval
.value
).u
.string
)
1653 len
= (lstrlenW((yyval
.value
).u
.string
) + 1) * sizeof (WCHAR
);
1654 (yyval
.value
).u
.string
= cond_track_mem( cond
, (yyval
.value
).u
.string
, len
);
1656 cond_free( (yyvsp
[0].identifier
) );
1658 #line 1659 "cond.tab.c" /* yacc.c:1646 */
1662 #line 287 "cond.y" /* yacc.c:1646 */
1664 COND_input
* cond
= (COND_input
*) info
;
1665 UINT len
= GetEnvironmentVariableW( (yyvsp
[0].identifier
), NULL
, 0 );
1666 (yyval
.value
).type
= VALUE_SYMBOL
;
1667 (yyval
.value
).u
.string
= NULL
;
1670 (yyval
.value
).u
.string
= cond_alloc( cond
, len
*sizeof (WCHAR
) );
1671 if( !(yyval
.value
).u
.string
)
1673 GetEnvironmentVariableW( (yyvsp
[0].identifier
), (yyval
.value
).u
.string
, len
);
1675 cond_free( (yyvsp
[0].identifier
) );
1677 #line 1678 "cond.tab.c" /* yacc.c:1646 */
1681 #line 302 "cond.y" /* yacc.c:1646 */
1683 COND_input
* cond
= (COND_input
*) info
;
1684 (yyval
.value
).type
= VALUE_LITERAL
;
1685 (yyval
.value
).u
.string
= COND_GetLiteral( cond
, &(yyvsp
[0].str
) );
1686 if( !(yyval
.value
).u
.string
)
1689 #line 1690 "cond.tab.c" /* yacc.c:1646 */
1693 #line 310 "cond.y" /* yacc.c:1646 */
1695 COND_input
* cond
= (COND_input
*) info
;
1696 LPWSTR szNum
= COND_GetString( cond
, &(yyvsp
[0].str
) );
1699 (yyval
.value
).type
= VALUE_INTEGER
;
1700 (yyval
.value
).u
.integer
= atoiW( szNum
);
1703 #line 1704 "cond.tab.c" /* yacc.c:1646 */
1707 #line 320 "cond.y" /* yacc.c:1646 */
1709 COND_input
* cond
= (COND_input
*) info
;
1710 INSTALLSTATE install
= INSTALLSTATE_UNKNOWN
, action
= INSTALLSTATE_UNKNOWN
;
1712 if(MSI_GetComponentStateW(cond
->package
, (yyvsp
[0].identifier
), &install
, &action
) != ERROR_SUCCESS
)
1714 (yyval
.value
).type
= VALUE_LITERAL
;
1715 (yyval
.value
).u
.string
= NULL
;
1719 (yyval
.value
).type
= VALUE_INTEGER
;
1720 (yyval
.value
).u
.integer
= action
;
1722 cond_free( (yyvsp
[0].identifier
) );
1724 #line 1725 "cond.tab.c" /* yacc.c:1646 */
1728 #line 337 "cond.y" /* yacc.c:1646 */
1730 COND_input
* cond
= (COND_input
*) info
;
1731 INSTALLSTATE install
= INSTALLSTATE_UNKNOWN
, action
= INSTALLSTATE_UNKNOWN
;
1733 if(MSI_GetComponentStateW(cond
->package
, (yyvsp
[0].identifier
), &install
, &action
) != ERROR_SUCCESS
)
1735 (yyval
.value
).type
= VALUE_LITERAL
;
1736 (yyval
.value
).u
.string
= NULL
;
1740 (yyval
.value
).type
= VALUE_INTEGER
;
1741 (yyval
.value
).u
.integer
= install
;
1743 cond_free( (yyvsp
[0].identifier
) );
1745 #line 1746 "cond.tab.c" /* yacc.c:1646 */
1749 #line 354 "cond.y" /* yacc.c:1646 */
1751 COND_input
* cond
= (COND_input
*) info
;
1752 INSTALLSTATE install
, action
;
1754 if (MSI_GetFeatureStateW(cond
->package
, (yyvsp
[0].identifier
), &install
, &action
) != ERROR_SUCCESS
)
1756 (yyval
.value
).type
= VALUE_LITERAL
;
1757 (yyval
.value
).u
.string
= NULL
;
1761 (yyval
.value
).type
= VALUE_INTEGER
;
1762 (yyval
.value
).u
.integer
= action
;
1764 cond_free( (yyvsp
[0].identifier
) );
1766 #line 1767 "cond.tab.c" /* yacc.c:1646 */
1770 #line 371 "cond.y" /* yacc.c:1646 */
1772 COND_input
* cond
= (COND_input
*) info
;
1773 INSTALLSTATE install
= INSTALLSTATE_UNKNOWN
, action
= INSTALLSTATE_UNKNOWN
;
1775 if(MSI_GetFeatureStateW(cond
->package
, (yyvsp
[0].identifier
), &install
, &action
) != ERROR_SUCCESS
)
1777 (yyval
.value
).type
= VALUE_LITERAL
;
1778 (yyval
.value
).u
.string
= NULL
;
1782 (yyval
.value
).type
= VALUE_INTEGER
;
1783 (yyval
.value
).u
.integer
= install
;
1785 cond_free( (yyvsp
[0].identifier
) );
1787 #line 1788 "cond.tab.c" /* yacc.c:1646 */
1791 #line 391 "cond.y" /* yacc.c:1646 */
1793 COND_input
* cond
= (COND_input
*) info
;
1794 (yyval
.identifier
) = COND_GetString( cond
, &(yyvsp
[0].str
) );
1795 if( !(yyval
.identifier
) )
1798 #line 1799 "cond.tab.c" /* yacc.c:1646 */
1802 #line 1803 "cond.tab.c" /* yacc.c:1646 */
1805 /* User semantic actions sometimes alter yychar, and that requires
1806 that yytoken be updated with the new translation. We take the
1807 approach of translating immediately before every use of yytoken.
1808 One alternative is translating here after every semantic action,
1809 but that translation would be missed if the semantic action invokes
1810 YYABORT, YYACCEPT, or YYERROR immediately after altering yychar or
1811 if it invokes YYBACKUP. In the case of YYABORT or YYACCEPT, an
1812 incorrect destructor might then be invoked immediately. In the
1813 case of YYERROR or YYBACKUP, subsequent parser actions might lead
1814 to an incorrect destructor call or verbose syntax error message
1815 before the lookahead is translated. */
1816 YY_SYMBOL_PRINT ("-> $$ =", yyr1
[yyn
], &yyval
, &yyloc
);
1820 YY_STACK_PRINT (yyss
, yyssp
);
1824 /* Now 'shift' the result of the reduction. Determine what state
1825 that goes to, based on the state we popped back to and the rule
1826 number reduced by. */
1830 yystate
= yypgoto
[yyn
- YYNTOKENS
] + *yyssp
;
1831 if (0 <= yystate
&& yystate
<= YYLAST
&& yycheck
[yystate
] == *yyssp
)
1832 yystate
= yytable
[yystate
];
1834 yystate
= yydefgoto
[yyn
- YYNTOKENS
];
1839 /*--------------------------------------.
1840 | yyerrlab -- here on detecting error. |
1841 `--------------------------------------*/
1843 /* Make sure we have latest lookahead translation. See comments at
1844 user semantic actions for why this is necessary. */
1845 yytoken
= yychar
== YYEMPTY
? YYEMPTY
: YYTRANSLATE (yychar
);
1847 /* If not already recovering from an error, report this error. */
1851 #if ! YYERROR_VERBOSE
1852 yyerror (info
, YY_("syntax error"));
1854 # define YYSYNTAX_ERROR yysyntax_error (&yymsg_alloc, &yymsg, \
1857 char const *yymsgp
= YY_("syntax error");
1858 int yysyntax_error_status
;
1859 yysyntax_error_status
= YYSYNTAX_ERROR
;
1860 if (yysyntax_error_status
== 0)
1862 else if (yysyntax_error_status
== 1)
1864 if (yymsg
!= yymsgbuf
)
1865 YYSTACK_FREE (yymsg
);
1866 yymsg
= (char *) YYSTACK_ALLOC (yymsg_alloc
);
1870 yymsg_alloc
= sizeof yymsgbuf
;
1871 yysyntax_error_status
= 2;
1875 yysyntax_error_status
= YYSYNTAX_ERROR
;
1879 yyerror (info
, yymsgp
);
1880 if (yysyntax_error_status
== 2)
1881 goto yyexhaustedlab
;
1883 # undef YYSYNTAX_ERROR
1889 if (yyerrstatus
== 3)
1891 /* If just tried and failed to reuse lookahead token after an
1892 error, discard it. */
1894 if (yychar
<= YYEOF
)
1896 /* Return failure if at end of input. */
1897 if (yychar
== YYEOF
)
1902 yydestruct ("Error: discarding",
1903 yytoken
, &yylval
, info
);
1908 /* Else will try to reuse lookahead token after shifting the error
1913 /*---------------------------------------------------.
1914 | yyerrorlab -- error raised explicitly by YYERROR. |
1915 `---------------------------------------------------*/
1918 /* Pacify compilers like GCC when the user code never invokes
1919 YYERROR and the label yyerrorlab therefore never appears in user
1921 if (/*CONSTCOND*/ 0)
1924 /* Do not reclaim the symbols of the rule whose action triggered
1928 YY_STACK_PRINT (yyss
, yyssp
);
1933 /*-------------------------------------------------------------.
1934 | yyerrlab1 -- common code for both syntax error and YYERROR. |
1935 `-------------------------------------------------------------*/
1937 yyerrstatus
= 3; /* Each real token shifted decrements this. */
1941 yyn
= yypact
[yystate
];
1942 if (!yypact_value_is_default (yyn
))
1945 if (0 <= yyn
&& yyn
<= YYLAST
&& yycheck
[yyn
] == YYTERROR
)
1953 /* Pop the current state because it cannot handle the error token. */
1958 yydestruct ("Error: popping",
1959 yystos
[yystate
], yyvsp
, info
);
1962 YY_STACK_PRINT (yyss
, yyssp
);
1965 YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
1967 YY_IGNORE_MAYBE_UNINITIALIZED_END
1970 /* Shift the error token. */
1971 YY_SYMBOL_PRINT ("Shifting", yystos
[yyn
], yyvsp
, yylsp
);
1977 /*-------------------------------------.
1978 | yyacceptlab -- YYACCEPT comes here. |
1979 `-------------------------------------*/
1984 /*-----------------------------------.
1985 | yyabortlab -- YYABORT comes here. |
1986 `-----------------------------------*/
1991 #if !defined yyoverflow || YYERROR_VERBOSE
1992 /*-------------------------------------------------.
1993 | yyexhaustedlab -- memory exhaustion comes here. |
1994 `-------------------------------------------------*/
1996 yyerror (info
, YY_("memory exhausted"));
2002 if (yychar
!= YYEMPTY
)
2004 /* Make sure we have latest lookahead translation. See comments at
2005 user semantic actions for why this is necessary. */
2006 yytoken
= YYTRANSLATE (yychar
);
2007 yydestruct ("Cleanup: discarding lookahead",
2008 yytoken
, &yylval
, info
);
2010 /* Do not reclaim the symbols of the rule whose action triggered
2011 this YYABORT or YYACCEPT. */
2013 YY_STACK_PRINT (yyss
, yyssp
);
2014 while (yyssp
!= yyss
)
2016 yydestruct ("Cleanup: popping",
2017 yystos
[*yyssp
], yyvsp
, info
);
2022 YYSTACK_FREE (yyss
);
2025 if (yymsg
!= yymsgbuf
)
2026 YYSTACK_FREE (yymsg
);
2030 #line 399 "cond.y" /* yacc.c:1906 */
2034 static int COND_IsAlpha( WCHAR x
)
2036 return( ( ( x
>= 'A' ) && ( x
<= 'Z' ) ) ||
2037 ( ( x
>= 'a' ) && ( x
<= 'z' ) ) ||
2041 static int COND_IsNumber( WCHAR x
)
2043 return( (( x
>= '0' ) && ( x
<= '9' )) || (x
=='-') || (x
=='.') );
2046 static WCHAR
*strstriW( const WCHAR
*str
, const WCHAR
*sub
)
2048 LPWSTR strlower
, sublower
, r
;
2049 strlower
= CharLowerW( strdupW( str
) );
2050 sublower
= CharLowerW( strdupW( sub
) );
2051 r
= strstrW( strlower
, sublower
);
2053 r
= (LPWSTR
)str
+ (r
- strlower
);
2054 msi_free( strlower
);
2055 msi_free( sublower
);
2059 static BOOL
str_is_number( LPCWSTR str
)
2066 for (i
= 0; i
< lstrlenW( str
); i
++)
2067 if (!isdigitW(str
[i
]))
2073 static INT
compare_substring( LPCWSTR a
, INT
operator, LPCWSTR b
)
2077 /* substring operators return 0 if LHS is missing */
2081 /* substring operators return 1 if RHS is missing */
2085 /* if both strings contain only numbers, use integer comparison */
2088 if (str_is_number(a
) && str_is_number(b
))
2089 return compare_int( lhs
, operator, rhs
);
2094 return strstrW( a
, b
) != 0;
2096 return strstriW( a
, b
) != 0;
2099 int l
= strlenW( a
);
2100 int r
= strlenW( b
);
2101 if (r
> l
) return 0;
2102 return !strncmpW( a
, b
, r
);
2106 int l
= strlenW( a
);
2107 int r
= strlenW( b
);
2108 if (r
> l
) return 0;
2109 return !strncmpW( a
+ (l
- r
), b
, r
);
2113 int l
= strlenW( a
);
2114 int r
= strlenW( b
);
2115 if (r
> l
) return 0;
2116 return !strncmpiW( a
, b
, r
);
2120 int l
= strlenW( a
);
2121 int r
= strlenW( b
);
2122 if (r
> l
) return 0;
2123 return !strncmpiW( a
+ (l
- r
), b
, r
);
2126 ERR("invalid substring operator\n");
2132 static INT
compare_string( LPCWSTR a
, INT
operator, LPCWSTR b
, BOOL convert
)
2134 if (operator >= COND_SS
&& operator <= COND_RHS
)
2135 return compare_substring( a
, operator, b
);
2137 /* null and empty string are equivalent */
2138 if (!a
) a
= szEmpty
;
2139 if (!b
) b
= szEmpty
;
2141 if (convert
&& str_is_number(a
) && str_is_number(b
))
2142 return compare_int( atoiW(a
), operator, atoiW(b
) );
2144 /* a or b may be NULL */
2148 return strcmpW( a
, b
) < 0;
2150 return strcmpW( a
, b
) > 0;
2152 return strcmpW( a
, b
) == 0;
2154 return strcmpW( a
, b
) != 0;
2156 return strcmpW( a
, b
) >= 0;
2158 return strcmpW( a
, b
) <= 0;
2160 return strcmpiW( a
, b
) < 0;
2162 return strcmpiW( a
, b
) > 0;
2164 return strcmpiW( a
, b
) == 0;
2166 return strcmpiW( a
, b
) != 0;
2168 return strcmpiW( a
, b
) >= 0;
2170 return strcmpiW( a
, b
) <= 0;
2172 ERR("invalid string operator\n");
2179 static INT
compare_int( INT a
, INT
operator, INT b
)
2203 return ( a
& b
) ? 1 : 0;
2205 return ( ( a
& 0xffff ) == b
) ? 1 : 0;
2207 return ( ( (a
>>16) & 0xffff ) == b
) ? 1 : 0;
2209 ERR("invalid integer operator\n");
2216 static int COND_IsIdent( WCHAR x
)
2218 return( COND_IsAlpha( x
) || COND_IsNumber( x
) || ( x
== '_' )
2219 || ( x
== '#' ) || (x
== '.') );
2222 static int COND_GetOperator( COND_input
*cond
)
2224 static const struct {
2228 { {'~','<','=',0}, COND_ILE
},
2229 { {'~','>','<',0}, COND_ISS
},
2230 { {'~','>','>',0}, COND_IRHS
},
2231 { {'~','<','>',0}, COND_INE
},
2232 { {'~','>','=',0}, COND_IGE
},
2233 { {'~','<','<',0}, COND_ILHS
},
2234 { {'~','=',0}, COND_IEQ
},
2235 { {'~','<',0}, COND_ILT
},
2236 { {'~','>',0}, COND_IGT
},
2237 { {'>','=',0}, COND_GE
},
2238 { {'>','<',0}, COND_SS
},
2239 { {'<','<',0}, COND_LHS
},
2240 { {'<','>',0}, COND_NE
},
2241 { {'<','=',0}, COND_LE
},
2242 { {'>','>',0}, COND_RHS
},
2243 { {'>',0}, COND_GT
},
2244 { {'<',0}, COND_LT
},
2247 LPCWSTR p
= &cond
->str
[cond
->n
];
2252 len
= lstrlenW( table
[i
].str
);
2253 if ( !len
|| 0 == strncmpW( table
[i
].str
, p
, len
) )
2261 static int COND_GetOne( struct cond_str
*str
, COND_input
*cond
)
2266 str
->data
= &cond
->str
[cond
->n
];
2273 case '(': rc
= COND_LPAR
; break;
2274 case ')': rc
= COND_RPAR
; break;
2275 case '&': rc
= COND_AMPER
; break;
2276 case '!': rc
= COND_EXCLAM
; break;
2277 case '$': rc
= COND_DOLLARS
; break;
2278 case '?': rc
= COND_QUESTION
; break;
2279 case '%': rc
= COND_PERCENT
; break;
2280 case ' ': rc
= COND_SPACE
; break;
2281 case '=': rc
= COND_EQ
; break;
2286 rc
= COND_GetOperator( cond
);
2302 LPCWSTR p
= strchrW( str
->data
+ 1, '"' );
2303 if (!p
) return COND_ERROR
;
2304 len
= p
- str
->data
+ 1;
2307 else if( COND_IsAlpha( ch
) )
2309 static const WCHAR szNot
[] = {'N','O','T',0};
2310 static const WCHAR szAnd
[] = {'A','N','D',0};
2311 static const WCHAR szXor
[] = {'X','O','R',0};
2312 static const WCHAR szEqv
[] = {'E','Q','V',0};
2313 static const WCHAR szImp
[] = {'I','M','P',0};
2314 static const WCHAR szOr
[] = {'O','R',0};
2316 while( COND_IsIdent( str
->data
[len
] ) )
2322 if ( !strncmpiW( str
->data
, szNot
, len
) )
2324 else if( !strncmpiW( str
->data
, szAnd
, len
) )
2326 else if( !strncmpiW( str
->data
, szXor
, len
) )
2328 else if( !strncmpiW( str
->data
, szEqv
, len
) )
2330 else if( !strncmpiW( str
->data
, szImp
, len
) )
2333 else if( (len
== 2) && !strncmpiW( str
->data
, szOr
, len
) )
2336 else if( COND_IsNumber( ch
) )
2338 while( COND_IsNumber( str
->data
[len
] ) )
2344 ERR("Got unknown character %c(%x)\n",ch
,ch
);
2354 static int cond_lex( void *COND_lval
, COND_input
*cond
)
2357 struct cond_str
*str
= COND_lval
;
2360 rc
= COND_GetOne( str
, cond
);
2361 } while (rc
== COND_SPACE
);
2366 static LPWSTR
COND_GetString( COND_input
*cond
, const struct cond_str
*str
)
2370 ret
= cond_alloc( cond
, (str
->len
+1) * sizeof (WCHAR
) );
2373 memcpy( ret
, str
->data
, str
->len
* sizeof(WCHAR
));
2376 TRACE("Got identifier %s\n",debugstr_w(ret
));
2380 static LPWSTR
COND_GetLiteral( COND_input
*cond
, const struct cond_str
*str
)
2384 ret
= cond_alloc( cond
, (str
->len
-1) * sizeof (WCHAR
) );
2387 memcpy( ret
, str
->data
+1, (str
->len
-2) * sizeof(WCHAR
) );
2388 ret
[str
->len
- 2]=0;
2390 TRACE("Got literal %s\n",debugstr_w(ret
));
2394 static void *cond_alloc( COND_input
*cond
, unsigned int sz
)
2398 mem
= msi_alloc( sizeof (struct list
) + sz
);
2402 list_add_head( &(cond
->mem
), mem
);
2406 static void *cond_track_mem( COND_input
*cond
, void *ptr
, unsigned int sz
)
2413 new_ptr
= cond_alloc( cond
, sz
);
2420 memcpy( new_ptr
, ptr
, sz
);
2425 static void cond_free( void *ptr
)
2427 struct list
*mem
= (struct list
*)ptr
- 1;
2436 static int cond_error( COND_input
*info
, const char *str
)
2438 TRACE("%s\n", str
);
2442 MSICONDITION
MSI_EvaluateConditionW( MSIPACKAGE
*package
, LPCWSTR szCondition
)
2446 struct list
*mem
, *safety
;
2448 TRACE("%s\n", debugstr_w( szCondition
) );
2450 if (szCondition
== NULL
) return MSICONDITION_NONE
;
2452 cond
.package
= package
;
2453 cond
.str
= szCondition
;
2455 cond
.result
= MSICONDITION_ERROR
;
2457 list_init( &cond
.mem
);
2459 if ( !cond_parse( &cond
) )
2462 r
= MSICONDITION_ERROR
;
2464 LIST_FOR_EACH_SAFE( mem
, safety
, &cond
.mem
)
2466 /* The tracked memory lives directly after the list struct */
2467 void *ptr
= mem
+ 1;
2468 if ( r
!= MSICONDITION_ERROR
)
2469 WARN( "condition parser failed to free up some memory: %p\n", ptr
);
2473 TRACE("%i <- %s\n", r
, debugstr_w(szCondition
));
2477 MSICONDITION WINAPI
MsiEvaluateConditionW( MSIHANDLE hInstall
, LPCWSTR szCondition
)
2479 MSIPACKAGE
*package
;
2482 package
= msihandle2msiinfo( hInstall
, MSIHANDLETYPE_PACKAGE
);
2487 IWineMsiRemotePackage
*remote_package
;
2489 remote_package
= (IWineMsiRemotePackage
*)msi_get_remote( hInstall
);
2490 if (!remote_package
)
2491 return MSICONDITION_ERROR
;
2493 condition
= SysAllocString( szCondition
);
2496 IWineMsiRemotePackage_Release( remote_package
);
2497 return ERROR_OUTOFMEMORY
;
2500 hr
= IWineMsiRemotePackage_EvaluateCondition( remote_package
, condition
);
2502 SysFreeString( condition
);
2503 IWineMsiRemotePackage_Release( remote_package
);
2507 if (HRESULT_FACILITY(hr
) == FACILITY_WIN32
)
2508 return HRESULT_CODE(hr
);
2510 return ERROR_FUNCTION_FAILED
;
2513 return ERROR_SUCCESS
;
2516 ret
= MSI_EvaluateConditionW( package
, szCondition
);
2517 msiobj_release( &package
->hdr
);
2521 MSICONDITION WINAPI
MsiEvaluateConditionA( MSIHANDLE hInstall
, LPCSTR szCondition
)
2523 LPWSTR szwCond
= NULL
;
2526 szwCond
= strdupAtoW( szCondition
);
2527 if( szCondition
&& !szwCond
)
2528 return MSICONDITION_ERROR
;
2530 r
= MsiEvaluateConditionW( hInstall
, szwCond
);
2531 msi_free( szwCond
);