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