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