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