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