[MSI] Sync with Wine 3.0. CORE-14225
[reactos.git] / dll / win32 / msi / cond.tab.c
1 /* A Bison parser, made by GNU Bison 3.0. */
2
3 /* Bison implementation for Yacc-like parsers in C
4
5 Copyright (C) 1984, 1989-1990, 2000-2013 Free Software Foundation, Inc.
6
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.
11
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.
16
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/>. */
19
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.
29
30 This special exception was added by the Free Software Foundation in
31 version 2.2 of Bison. */
32
33 /* C LALR(1) parser skeleton written by Richard Stallman, by
34 simplifying the original so-called "semantic" parser. */
35
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. */
42
43 /* Identify Bison output. */
44 #define YYBISON 1
45
46 /* Bison version. */
47 #define YYBISON_VERSION "3.0"
48
49 /* Skeleton name. */
50 #define YYSKELETON_NAME "yacc.c"
51
52 /* Pure parsers. */
53 #define YYPURE 1
54
55 /* Push parsers. */
56 #define YYPUSH 0
57
58 /* Pull parsers. */
59 #define YYPULL 1
60
61
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
68
69
70 /* Copy the first part of user declarations. */
71 #line 1 "cond.y" /* yacc.c:339 */
72
73
74 /*
75 * Implementation of the Microsoft Installer (msi.dll)
76 *
77 * Copyright 2003 Mike McCormack for CodeWeavers
78 *
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.
83 *
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.
88 *
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
92 */
93
94 #include "msipriv.h"
95
96 WINE_DEFAULT_DEBUG_CHANNEL(msi);
97
98 typedef struct tag_yyinput
99 {
100 MSIPACKAGE *package;
101 LPCWSTR str;
102 INT n;
103 MSICONDITION result;
104 struct list mem;
105 } COND_input;
106
107 struct cond_str {
108 LPCWSTR data;
109 INT len;
110 };
111
112 struct value {
113 enum value_type {
114 VALUE_INTEGER,
115 VALUE_LITERAL,
116 VALUE_SYMBOL
117 } type;
118 union {
119 INT integer;
120 WCHAR *string;
121 } u;
122 };
123
124 static LPWSTR COND_GetString( COND_input *info, const struct cond_str *str );
125 static LPWSTR COND_GetLiteral( COND_input *info, const struct cond_str *str );
126 static int cond_lex( void *COND_lval, COND_input *info);
127 static int cond_error( COND_input *info, const char *str);
128
129 static void *cond_alloc( COND_input *cond, unsigned int sz );
130 static void *cond_track_mem( COND_input *cond, void *ptr, unsigned int sz );
131 static void cond_free( void *ptr );
132
133 static INT compare_int( INT a, INT operator, INT b );
134 static INT compare_string( LPCWSTR a, INT operator, LPCWSTR b, BOOL convert );
135
136 static BOOL num_from_prop( LPCWSTR p, INT *val )
137 {
138 INT ret = 0, sign = 1;
139
140 if (!p)
141 return FALSE;
142 if (*p == '-')
143 {
144 sign = -1;
145 p++;
146 }
147 if (!*p)
148 return FALSE;
149 while (*p)
150 {
151 if( *p < '0' || *p > '9' )
152 return FALSE;
153 ret = ret*10 + (*p - '0');
154 p++;
155 }
156 *val = ret*sign;
157 return TRUE;
158 }
159
160 static void value_free( struct value val )
161 {
162 if (val.type != VALUE_INTEGER)
163 cond_free( val.u.string );
164 }
165
166
167 #line 168 "cond.tab.c" /* yacc.c:339 */
168
169 # ifndef YY_NULL
170 # if defined __cplusplus && 201103L <= __cplusplus
171 # define YY_NULL nullptr
172 # else
173 # define YY_NULL 0
174 # endif
175 # endif
176
177 /* Enabling verbose error messages. */
178 #ifdef YYERROR_VERBOSE
179 # undef YYERROR_VERBOSE
180 # define YYERROR_VERBOSE 1
181 #else
182 # define YYERROR_VERBOSE 0
183 #endif
184
185 /* In a future release of Bison, this section will be replaced
186 by #include "cond.tab.h". */
187 #ifndef YY_COND_E_REACTOSSYNC3_0_GCC_DLL_WIN32_MSI_COND_TAB_H_INCLUDED
188 # define YY_COND_E_REACTOSSYNC3_0_GCC_DLL_WIN32_MSI_COND_TAB_H_INCLUDED
189 /* Debug traces. */
190 #ifndef YYDEBUG
191 # define YYDEBUG 0
192 #endif
193 #if YYDEBUG
194 extern int cond_debug;
195 #endif
196
197 /* Token type. */
198 #ifndef YYTOKENTYPE
199 # define YYTOKENTYPE
200 enum yytokentype
201 {
202 COND_SPACE = 258,
203 COND_EOF = 259,
204 COND_OR = 260,
205 COND_AND = 261,
206 COND_NOT = 262,
207 COND_XOR = 263,
208 COND_IMP = 264,
209 COND_EQV = 265,
210 COND_LT = 266,
211 COND_GT = 267,
212 COND_EQ = 268,
213 COND_NE = 269,
214 COND_GE = 270,
215 COND_LE = 271,
216 COND_ILT = 272,
217 COND_IGT = 273,
218 COND_IEQ = 274,
219 COND_INE = 275,
220 COND_IGE = 276,
221 COND_ILE = 277,
222 COND_LPAR = 278,
223 COND_RPAR = 279,
224 COND_TILDA = 280,
225 COND_SS = 281,
226 COND_ISS = 282,
227 COND_ILHS = 283,
228 COND_IRHS = 284,
229 COND_LHS = 285,
230 COND_RHS = 286,
231 COND_PERCENT = 287,
232 COND_DOLLARS = 288,
233 COND_QUESTION = 289,
234 COND_AMPER = 290,
235 COND_EXCLAM = 291,
236 COND_IDENT = 292,
237 COND_NUMBER = 293,
238 COND_LITER = 294,
239 COND_ERROR = 295
240 };
241 #endif
242
243 /* Value type. */
244 #if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
245 typedef union YYSTYPE YYSTYPE;
246 union YYSTYPE
247 {
248 #line 102 "cond.y" /* yacc.c:355 */
249
250 struct cond_str str;
251 struct value value;
252 LPWSTR identifier;
253 INT operator;
254 BOOL bool;
255
256 #line 257 "cond.tab.c" /* yacc.c:355 */
257 };
258 # define YYSTYPE_IS_TRIVIAL 1
259 # define YYSTYPE_IS_DECLARED 1
260 #endif
261
262
263
264 int cond_parse (COND_input *info);
265
266 #endif /* !YY_COND_E_REACTOSSYNC3_0_GCC_DLL_WIN32_MSI_COND_TAB_H_INCLUDED */
267
268 /* Copy the second part of user declarations. */
269
270 #line 271 "cond.tab.c" /* yacc.c:358 */
271
272 #ifdef short
273 # undef short
274 #endif
275
276 #ifdef YYTYPE_UINT8
277 typedef YYTYPE_UINT8 yytype_uint8;
278 #else
279 typedef unsigned char yytype_uint8;
280 #endif
281
282 #ifdef YYTYPE_INT8
283 typedef YYTYPE_INT8 yytype_int8;
284 #else
285 typedef signed char yytype_int8;
286 #endif
287
288 #ifdef YYTYPE_UINT16
289 typedef YYTYPE_UINT16 yytype_uint16;
290 #else
291 typedef unsigned short int yytype_uint16;
292 #endif
293
294 #ifdef YYTYPE_INT16
295 typedef YYTYPE_INT16 yytype_int16;
296 #else
297 typedef short int yytype_int16;
298 #endif
299
300 #ifndef YYSIZE_T
301 # ifdef __SIZE_TYPE__
302 # define YYSIZE_T __SIZE_TYPE__
303 # elif defined size_t
304 # define YYSIZE_T size_t
305 # elif ! defined YYSIZE_T
306 # include <stddef.h> /* INFRINGES ON USER NAME SPACE */
307 # define YYSIZE_T size_t
308 # else
309 # define YYSIZE_T unsigned int
310 # endif
311 #endif
312
313 #define YYSIZE_MAXIMUM ((YYSIZE_T) -1)
314
315 #ifndef YY_
316 # if defined YYENABLE_NLS && YYENABLE_NLS
317 # if ENABLE_NLS
318 # include <libintl.h> /* INFRINGES ON USER NAME SPACE */
319 # define YY_(Msgid) dgettext ("bison-runtime", Msgid)
320 # endif
321 # endif
322 # ifndef YY_
323 # define YY_(Msgid) Msgid
324 # endif
325 #endif
326
327 #ifndef __attribute__
328 /* This feature is available in gcc versions 2.5 and later. */
329 # if (! defined __GNUC__ || __GNUC__ < 2 \
330 || (__GNUC__ == 2 && __GNUC_MINOR__ < 5))
331 # define __attribute__(Spec) /* empty */
332 # endif
333 #endif
334
335 /* Suppress unused-variable warnings by "using" E. */
336 #if ! defined lint || defined __GNUC__
337 # define YYUSE(E) ((void) (E))
338 #else
339 # define YYUSE(E) /* empty */
340 #endif
341
342 #if defined __GNUC__ && 407 <= __GNUC__ * 100 + __GNUC_MINOR__
343 /* Suppress an incorrect diagnostic about yylval being uninitialized. */
344 # define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN \
345 _Pragma ("GCC diagnostic push") \
346 _Pragma ("GCC diagnostic ignored \"-Wuninitialized\"")\
347 _Pragma ("GCC diagnostic ignored \"-Wmaybe-uninitialized\"")
348 # define YY_IGNORE_MAYBE_UNINITIALIZED_END \
349 _Pragma ("GCC diagnostic pop")
350 #else
351 # define YY_INITIAL_VALUE(Value) Value
352 #endif
353 #ifndef YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
354 # define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
355 # define YY_IGNORE_MAYBE_UNINITIALIZED_END
356 #endif
357 #ifndef YY_INITIAL_VALUE
358 # define YY_INITIAL_VALUE(Value) /* Nothing. */
359 #endif
360
361
362 #if ! defined yyoverflow || YYERROR_VERBOSE
363
364 /* The parser invokes alloca or malloc; define the necessary symbols. */
365
366 # ifdef YYSTACK_USE_ALLOCA
367 # if YYSTACK_USE_ALLOCA
368 # ifdef __GNUC__
369 # define YYSTACK_ALLOC __builtin_alloca
370 # elif defined __BUILTIN_VA_ARG_INCR
371 # include <alloca.h> /* INFRINGES ON USER NAME SPACE */
372 # elif defined _AIX
373 # define YYSTACK_ALLOC __alloca
374 # elif defined _MSC_VER
375 # include <malloc.h> /* INFRINGES ON USER NAME SPACE */
376 # define alloca _alloca
377 # else
378 # define YYSTACK_ALLOC alloca
379 # if ! defined _ALLOCA_H && ! defined EXIT_SUCCESS
380 # include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
381 /* Use EXIT_SUCCESS as a witness for stdlib.h. */
382 # ifndef EXIT_SUCCESS
383 # define EXIT_SUCCESS 0
384 # endif
385 # endif
386 # endif
387 # endif
388 # endif
389
390 # ifdef YYSTACK_ALLOC
391 /* Pacify GCC's 'empty if-body' warning. */
392 # define YYSTACK_FREE(Ptr) do { /* empty */; } while (0)
393 # ifndef YYSTACK_ALLOC_MAXIMUM
394 /* The OS might guarantee only one guard page at the bottom of the stack,
395 and a page size can be as small as 4096 bytes. So we cannot safely
396 invoke alloca (N) if N exceeds 4096. Use a slightly smaller number
397 to allow for a few compiler-allocated temporary stack slots. */
398 # define YYSTACK_ALLOC_MAXIMUM 4032 /* reasonable circa 2006 */
399 # endif
400 # else
401 # define YYSTACK_ALLOC YYMALLOC
402 # define YYSTACK_FREE YYFREE
403 # ifndef YYSTACK_ALLOC_MAXIMUM
404 # define YYSTACK_ALLOC_MAXIMUM YYSIZE_MAXIMUM
405 # endif
406 # if (defined __cplusplus && ! defined EXIT_SUCCESS \
407 && ! ((defined YYMALLOC || defined malloc) \
408 && (defined YYFREE || defined free)))
409 # include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
410 # ifndef EXIT_SUCCESS
411 # define EXIT_SUCCESS 0
412 # endif
413 # endif
414 # ifndef YYMALLOC
415 # define YYMALLOC malloc
416 # if ! defined malloc && ! defined EXIT_SUCCESS
417 void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */
418 # endif
419 # endif
420 # ifndef YYFREE
421 # define YYFREE free
422 # if ! defined free && ! defined EXIT_SUCCESS
423 void free (void *); /* INFRINGES ON USER NAME SPACE */
424 # endif
425 # endif
426 # endif
427 #endif /* ! defined yyoverflow || YYERROR_VERBOSE */
428
429
430 #if (! defined yyoverflow \
431 && (! defined __cplusplus \
432 || (defined YYSTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL)))
433
434 /* A type that is properly aligned for any stack member. */
435 union yyalloc
436 {
437 yytype_int16 yyss_alloc;
438 YYSTYPE yyvs_alloc;
439 };
440
441 /* The size of the maximum gap between one aligned stack and the next. */
442 # define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1)
443
444 /* The size of an array large to enough to hold all stacks, each with
445 N elements. */
446 # define YYSTACK_BYTES(N) \
447 ((N) * (sizeof (yytype_int16) + sizeof (YYSTYPE)) \
448 + YYSTACK_GAP_MAXIMUM)
449
450 # define YYCOPY_NEEDED 1
451
452 /* Relocate STACK from its old location to the new one. The
453 local variables YYSIZE and YYSTACKSIZE give the old and new number of
454 elements in the stack, and YYPTR gives the new location of the
455 stack. Advance YYPTR to a properly aligned location for the next
456 stack. */
457 # define YYSTACK_RELOCATE(Stack_alloc, Stack) \
458 do \
459 { \
460 YYSIZE_T yynewbytes; \
461 YYCOPY (&yyptr->Stack_alloc, Stack, yysize); \
462 Stack = &yyptr->Stack_alloc; \
463 yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \
464 yyptr += yynewbytes / sizeof (*yyptr); \
465 } \
466 while (0)
467
468 #endif
469
470 #if defined YYCOPY_NEEDED && YYCOPY_NEEDED
471 /* Copy COUNT objects from SRC to DST. The source and destination do
472 not overlap. */
473 # ifndef YYCOPY
474 # if defined __GNUC__ && 1 < __GNUC__
475 # define YYCOPY(Dst, Src, Count) \
476 __builtin_memcpy (Dst, Src, (Count) * sizeof (*(Src)))
477 # else
478 # define YYCOPY(Dst, Src, Count) \
479 do \
480 { \
481 YYSIZE_T yyi; \
482 for (yyi = 0; yyi < (Count); yyi++) \
483 (Dst)[yyi] = (Src)[yyi]; \
484 } \
485 while (0)
486 # endif
487 # endif
488 #endif /* !YYCOPY_NEEDED */
489
490 /* YYFINAL -- State number of the termination state. */
491 #define YYFINAL 24
492 /* YYLAST -- Last index in YYTABLE. */
493 #define YYLAST 67
494
495 /* YYNTOKENS -- Number of terminals. */
496 #define YYNTOKENS 41
497 /* YYNNTS -- Number of nonterminals. */
498 #define YYNNTS 8
499 /* YYNRULES -- Number of rules. */
500 #define YYNRULES 41
501 /* YYNSTATES -- Number of states. */
502 #define YYNSTATES 56
503
504 /* YYTRANSLATE[YYX] -- Symbol number corresponding to YYX as returned
505 by yylex, with out-of-bounds checking. */
506 #define YYUNDEFTOK 2
507 #define YYMAXUTOK 295
508
509 #define YYTRANSLATE(YYX) \
510 ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK)
511
512 /* YYTRANSLATE[TOKEN-NUM] -- Symbol number corresponding to TOKEN-NUM
513 as returned by yylex, without out-of-bounds checking. */
514 static const yytype_uint8 yytranslate[] =
515 {
516 0, 2, 2, 2, 2, 2, 2, 2, 2, 2,
517 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
518 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
519 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
520 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
521 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
522 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
523 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
524 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
525 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
526 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
527 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
528 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
529 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
530 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
531 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
532 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
533 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
534 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
535 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
536 2, 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, 1, 2, 3, 4,
542 5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
543 15, 16, 17, 18, 19, 20, 21, 22, 23, 24,
544 25, 26, 27, 28, 29, 30, 31, 32, 33, 34,
545 35, 36, 37, 38, 39, 40
546 };
547
548 #if YYDEBUG
549 /* YYRLINE[YYN] -- Source line where rule number YYN was defined. */
550 static const yytype_uint16 yyrline[] =
551 {
552 0, 129, 129, 135, 142, 146, 150, 154, 158, 165,
553 169, 176, 180, 188, 223, 231, 232, 233, 234, 235,
554 236, 237, 238, 239, 240, 241, 242, 243, 244, 245,
555 246, 247, 248, 252, 266, 281, 289, 299, 316, 333,
556 350, 370
557 };
558 #endif
559
560 #if YYDEBUG || YYERROR_VERBOSE || 0
561 /* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
562 First, the terminals, then, starting at YYNTOKENS, nonterminals. */
563 static const char *const yytname[] =
564 {
565 "$end", "error", "$undefined", "COND_SPACE", "COND_EOF", "COND_OR",
566 "COND_AND", "COND_NOT", "COND_XOR", "COND_IMP", "COND_EQV", "COND_LT",
567 "COND_GT", "COND_EQ", "COND_NE", "COND_GE", "COND_LE", "COND_ILT",
568 "COND_IGT", "COND_IEQ", "COND_INE", "COND_IGE", "COND_ILE", "COND_LPAR",
569 "COND_RPAR", "COND_TILDA", "COND_SS", "COND_ISS", "COND_ILHS",
570 "COND_IRHS", "COND_LHS", "COND_RHS", "COND_PERCENT", "COND_DOLLARS",
571 "COND_QUESTION", "COND_AMPER", "COND_EXCLAM", "COND_IDENT",
572 "COND_NUMBER", "COND_LITER", "COND_ERROR", "$accept", "condition",
573 "expression", "boolean_term", "boolean_factor", "operator", "value",
574 "identifier", YY_NULL
575 };
576 #endif
577
578 # ifdef YYPRINT
579 /* YYTOKNUM[NUM] -- (External) token number corresponding to the
580 (internal) symbol number NUM (which must be that of a token). */
581 static const yytype_uint16 yytoknum[] =
582 {
583 0, 256, 257, 258, 259, 260, 261, 262, 263, 264,
584 265, 266, 267, 268, 269, 270, 271, 272, 273, 274,
585 275, 276, 277, 278, 279, 280, 281, 282, 283, 284,
586 285, 286, 287, 288, 289, 290, 291, 292, 293, 294,
587 295
588 };
589 # endif
590
591 #define YYPACT_NINF -45
592
593 #define yypact_value_is_default(Yystate) \
594 (!!((Yystate) == (-45)))
595
596 #define YYTABLE_NINF -1
597
598 #define yytable_value_is_error(Yytable_value) \
599 0
600
601 /* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
602 STATE-NUM. */
603 static const yytype_int8 yypact[] =
604 {
605 -7, -7, -7, -36, -36, -36, -36, -36, -45, -45,
606 -45, 2, 5, 3, -45, 23, -45, -45, -2, -45,
607 -45, -45, -45, -45, -45, -7, -7, -7, -7, -7,
608 -45, -45, -45, -45, -45, -45, -45, -45, -45, -45,
609 -45, -45, -45, -45, -45, -45, -45, -45, 24, -45,
610 3, 3, 3, 3, -45, -45
611 };
612
613 /* YYDEFACT[STATE-NUM] -- Default reduction number in state STATE-NUM.
614 Performed when YYTABLE does not specify something else to do. Zero
615 means the default is an error. */
616 static const yytype_uint8 yydefact[] =
617 {
618 3, 0, 0, 0, 0, 0, 0, 0, 41, 36,
619 35, 0, 2, 4, 9, 12, 33, 11, 0, 34,
620 37, 38, 39, 40, 1, 0, 0, 0, 0, 0,
621 17, 18, 15, 16, 20, 19, 24, 25, 22, 23,
622 27, 26, 21, 28, 31, 32, 29, 30, 0, 14,
623 5, 7, 6, 8, 10, 13
624 };
625
626 /* YYPGOTO[NTERM-NUM]. */
627 static const yytype_int8 yypgoto[] =
628 {
629 -45, -45, 9, 39, 4, -45, -44, 14
630 };
631
632 /* YYDEFGOTO[NTERM-NUM]. */
633 static const yytype_int8 yydefgoto[] =
634 {
635 -1, 11, 12, 13, 14, 48, 15, 16
636 };
637
638 /* YYTABLE[YYPACT[STATE-NUM]] -- What to do in state STATE-NUM. If
639 positive, shift that token. If negative, reduce the rule whose
640 number is the opposite. If YYTABLE_NINF, syntax error. */
641 static const yytype_uint8 yytable[] =
642 {
643 1, 8, 24, 25, 55, 17, 26, 27, 28, 29,
644 25, 18, 0, 26, 27, 28, 2, 19, 20, 21,
645 22, 23, 49, 0, 0, 3, 4, 5, 6, 7,
646 8, 9, 10, 54, 30, 31, 32, 33, 34, 35,
647 36, 37, 38, 39, 40, 41, 0, 0, 0, 42,
648 43, 44, 45, 46, 47, 0, 3, 4, 5, 6,
649 7, 8, 9, 10, 50, 51, 52, 53
650 };
651
652 static const yytype_int8 yycheck[] =
653 {
654 7, 37, 0, 5, 48, 1, 8, 9, 10, 6,
655 5, 2, -1, 8, 9, 10, 23, 3, 4, 5,
656 6, 7, 24, -1, -1, 32, 33, 34, 35, 36,
657 37, 38, 39, 29, 11, 12, 13, 14, 15, 16,
658 17, 18, 19, 20, 21, 22, -1, -1, -1, 26,
659 27, 28, 29, 30, 31, -1, 32, 33, 34, 35,
660 36, 37, 38, 39, 25, 26, 27, 28
661 };
662
663 /* YYSTOS[STATE-NUM] -- The (internal number of the) accessing
664 symbol of state STATE-NUM. */
665 static const yytype_uint8 yystos[] =
666 {
667 0, 7, 23, 32, 33, 34, 35, 36, 37, 38,
668 39, 42, 43, 44, 45, 47, 48, 45, 43, 48,
669 48, 48, 48, 48, 0, 5, 8, 9, 10, 6,
670 11, 12, 13, 14, 15, 16, 17, 18, 19, 20,
671 21, 22, 26, 27, 28, 29, 30, 31, 46, 24,
672 44, 44, 44, 44, 45, 47
673 };
674
675 /* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */
676 static const yytype_uint8 yyr1[] =
677 {
678 0, 41, 42, 42, 43, 43, 43, 43, 43, 44,
679 44, 45, 45, 45, 45, 46, 46, 46, 46, 46,
680 46, 46, 46, 46, 46, 46, 46, 46, 46, 46,
681 46, 46, 46, 47, 47, 47, 47, 47, 47, 47,
682 47, 48
683 };
684
685 /* YYR2[YYN] -- Number of symbols on the right hand side of rule YYN. */
686 static const yytype_uint8 yyr2[] =
687 {
688 0, 2, 1, 0, 1, 3, 3, 3, 3, 1,
689 3, 2, 1, 3, 3, 1, 1, 1, 1, 1,
690 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
691 1, 1, 1, 1, 2, 1, 1, 2, 2, 2,
692 2, 1
693 };
694
695
696 #define yyerrok (yyerrstatus = 0)
697 #define yyclearin (yychar = YYEMPTY)
698 #define YYEMPTY (-2)
699 #define YYEOF 0
700
701 #define YYACCEPT goto yyacceptlab
702 #define YYABORT goto yyabortlab
703 #define YYERROR goto yyerrorlab
704
705
706 #define YYRECOVERING() (!!yyerrstatus)
707
708 #define YYBACKUP(Token, Value) \
709 do \
710 if (yychar == YYEMPTY) \
711 { \
712 yychar = (Token); \
713 yylval = (Value); \
714 YYPOPSTACK (yylen); \
715 yystate = *yyssp; \
716 goto yybackup; \
717 } \
718 else \
719 { \
720 yyerror (info, YY_("syntax error: cannot back up")); \
721 YYERROR; \
722 } \
723 while (0)
724
725 /* Error token number */
726 #define YYTERROR 1
727 #define YYERRCODE 256
728
729
730
731 /* Enable debugging if requested. */
732 #if YYDEBUG
733
734 # ifndef YYFPRINTF
735 # include <stdio.h> /* INFRINGES ON USER NAME SPACE */
736 # define YYFPRINTF fprintf
737 # endif
738
739 # define YYDPRINTF(Args) \
740 do { \
741 if (yydebug) \
742 YYFPRINTF Args; \
743 } while (0)
744
745 /* This macro is provided for backward compatibility. */
746 #ifndef YY_LOCATION_PRINT
747 # define YY_LOCATION_PRINT(File, Loc) ((void) 0)
748 #endif
749
750
751 # define YY_SYMBOL_PRINT(Title, Type, Value, Location) \
752 do { \
753 if (yydebug) \
754 { \
755 YYFPRINTF (stderr, "%s ", Title); \
756 yy_symbol_print (stderr, \
757 Type, Value, info); \
758 YYFPRINTF (stderr, "\n"); \
759 } \
760 } while (0)
761
762
763 /*----------------------------------------.
764 | Print this symbol's value on YYOUTPUT. |
765 `----------------------------------------*/
766
767 static void
768 yy_symbol_value_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep, COND_input *info)
769 {
770 FILE *yyo = yyoutput;
771 YYUSE (yyo);
772 YYUSE (info);
773 if (!yyvaluep)
774 return;
775 # ifdef YYPRINT
776 if (yytype < YYNTOKENS)
777 YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep);
778 # endif
779 YYUSE (yytype);
780 }
781
782
783 /*--------------------------------.
784 | Print this symbol on YYOUTPUT. |
785 `--------------------------------*/
786
787 static void
788 yy_symbol_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep, COND_input *info)
789 {
790 YYFPRINTF (yyoutput, "%s %s (",
791 yytype < YYNTOKENS ? "token" : "nterm", yytname[yytype]);
792
793 yy_symbol_value_print (yyoutput, yytype, yyvaluep, info);
794 YYFPRINTF (yyoutput, ")");
795 }
796
797 /*------------------------------------------------------------------.
798 | yy_stack_print -- Print the state stack from its BOTTOM up to its |
799 | TOP (included). |
800 `------------------------------------------------------------------*/
801
802 static void
803 yy_stack_print (yytype_int16 *yybottom, yytype_int16 *yytop)
804 {
805 YYFPRINTF (stderr, "Stack now");
806 for (; yybottom <= yytop; yybottom++)
807 {
808 int yybot = *yybottom;
809 YYFPRINTF (stderr, " %d", yybot);
810 }
811 YYFPRINTF (stderr, "\n");
812 }
813
814 # define YY_STACK_PRINT(Bottom, Top) \
815 do { \
816 if (yydebug) \
817 yy_stack_print ((Bottom), (Top)); \
818 } while (0)
819
820
821 /*------------------------------------------------.
822 | Report that the YYRULE is going to be reduced. |
823 `------------------------------------------------*/
824
825 static void
826 yy_reduce_print (yytype_int16 *yyssp, YYSTYPE *yyvsp, int yyrule, COND_input *info)
827 {
828 unsigned long int yylno = yyrline[yyrule];
829 int yynrhs = yyr2[yyrule];
830 int yyi;
831 YYFPRINTF (stderr, "Reducing stack by rule %d (line %lu):\n",
832 yyrule - 1, yylno);
833 /* The symbols being reduced. */
834 for (yyi = 0; yyi < yynrhs; yyi++)
835 {
836 YYFPRINTF (stderr, " $%d = ", yyi + 1);
837 yy_symbol_print (stderr,
838 yystos[yyssp[yyi + 1 - yynrhs]],
839 &(yyvsp[(yyi + 1) - (yynrhs)])
840 , info);
841 YYFPRINTF (stderr, "\n");
842 }
843 }
844
845 # define YY_REDUCE_PRINT(Rule) \
846 do { \
847 if (yydebug) \
848 yy_reduce_print (yyssp, yyvsp, Rule, info); \
849 } while (0)
850
851 /* Nonzero means print parse trace. It is left uninitialized so that
852 multiple parsers can coexist. */
853 int yydebug;
854 #else /* !YYDEBUG */
855 # define YYDPRINTF(Args)
856 # define YY_SYMBOL_PRINT(Title, Type, Value, Location)
857 # define YY_STACK_PRINT(Bottom, Top)
858 # define YY_REDUCE_PRINT(Rule)
859 #endif /* !YYDEBUG */
860
861
862 /* YYINITDEPTH -- initial size of the parser's stacks. */
863 #ifndef YYINITDEPTH
864 # define YYINITDEPTH 200
865 #endif
866
867 /* YYMAXDEPTH -- maximum size the stacks can grow to (effective only
868 if the built-in stack extension method is used).
869
870 Do not make this value too large; the results are undefined if
871 YYSTACK_ALLOC_MAXIMUM < YYSTACK_BYTES (YYMAXDEPTH)
872 evaluated with infinite-precision integer arithmetic. */
873
874 #ifndef YYMAXDEPTH
875 # define YYMAXDEPTH 10000
876 #endif
877
878
879 #if YYERROR_VERBOSE
880
881 # ifndef yystrlen
882 # if defined __GLIBC__ && defined _STRING_H
883 # define yystrlen strlen
884 # else
885 /* Return the length of YYSTR. */
886 static YYSIZE_T
887 yystrlen (const char *yystr)
888 {
889 YYSIZE_T yylen;
890 for (yylen = 0; yystr[yylen]; yylen++)
891 continue;
892 return yylen;
893 }
894 # endif
895 # endif
896
897 # ifndef yystpcpy
898 # if defined __GLIBC__ && defined _STRING_H && defined _GNU_SOURCE
899 # define yystpcpy stpcpy
900 # else
901 /* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in
902 YYDEST. */
903 static char *
904 yystpcpy (char *yydest, const char *yysrc)
905 {
906 char *yyd = yydest;
907 const char *yys = yysrc;
908
909 while ((*yyd++ = *yys++) != '\0')
910 continue;
911
912 return yyd - 1;
913 }
914 # endif
915 # endif
916
917 # ifndef yytnamerr
918 /* Copy to YYRES the contents of YYSTR after stripping away unnecessary
919 quotes and backslashes, so that it's suitable for yyerror. The
920 heuristic is that double-quoting is unnecessary unless the string
921 contains an apostrophe, a comma, or backslash (other than
922 backslash-backslash). YYSTR is taken from yytname. If YYRES is
923 null, do not copy; instead, return the length of what the result
924 would have been. */
925 static YYSIZE_T
926 yytnamerr (char *yyres, const char *yystr)
927 {
928 if (*yystr == '"')
929 {
930 YYSIZE_T yyn = 0;
931 char const *yyp = yystr;
932
933 for (;;)
934 switch (*++yyp)
935 {
936 case '\'':
937 case ',':
938 goto do_not_strip_quotes;
939
940 case '\\':
941 if (*++yyp != '\\')
942 goto do_not_strip_quotes;
943 /* Fall through. */
944 default:
945 if (yyres)
946 yyres[yyn] = *yyp;
947 yyn++;
948 break;
949
950 case '"':
951 if (yyres)
952 yyres[yyn] = '\0';
953 return yyn;
954 }
955 do_not_strip_quotes: ;
956 }
957
958 if (! yyres)
959 return yystrlen (yystr);
960
961 return yystpcpy (yyres, yystr) - yyres;
962 }
963 # endif
964
965 /* Copy into *YYMSG, which is of size *YYMSG_ALLOC, an error message
966 about the unexpected token YYTOKEN for the state stack whose top is
967 YYSSP.
968
969 Return 0 if *YYMSG was successfully written. Return 1 if *YYMSG is
970 not large enough to hold the message. In that case, also set
971 *YYMSG_ALLOC to the required number of bytes. Return 2 if the
972 required number of bytes is too large to store. */
973 static int
974 yysyntax_error (YYSIZE_T *yymsg_alloc, char **yymsg,
975 yytype_int16 *yyssp, int yytoken)
976 {
977 YYSIZE_T yysize0 = yytnamerr (YY_NULL, yytname[yytoken]);
978 YYSIZE_T yysize = yysize0;
979 enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 };
980 /* Internationalized format string. */
981 const char *yyformat = YY_NULL;
982 /* Arguments of yyformat. */
983 char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM];
984 /* Number of reported tokens (one for the "unexpected", one per
985 "expected"). */
986 int yycount = 0;
987
988 /* There are many possibilities here to consider:
989 - If this state is a consistent state with a default action, then
990 the only way this function was invoked is if the default action
991 is an error action. In that case, don't check for expected
992 tokens because there are none.
993 - The only way there can be no lookahead present (in yychar) is if
994 this state is a consistent state with a default action. Thus,
995 detecting the absence of a lookahead is sufficient to determine
996 that there is no unexpected or expected token to report. In that
997 case, just report a simple "syntax error".
998 - Don't assume there isn't a lookahead just because this state is a
999 consistent state with a default action. There might have been a
1000 previous inconsistent state, consistent state with a non-default
1001 action, or user semantic action that manipulated yychar.
1002 - Of course, the expected token list depends on states to have
1003 correct lookahead information, and it depends on the parser not
1004 to perform extra reductions after fetching a lookahead from the
1005 scanner and before detecting a syntax error. Thus, state merging
1006 (from LALR or IELR) and default reductions corrupt the expected
1007 token list. However, the list is correct for canonical LR with
1008 one exception: it will still contain any token that will not be
1009 accepted due to an error action in a later state.
1010 */
1011 if (yytoken != YYEMPTY)
1012 {
1013 int yyn = yypact[*yyssp];
1014 yyarg[yycount++] = yytname[yytoken];
1015 if (!yypact_value_is_default (yyn))
1016 {
1017 /* Start YYX at -YYN if negative to avoid negative indexes in
1018 YYCHECK. In other words, skip the first -YYN actions for
1019 this state because they are default actions. */
1020 int yyxbegin = yyn < 0 ? -yyn : 0;
1021 /* Stay within bounds of both yycheck and yytname. */
1022 int yychecklim = YYLAST - yyn + 1;
1023 int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS;
1024 int yyx;
1025
1026 for (yyx = yyxbegin; yyx < yyxend; ++yyx)
1027 if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR
1028 && !yytable_value_is_error (yytable[yyx + yyn]))
1029 {
1030 if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM)
1031 {
1032 yycount = 1;
1033 yysize = yysize0;
1034 break;
1035 }
1036 yyarg[yycount++] = yytname[yyx];
1037 {
1038 YYSIZE_T yysize1 = yysize + yytnamerr (YY_NULL, yytname[yyx]);
1039 if (! (yysize <= yysize1
1040 && yysize1 <= YYSTACK_ALLOC_MAXIMUM))
1041 return 2;
1042 yysize = yysize1;
1043 }
1044 }
1045 }
1046 }
1047
1048 switch (yycount)
1049 {
1050 # define YYCASE_(N, S) \
1051 case N: \
1052 yyformat = S; \
1053 break
1054 YYCASE_(0, YY_("syntax error"));
1055 YYCASE_(1, YY_("syntax error, unexpected %s"));
1056 YYCASE_(2, YY_("syntax error, unexpected %s, expecting %s"));
1057 YYCASE_(3, YY_("syntax error, unexpected %s, expecting %s or %s"));
1058 YYCASE_(4, YY_("syntax error, unexpected %s, expecting %s or %s or %s"));
1059 YYCASE_(5, YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s"));
1060 # undef YYCASE_
1061 }
1062
1063 {
1064 YYSIZE_T yysize1 = yysize + yystrlen (yyformat);
1065 if (! (yysize <= yysize1 && yysize1 <= YYSTACK_ALLOC_MAXIMUM))
1066 return 2;
1067 yysize = yysize1;
1068 }
1069
1070 if (*yymsg_alloc < yysize)
1071 {
1072 *yymsg_alloc = 2 * yysize;
1073 if (! (yysize <= *yymsg_alloc
1074 && *yymsg_alloc <= YYSTACK_ALLOC_MAXIMUM))
1075 *yymsg_alloc = YYSTACK_ALLOC_MAXIMUM;
1076 return 1;
1077 }
1078
1079 /* Avoid sprintf, as that infringes on the user's name space.
1080 Don't have undefined behavior even if the translation
1081 produced a string with the wrong number of "%s"s. */
1082 {
1083 char *yyp = *yymsg;
1084 int yyi = 0;
1085 while ((*yyp = *yyformat) != '\0')
1086 if (*yyp == '%' && yyformat[1] == 's' && yyi < yycount)
1087 {
1088 yyp += yytnamerr (yyp, yyarg[yyi++]);
1089 yyformat += 2;
1090 }
1091 else
1092 {
1093 yyp++;
1094 yyformat++;
1095 }
1096 }
1097 return 0;
1098 }
1099 #endif /* YYERROR_VERBOSE */
1100
1101 /*-----------------------------------------------.
1102 | Release the memory associated to this symbol. |
1103 `-----------------------------------------------*/
1104
1105 static void
1106 yydestruct (const char *yymsg, int yytype, YYSTYPE *yyvaluep, COND_input *info)
1107 {
1108 YYUSE (yyvaluep);
1109 YYUSE (info);
1110 if (!yymsg)
1111 yymsg = "Deleting";
1112 YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp);
1113
1114 YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
1115 YYUSE (yytype);
1116 YY_IGNORE_MAYBE_UNINITIALIZED_END
1117 }
1118
1119
1120
1121
1122 /*----------.
1123 | yyparse. |
1124 `----------*/
1125
1126 int
1127 yyparse (COND_input *info)
1128 {
1129 /* The lookahead symbol. */
1130 int yychar;
1131
1132
1133 /* The semantic value of the lookahead symbol. */
1134 /* Default value used for initialization, for pacifying older GCCs
1135 or non-GCC compilers. */
1136 YY_INITIAL_VALUE (static YYSTYPE yyval_default;)
1137 YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default);
1138
1139 /* Number of syntax errors so far. */
1140 int yynerrs;
1141
1142 int yystate;
1143 /* Number of tokens to shift before error messages enabled. */
1144 int yyerrstatus;
1145
1146 /* The stacks and their tools:
1147 'yyss': related to states.
1148 'yyvs': related to semantic values.
1149
1150 Refer to the stacks through separate pointers, to allow yyoverflow
1151 to reallocate them elsewhere. */
1152
1153 /* The state stack. */
1154 yytype_int16 yyssa[YYINITDEPTH];
1155 yytype_int16 *yyss;
1156 yytype_int16 *yyssp;
1157
1158 /* The semantic value stack. */
1159 YYSTYPE yyvsa[YYINITDEPTH];
1160 YYSTYPE *yyvs;
1161 YYSTYPE *yyvsp;
1162
1163 YYSIZE_T yystacksize;
1164
1165 int yyn;
1166 int yyresult;
1167 /* Lookahead token as an internal (translated) token number. */
1168 int yytoken = 0;
1169 /* The variables used to return semantic value and location from the
1170 action routines. */
1171 YYSTYPE yyval;
1172
1173 #if YYERROR_VERBOSE
1174 /* Buffer for error messages, and its allocated size. */
1175 char yymsgbuf[128];
1176 char *yymsg = yymsgbuf;
1177 YYSIZE_T yymsg_alloc = sizeof yymsgbuf;
1178 #endif
1179
1180 #define YYPOPSTACK(N) (yyvsp -= (N), yyssp -= (N))
1181
1182 /* The number of symbols on the RHS of the reduced rule.
1183 Keep to zero when no symbol should be popped. */
1184 int yylen = 0;
1185
1186 yyssp = yyss = yyssa;
1187 yyvsp = yyvs = yyvsa;
1188 yystacksize = YYINITDEPTH;
1189
1190 YYDPRINTF ((stderr, "Starting parse\n"));
1191
1192 yystate = 0;
1193 yyerrstatus = 0;
1194 yynerrs = 0;
1195 yychar = YYEMPTY; /* Cause a token to be read. */
1196 goto yysetstate;
1197
1198 /*------------------------------------------------------------.
1199 | yynewstate -- Push a new state, which is found in yystate. |
1200 `------------------------------------------------------------*/
1201 yynewstate:
1202 /* In all cases, when you get here, the value and location stacks
1203 have just been pushed. So pushing a state here evens the stacks. */
1204 yyssp++;
1205
1206 yysetstate:
1207 *yyssp = yystate;
1208
1209 if (yyss + yystacksize - 1 <= yyssp)
1210 {
1211 /* Get the current used size of the three stacks, in elements. */
1212 YYSIZE_T yysize = yyssp - yyss + 1;
1213
1214 #ifdef yyoverflow
1215 {
1216 /* Give user a chance to reallocate the stack. Use copies of
1217 these so that the &'s don't force the real ones into
1218 memory. */
1219 YYSTYPE *yyvs1 = yyvs;
1220 yytype_int16 *yyss1 = yyss;
1221
1222 /* Each stack pointer address is followed by the size of the
1223 data in use in that stack, in bytes. This used to be a
1224 conditional around just the two extra args, but that might
1225 be undefined if yyoverflow is a macro. */
1226 yyoverflow (YY_("memory exhausted"),
1227 &yyss1, yysize * sizeof (*yyssp),
1228 &yyvs1, yysize * sizeof (*yyvsp),
1229 &yystacksize);
1230
1231 yyss = yyss1;
1232 yyvs = yyvs1;
1233 }
1234 #else /* no yyoverflow */
1235 # ifndef YYSTACK_RELOCATE
1236 goto yyexhaustedlab;
1237 # else
1238 /* Extend the stack our own way. */
1239 if (YYMAXDEPTH <= yystacksize)
1240 goto yyexhaustedlab;
1241 yystacksize *= 2;
1242 if (YYMAXDEPTH < yystacksize)
1243 yystacksize = YYMAXDEPTH;
1244
1245 {
1246 yytype_int16 *yyss1 = yyss;
1247 union yyalloc *yyptr =
1248 (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize));
1249 if (! yyptr)
1250 goto yyexhaustedlab;
1251 YYSTACK_RELOCATE (yyss_alloc, yyss);
1252 YYSTACK_RELOCATE (yyvs_alloc, yyvs);
1253 # undef YYSTACK_RELOCATE
1254 if (yyss1 != yyssa)
1255 YYSTACK_FREE (yyss1);
1256 }
1257 # endif
1258 #endif /* no yyoverflow */
1259
1260 yyssp = yyss + yysize - 1;
1261 yyvsp = yyvs + yysize - 1;
1262
1263 YYDPRINTF ((stderr, "Stack size increased to %lu\n",
1264 (unsigned long int) yystacksize));
1265
1266 if (yyss + yystacksize - 1 <= yyssp)
1267 YYABORT;
1268 }
1269
1270 YYDPRINTF ((stderr, "Entering state %d\n", yystate));
1271
1272 if (yystate == YYFINAL)
1273 YYACCEPT;
1274
1275 goto yybackup;
1276
1277 /*-----------.
1278 | yybackup. |
1279 `-----------*/
1280 yybackup:
1281
1282 /* Do appropriate processing given the current state. Read a
1283 lookahead token if we need one and don't already have one. */
1284
1285 /* First try to decide what to do without reference to lookahead token. */
1286 yyn = yypact[yystate];
1287 if (yypact_value_is_default (yyn))
1288 goto yydefault;
1289
1290 /* Not known => get a lookahead token if don't already have one. */
1291
1292 /* YYCHAR is either YYEMPTY or YYEOF or a valid lookahead symbol. */
1293 if (yychar == YYEMPTY)
1294 {
1295 YYDPRINTF ((stderr, "Reading a token: "));
1296 yychar = yylex (&yylval, info);
1297 }
1298
1299 if (yychar <= YYEOF)
1300 {
1301 yychar = yytoken = YYEOF;
1302 YYDPRINTF ((stderr, "Now at end of input.\n"));
1303 }
1304 else
1305 {
1306 yytoken = YYTRANSLATE (yychar);
1307 YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc);
1308 }
1309
1310 /* If the proper action on seeing token YYTOKEN is to reduce or to
1311 detect an error, take that action. */
1312 yyn += yytoken;
1313 if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken)
1314 goto yydefault;
1315 yyn = yytable[yyn];
1316 if (yyn <= 0)
1317 {
1318 if (yytable_value_is_error (yyn))
1319 goto yyerrlab;
1320 yyn = -yyn;
1321 goto yyreduce;
1322 }
1323
1324 /* Count tokens shifted since error; after three, turn off error
1325 status. */
1326 if (yyerrstatus)
1327 yyerrstatus--;
1328
1329 /* Shift the lookahead token. */
1330 YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc);
1331
1332 /* Discard the shifted token. */
1333 yychar = YYEMPTY;
1334
1335 yystate = yyn;
1336 YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
1337 *++yyvsp = yylval;
1338 YY_IGNORE_MAYBE_UNINITIALIZED_END
1339
1340 goto yynewstate;
1341
1342
1343 /*-----------------------------------------------------------.
1344 | yydefault -- do the default action for the current state. |
1345 `-----------------------------------------------------------*/
1346 yydefault:
1347 yyn = yydefact[yystate];
1348 if (yyn == 0)
1349 goto yyerrlab;
1350 goto yyreduce;
1351
1352
1353 /*-----------------------------.
1354 | yyreduce -- Do a reduction. |
1355 `-----------------------------*/
1356 yyreduce:
1357 /* yyn is the number of a rule to reduce with. */
1358 yylen = yyr2[yyn];
1359
1360 /* If YYLEN is nonzero, implement the default value of the action:
1361 '$$ = $1'.
1362
1363 Otherwise, the following line sets YYVAL to garbage.
1364 This behavior is undocumented and Bison
1365 users should not rely upon it. Assigning to YYVAL
1366 unconditionally makes the parser a bit smaller, and it avoids a
1367 GCC warning that YYVAL may be used uninitialized. */
1368 yyval = yyvsp[1-yylen];
1369
1370
1371 YY_REDUCE_PRINT (yyn);
1372 switch (yyn)
1373 {
1374 case 2:
1375 #line 130 "cond.y" /* yacc.c:1646 */
1376 {
1377 COND_input* cond = (COND_input*) info;
1378 cond->result = (yyvsp[0].bool);
1379 }
1380 #line 1381 "E:/reactosSync3.0_gcc/dll/win32/msi/cond.tab.c" /* yacc.c:1646 */
1381 break;
1382
1383 case 3:
1384 #line 135 "cond.y" /* yacc.c:1646 */
1385 {
1386 COND_input* cond = (COND_input*) info;
1387 cond->result = MSICONDITION_NONE;
1388 }
1389 #line 1390 "E:/reactosSync3.0_gcc/dll/win32/msi/cond.tab.c" /* yacc.c:1646 */
1390 break;
1391
1392 case 4:
1393 #line 143 "cond.y" /* yacc.c:1646 */
1394 {
1395 (yyval.bool) = (yyvsp[0].bool);
1396 }
1397 #line 1398 "E:/reactosSync3.0_gcc/dll/win32/msi/cond.tab.c" /* yacc.c:1646 */
1398 break;
1399
1400 case 5:
1401 #line 147 "cond.y" /* yacc.c:1646 */
1402 {
1403 (yyval.bool) = (yyvsp[-2].bool) || (yyvsp[0].bool);
1404 }
1405 #line 1406 "E:/reactosSync3.0_gcc/dll/win32/msi/cond.tab.c" /* yacc.c:1646 */
1406 break;
1407
1408 case 6:
1409 #line 151 "cond.y" /* yacc.c:1646 */
1410 {
1411 (yyval.bool) = !(yyvsp[-2].bool) || (yyvsp[0].bool);
1412 }
1413 #line 1414 "E:/reactosSync3.0_gcc/dll/win32/msi/cond.tab.c" /* yacc.c:1646 */
1414 break;
1415
1416 case 7:
1417 #line 155 "cond.y" /* yacc.c:1646 */
1418 {
1419 (yyval.bool) = ( (yyvsp[-2].bool) || (yyvsp[0].bool) ) && !( (yyvsp[-2].bool) && (yyvsp[0].bool) );
1420 }
1421 #line 1422 "E:/reactosSync3.0_gcc/dll/win32/msi/cond.tab.c" /* yacc.c:1646 */
1422 break;
1423
1424 case 8:
1425 #line 159 "cond.y" /* yacc.c:1646 */
1426 {
1427 (yyval.bool) = ( (yyvsp[-2].bool) && (yyvsp[0].bool) ) || ( !(yyvsp[-2].bool) && !(yyvsp[0].bool) );
1428 }
1429 #line 1430 "E:/reactosSync3.0_gcc/dll/win32/msi/cond.tab.c" /* yacc.c:1646 */
1430 break;
1431
1432 case 9:
1433 #line 166 "cond.y" /* yacc.c:1646 */
1434 {
1435 (yyval.bool) = (yyvsp[0].bool);
1436 }
1437 #line 1438 "E:/reactosSync3.0_gcc/dll/win32/msi/cond.tab.c" /* yacc.c:1646 */
1438 break;
1439
1440 case 10:
1441 #line 170 "cond.y" /* yacc.c:1646 */
1442 {
1443 (yyval.bool) = (yyvsp[-2].bool) && (yyvsp[0].bool);
1444 }
1445 #line 1446 "E:/reactosSync3.0_gcc/dll/win32/msi/cond.tab.c" /* yacc.c:1646 */
1446 break;
1447
1448 case 11:
1449 #line 177 "cond.y" /* yacc.c:1646 */
1450 {
1451 (yyval.bool) = !(yyvsp[0].bool);
1452 }
1453 #line 1454 "E:/reactosSync3.0_gcc/dll/win32/msi/cond.tab.c" /* yacc.c:1646 */
1454 break;
1455
1456 case 12:
1457 #line 181 "cond.y" /* yacc.c:1646 */
1458 {
1459 if ((yyvsp[0].value).type == VALUE_INTEGER)
1460 (yyval.bool) = (yyvsp[0].value).u.integer ? 1 : 0;
1461 else
1462 (yyval.bool) = (yyvsp[0].value).u.string && (yyvsp[0].value).u.string[0];
1463 value_free( (yyvsp[0].value) );
1464 }
1465 #line 1466 "E:/reactosSync3.0_gcc/dll/win32/msi/cond.tab.c" /* yacc.c:1646 */
1466 break;
1467
1468 case 13:
1469 #line 189 "cond.y" /* yacc.c:1646 */
1470 {
1471 if ((yyvsp[-2].value).type == VALUE_INTEGER && (yyvsp[0].value).type == VALUE_INTEGER)
1472 {
1473 (yyval.bool) = compare_int((yyvsp[-2].value).u.integer, (yyvsp[-1].operator), (yyvsp[0].value).u.integer);
1474 }
1475 else if ((yyvsp[-2].value).type != VALUE_INTEGER && (yyvsp[0].value).type != VALUE_INTEGER)
1476 {
1477 (yyval.bool) = compare_string((yyvsp[-2].value).u.string, (yyvsp[-1].operator), (yyvsp[0].value).u.string,
1478 (yyvsp[-2].value).type == VALUE_SYMBOL || (yyvsp[0].value).type == VALUE_SYMBOL);
1479 }
1480 else if ((yyvsp[-2].value).type == VALUE_LITERAL || (yyvsp[0].value).type == VALUE_LITERAL)
1481 {
1482 (yyval.bool) = FALSE;
1483 }
1484 else if ((yyvsp[-2].value).type == VALUE_SYMBOL) /* symbol operator integer */
1485 {
1486 int num;
1487 if (num_from_prop( (yyvsp[-2].value).u.string, &num ))
1488 (yyval.bool) = compare_int( num, (yyvsp[-1].operator), (yyvsp[0].value).u.integer );
1489 else
1490 (yyval.bool) = ((yyvsp[-1].operator) == COND_NE || (yyvsp[-1].operator) == COND_INE );
1491 }
1492 else /* integer operator symbol */
1493 {
1494 int num;
1495 if (num_from_prop( (yyvsp[0].value).u.string, &num ))
1496 (yyval.bool) = compare_int( (yyvsp[-2].value).u.integer, (yyvsp[-1].operator), num );
1497 else
1498 (yyval.bool) = ((yyvsp[-1].operator) == COND_NE || (yyvsp[-1].operator) == COND_INE );
1499 }
1500
1501 value_free( (yyvsp[-2].value) );
1502 value_free( (yyvsp[0].value) );
1503 }
1504 #line 1505 "E:/reactosSync3.0_gcc/dll/win32/msi/cond.tab.c" /* yacc.c:1646 */
1505 break;
1506
1507 case 14:
1508 #line 224 "cond.y" /* yacc.c:1646 */
1509 {
1510 (yyval.bool) = (yyvsp[-1].bool);
1511 }
1512 #line 1513 "E:/reactosSync3.0_gcc/dll/win32/msi/cond.tab.c" /* yacc.c:1646 */
1513 break;
1514
1515 case 15:
1516 #line 231 "cond.y" /* yacc.c:1646 */
1517 { (yyval.operator) = COND_EQ; }
1518 #line 1519 "E:/reactosSync3.0_gcc/dll/win32/msi/cond.tab.c" /* yacc.c:1646 */
1519 break;
1520
1521 case 16:
1522 #line 232 "cond.y" /* yacc.c:1646 */
1523 { (yyval.operator) = COND_NE; }
1524 #line 1525 "E:/reactosSync3.0_gcc/dll/win32/msi/cond.tab.c" /* yacc.c:1646 */
1525 break;
1526
1527 case 17:
1528 #line 233 "cond.y" /* yacc.c:1646 */
1529 { (yyval.operator) = COND_LT; }
1530 #line 1531 "E:/reactosSync3.0_gcc/dll/win32/msi/cond.tab.c" /* yacc.c:1646 */
1531 break;
1532
1533 case 18:
1534 #line 234 "cond.y" /* yacc.c:1646 */
1535 { (yyval.operator) = COND_GT; }
1536 #line 1537 "E:/reactosSync3.0_gcc/dll/win32/msi/cond.tab.c" /* yacc.c:1646 */
1537 break;
1538
1539 case 19:
1540 #line 235 "cond.y" /* yacc.c:1646 */
1541 { (yyval.operator) = COND_LE; }
1542 #line 1543 "E:/reactosSync3.0_gcc/dll/win32/msi/cond.tab.c" /* yacc.c:1646 */
1543 break;
1544
1545 case 20:
1546 #line 236 "cond.y" /* yacc.c:1646 */
1547 { (yyval.operator) = COND_GE; }
1548 #line 1549 "E:/reactosSync3.0_gcc/dll/win32/msi/cond.tab.c" /* yacc.c:1646 */
1549 break;
1550
1551 case 21:
1552 #line 237 "cond.y" /* yacc.c:1646 */
1553 { (yyval.operator) = COND_SS; }
1554 #line 1555 "E:/reactosSync3.0_gcc/dll/win32/msi/cond.tab.c" /* yacc.c:1646 */
1555 break;
1556
1557 case 22:
1558 #line 238 "cond.y" /* yacc.c:1646 */
1559 { (yyval.operator) = COND_IEQ; }
1560 #line 1561 "E:/reactosSync3.0_gcc/dll/win32/msi/cond.tab.c" /* yacc.c:1646 */
1561 break;
1562
1563 case 23:
1564 #line 239 "cond.y" /* yacc.c:1646 */
1565 { (yyval.operator) = COND_INE; }
1566 #line 1567 "E:/reactosSync3.0_gcc/dll/win32/msi/cond.tab.c" /* yacc.c:1646 */
1567 break;
1568
1569 case 24:
1570 #line 240 "cond.y" /* yacc.c:1646 */
1571 { (yyval.operator) = COND_ILT; }
1572 #line 1573 "E:/reactosSync3.0_gcc/dll/win32/msi/cond.tab.c" /* yacc.c:1646 */
1573 break;
1574
1575 case 25:
1576 #line 241 "cond.y" /* yacc.c:1646 */
1577 { (yyval.operator) = COND_IGT; }
1578 #line 1579 "E:/reactosSync3.0_gcc/dll/win32/msi/cond.tab.c" /* yacc.c:1646 */
1579 break;
1580
1581 case 26:
1582 #line 242 "cond.y" /* yacc.c:1646 */
1583 { (yyval.operator) = COND_ILE; }
1584 #line 1585 "E:/reactosSync3.0_gcc/dll/win32/msi/cond.tab.c" /* yacc.c:1646 */
1585 break;
1586
1587 case 27:
1588 #line 243 "cond.y" /* yacc.c:1646 */
1589 { (yyval.operator) = COND_IGE; }
1590 #line 1591 "E:/reactosSync3.0_gcc/dll/win32/msi/cond.tab.c" /* yacc.c:1646 */
1591 break;
1592
1593 case 28:
1594 #line 244 "cond.y" /* yacc.c:1646 */
1595 { (yyval.operator) = COND_ISS; }
1596 #line 1597 "E:/reactosSync3.0_gcc/dll/win32/msi/cond.tab.c" /* yacc.c:1646 */
1597 break;
1598
1599 case 29:
1600 #line 245 "cond.y" /* yacc.c:1646 */
1601 { (yyval.operator) = COND_LHS; }
1602 #line 1603 "E:/reactosSync3.0_gcc/dll/win32/msi/cond.tab.c" /* yacc.c:1646 */
1603 break;
1604
1605 case 30:
1606 #line 246 "cond.y" /* yacc.c:1646 */
1607 { (yyval.operator) = COND_RHS; }
1608 #line 1609 "E:/reactosSync3.0_gcc/dll/win32/msi/cond.tab.c" /* yacc.c:1646 */
1609 break;
1610
1611 case 31:
1612 #line 247 "cond.y" /* yacc.c:1646 */
1613 { (yyval.operator) = COND_ILHS; }
1614 #line 1615 "E:/reactosSync3.0_gcc/dll/win32/msi/cond.tab.c" /* yacc.c:1646 */
1615 break;
1616
1617 case 32:
1618 #line 248 "cond.y" /* yacc.c:1646 */
1619 { (yyval.operator) = COND_IRHS; }
1620 #line 1621 "E:/reactosSync3.0_gcc/dll/win32/msi/cond.tab.c" /* yacc.c:1646 */
1621 break;
1622
1623 case 33:
1624 #line 253 "cond.y" /* yacc.c:1646 */
1625 {
1626 COND_input* cond = (COND_input*) info;
1627 UINT len;
1628
1629 (yyval.value).type = VALUE_SYMBOL;
1630 (yyval.value).u.string = msi_dup_property( cond->package->db, (yyvsp[0].identifier) );
1631 if ((yyval.value).u.string)
1632 {
1633 len = (lstrlenW((yyval.value).u.string) + 1) * sizeof (WCHAR);
1634 (yyval.value).u.string = cond_track_mem( cond, (yyval.value).u.string, len );
1635 }
1636 cond_free( (yyvsp[0].identifier) );
1637 }
1638 #line 1639 "E:/reactosSync3.0_gcc/dll/win32/msi/cond.tab.c" /* yacc.c:1646 */
1639 break;
1640
1641 case 34:
1642 #line 267 "cond.y" /* yacc.c:1646 */
1643 {
1644 COND_input* cond = (COND_input*) info;
1645 UINT len = GetEnvironmentVariableW( (yyvsp[0].identifier), NULL, 0 );
1646 (yyval.value).type = VALUE_SYMBOL;
1647 (yyval.value).u.string = NULL;
1648 if (len++)
1649 {
1650 (yyval.value).u.string = cond_alloc( cond, len*sizeof (WCHAR) );
1651 if( !(yyval.value).u.string )
1652 YYABORT;
1653 GetEnvironmentVariableW( (yyvsp[0].identifier), (yyval.value).u.string, len );
1654 }
1655 cond_free( (yyvsp[0].identifier) );
1656 }
1657 #line 1658 "E:/reactosSync3.0_gcc/dll/win32/msi/cond.tab.c" /* yacc.c:1646 */
1658 break;
1659
1660 case 35:
1661 #line 282 "cond.y" /* yacc.c:1646 */
1662 {
1663 COND_input* cond = (COND_input*) info;
1664 (yyval.value).type = VALUE_LITERAL;
1665 (yyval.value).u.string = COND_GetLiteral( cond, &(yyvsp[0].str) );
1666 if( !(yyval.value).u.string )
1667 YYABORT;
1668 }
1669 #line 1670 "E:/reactosSync3.0_gcc/dll/win32/msi/cond.tab.c" /* yacc.c:1646 */
1670 break;
1671
1672 case 36:
1673 #line 290 "cond.y" /* yacc.c:1646 */
1674 {
1675 COND_input* cond = (COND_input*) info;
1676 LPWSTR szNum = COND_GetString( cond, &(yyvsp[0].str) );
1677 if( !szNum )
1678 YYABORT;
1679 (yyval.value).type = VALUE_INTEGER;
1680 (yyval.value).u.integer = atoiW( szNum );
1681 cond_free( szNum );
1682 }
1683 #line 1684 "E:/reactosSync3.0_gcc/dll/win32/msi/cond.tab.c" /* yacc.c:1646 */
1684 break;
1685
1686 case 37:
1687 #line 300 "cond.y" /* yacc.c:1646 */
1688 {
1689 COND_input* cond = (COND_input*) info;
1690 INSTALLSTATE install = INSTALLSTATE_UNKNOWN, action = INSTALLSTATE_UNKNOWN;
1691
1692 if(MSI_GetComponentStateW(cond->package, (yyvsp[0].identifier), &install, &action ) != ERROR_SUCCESS)
1693 {
1694 (yyval.value).type = VALUE_LITERAL;
1695 (yyval.value).u.string = NULL;
1696 }
1697 else
1698 {
1699 (yyval.value).type = VALUE_INTEGER;
1700 (yyval.value).u.integer = action;
1701 }
1702 cond_free( (yyvsp[0].identifier) );
1703 }
1704 #line 1705 "E:/reactosSync3.0_gcc/dll/win32/msi/cond.tab.c" /* yacc.c:1646 */
1705 break;
1706
1707 case 38:
1708 #line 317 "cond.y" /* yacc.c:1646 */
1709 {
1710 COND_input* cond = (COND_input*) info;
1711 INSTALLSTATE install = INSTALLSTATE_UNKNOWN, action = INSTALLSTATE_UNKNOWN;
1712
1713 if(MSI_GetComponentStateW(cond->package, (yyvsp[0].identifier), &install, &action ) != ERROR_SUCCESS)
1714 {
1715 (yyval.value).type = VALUE_LITERAL;
1716 (yyval.value).u.string = NULL;
1717 }
1718 else
1719 {
1720 (yyval.value).type = VALUE_INTEGER;
1721 (yyval.value).u.integer = install;
1722 }
1723 cond_free( (yyvsp[0].identifier) );
1724 }
1725 #line 1726 "E:/reactosSync3.0_gcc/dll/win32/msi/cond.tab.c" /* yacc.c:1646 */
1726 break;
1727
1728 case 39:
1729 #line 334 "cond.y" /* yacc.c:1646 */
1730 {
1731 COND_input* cond = (COND_input*) info;
1732 INSTALLSTATE install, action;
1733
1734 if (MSI_GetFeatureStateW(cond->package, (yyvsp[0].identifier), &install, &action ) != ERROR_SUCCESS)
1735 {
1736 (yyval.value).type = VALUE_LITERAL;
1737 (yyval.value).u.string = NULL;
1738 }
1739 else
1740 {
1741 (yyval.value).type = VALUE_INTEGER;
1742 (yyval.value).u.integer = action;
1743 }
1744 cond_free( (yyvsp[0].identifier) );
1745 }
1746 #line 1747 "E:/reactosSync3.0_gcc/dll/win32/msi/cond.tab.c" /* yacc.c:1646 */
1747 break;
1748
1749 case 40:
1750 #line 351 "cond.y" /* yacc.c:1646 */
1751 {
1752 COND_input* cond = (COND_input*) info;
1753 INSTALLSTATE install = INSTALLSTATE_UNKNOWN, action = INSTALLSTATE_UNKNOWN;
1754
1755 if(MSI_GetFeatureStateW(cond->package, (yyvsp[0].identifier), &install, &action ) != ERROR_SUCCESS)
1756 {
1757 (yyval.value).type = VALUE_LITERAL;
1758 (yyval.value).u.string = NULL;
1759 }
1760 else
1761 {
1762 (yyval.value).type = VALUE_INTEGER;
1763 (yyval.value).u.integer = install;
1764 }
1765 cond_free( (yyvsp[0].identifier) );
1766 }
1767 #line 1768 "E:/reactosSync3.0_gcc/dll/win32/msi/cond.tab.c" /* yacc.c:1646 */
1768 break;
1769
1770 case 41:
1771 #line 371 "cond.y" /* yacc.c:1646 */
1772 {
1773 COND_input* cond = (COND_input*) info;
1774 (yyval.identifier) = COND_GetString( cond, &(yyvsp[0].str) );
1775 if( !(yyval.identifier) )
1776 YYABORT;
1777 }
1778 #line 1779 "E:/reactosSync3.0_gcc/dll/win32/msi/cond.tab.c" /* yacc.c:1646 */
1779 break;
1780
1781
1782 #line 1783 "E:/reactosSync3.0_gcc/dll/win32/msi/cond.tab.c" /* yacc.c:1646 */
1783 default: break;
1784 }
1785 /* User semantic actions sometimes alter yychar, and that requires
1786 that yytoken be updated with the new translation. We take the
1787 approach of translating immediately before every use of yytoken.
1788 One alternative is translating here after every semantic action,
1789 but that translation would be missed if the semantic action invokes
1790 YYABORT, YYACCEPT, or YYERROR immediately after altering yychar or
1791 if it invokes YYBACKUP. In the case of YYABORT or YYACCEPT, an
1792 incorrect destructor might then be invoked immediately. In the
1793 case of YYERROR or YYBACKUP, subsequent parser actions might lead
1794 to an incorrect destructor call or verbose syntax error message
1795 before the lookahead is translated. */
1796 YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc);
1797
1798 YYPOPSTACK (yylen);
1799 yylen = 0;
1800 YY_STACK_PRINT (yyss, yyssp);
1801
1802 *++yyvsp = yyval;
1803
1804 /* Now 'shift' the result of the reduction. Determine what state
1805 that goes to, based on the state we popped back to and the rule
1806 number reduced by. */
1807
1808 yyn = yyr1[yyn];
1809
1810 yystate = yypgoto[yyn - YYNTOKENS] + *yyssp;
1811 if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp)
1812 yystate = yytable[yystate];
1813 else
1814 yystate = yydefgoto[yyn - YYNTOKENS];
1815
1816 goto yynewstate;
1817
1818
1819 /*--------------------------------------.
1820 | yyerrlab -- here on detecting error. |
1821 `--------------------------------------*/
1822 yyerrlab:
1823 /* Make sure we have latest lookahead translation. See comments at
1824 user semantic actions for why this is necessary. */
1825 yytoken = yychar == YYEMPTY ? YYEMPTY : YYTRANSLATE (yychar);
1826
1827 /* If not already recovering from an error, report this error. */
1828 if (!yyerrstatus)
1829 {
1830 ++yynerrs;
1831 #if ! YYERROR_VERBOSE
1832 yyerror (info, YY_("syntax error"));
1833 #else
1834 # define YYSYNTAX_ERROR yysyntax_error (&yymsg_alloc, &yymsg, \
1835 yyssp, yytoken)
1836 {
1837 char const *yymsgp = YY_("syntax error");
1838 int yysyntax_error_status;
1839 yysyntax_error_status = YYSYNTAX_ERROR;
1840 if (yysyntax_error_status == 0)
1841 yymsgp = yymsg;
1842 else if (yysyntax_error_status == 1)
1843 {
1844 if (yymsg != yymsgbuf)
1845 YYSTACK_FREE (yymsg);
1846 yymsg = (char *) YYSTACK_ALLOC (yymsg_alloc);
1847 if (!yymsg)
1848 {
1849 yymsg = yymsgbuf;
1850 yymsg_alloc = sizeof yymsgbuf;
1851 yysyntax_error_status = 2;
1852 }
1853 else
1854 {
1855 yysyntax_error_status = YYSYNTAX_ERROR;
1856 yymsgp = yymsg;
1857 }
1858 }
1859 yyerror (info, yymsgp);
1860 if (yysyntax_error_status == 2)
1861 goto yyexhaustedlab;
1862 }
1863 # undef YYSYNTAX_ERROR
1864 #endif
1865 }
1866
1867
1868
1869 if (yyerrstatus == 3)
1870 {
1871 /* If just tried and failed to reuse lookahead token after an
1872 error, discard it. */
1873
1874 if (yychar <= YYEOF)
1875 {
1876 /* Return failure if at end of input. */
1877 if (yychar == YYEOF)
1878 YYABORT;
1879 }
1880 else
1881 {
1882 yydestruct ("Error: discarding",
1883 yytoken, &yylval, info);
1884 yychar = YYEMPTY;
1885 }
1886 }
1887
1888 /* Else will try to reuse lookahead token after shifting the error
1889 token. */
1890 goto yyerrlab1;
1891
1892
1893 /*---------------------------------------------------.
1894 | yyerrorlab -- error raised explicitly by YYERROR. |
1895 `---------------------------------------------------*/
1896 yyerrorlab:
1897
1898 /* Pacify compilers like GCC when the user code never invokes
1899 YYERROR and the label yyerrorlab therefore never appears in user
1900 code. */
1901 if (/*CONSTCOND*/ 0)
1902 goto yyerrorlab;
1903
1904 /* Do not reclaim the symbols of the rule whose action triggered
1905 this YYERROR. */
1906 YYPOPSTACK (yylen);
1907 yylen = 0;
1908 YY_STACK_PRINT (yyss, yyssp);
1909 yystate = *yyssp;
1910 goto yyerrlab1;
1911
1912
1913 /*-------------------------------------------------------------.
1914 | yyerrlab1 -- common code for both syntax error and YYERROR. |
1915 `-------------------------------------------------------------*/
1916 yyerrlab1:
1917 yyerrstatus = 3; /* Each real token shifted decrements this. */
1918
1919 for (;;)
1920 {
1921 yyn = yypact[yystate];
1922 if (!yypact_value_is_default (yyn))
1923 {
1924 yyn += YYTERROR;
1925 if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR)
1926 {
1927 yyn = yytable[yyn];
1928 if (0 < yyn)
1929 break;
1930 }
1931 }
1932
1933 /* Pop the current state because it cannot handle the error token. */
1934 if (yyssp == yyss)
1935 YYABORT;
1936
1937
1938 yydestruct ("Error: popping",
1939 yystos[yystate], yyvsp, info);
1940 YYPOPSTACK (1);
1941 yystate = *yyssp;
1942 YY_STACK_PRINT (yyss, yyssp);
1943 }
1944
1945 YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
1946 *++yyvsp = yylval;
1947 YY_IGNORE_MAYBE_UNINITIALIZED_END
1948
1949
1950 /* Shift the error token. */
1951 YY_SYMBOL_PRINT ("Shifting", yystos[yyn], yyvsp, yylsp);
1952
1953 yystate = yyn;
1954 goto yynewstate;
1955
1956
1957 /*-------------------------------------.
1958 | yyacceptlab -- YYACCEPT comes here. |
1959 `-------------------------------------*/
1960 yyacceptlab:
1961 yyresult = 0;
1962 goto yyreturn;
1963
1964 /*-----------------------------------.
1965 | yyabortlab -- YYABORT comes here. |
1966 `-----------------------------------*/
1967 yyabortlab:
1968 yyresult = 1;
1969 goto yyreturn;
1970
1971 #if !defined yyoverflow || YYERROR_VERBOSE
1972 /*-------------------------------------------------.
1973 | yyexhaustedlab -- memory exhaustion comes here. |
1974 `-------------------------------------------------*/
1975 yyexhaustedlab:
1976 yyerror (info, YY_("memory exhausted"));
1977 yyresult = 2;
1978 /* Fall through. */
1979 #endif
1980
1981 yyreturn:
1982 if (yychar != YYEMPTY)
1983 {
1984 /* Make sure we have latest lookahead translation. See comments at
1985 user semantic actions for why this is necessary. */
1986 yytoken = YYTRANSLATE (yychar);
1987 yydestruct ("Cleanup: discarding lookahead",
1988 yytoken, &yylval, info);
1989 }
1990 /* Do not reclaim the symbols of the rule whose action triggered
1991 this YYABORT or YYACCEPT. */
1992 YYPOPSTACK (yylen);
1993 YY_STACK_PRINT (yyss, yyssp);
1994 while (yyssp != yyss)
1995 {
1996 yydestruct ("Cleanup: popping",
1997 yystos[*yyssp], yyvsp, info);
1998 YYPOPSTACK (1);
1999 }
2000 #ifndef yyoverflow
2001 if (yyss != yyssa)
2002 YYSTACK_FREE (yyss);
2003 #endif
2004 #if YYERROR_VERBOSE
2005 if (yymsg != yymsgbuf)
2006 YYSTACK_FREE (yymsg);
2007 #endif
2008 return yyresult;
2009 }
2010 #line 379 "cond.y" /* yacc.c:1906 */
2011
2012
2013
2014 static int COND_IsAlpha( WCHAR x )
2015 {
2016 return( ( ( x >= 'A' ) && ( x <= 'Z' ) ) ||
2017 ( ( x >= 'a' ) && ( x <= 'z' ) ) ||
2018 ( ( x == '_' ) ) );
2019 }
2020
2021 static int COND_IsNumber( WCHAR x )
2022 {
2023 return( (( x >= '0' ) && ( x <= '9' )) || (x =='-') || (x =='.') );
2024 }
2025
2026 static WCHAR *strstriW( const WCHAR *str, const WCHAR *sub )
2027 {
2028 LPWSTR strlower, sublower, r;
2029 strlower = CharLowerW( strdupW( str ) );
2030 sublower = CharLowerW( strdupW( sub ) );
2031 r = strstrW( strlower, sublower );
2032 if (r)
2033 r = (LPWSTR)str + (r - strlower);
2034 msi_free( strlower );
2035 msi_free( sublower );
2036 return r;
2037 }
2038
2039 static BOOL str_is_number( LPCWSTR str )
2040 {
2041 int i;
2042
2043 if (!*str)
2044 return FALSE;
2045
2046 for (i = 0; i < lstrlenW( str ); i++)
2047 if (!isdigitW(str[i]))
2048 return FALSE;
2049
2050 return TRUE;
2051 }
2052
2053 static INT compare_substring( LPCWSTR a, INT operator, LPCWSTR b )
2054 {
2055 int lhs, rhs;
2056
2057 /* substring operators return 0 if LHS is missing */
2058 if (!a || !*a)
2059 return 0;
2060
2061 /* substring operators return 1 if RHS is missing */
2062 if (!b || !*b)
2063 return 1;
2064
2065 /* if both strings contain only numbers, use integer comparison */
2066 lhs = atoiW(a);
2067 rhs = atoiW(b);
2068 if (str_is_number(a) && str_is_number(b))
2069 return compare_int( lhs, operator, rhs );
2070
2071 switch (operator)
2072 {
2073 case COND_SS:
2074 return strstrW( a, b ) != 0;
2075 case COND_ISS:
2076 return strstriW( a, b ) != 0;
2077 case COND_LHS:
2078 {
2079 int l = strlenW( a );
2080 int r = strlenW( b );
2081 if (r > l) return 0;
2082 return !strncmpW( a, b, r );
2083 }
2084 case COND_RHS:
2085 {
2086 int l = strlenW( a );
2087 int r = strlenW( b );
2088 if (r > l) return 0;
2089 return !strncmpW( a + (l - r), b, r );
2090 }
2091 case COND_ILHS:
2092 {
2093 int l = strlenW( a );
2094 int r = strlenW( b );
2095 if (r > l) return 0;
2096 return !strncmpiW( a, b, r );
2097 }
2098 case COND_IRHS:
2099 {
2100 int l = strlenW( a );
2101 int r = strlenW( b );
2102 if (r > l) return 0;
2103 return !strncmpiW( a + (l - r), b, r );
2104 }
2105 default:
2106 ERR("invalid substring operator\n");
2107 return 0;
2108 }
2109 return 0;
2110 }
2111
2112 static INT compare_string( LPCWSTR a, INT operator, LPCWSTR b, BOOL convert )
2113 {
2114 if (operator >= COND_SS && operator <= COND_RHS)
2115 return compare_substring( a, operator, b );
2116
2117 /* null and empty string are equivalent */
2118 if (!a) a = szEmpty;
2119 if (!b) b = szEmpty;
2120
2121 if (convert && str_is_number(a) && str_is_number(b))
2122 return compare_int( atoiW(a), operator, atoiW(b) );
2123
2124 /* a or b may be NULL */
2125 switch (operator)
2126 {
2127 case COND_LT:
2128 return strcmpW( a, b ) < 0;
2129 case COND_GT:
2130 return strcmpW( a, b ) > 0;
2131 case COND_EQ:
2132 return strcmpW( a, b ) == 0;
2133 case COND_NE:
2134 return strcmpW( a, b ) != 0;
2135 case COND_GE:
2136 return strcmpW( a, b ) >= 0;
2137 case COND_LE:
2138 return strcmpW( a, b ) <= 0;
2139 case COND_ILT:
2140 return strcmpiW( a, b ) < 0;
2141 case COND_IGT:
2142 return strcmpiW( a, b ) > 0;
2143 case COND_IEQ:
2144 return strcmpiW( a, b ) == 0;
2145 case COND_INE:
2146 return strcmpiW( a, b ) != 0;
2147 case COND_IGE:
2148 return strcmpiW( a, b ) >= 0;
2149 case COND_ILE:
2150 return strcmpiW( a, b ) <= 0;
2151 default:
2152 ERR("invalid string operator\n");
2153 return 0;
2154 }
2155 return 0;
2156 }
2157
2158
2159 static INT compare_int( INT a, INT operator, INT b )
2160 {
2161 switch (operator)
2162 {
2163 case COND_LT:
2164 case COND_ILT:
2165 return a < b;
2166 case COND_GT:
2167 case COND_IGT:
2168 return a > b;
2169 case COND_EQ:
2170 case COND_IEQ:
2171 return a == b;
2172 case COND_NE:
2173 case COND_INE:
2174 return a != b;
2175 case COND_GE:
2176 case COND_IGE:
2177 return a >= b;
2178 case COND_LE:
2179 case COND_ILE:
2180 return a <= b;
2181 case COND_SS:
2182 case COND_ISS:
2183 return ( a & b ) ? 1 : 0;
2184 case COND_RHS:
2185 return ( ( a & 0xffff ) == b ) ? 1 : 0;
2186 case COND_LHS:
2187 return ( ( (a>>16) & 0xffff ) == b ) ? 1 : 0;
2188 default:
2189 ERR("invalid integer operator\n");
2190 return 0;
2191 }
2192 return 0;
2193 }
2194
2195
2196 static int COND_IsIdent( WCHAR x )
2197 {
2198 return( COND_IsAlpha( x ) || COND_IsNumber( x ) || ( x == '_' )
2199 || ( x == '#' ) || (x == '.') );
2200 }
2201
2202 static int COND_GetOperator( COND_input *cond )
2203 {
2204 static const struct {
2205 const WCHAR str[4];
2206 int id;
2207 } table[] = {
2208 { {'~','<','=',0}, COND_ILE },
2209 { {'~','>','<',0}, COND_ISS },
2210 { {'~','>','>',0}, COND_IRHS },
2211 { {'~','<','>',0}, COND_INE },
2212 { {'~','>','=',0}, COND_IGE },
2213 { {'~','<','<',0}, COND_ILHS },
2214 { {'~','=',0}, COND_IEQ },
2215 { {'~','<',0}, COND_ILT },
2216 { {'~','>',0}, COND_IGT },
2217 { {'>','=',0}, COND_GE },
2218 { {'>','<',0}, COND_SS },
2219 { {'<','<',0}, COND_LHS },
2220 { {'<','>',0}, COND_NE },
2221 { {'<','=',0}, COND_LE },
2222 { {'>','>',0}, COND_RHS },
2223 { {'>',0}, COND_GT },
2224 { {'<',0}, COND_LT },
2225 { {0}, 0 }
2226 };
2227 LPCWSTR p = &cond->str[cond->n];
2228 int i = 0, len;
2229
2230 while ( 1 )
2231 {
2232 len = lstrlenW( table[i].str );
2233 if ( !len || 0 == strncmpW( table[i].str, p, len ) )
2234 break;
2235 i++;
2236 }
2237 cond->n += len;
2238 return table[i].id;
2239 }
2240
2241 static int COND_GetOne( struct cond_str *str, COND_input *cond )
2242 {
2243 int rc, len = 1;
2244 WCHAR ch;
2245
2246 str->data = &cond->str[cond->n];
2247
2248 ch = str->data[0];
2249
2250 switch( ch )
2251 {
2252 case 0: return 0;
2253 case '(': rc = COND_LPAR; break;
2254 case ')': rc = COND_RPAR; break;
2255 case '&': rc = COND_AMPER; break;
2256 case '!': rc = COND_EXCLAM; break;
2257 case '$': rc = COND_DOLLARS; break;
2258 case '?': rc = COND_QUESTION; break;
2259 case '%': rc = COND_PERCENT; break;
2260 case ' ': rc = COND_SPACE; break;
2261 case '=': rc = COND_EQ; break;
2262
2263 case '~':
2264 case '<':
2265 case '>':
2266 rc = COND_GetOperator( cond );
2267 if (!rc)
2268 rc = COND_ERROR;
2269 return rc;
2270 default:
2271 rc = 0;
2272 }
2273
2274 if ( rc )
2275 {
2276 cond->n += len;
2277 return rc;
2278 }
2279
2280 if (ch == '"' )
2281 {
2282 LPCWSTR p = strchrW( str->data + 1, '"' );
2283 if (!p) return COND_ERROR;
2284 len = p - str->data + 1;
2285 rc = COND_LITER;
2286 }
2287 else if( COND_IsAlpha( ch ) )
2288 {
2289 static const WCHAR szNot[] = {'N','O','T',0};
2290 static const WCHAR szAnd[] = {'A','N','D',0};
2291 static const WCHAR szXor[] = {'X','O','R',0};
2292 static const WCHAR szEqv[] = {'E','Q','V',0};
2293 static const WCHAR szImp[] = {'I','M','P',0};
2294 static const WCHAR szOr[] = {'O','R',0};
2295
2296 while( COND_IsIdent( str->data[len] ) )
2297 len++;
2298 rc = COND_IDENT;
2299
2300 if ( len == 3 )
2301 {
2302 if ( !strncmpiW( str->data, szNot, len ) )
2303 rc = COND_NOT;
2304 else if( !strncmpiW( str->data, szAnd, len ) )
2305 rc = COND_AND;
2306 else if( !strncmpiW( str->data, szXor, len ) )
2307 rc = COND_XOR;
2308 else if( !strncmpiW( str->data, szEqv, len ) )
2309 rc = COND_EQV;
2310 else if( !strncmpiW( str->data, szImp, len ) )
2311 rc = COND_IMP;
2312 }
2313 else if( (len == 2) && !strncmpiW( str->data, szOr, len ) )
2314 rc = COND_OR;
2315 }
2316 else if( COND_IsNumber( ch ) )
2317 {
2318 while( COND_IsNumber( str->data[len] ) )
2319 len++;
2320 rc = COND_NUMBER;
2321 }
2322 else
2323 {
2324 ERR("Got unknown character %c(%x)\n",ch,ch);
2325 return COND_ERROR;
2326 }
2327
2328 cond->n += len;
2329 str->len = len;
2330
2331 return rc;
2332 }
2333
2334 static int cond_lex( void *COND_lval, COND_input *cond )
2335 {
2336 int rc;
2337 struct cond_str *str = COND_lval;
2338
2339 do {
2340 rc = COND_GetOne( str, cond );
2341 } while (rc == COND_SPACE);
2342
2343 return rc;
2344 }
2345
2346 static LPWSTR COND_GetString( COND_input *cond, const struct cond_str *str )
2347 {
2348 LPWSTR ret;
2349
2350 ret = cond_alloc( cond, (str->len+1) * sizeof (WCHAR) );
2351 if( ret )
2352 {
2353 memcpy( ret, str->data, str->len * sizeof(WCHAR));
2354 ret[str->len]=0;
2355 }
2356 TRACE("Got identifier %s\n",debugstr_w(ret));
2357 return ret;
2358 }
2359
2360 static LPWSTR COND_GetLiteral( COND_input *cond, const struct cond_str *str )
2361 {
2362 LPWSTR ret;
2363
2364 ret = cond_alloc( cond, (str->len-1) * sizeof (WCHAR) );
2365 if( ret )
2366 {
2367 memcpy( ret, str->data+1, (str->len-2) * sizeof(WCHAR) );
2368 ret[str->len - 2]=0;
2369 }
2370 TRACE("Got literal %s\n",debugstr_w(ret));
2371 return ret;
2372 }
2373
2374 static void *cond_alloc( COND_input *cond, unsigned int sz )
2375 {
2376 struct list *mem;
2377
2378 mem = msi_alloc( sizeof (struct list) + sz );
2379 if( !mem )
2380 return NULL;
2381
2382 list_add_head( &(cond->mem), mem );
2383 return mem + 1;
2384 }
2385
2386 static void *cond_track_mem( COND_input *cond, void *ptr, unsigned int sz )
2387 {
2388 void *new_ptr;
2389
2390 if( !ptr )
2391 return ptr;
2392
2393 new_ptr = cond_alloc( cond, sz );
2394 if( !new_ptr )
2395 {
2396 msi_free( ptr );
2397 return NULL;
2398 }
2399
2400 memcpy( new_ptr, ptr, sz );
2401 msi_free( ptr );
2402 return new_ptr;
2403 }
2404
2405 static void cond_free( void *ptr )
2406 {
2407 struct list *mem = (struct list *)ptr - 1;
2408
2409 if( ptr )
2410 {
2411 list_remove( mem );
2412 msi_free( mem );
2413 }
2414 }
2415
2416 static int cond_error( COND_input *info, const char *str )
2417 {
2418 TRACE("%s\n", str );
2419 return 0;
2420 }
2421
2422 MSICONDITION MSI_EvaluateConditionW( MSIPACKAGE *package, LPCWSTR szCondition )
2423 {
2424 COND_input cond;
2425 MSICONDITION r;
2426 struct list *mem, *safety;
2427
2428 TRACE("%s\n", debugstr_w( szCondition ) );
2429
2430 if (szCondition == NULL) return MSICONDITION_NONE;
2431
2432 cond.package = package;
2433 cond.str = szCondition;
2434 cond.n = 0;
2435 cond.result = MSICONDITION_ERROR;
2436
2437 list_init( &cond.mem );
2438
2439 if ( !cond_parse( &cond ) )
2440 r = cond.result;
2441 else
2442 r = MSICONDITION_ERROR;
2443
2444 LIST_FOR_EACH_SAFE( mem, safety, &cond.mem )
2445 {
2446 /* The tracked memory lives directly after the list struct */
2447 void *ptr = mem + 1;
2448 if ( r != MSICONDITION_ERROR )
2449 WARN( "condition parser failed to free up some memory: %p\n", ptr );
2450 cond_free( ptr );
2451 }
2452
2453 TRACE("%i <- %s\n", r, debugstr_w(szCondition));
2454 return r;
2455 }
2456
2457 MSICONDITION WINAPI MsiEvaluateConditionW( MSIHANDLE hInstall, LPCWSTR szCondition )
2458 {
2459 MSIPACKAGE *package;
2460 UINT ret;
2461
2462 package = msihandle2msiinfo( hInstall, MSIHANDLETYPE_PACKAGE);
2463 if( !package )
2464 {
2465 HRESULT hr;
2466 BSTR condition;
2467 IWineMsiRemotePackage *remote_package;
2468
2469 remote_package = (IWineMsiRemotePackage *)msi_get_remote( hInstall );
2470 if (!remote_package)
2471 return MSICONDITION_ERROR;
2472
2473 condition = SysAllocString( szCondition );
2474 if (!condition)
2475 {
2476 IWineMsiRemotePackage_Release( remote_package );
2477 return ERROR_OUTOFMEMORY;
2478 }
2479
2480 hr = IWineMsiRemotePackage_EvaluateCondition( remote_package, condition );
2481
2482 SysFreeString( condition );
2483 IWineMsiRemotePackage_Release( remote_package );
2484
2485 if (FAILED(hr))
2486 {
2487 if (HRESULT_FACILITY(hr) == FACILITY_WIN32)
2488 return HRESULT_CODE(hr);
2489
2490 return ERROR_FUNCTION_FAILED;
2491 }
2492
2493 return ERROR_SUCCESS;
2494 }
2495
2496 ret = MSI_EvaluateConditionW( package, szCondition );
2497 msiobj_release( &package->hdr );
2498 return ret;
2499 }
2500
2501 MSICONDITION WINAPI MsiEvaluateConditionA( MSIHANDLE hInstall, LPCSTR szCondition )
2502 {
2503 LPWSTR szwCond = NULL;
2504 MSICONDITION r;
2505
2506 szwCond = strdupAtoW( szCondition );
2507 if( szCondition && !szwCond )
2508 return MSICONDITION_ERROR;
2509
2510 r = MsiEvaluateConditionW( hInstall, szwCond );
2511 msi_free( szwCond );
2512 return r;
2513 }