Set license using %license
[platform/upstream/libical.git] / src / libicalss / icalssyacc.c
1 /* A Bison parser, made by GNU Bison 2.3.  */
2
3 /* Skeleton implementation for Bison's Yacc-like parsers in C
4
5    Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006
6    Free Software Foundation, Inc.
7
8    This program is free software; you can redistribute it and/or modify
9    it under the terms of the GNU General Public License as published by
10    the Free Software Foundation; either version 2, or (at your option)
11    any later version.
12
13    This program is distributed in the hope that it will be useful,
14    but WITHOUT ANY WARRANTY; without even the implied warranty of
15    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16    GNU General Public License for more details.
17
18    You should have received a copy of the GNU General Public License
19    along with this program; if not, write to the Free Software
20    Foundation, Inc., 51 Franklin Street, Fifth Floor,
21    Boston, MA 02110-1301, USA.  */
22
23 /* As a special exception, you may create a larger work that contains
24    part or all of the Bison parser skeleton and distribute that work
25    under terms of your choice, so long as that work isn't itself a
26    parser generator using the skeleton or a modified version thereof
27    as a parser skeleton.  Alternatively, if you modify or redistribute
28    the parser skeleton itself, you may (at your option) remove this
29    special exception, which will cause the skeleton and the resulting
30    Bison output files to be licensed under the GNU General Public
31    License without this special exception.
32
33    This special exception was added by the Free Software Foundation in
34    version 2.2 of Bison.  */
35
36 /* C LALR(1) parser skeleton written by Richard Stallman, by
37    simplifying the original so-called "semantic" parser.  */
38
39 /* All symbols defined below should begin with yy or YY, to avoid
40    infringing on user name space.  This should be done even for local
41    variables, as they might otherwise be expanded by user macros.
42    There are some unavoidable exceptions within include files to
43    define necessary library symbols; they are noted "INFRINGES ON
44    USER NAME SPACE" below.  */
45
46 /* Identify Bison output.  */
47 #define YYBISON 1
48
49 /* Bison version.  */
50 #define YYBISON_VERSION "2.3"
51
52 /* Skeleton name.  */
53 #define YYSKELETON_NAME "yacc.c"
54
55 /* Pure parsers.  */
56 #define YYPURE 0
57
58 /* Using locations.  */
59 #define YYLSP_NEEDED 0
60
61 /* Substitute the variable and function names.  */
62 #define yyparse ssparse
63 #define yylex   sslex
64 #define yyerror sserror
65 #define yylval  sslval
66 #define yychar  sschar
67 #define yydebug ssdebug
68 #define yynerrs ssnerrs
69
70
71 /* Tokens.  */
72 #ifndef YYTOKENTYPE
73 # define YYTOKENTYPE
74    /* Put the tokens into the symbol table, so that GDB and other debuggers
75       know about them.  */
76    enum yytokentype {
77      STRING = 258,
78      SELECT = 259,
79      FROM = 260,
80      WHERE = 261,
81      COMMA = 262,
82      QUOTE = 263,
83      EQUALS = 264,
84      NOTEQUALS = 265,
85      LESS = 266,
86      GREATER = 267,
87      LESSEQUALS = 268,
88      GREATEREQUALS = 269,
89      AND = 270,
90      OR = 271,
91      EOL = 272,
92      END = 273,
93      IS = 274,
94      NOT = 275,
95      SQLNULL = 276
96    };
97 #endif
98 /* Tokens.  */
99 #define STRING 258
100 #define SELECT 259
101 #define FROM 260
102 #define WHERE 261
103 #define COMMA 262
104 #define QUOTE 263
105 #define EQUALS 264
106 #define NOTEQUALS 265
107 #define LESS 266
108 #define GREATER 267
109 #define LESSEQUALS 268
110 #define GREATEREQUALS 269
111 #define AND 270
112 #define OR 271
113 #define EOL 272
114 #define END 273
115 #define IS 274
116 #define NOT 275
117 #define SQLNULL 276
118
119
120
121
122 /* Copy the first part of user declarations.  */
123
124 /* -*- Mode: C -*-                                                         */
125 /*  ====================================================================== */
126 /*  FILE: icalssyacc.y                                                     */
127 /*  CREATOR: eric 08 Aug 2000                                              */
128 /*                                                                         */
129 /*  DESCRIPTION:                                                           */
130 /*                                                                         */                                                                       
131 /*  $Id: icalssyacc.y,v 1.10 2008-01-14 00:35:26 dothebart Exp $           */
132 /*  $Locker:  $                                                            */
133 /*                                                                         */                                                                     
134 /*  (C) COPYRIGHT 2000, Eric Busboom, http://www.softwarestudio.org        */
135 /*                                                                         */
136 /* This program is free software; you can redistribute it and/or modify    */
137 /* it under the terms of either:                                           */
138 /*                                                                         */
139 /*    The LGPL as published by the Free Software Foundation, version       */
140 /*    2.1, available at: http://www.fsf.org/copyleft/lesser.html           */
141 /*                                                                         */
142 /*  Or:                                                                    */
143 /*                                                                         */
144 /*    The Mozilla Public License Version 1.0. You may obtain a copy of     */
145 /*    the License at http://www.mozilla.org/MPL/                           */
146 /*                                                                         */
147 /* The Original Code is eric. The Initial Developer of the Original        */
148 /* Code is Eric Busboom                                                    */
149 /*                                                                         */
150 /*  ====================================================================== */
151 #define YYDEBUG 1
152 #include <stdlib.h>
153 #include <string.h> /* for strdup() */
154 #include <limits.h> /* for SHRT_MAX*/
155 #include <libical/ical.h>
156 #include "icalgauge.h"
157 #include "icalgaugeimpl.h"
158
159 extern struct icalgauge_impl *icalss_yy_gauge;
160
161 #define YYPARSE_PARAM yy_globals
162 #define YYLEX_PARAM yy_globals
163 #define YY_EXTRA_TYPE  icalgauge_impl*
164
165
166 void sserror(char *s); 
167
168 static void ssyacc_add_where(struct icalgauge_impl* impl, char* prop, 
169                         icalgaugecompare compare , char* value);
170 static void ssyacc_add_select(struct icalgauge_impl* impl, char* str1);
171 static void ssyacc_add_from(struct icalgauge_impl* impl, char* str1);
172 static void set_logic(struct icalgauge_impl* impl,icalgaugelogic l);
173
174 /* Don't know why I need this....  */
175  
176 /* older flex version (such as included in OpenBSD) takes a different calling syntax */
177 #ifdef YYPARSE_PARAM 
178 int sslex(void *YYPARSE_PARAM); 
179 #else 
180 int sslex(void);
181 #endif 
182
183
184 /* Enabling traces.  */
185 #ifndef YYDEBUG
186 # define YYDEBUG 0
187 #endif
188
189 /* Enabling verbose error messages.  */
190 #ifdef YYERROR_VERBOSE
191 # undef YYERROR_VERBOSE
192 # define YYERROR_VERBOSE 1
193 #else
194 # define YYERROR_VERBOSE 0
195 #endif
196
197 /* Enabling the token table.  */
198 #ifndef YYTOKEN_TABLE
199 # define YYTOKEN_TABLE 0
200 #endif
201
202 #if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
203 typedef union YYSTYPE
204 {
205         char* v_string;
206 }
207 /* Line 187 of yacc.c.  */
208         YYSTYPE;
209 # define yystype YYSTYPE /* obsolescent; will be withdrawn */
210 # define YYSTYPE_IS_DECLARED 1
211 # define YYSTYPE_IS_TRIVIAL 1
212 #endif
213
214
215
216 /* Copy the second part of user declarations.  */
217
218
219 /* Line 216 of yacc.c.  */
220
221 #ifdef short
222 # undef short
223 #endif
224
225 #ifdef YYTYPE_UINT8
226 typedef YYTYPE_UINT8 yytype_uint8;
227 #else
228 typedef unsigned char yytype_uint8;
229 #endif
230
231 #ifdef YYTYPE_INT8
232 typedef YYTYPE_INT8 yytype_int8;
233 #elif (defined __STDC__ || defined __C99__FUNC__ \
234      || defined __cplusplus || defined _MSC_VER)
235 typedef signed char yytype_int8;
236 #else
237 typedef short int yytype_int8;
238 #endif
239
240 #ifdef YYTYPE_UINT16
241 typedef YYTYPE_UINT16 yytype_uint16;
242 #else
243 typedef unsigned short int yytype_uint16;
244 #endif
245
246 #ifdef YYTYPE_INT16
247 typedef YYTYPE_INT16 yytype_int16;
248 #else
249 typedef short int yytype_int16;
250 #endif
251
252 #ifndef YYSIZE_T
253 # ifdef __SIZE_TYPE__
254 #  define YYSIZE_T __SIZE_TYPE__
255 # elif defined size_t
256 #  define YYSIZE_T size_t
257 # elif ! defined YYSIZE_T && (defined __STDC__ || defined __C99__FUNC__ \
258      || defined __cplusplus || defined _MSC_VER)
259 #  include <stddef.h> /* INFRINGES ON USER NAME SPACE */
260 #  define YYSIZE_T size_t
261 # else
262 #  define YYSIZE_T unsigned int
263 # endif
264 #endif
265
266 #define YYSIZE_MAXIMUM ((YYSIZE_T) -1)
267
268 #ifndef YY_
269 # if YYENABLE_NLS
270 #  if ENABLE_NLS
271 #   include <libintl.h> /* INFRINGES ON USER NAME SPACE */
272 #   define YY_(msgid) dgettext ("bison-runtime", msgid)
273 #  endif
274 # endif
275 # ifndef YY_
276 #  define YY_(msgid) msgid
277 # endif
278 #endif
279
280 /* Suppress unused-variable warnings by "using" E.  */
281 #if ! defined lint || defined __GNUC__
282 # define YYUSE(e) ((void) (e))
283 #else
284 # define YYUSE(e) /* empty */
285 #endif
286
287 /* Identity function, used to suppress warnings about constant conditions.  */
288 #ifndef lint
289 # define YYID(n) (n)
290 #else
291 #if (defined __STDC__ || defined __C99__FUNC__ \
292      || defined __cplusplus || defined _MSC_VER)
293 static int
294 YYID (int i)
295 #else
296 static int
297 YYID (i)
298     int i;
299 #endif
300 {
301   return i;
302 }
303 #endif
304
305 #if ! defined yyoverflow || YYERROR_VERBOSE
306
307 /* The parser invokes alloca or malloc; define the necessary symbols.  */
308
309 # ifdef YYSTACK_USE_ALLOCA
310 #  if YYSTACK_USE_ALLOCA
311 #   ifdef __GNUC__
312 #    define YYSTACK_ALLOC __builtin_alloca
313 #   elif defined __BUILTIN_VA_ARG_INCR
314 #    include <alloca.h> /* INFRINGES ON USER NAME SPACE */
315 #   elif defined _AIX
316 #    define YYSTACK_ALLOC __alloca
317 #   elif defined _MSC_VER
318 #    include <malloc.h> /* INFRINGES ON USER NAME SPACE */
319 #    define alloca _alloca
320 #   else
321 #    define YYSTACK_ALLOC alloca
322 #    if ! defined _ALLOCA_H && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \
323      || defined __cplusplus || defined _MSC_VER)
324 #     include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
325 #     ifndef _STDLIB_H
326 #      define _STDLIB_H 1
327 #     endif
328 #    endif
329 #   endif
330 #  endif
331 # endif
332
333 # ifdef YYSTACK_ALLOC
334    /* Pacify GCC's `empty if-body' warning.  */
335 #  define YYSTACK_FREE(Ptr) do { /* empty */; } while (YYID (0))
336 #  ifndef YYSTACK_ALLOC_MAXIMUM
337     /* The OS might guarantee only one guard page at the bottom of the stack,
338        and a page size can be as small as 4096 bytes.  So we cannot safely
339        invoke alloca (N) if N exceeds 4096.  Use a slightly smaller number
340        to allow for a few compiler-allocated temporary stack slots.  */
341 #   define YYSTACK_ALLOC_MAXIMUM 4032 /* reasonable circa 2006 */
342 #  endif
343 # else
344 #  define YYSTACK_ALLOC YYMALLOC
345 #  define YYSTACK_FREE YYFREE
346 #  ifndef YYSTACK_ALLOC_MAXIMUM
347 #   define YYSTACK_ALLOC_MAXIMUM YYSIZE_MAXIMUM
348 #  endif
349 #  if (defined __cplusplus && ! defined _STDLIB_H \
350        && ! ((defined YYMALLOC || defined malloc) \
351              && (defined YYFREE || defined free)))
352 #   include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
353 #   ifndef _STDLIB_H
354 #    define _STDLIB_H 1
355 #   endif
356 #  endif
357 #  ifndef YYMALLOC
358 #   define YYMALLOC malloc
359 #   if ! defined malloc && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \
360      || defined __cplusplus)
361 void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */
362 #   endif
363 #  endif
364 #  ifndef YYFREE
365 #   define YYFREE free
366 #   if ! defined free && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \
367      || defined __cplusplus)
368 void free (void *); /* INFRINGES ON USER NAME SPACE */
369 #   endif
370 #  endif
371 # endif
372 #endif /* ! defined yyoverflow || YYERROR_VERBOSE */
373
374
375 #if (! defined yyoverflow \
376      && (! defined __cplusplus \
377          || (defined YYSTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL)))
378
379 /* A type that is properly aligned for any stack member.  */
380 union yyalloc
381 {
382   yytype_int16 yyss;
383   YYSTYPE yyvs;
384   };
385
386 /* The size of the maximum gap between one aligned stack and the next.  */
387 # define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1)
388
389 /* The size of an array large to enough to hold all stacks, each with
390    N elements.  */
391 # define YYSTACK_BYTES(N) \
392      ((N) * (sizeof (yytype_int16) + sizeof (YYSTYPE)) \
393       + YYSTACK_GAP_MAXIMUM)
394
395 /* Copy COUNT objects from FROM to TO.  The source and destination do
396    not overlap.  */
397 # ifndef YYCOPY
398 #  if defined __GNUC__ && 1 < __GNUC__
399 #   define YYCOPY(To, From, Count) \
400       __builtin_memcpy (To, From, (Count) * sizeof (*(From)))
401 #  else
402 #   define YYCOPY(To, From, Count)              \
403       do                                        \
404         {                                       \
405           YYSIZE_T yyi;                         \
406           for (yyi = 0; yyi < (Count); yyi++)   \
407             (To)[yyi] = (From)[yyi];            \
408         }                                       \
409       while (YYID (0))
410 #  endif
411 # endif
412
413 /* Relocate STACK from its old location to the new one.  The
414    local variables YYSIZE and YYSTACKSIZE give the old and new number of
415    elements in the stack, and YYPTR gives the new location of the
416    stack.  Advance YYPTR to a properly aligned location for the next
417    stack.  */
418 # define YYSTACK_RELOCATE(Stack)                                        \
419     do                                                                  \
420       {                                                                 \
421         YYSIZE_T yynewbytes;                                            \
422         YYCOPY (&yyptr->Stack, Stack, yysize);                          \
423         Stack = &yyptr->Stack;                                          \
424         yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \
425         yyptr += yynewbytes / sizeof (*yyptr);                          \
426       }                                                                 \
427     while (YYID (0))
428
429 #endif
430
431 /* YYFINAL -- State number of the termination state.  */
432 #define YYFINAL  6
433 /* YYLAST -- Last index in YYTABLE.  */
434 #define YYLAST   31
435
436 /* YYNTOKENS -- Number of terminals.  */
437 #define YYNTOKENS  22
438 /* YYNNTS -- Number of nonterminals.  */
439 #define YYNNTS  6
440 /* YYNRULES -- Number of rules.  */
441 #define YYNRULES  20
442 /* YYNRULES -- Number of states.  */
443 #define YYNSTATES  38
444
445 /* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX.  */
446 #define YYUNDEFTOK  2
447 #define YYMAXUTOK   276
448
449 #define YYTRANSLATE(YYX)                                                \
450   ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK)
451
452 /* YYTRANSLATE[YYLEX] -- Bison symbol number corresponding to YYLEX.  */
453 static const yytype_uint8 yytranslate[] =
454 {
455        0,     2,     2,     2,     2,     2,     2,     2,     2,     2,
456        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
457        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
458        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
459        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
460        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
461        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
462        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
463        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
464        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
465        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
466        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
467        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
468        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
469        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
470        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
471        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
472        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
473        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
474        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
475        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
476        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
477        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
478        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
479        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
480        2,     2,     2,     2,     2,     2,     1,     2,     3,     4,
481        5,     6,     7,     8,     9,    10,    11,    12,    13,    14,
482       15,    16,    17,    18,    19,    20,    21
483 };
484
485 #if YYDEBUG
486 /* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in
487    YYRHS.  */
488 static const yytype_uint8 yyprhs[] =
489 {
490        0,     0,     3,    10,    15,    17,    19,    23,    25,    29,
491       30,    34,    38,    43,    47,    51,    55,    59,    63,    65,
492       69
493 };
494
495 /* YYRHS -- A `-1'-separated list of the rules' RHS.  */
496 static const yytype_int8 yyrhs[] =
497 {
498       23,     0,    -1,     4,    24,     5,    25,     6,    27,    -1,
499        4,    24,     5,    25,    -1,     1,    -1,     3,    -1,    24,
500        7,     3,    -1,     3,    -1,    25,     7,     3,    -1,    -1,
501        3,     9,     3,    -1,     3,    19,    21,    -1,     3,    19,
502       20,    21,    -1,     3,    10,     3,    -1,     3,    11,     3,
503       -1,     3,    12,     3,    -1,     3,    13,     3,    -1,     3,
504       14,     3,    -1,    26,    -1,    27,    15,    26,    -1,    27,
505       16,    26,    -1
506 };
507
508 /* YYRLINE[YYN] -- source line where rule number YYN was defined.  */
509 static const yytype_uint8 yyrline[] =
510 {
511        0,    73,    73,    74,    75,    82,    83,    88,    89,    92,
512       94,    95,    96,    97,    98,    99,   100,   101,   105,   106,
513      107
514 };
515 #endif
516
517 #if YYDEBUG || YYERROR_VERBOSE || YYTOKEN_TABLE
518 /* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
519    First, the terminals, then, starting at YYNTOKENS, nonterminals.  */
520 static const char *const yytname[] =
521 {
522   "$end", "error", "$undefined", "STRING", "SELECT", "FROM", "WHERE",
523   "COMMA", "QUOTE", "EQUALS", "NOTEQUALS", "LESS", "GREATER", "LESSEQUALS",
524   "GREATEREQUALS", "AND", "OR", "EOL", "END", "IS", "NOT", "SQLNULL",
525   "$accept", "query_min", "select_list", "from_list", "where_clause",
526   "where_list", 0
527 };
528 #endif
529
530 # ifdef YYPRINT
531 /* YYTOKNUM[YYLEX-NUM] -- Internal token number corresponding to
532    token YYLEX-NUM.  */
533 static const yytype_uint16 yytoknum[] =
534 {
535        0,   256,   257,   258,   259,   260,   261,   262,   263,   264,
536      265,   266,   267,   268,   269,   270,   271,   272,   273,   274,
537      275,   276
538 };
539 # endif
540
541 /* YYR1[YYN] -- Symbol number of symbol that rule YYN derives.  */
542 static const yytype_uint8 yyr1[] =
543 {
544        0,    22,    23,    23,    23,    24,    24,    25,    25,    26,
545       26,    26,    26,    26,    26,    26,    26,    26,    27,    27,
546       27
547 };
548
549 /* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN.  */
550 static const yytype_uint8 yyr2[] =
551 {
552        0,     2,     6,     4,     1,     1,     3,     1,     3,     0,
553        3,     3,     4,     3,     3,     3,     3,     3,     1,     3,
554        3
555 };
556
557 /* YYDEFACT[STATE-NAME] -- Default rule to reduce with in state
558    STATE-NUM when YYTABLE doesn't specify something else to do.  Zero
559    means the default is an error.  */
560 static const yytype_uint8 yydefact[] =
561 {
562        0,     4,     0,     0,     5,     0,     1,     0,     0,     7,
563        3,     6,     9,     0,     0,    18,     2,     8,     0,     0,
564        0,     0,     0,     0,     0,     9,     9,    10,    13,    14,
565       15,    16,    17,     0,    11,    19,    20,    12
566 };
567
568 /* YYDEFGOTO[NTERM-NUM].  */
569 static const yytype_int8 yydefgoto[] =
570 {
571       -1,     3,     5,    10,    15,    16
572 };
573
574 /* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
575    STATE-NUM.  */
576 #define YYPACT_NINF -10
577 static const yytype_int8 yypact[] =
578 {
579        5,   -10,     9,    20,   -10,     6,   -10,    18,    19,   -10,
580        1,   -10,    21,    22,    -9,   -10,    -1,   -10,    23,    24,
581       25,    26,    27,    28,    -4,    21,    21,   -10,   -10,   -10,
582      -10,   -10,   -10,     2,   -10,   -10,   -10,   -10
583 };
584
585 /* YYPGOTO[NTERM-NUM].  */
586 static const yytype_int8 yypgoto[] =
587 {
588      -10,   -10,   -10,   -10,    -7,   -10
589 };
590
591 /* YYTABLE[YYPACT[STATE-NUM]].  What to do in state STATE-NUM.  If
592    positive, shift that token.  If negative, reduce the rule which
593    number is the opposite.  If zero, do what YYDEFACT says.
594    If YYTABLE_NINF, syntax error.  */
595 #define YYTABLE_NINF -1
596 static const yytype_uint8 yytable[] =
597 {
598       18,    19,    20,    21,    22,    23,     1,    12,    13,     2,
599       24,     7,     4,     8,    25,    26,    33,    34,    35,    36,
600        6,     9,    11,    37,    14,    17,    27,    28,    29,    30,
601       31,    32
602 };
603
604 static const yytype_uint8 yycheck[] =
605 {
606        9,    10,    11,    12,    13,    14,     1,     6,     7,     4,
607       19,     5,     3,     7,    15,    16,    20,    21,    25,    26,
608        0,     3,     3,    21,     3,     3,     3,     3,     3,     3,
609        3,     3
610 };
611
612 /* YYSTOS[STATE-NUM] -- The (internal number of the) accessing
613    symbol of state STATE-NUM.  */
614 static const yytype_uint8 yystos[] =
615 {
616        0,     1,     4,    23,     3,    24,     0,     5,     7,     3,
617       25,     3,     6,     7,     3,    26,    27,     3,     9,    10,
618       11,    12,    13,    14,    19,    15,    16,     3,     3,     3,
619        3,     3,     3,    20,    21,    26,    26,    21
620 };
621
622 #define yyerrok         (yyerrstatus = 0)
623 #define yyclearin       (yychar = YYEMPTY)
624 #define YYEMPTY         (-2)
625 #define YYEOF           0
626
627 #define YYACCEPT        goto yyacceptlab
628 #define YYABORT         goto yyabortlab
629 #define YYERROR         goto yyerrorlab
630
631
632 /* Like YYERROR except do call yyerror.  This remains here temporarily
633    to ease the transition to the new meaning of YYERROR, for GCC.
634    Once GCC version 2 has supplanted version 1, this can go.  */
635
636 #define YYFAIL          goto yyerrlab
637
638 #define YYRECOVERING()  (!!yyerrstatus)
639
640 #define YYBACKUP(Token, Value)                                  \
641 do                                                              \
642   if (yychar == YYEMPTY && yylen == 1)                          \
643     {                                                           \
644       yychar = (Token);                                         \
645       yylval = (Value);                                         \
646       yytoken = YYTRANSLATE (yychar);                           \
647       YYPOPSTACK (1);                                           \
648       goto yybackup;                                            \
649     }                                                           \
650   else                                                          \
651     {                                                           \
652       yyerror (YY_("syntax error: cannot back up")); \
653       YYERROR;                                                  \
654     }                                                           \
655 while (YYID (0))
656
657
658 #define YYTERROR        1
659 #define YYERRCODE       256
660
661
662 /* YYLLOC_DEFAULT -- Set CURRENT to span from RHS[1] to RHS[N].
663    If N is 0, then set CURRENT to the empty location which ends
664    the previous symbol: RHS[0] (always defined).  */
665
666 #define YYRHSLOC(Rhs, K) ((Rhs)[K])
667 #ifndef YYLLOC_DEFAULT
668 # define YYLLOC_DEFAULT(Current, Rhs, N)                                \
669     do                                                                  \
670       if (YYID (N))                                                    \
671         {                                                               \
672           (Current).first_line   = YYRHSLOC (Rhs, 1).first_line;        \
673           (Current).first_column = YYRHSLOC (Rhs, 1).first_column;      \
674           (Current).last_line    = YYRHSLOC (Rhs, N).last_line;         \
675           (Current).last_column  = YYRHSLOC (Rhs, N).last_column;       \
676         }                                                               \
677       else                                                              \
678         {                                                               \
679           (Current).first_line   = (Current).last_line   =              \
680             YYRHSLOC (Rhs, 0).last_line;                                \
681           (Current).first_column = (Current).last_column =              \
682             YYRHSLOC (Rhs, 0).last_column;                              \
683         }                                                               \
684     while (YYID (0))
685 #endif
686
687
688 /* YY_LOCATION_PRINT -- Print the location on the stream.
689    This macro was not mandated originally: define only if we know
690    we won't break user code: when these are the locations we know.  */
691
692 #ifndef YY_LOCATION_PRINT
693 # if YYLTYPE_IS_TRIVIAL
694 #  define YY_LOCATION_PRINT(File, Loc)                  \
695      fprintf (File, "%d.%d-%d.%d",                      \
696               (Loc).first_line, (Loc).first_column,     \
697               (Loc).last_line,  (Loc).last_column)
698 # else
699 #  define YY_LOCATION_PRINT(File, Loc) ((void) 0)
700 # endif
701 #endif
702
703
704 /* YYLEX -- calling `yylex' with the right arguments.  */
705
706 #ifdef YYLEX_PARAM
707 # define YYLEX yylex (YYLEX_PARAM)
708 #else
709 # define YYLEX yylex ()
710 #endif
711
712 /* Enable debugging if requested.  */
713 #if YYDEBUG
714
715 # ifndef YYFPRINTF
716 #  include <stdio.h> /* INFRINGES ON USER NAME SPACE */
717 #  define YYFPRINTF fprintf
718 # endif
719
720 # define YYDPRINTF(Args)                        \
721 do {                                            \
722   if (yydebug)                                  \
723     YYFPRINTF Args;                             \
724 } while (YYID (0))
725
726 # define YY_SYMBOL_PRINT(Title, Type, Value, Location)                    \
727 do {                                                                      \
728   if (yydebug)                                                            \
729     {                                                                     \
730       YYFPRINTF (stderr, "%s ", Title);                                   \
731       yy_symbol_print (stderr,                                            \
732                   Type, Value); \
733       YYFPRINTF (stderr, "\n");                                           \
734     }                                                                     \
735 } while (YYID (0))
736
737
738 /*--------------------------------.
739 | Print this symbol on YYOUTPUT.  |
740 `--------------------------------*/
741
742 /*ARGSUSED*/
743 #if (defined __STDC__ || defined __C99__FUNC__ \
744      || defined __cplusplus || defined _MSC_VER)
745 static void
746 yy_symbol_value_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep)
747 #else
748 static void
749 yy_symbol_value_print (yyoutput, yytype, yyvaluep)
750     FILE *yyoutput;
751     int yytype;
752     YYSTYPE const * const yyvaluep;
753 #endif
754 {
755   if (!yyvaluep)
756     return;
757 # ifdef YYPRINT
758   if (yytype < YYNTOKENS)
759     YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep);
760 # else
761   YYUSE (yyoutput);
762 # endif
763   switch (yytype)
764     {
765       default:
766         break;
767     }
768 }
769
770
771 /*--------------------------------.
772 | Print this symbol on YYOUTPUT.  |
773 `--------------------------------*/
774
775 #if (defined __STDC__ || defined __C99__FUNC__ \
776      || defined __cplusplus || defined _MSC_VER)
777 static void
778 yy_symbol_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep)
779 #else
780 static void
781 yy_symbol_print (yyoutput, yytype, yyvaluep)
782     FILE *yyoutput;
783     int yytype;
784     YYSTYPE const * const yyvaluep;
785 #endif
786 {
787   if (yytype < YYNTOKENS)
788     YYFPRINTF (yyoutput, "token %s (", yytname[yytype]);
789   else
790     YYFPRINTF (yyoutput, "nterm %s (", yytname[yytype]);
791
792   yy_symbol_value_print (yyoutput, yytype, yyvaluep);
793   YYFPRINTF (yyoutput, ")");
794 }
795
796 /*------------------------------------------------------------------.
797 | yy_stack_print -- Print the state stack from its BOTTOM up to its |
798 | TOP (included).                                                   |
799 `------------------------------------------------------------------*/
800
801 #if (defined __STDC__ || defined __C99__FUNC__ \
802      || defined __cplusplus || defined _MSC_VER)
803 static void
804 yy_stack_print (yytype_int16 *bottom, yytype_int16 *top)
805 #else
806 static void
807 yy_stack_print (bottom, top)
808     yytype_int16 *bottom;
809     yytype_int16 *top;
810 #endif
811 {
812   YYFPRINTF (stderr, "Stack now");
813   for (; bottom <= top; ++bottom)
814     YYFPRINTF (stderr, " %d", *bottom);
815   YYFPRINTF (stderr, "\n");
816 }
817
818 # define YY_STACK_PRINT(Bottom, Top)                            \
819 do {                                                            \
820   if (yydebug)                                                  \
821     yy_stack_print ((Bottom), (Top));                           \
822 } while (YYID (0))
823
824
825 /*------------------------------------------------.
826 | Report that the YYRULE is going to be reduced.  |
827 `------------------------------------------------*/
828
829 #if (defined __STDC__ || defined __C99__FUNC__ \
830      || defined __cplusplus || defined _MSC_VER)
831 static void
832 yy_reduce_print (YYSTYPE *yyvsp, int yyrule)
833 #else
834 static void
835 yy_reduce_print (yyvsp, yyrule)
836     YYSTYPE *yyvsp;
837     int yyrule;
838 #endif
839 {
840   int yynrhs = yyr2[yyrule];
841   int yyi;
842   unsigned long int yylno = yyrline[yyrule];
843   YYFPRINTF (stderr, "Reducing stack by rule %d (line %lu):\n",
844              yyrule - 1, yylno);
845   /* The symbols being reduced.  */
846   for (yyi = 0; yyi < yynrhs; yyi++)
847     {
848       fprintf (stderr, "   $%d = ", yyi + 1);
849       yy_symbol_print (stderr, yyrhs[yyprhs[yyrule] + yyi],
850                        &(yyvsp[(yyi + 1) - (yynrhs)])
851                                        );
852       fprintf (stderr, "\n");
853     }
854 }
855
856 # define YY_REDUCE_PRINT(Rule)          \
857 do {                                    \
858   if (yydebug)                          \
859     yy_reduce_print (yyvsp, Rule); \
860 } while (YYID (0))
861
862 /* Nonzero means print parse trace.  It is left uninitialized so that
863    multiple parsers can coexist.  */
864 int yydebug;
865 #else /* !YYDEBUG */
866 # define YYDPRINTF(Args)
867 # define YY_SYMBOL_PRINT(Title, Type, Value, Location)
868 # define YY_STACK_PRINT(Bottom, Top)
869 # define YY_REDUCE_PRINT(Rule)
870 #endif /* !YYDEBUG */
871
872
873 /* YYINITDEPTH -- initial size of the parser's stacks.  */
874 #ifndef YYINITDEPTH
875 # define YYINITDEPTH 200
876 #endif
877
878 /* YYMAXDEPTH -- maximum size the stacks can grow to (effective only
879    if the built-in stack extension method is used).
880
881    Do not make this value too large; the results are undefined if
882    YYSTACK_ALLOC_MAXIMUM < YYSTACK_BYTES (YYMAXDEPTH)
883    evaluated with infinite-precision integer arithmetic.  */
884
885 #ifndef YYMAXDEPTH
886 # define YYMAXDEPTH 10000
887 #endif
888
889 \f
890
891 #if YYERROR_VERBOSE
892
893 # ifndef yystrlen
894 #  if defined __GLIBC__ && defined _STRING_H
895 #   define yystrlen strlen
896 #  else
897 /* Return the length of YYSTR.  */
898 #if (defined __STDC__ || defined __C99__FUNC__ \
899      || defined __cplusplus || defined _MSC_VER)
900 static YYSIZE_T
901 yystrlen (const char *yystr)
902 #else
903 static YYSIZE_T
904 yystrlen (yystr)
905     const char *yystr;
906 #endif
907 {
908   YYSIZE_T yylen;
909   for (yylen = 0; yystr[yylen]; yylen++)
910     continue;
911   return yylen;
912 }
913 #  endif
914 # endif
915
916 # ifndef yystpcpy
917 #  if defined __GLIBC__ && defined _STRING_H && defined _GNU_SOURCE
918 #   define yystpcpy stpcpy
919 #  else
920 /* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in
921    YYDEST.  */
922 #if (defined __STDC__ || defined __C99__FUNC__ \
923      || defined __cplusplus || defined _MSC_VER)
924 static char *
925 yystpcpy (char *yydest, const char *yysrc)
926 #else
927 static char *
928 yystpcpy (yydest, yysrc)
929     char *yydest;
930     const char *yysrc;
931 #endif
932 {
933   char *yyd = yydest;
934   const char *yys = yysrc;
935
936   while ((*yyd++ = *yys++) != '\0')
937     continue;
938
939   return yyd - 1;
940 }
941 #  endif
942 # endif
943
944 # ifndef yytnamerr
945 /* Copy to YYRES the contents of YYSTR after stripping away unnecessary
946    quotes and backslashes, so that it's suitable for yyerror.  The
947    heuristic is that double-quoting is unnecessary unless the string
948    contains an apostrophe, a comma, or backslash (other than
949    backslash-backslash).  YYSTR is taken from yytname.  If YYRES is
950    null, do not copy; instead, return the length of what the result
951    would have been.  */
952 static YYSIZE_T
953 yytnamerr (char *yyres, const char *yystr)
954 {
955   if (*yystr == '"')
956     {
957       YYSIZE_T yyn = 0;
958       char const *yyp = yystr;
959
960       for (;;)
961         switch (*++yyp)
962           {
963           case '\'':
964           case ',':
965             goto do_not_strip_quotes;
966
967           case '\\':
968             if (*++yyp != '\\')
969               goto do_not_strip_quotes;
970             /* Fall through.  */
971           default:
972             if (yyres)
973               yyres[yyn] = *yyp;
974             yyn++;
975             break;
976
977           case '"':
978             if (yyres)
979               yyres[yyn] = '\0';
980             return yyn;
981           }
982     do_not_strip_quotes: ;
983     }
984
985   if (! yyres)
986     return yystrlen (yystr);
987
988   return yystpcpy (yyres, yystr) - yyres;
989 }
990 # endif
991
992 /* Copy into YYRESULT an error message about the unexpected token
993    YYCHAR while in state YYSTATE.  Return the number of bytes copied,
994    including the terminating null byte.  If YYRESULT is null, do not
995    copy anything; just return the number of bytes that would be
996    copied.  As a special case, return 0 if an ordinary "syntax error"
997    message will do.  Return YYSIZE_MAXIMUM if overflow occurs during
998    size calculation.  */
999 static YYSIZE_T
1000 yysyntax_error (char *yyresult, int yystate, int yychar)
1001 {
1002   int yyn = yypact[yystate];
1003
1004   if (! (YYPACT_NINF < yyn && yyn <= YYLAST))
1005     return 0;
1006   else
1007     {
1008       int yytype = YYTRANSLATE (yychar);
1009       YYSIZE_T yysize0 = yytnamerr (0, yytname[yytype]);
1010       YYSIZE_T yysize = yysize0;
1011       YYSIZE_T yysize1;
1012       int yysize_overflow = 0;
1013       enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 };
1014       char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM];
1015       int yyx;
1016
1017 # if 0
1018       /* This is so xgettext sees the translatable formats that are
1019          constructed on the fly.  */
1020       YY_("syntax error, unexpected %s");
1021       YY_("syntax error, unexpected %s, expecting %s");
1022       YY_("syntax error, unexpected %s, expecting %s or %s");
1023       YY_("syntax error, unexpected %s, expecting %s or %s or %s");
1024       YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s");
1025 # endif
1026       char *yyfmt;
1027       char const *yyf;
1028       static char const yyunexpected[] = "syntax error, unexpected %s";
1029       static char const yyexpecting[] = ", expecting %s";
1030       static char const yyor[] = " or %s";
1031       char yyformat[sizeof yyunexpected
1032                     + sizeof yyexpecting - 1
1033                     + ((YYERROR_VERBOSE_ARGS_MAXIMUM - 2)
1034                        * (sizeof yyor - 1))];
1035       char const *yyprefix = yyexpecting;
1036
1037       /* Start YYX at -YYN if negative to avoid negative indexes in
1038          YYCHECK.  */
1039       int yyxbegin = yyn < 0 ? -yyn : 0;
1040
1041       /* Stay within bounds of both yycheck and yytname.  */
1042       int yychecklim = YYLAST - yyn + 1;
1043       int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS;
1044       int yycount = 1;
1045
1046       yyarg[0] = yytname[yytype];
1047       yyfmt = yystpcpy (yyformat, yyunexpected);
1048
1049       for (yyx = yyxbegin; yyx < yyxend; ++yyx)
1050         if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR)
1051           {
1052             if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM)
1053               {
1054                 yycount = 1;
1055                 yysize = yysize0;
1056                 yyformat[sizeof yyunexpected - 1] = '\0';
1057                 break;
1058               }
1059             yyarg[yycount++] = yytname[yyx];
1060             yysize1 = yysize + yytnamerr (0, yytname[yyx]);
1061             yysize_overflow |= (yysize1 < yysize);
1062             yysize = yysize1;
1063             yyfmt = yystpcpy (yyfmt, yyprefix);
1064             yyprefix = yyor;
1065           }
1066
1067       yyf = YY_(yyformat);
1068       yysize1 = yysize + yystrlen (yyf);
1069       yysize_overflow |= (yysize1 < yysize);
1070       yysize = yysize1;
1071
1072       if (yysize_overflow)
1073         return YYSIZE_MAXIMUM;
1074
1075       if (yyresult)
1076         {
1077           /* Avoid sprintf, as that infringes on the user's name space.
1078              Don't have undefined behavior even if the translation
1079              produced a string with the wrong number of "%s"s.  */
1080           char *yyp = yyresult;
1081           int yyi = 0;
1082           while ((*yyp = *yyf) != '\0')
1083             {
1084               if (*yyp == '%' && yyf[1] == 's' && yyi < yycount)
1085                 {
1086                   yyp += yytnamerr (yyp, yyarg[yyi++]);
1087                   yyf += 2;
1088                 }
1089               else
1090                 {
1091                   yyp++;
1092                   yyf++;
1093                 }
1094             }
1095         }
1096       return yysize;
1097     }
1098 }
1099 #endif /* YYERROR_VERBOSE */
1100 \f
1101
1102 /*-----------------------------------------------.
1103 | Release the memory associated to this symbol.  |
1104 `-----------------------------------------------*/
1105
1106 /*ARGSUSED*/
1107 #if (defined __STDC__ || defined __C99__FUNC__ \
1108      || defined __cplusplus || defined _MSC_VER)
1109 static void
1110 yydestruct (const char *yymsg, int yytype, YYSTYPE *yyvaluep)
1111 #else
1112 static void
1113 yydestruct (yymsg, yytype, yyvaluep)
1114     const char *yymsg;
1115     int yytype;
1116     YYSTYPE *yyvaluep;
1117 #endif
1118 {
1119   YYUSE (yyvaluep);
1120
1121   if (!yymsg)
1122     yymsg = "Deleting";
1123   YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp);
1124
1125   switch (yytype)
1126     {
1127
1128       default:
1129         break;
1130     }
1131 }
1132 \f
1133
1134 /* Prevent warnings from -Wmissing-prototypes.  */
1135
1136 #ifdef YYPARSE_PARAM
1137 #if defined __STDC__ || defined __cplusplus
1138 int yyparse (void *YYPARSE_PARAM);
1139 #else
1140 int yyparse ();
1141 #endif
1142 #else /* ! YYPARSE_PARAM */
1143 #if defined __STDC__ || defined __cplusplus
1144 int yyparse (void);
1145 #else
1146 int yyparse ();
1147 #endif
1148 #endif /* ! YYPARSE_PARAM */
1149
1150
1151
1152 /* The look-ahead symbol.  */
1153 int yychar;
1154
1155 /* The semantic value of the look-ahead symbol.  */
1156 YYSTYPE yylval;
1157
1158 /* Number of syntax errors so far.  */
1159 int yynerrs;
1160
1161
1162
1163 /*----------.
1164 | yyparse.  |
1165 `----------*/
1166
1167 #ifdef YYPARSE_PARAM
1168 #if (defined __STDC__ || defined __C99__FUNC__ \
1169      || defined __cplusplus || defined _MSC_VER)
1170 int
1171 yyparse (void *YYPARSE_PARAM)
1172 #else
1173 int
1174 yyparse (YYPARSE_PARAM)
1175     void *YYPARSE_PARAM;
1176 #endif
1177 #else /* ! YYPARSE_PARAM */
1178 #if (defined __STDC__ || defined __C99__FUNC__ \
1179      || defined __cplusplus || defined _MSC_VER)
1180 int
1181 yyparse (void)
1182 #else
1183 int
1184 yyparse ()
1185
1186 #endif
1187 #endif
1188 {
1189   
1190   int yystate;
1191   int yyn;
1192   int yyresult;
1193   /* Number of tokens to shift before error messages enabled.  */
1194   int yyerrstatus;
1195   /* Look-ahead token as an internal (translated) token number.  */
1196   int yytoken = 0;
1197 #if YYERROR_VERBOSE
1198   /* Buffer for error messages, and its allocated size.  */
1199   char yymsgbuf[128];
1200   char *yymsg = yymsgbuf;
1201   YYSIZE_T yymsg_alloc = sizeof yymsgbuf;
1202 #endif
1203
1204   /* Three stacks and their tools:
1205      `yyss': related to states,
1206      `yyvs': related to semantic values,
1207      `yyls': related to locations.
1208
1209      Refer to the stacks thru separate pointers, to allow yyoverflow
1210      to reallocate them elsewhere.  */
1211
1212   /* The state stack.  */
1213   yytype_int16 yyssa[YYINITDEPTH];
1214   yytype_int16 *yyss = yyssa;
1215   yytype_int16 *yyssp;
1216
1217   /* The semantic value stack.  */
1218   YYSTYPE yyvsa[YYINITDEPTH];
1219   YYSTYPE *yyvs = yyvsa;
1220   YYSTYPE *yyvsp;
1221
1222
1223
1224 #define YYPOPSTACK(N)   (yyvsp -= (N), yyssp -= (N))
1225
1226   YYSIZE_T yystacksize = YYINITDEPTH;
1227
1228   /* The variables used to return semantic value and location from the
1229      action routines.  */
1230   YYSTYPE yyval;
1231
1232
1233   /* The number of symbols on the RHS of the reduced rule.
1234      Keep to zero when no symbol should be popped.  */
1235   int yylen = 0;
1236
1237   YYDPRINTF ((stderr, "Starting parse\n"));
1238
1239   yystate = 0;
1240   yyerrstatus = 0;
1241   yynerrs = 0;
1242   yychar = YYEMPTY;             /* Cause a token to be read.  */
1243
1244   /* Initialize stack pointers.
1245      Waste one element of value and location stack
1246      so that they stay on the same level as the state stack.
1247      The wasted elements are never initialized.  */
1248
1249   yyssp = yyss;
1250   yyvsp = yyvs;
1251
1252   goto yysetstate;
1253
1254 /*------------------------------------------------------------.
1255 | yynewstate -- Push a new state, which is found in yystate.  |
1256 `------------------------------------------------------------*/
1257  yynewstate:
1258   /* In all cases, when you get here, the value and location stacks
1259      have just been pushed.  So pushing a state here evens the stacks.  */
1260   yyssp++;
1261
1262  yysetstate:
1263   *yyssp = yystate;
1264
1265   if (yyss + yystacksize - 1 <= yyssp)
1266     {
1267       /* Get the current used size of the three stacks, in elements.  */
1268       YYSIZE_T yysize = yyssp - yyss + 1;
1269
1270 #ifdef yyoverflow
1271       {
1272         /* Give user a chance to reallocate the stack.  Use copies of
1273            these so that the &'s don't force the real ones into
1274            memory.  */
1275         YYSTYPE *yyvs1 = yyvs;
1276         yytype_int16 *yyss1 = yyss;
1277
1278
1279         /* Each stack pointer address is followed by the size of the
1280            data in use in that stack, in bytes.  This used to be a
1281            conditional around just the two extra args, but that might
1282            be undefined if yyoverflow is a macro.  */
1283         yyoverflow (YY_("memory exhausted"),
1284                     &yyss1, yysize * sizeof (*yyssp),
1285                     &yyvs1, yysize * sizeof (*yyvsp),
1286
1287                     &yystacksize);
1288
1289         yyss = yyss1;
1290         yyvs = yyvs1;
1291       }
1292 #else /* no yyoverflow */
1293 # ifndef YYSTACK_RELOCATE
1294       goto yyexhaustedlab;
1295 # else
1296       /* Extend the stack our own way.  */
1297       if (YYMAXDEPTH <= yystacksize)
1298         goto yyexhaustedlab;
1299       yystacksize *= 2;
1300       if (YYMAXDEPTH < yystacksize)
1301         yystacksize = YYMAXDEPTH;
1302
1303       {
1304         yytype_int16 *yyss1 = yyss;
1305         union yyalloc *yyptr =
1306           (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize));
1307         if (! yyptr)
1308           goto yyexhaustedlab;
1309         YYSTACK_RELOCATE (yyss);
1310         YYSTACK_RELOCATE (yyvs);
1311
1312 #  undef YYSTACK_RELOCATE
1313         if (yyss1 != yyssa)
1314           YYSTACK_FREE (yyss1);
1315       }
1316 # endif
1317 #endif /* no yyoverflow */
1318
1319       yyssp = yyss + yysize - 1;
1320       yyvsp = yyvs + yysize - 1;
1321
1322
1323       YYDPRINTF ((stderr, "Stack size increased to %lu\n",
1324                   (unsigned long int) yystacksize));
1325
1326       if (yyss + yystacksize - 1 <= yyssp)
1327         YYABORT;
1328     }
1329
1330   YYDPRINTF ((stderr, "Entering state %d\n", yystate));
1331
1332   goto yybackup;
1333
1334 /*-----------.
1335 | yybackup.  |
1336 `-----------*/
1337 yybackup:
1338
1339   /* Do appropriate processing given the current state.  Read a
1340      look-ahead token if we need one and don't already have one.  */
1341
1342   /* First try to decide what to do without reference to look-ahead token.  */
1343   yyn = yypact[yystate];
1344   if (yyn == YYPACT_NINF)
1345     goto yydefault;
1346
1347   /* Not known => get a look-ahead token if don't already have one.  */
1348
1349   /* YYCHAR is either YYEMPTY or YYEOF or a valid look-ahead symbol.  */
1350   if (yychar == YYEMPTY)
1351     {
1352       YYDPRINTF ((stderr, "Reading a token: "));
1353       yychar = YYLEX;
1354     }
1355
1356   if (yychar <= YYEOF)
1357     {
1358       yychar = yytoken = YYEOF;
1359       YYDPRINTF ((stderr, "Now at end of input.\n"));
1360     }
1361   else
1362     {
1363       yytoken = YYTRANSLATE (yychar);
1364       YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc);
1365     }
1366
1367   /* If the proper action on seeing token YYTOKEN is to reduce or to
1368      detect an error, take that action.  */
1369   yyn += yytoken;
1370   if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken)
1371     goto yydefault;
1372   yyn = yytable[yyn];
1373   if (yyn <= 0)
1374     {
1375       if (yyn == 0 || yyn == YYTABLE_NINF)
1376         goto yyerrlab;
1377       yyn = -yyn;
1378       goto yyreduce;
1379     }
1380
1381   if (yyn == YYFINAL)
1382     YYACCEPT;
1383
1384   /* Count tokens shifted since error; after three, turn off error
1385      status.  */
1386   if (yyerrstatus)
1387     yyerrstatus--;
1388
1389   /* Shift the look-ahead token.  */
1390   YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc);
1391
1392   /* Discard the shifted token unless it is eof.  */
1393   if (yychar != YYEOF)
1394     yychar = YYEMPTY;
1395
1396   yystate = yyn;
1397   *++yyvsp = yylval;
1398
1399   goto yynewstate;
1400
1401
1402 /*-----------------------------------------------------------.
1403 | yydefault -- do the default action for the current state.  |
1404 `-----------------------------------------------------------*/
1405 yydefault:
1406   yyn = yydefact[yystate];
1407   if (yyn == 0)
1408     goto yyerrlab;
1409   goto yyreduce;
1410
1411
1412 /*-----------------------------.
1413 | yyreduce -- Do a reduction.  |
1414 `-----------------------------*/
1415 yyreduce:
1416   /* yyn is the number of a rule to reduce with.  */
1417   yylen = yyr2[yyn];
1418
1419   /* If YYLEN is nonzero, implement the default value of the action:
1420      `$$ = $1'.
1421
1422      Otherwise, the following line sets YYVAL to garbage.
1423      This behavior is undocumented and Bison
1424      users should not rely upon it.  Assigning to YYVAL
1425      unconditionally makes the parser a bit smaller, and it avoids a
1426      GCC warning that YYVAL may be used uninitialized.  */
1427   yyval = yyvsp[1-yylen];
1428
1429
1430   YY_REDUCE_PRINT (yyn);
1431   switch (yyn)
1432     {
1433         case 4:
1434     { 
1435                  yyclearin;
1436                  YYABORT;
1437            }
1438     break;
1439
1440   case 5:
1441     {ssyacc_add_select(icalss_yy_gauge,(yyvsp[(1) - (1)].v_string));}
1442     break;
1443
1444   case 6:
1445     {ssyacc_add_select(icalss_yy_gauge,(yyvsp[(3) - (3)].v_string));}
1446     break;
1447
1448   case 7:
1449     {ssyacc_add_from(icalss_yy_gauge,(yyvsp[(1) - (1)].v_string));}
1450     break;
1451
1452   case 8:
1453     {ssyacc_add_from(icalss_yy_gauge,(yyvsp[(3) - (3)].v_string));}
1454     break;
1455
1456   case 10:
1457     {ssyacc_add_where(icalss_yy_gauge,(yyvsp[(1) - (3)].v_string),ICALGAUGECOMPARE_EQUAL,(yyvsp[(3) - (3)].v_string)); }
1458     break;
1459
1460   case 11:
1461     {ssyacc_add_where(icalss_yy_gauge,(yyvsp[(1) - (3)].v_string),ICALGAUGECOMPARE_ISNULL,""); }
1462     break;
1463
1464   case 12:
1465     {ssyacc_add_where(icalss_yy_gauge,(yyvsp[(1) - (4)].v_string),ICALGAUGECOMPARE_ISNOTNULL,""); }
1466     break;
1467
1468   case 13:
1469     {ssyacc_add_where(icalss_yy_gauge,(yyvsp[(1) - (3)].v_string),ICALGAUGECOMPARE_NOTEQUAL,(yyvsp[(3) - (3)].v_string)); }
1470     break;
1471
1472   case 14:
1473     {ssyacc_add_where(icalss_yy_gauge,(yyvsp[(1) - (3)].v_string),ICALGAUGECOMPARE_LESS,(yyvsp[(3) - (3)].v_string)); }
1474     break;
1475
1476   case 15:
1477     {ssyacc_add_where(icalss_yy_gauge,(yyvsp[(1) - (3)].v_string),ICALGAUGECOMPARE_GREATER,(yyvsp[(3) - (3)].v_string)); }
1478     break;
1479
1480   case 16:
1481     {ssyacc_add_where(icalss_yy_gauge,(yyvsp[(1) - (3)].v_string),ICALGAUGECOMPARE_LESSEQUAL,(yyvsp[(3) - (3)].v_string)); }
1482     break;
1483
1484   case 17:
1485     {ssyacc_add_where(icalss_yy_gauge,(yyvsp[(1) - (3)].v_string),ICALGAUGECOMPARE_GREATEREQUAL,(yyvsp[(3) - (3)].v_string)); }
1486     break;
1487
1488   case 18:
1489     {set_logic(icalss_yy_gauge,ICALGAUGELOGIC_NONE);}
1490     break;
1491
1492   case 19:
1493     {set_logic(icalss_yy_gauge,ICALGAUGELOGIC_AND);}
1494     break;
1495
1496   case 20:
1497     {set_logic(icalss_yy_gauge,ICALGAUGELOGIC_OR);}
1498     break;
1499
1500
1501 /* Line 1267 of yacc.c.  */
1502       default: break;
1503     }
1504   YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc);
1505
1506   YYPOPSTACK (yylen);
1507   yylen = 0;
1508   YY_STACK_PRINT (yyss, yyssp);
1509
1510   *++yyvsp = yyval;
1511
1512
1513   /* Now `shift' the result of the reduction.  Determine what state
1514      that goes to, based on the state we popped back to and the rule
1515      number reduced by.  */
1516
1517   yyn = yyr1[yyn];
1518
1519   yystate = yypgoto[yyn - YYNTOKENS] + *yyssp;
1520   if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp)
1521     yystate = yytable[yystate];
1522   else
1523     yystate = yydefgoto[yyn - YYNTOKENS];
1524
1525   goto yynewstate;
1526
1527
1528 /*------------------------------------.
1529 | yyerrlab -- here on detecting error |
1530 `------------------------------------*/
1531 yyerrlab:
1532   /* If not already recovering from an error, report this error.  */
1533   if (!yyerrstatus)
1534     {
1535       ++yynerrs;
1536 #if ! YYERROR_VERBOSE
1537       yyerror (YY_("syntax error"));
1538 #else
1539       {
1540         YYSIZE_T yysize = yysyntax_error (0, yystate, yychar);
1541         if (yymsg_alloc < yysize && yymsg_alloc < YYSTACK_ALLOC_MAXIMUM)
1542           {
1543             YYSIZE_T yyalloc = 2 * yysize;
1544             if (! (yysize <= yyalloc && yyalloc <= YYSTACK_ALLOC_MAXIMUM))
1545               yyalloc = YYSTACK_ALLOC_MAXIMUM;
1546             if (yymsg != yymsgbuf)
1547               YYSTACK_FREE (yymsg);
1548             yymsg = (char *) YYSTACK_ALLOC (yyalloc);
1549             if (yymsg)
1550               yymsg_alloc = yyalloc;
1551             else
1552               {
1553                 yymsg = yymsgbuf;
1554                 yymsg_alloc = sizeof yymsgbuf;
1555               }
1556           }
1557
1558         if (0 < yysize && yysize <= yymsg_alloc)
1559           {
1560             (void) yysyntax_error (yymsg, yystate, yychar);
1561             yyerror (yymsg);
1562           }
1563         else
1564           {
1565             yyerror (YY_("syntax error"));
1566             if (yysize != 0)
1567               goto yyexhaustedlab;
1568           }
1569       }
1570 #endif
1571     }
1572
1573
1574
1575   if (yyerrstatus == 3)
1576     {
1577       /* If just tried and failed to reuse look-ahead token after an
1578          error, discard it.  */
1579
1580       if (yychar <= YYEOF)
1581         {
1582           /* Return failure if at end of input.  */
1583           if (yychar == YYEOF)
1584             YYABORT;
1585         }
1586       else
1587         {
1588           yydestruct ("Error: discarding",
1589                       yytoken, &yylval);
1590           yychar = YYEMPTY;
1591         }
1592     }
1593
1594   /* Else will try to reuse look-ahead token after shifting the error
1595      token.  */
1596   goto yyerrlab1;
1597
1598
1599 /*---------------------------------------------------.
1600 | yyerrorlab -- error raised explicitly by YYERROR.  |
1601 `---------------------------------------------------*/
1602 yyerrorlab:
1603
1604   /* Pacify compilers like GCC when the user code never invokes
1605      YYERROR and the label yyerrorlab therefore never appears in user
1606      code.  */
1607   if (/*CONSTCOND*/ 0)
1608      goto yyerrorlab;
1609
1610   /* Do not reclaim the symbols of the rule which action triggered
1611      this YYERROR.  */
1612   YYPOPSTACK (yylen);
1613   yylen = 0;
1614   YY_STACK_PRINT (yyss, yyssp);
1615   yystate = *yyssp;
1616   goto yyerrlab1;
1617
1618
1619 /*-------------------------------------------------------------.
1620 | yyerrlab1 -- common code for both syntax error and YYERROR.  |
1621 `-------------------------------------------------------------*/
1622 yyerrlab1:
1623   yyerrstatus = 3;      /* Each real token shifted decrements this.  */
1624
1625   for (;;)
1626     {
1627       yyn = yypact[yystate];
1628       if (yyn != YYPACT_NINF)
1629         {
1630           yyn += YYTERROR;
1631           if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR)
1632             {
1633               yyn = yytable[yyn];
1634               if (0 < yyn)
1635                 break;
1636             }
1637         }
1638
1639       /* Pop the current state because it cannot handle the error token.  */
1640       if (yyssp == yyss)
1641         YYABORT;
1642
1643
1644       yydestruct ("Error: popping",
1645                   yystos[yystate], yyvsp);
1646       YYPOPSTACK (1);
1647       yystate = *yyssp;
1648       YY_STACK_PRINT (yyss, yyssp);
1649     }
1650
1651   if (yyn == YYFINAL)
1652     YYACCEPT;
1653
1654   *++yyvsp = yylval;
1655
1656
1657   /* Shift the error token.  */
1658   YY_SYMBOL_PRINT ("Shifting", yystos[yyn], yyvsp, yylsp);
1659
1660   yystate = yyn;
1661   goto yynewstate;
1662
1663
1664 /*-------------------------------------.
1665 | yyacceptlab -- YYACCEPT comes here.  |
1666 `-------------------------------------*/
1667 yyacceptlab:
1668   yyresult = 0;
1669   goto yyreturn;
1670
1671 /*-----------------------------------.
1672 | yyabortlab -- YYABORT comes here.  |
1673 `-----------------------------------*/
1674 yyabortlab:
1675   yyresult = 1;
1676   goto yyreturn;
1677
1678 #ifndef yyoverflow
1679 /*-------------------------------------------------.
1680 | yyexhaustedlab -- memory exhaustion comes here.  |
1681 `-------------------------------------------------*/
1682 yyexhaustedlab:
1683   yyerror (YY_("memory exhausted"));
1684   yyresult = 2;
1685   /* Fall through.  */
1686 #endif
1687
1688 yyreturn:
1689   if (yychar != YYEOF && yychar != YYEMPTY)
1690      yydestruct ("Cleanup: discarding lookahead",
1691                  yytoken, &yylval);
1692   /* Do not reclaim the symbols of the rule which action triggered
1693      this YYABORT or YYACCEPT.  */
1694   YYPOPSTACK (yylen);
1695   YY_STACK_PRINT (yyss, yyssp);
1696   while (yyssp != yyss)
1697     {
1698       yydestruct ("Cleanup: popping",
1699                   yystos[*yyssp], yyvsp);
1700       YYPOPSTACK (1);
1701     }
1702 #ifndef yyoverflow
1703   if (yyss != yyssa)
1704     YYSTACK_FREE (yyss);
1705 #endif
1706 #if YYERROR_VERBOSE
1707   if (yymsg != yymsgbuf)
1708     YYSTACK_FREE (yymsg);
1709 #endif
1710   /* Make sure YYID is used.  */
1711   return YYID (yyresult);
1712 }
1713
1714
1715
1716
1717 static void ssyacc_add_where(struct icalgauge_impl* impl, char* str1, 
1718         icalgaugecompare compare , char* value_str)
1719 {
1720
1721     struct icalgauge_where *where;
1722     char *compstr, *propstr, *c, *s,*l;
1723     
1724     if ( (where = malloc(sizeof(struct icalgauge_where))) ==0){
1725         icalerror_set_errno(ICAL_NEWFAILED_ERROR);
1726         return;
1727     }
1728
1729     memset(where,0,sizeof(struct icalgauge_where));
1730     where->logic = ICALGAUGELOGIC_NONE;
1731     where->compare = ICALGAUGECOMPARE_NONE;
1732     where->comp = ICAL_NO_COMPONENT;
1733     where->prop = ICAL_NO_PROPERTY;
1734
1735     /* remove enclosing quotes */
1736     s = value_str;
1737     if(*s == '\''){
1738         s++;
1739     }
1740     l = s+strlen(s)-1;
1741     if(*l == '\''){
1742         *l=0;
1743     }
1744         
1745     where->value = strdup(s);
1746
1747     /* Is there a period in str1 ? If so, the string specified both a */
1748     /* component and a property                                       */ 
1749     if( (c = strrchr(str1,'.')) != 0){
1750         compstr = str1;
1751         propstr = c+1;
1752         *c = '\0';
1753     } else {
1754         compstr = 0;
1755         propstr = str1;
1756     }
1757
1758
1759     /* Handle the case where a component was specified */
1760     if(compstr != 0){
1761         where->comp = icalenum_string_to_component_kind(compstr);
1762     } else {
1763         where->comp = ICAL_NO_COMPONENT;
1764     }
1765
1766     where->prop = icalenum_string_to_property_kind(propstr);    
1767
1768     where->compare = compare;
1769
1770     if(where->value == 0){
1771         icalerror_set_errno(ICAL_NEWFAILED_ERROR);
1772         free(where->value);
1773         return;
1774     }
1775
1776     pvl_push(impl->where,where);
1777 }
1778
1779 static void set_logic(struct icalgauge_impl* impl,icalgaugelogic l)
1780 {
1781     pvl_elem e = pvl_tail(impl->where);
1782     struct icalgauge_where *where = pvl_data(e);
1783
1784     where->logic = l;
1785    
1786 }
1787
1788
1789
1790 static void ssyacc_add_select(struct icalgauge_impl* impl, char* str1)
1791 {
1792     char *c, *compstr, *propstr;
1793     struct icalgauge_where *where;
1794     
1795     /* Uses only the prop and comp fields of the where structure */
1796     if ( (where = malloc(sizeof(struct icalgauge_where))) ==0){
1797         icalerror_set_errno(ICAL_NEWFAILED_ERROR);
1798         return;
1799     }
1800
1801     memset(where,0,sizeof(struct icalgauge_where));
1802     where->logic = ICALGAUGELOGIC_NONE;
1803     where->compare = ICALGAUGECOMPARE_NONE;
1804     where->comp = ICAL_NO_COMPONENT;
1805     where->prop = ICAL_NO_PROPERTY;
1806
1807     /* Is there a period in str1 ? If so, the string specified both a */
1808     /* component and a property */
1809     if( (c = strrchr(str1,'.')) != 0){
1810         compstr = str1;
1811         propstr = c+1;
1812         *c = '\0';
1813     } else {
1814         compstr = 0;
1815         propstr = str1;
1816     }
1817
1818
1819     /* Handle the case where a component was specified */
1820     if(compstr != 0){
1821         where->comp = icalenum_string_to_component_kind(compstr);
1822     } else {
1823         where->comp = ICAL_NO_COMPONENT;
1824     }
1825
1826
1827     /* If the property was '*', then accept all properties */
1828     if(strcmp("*",propstr) == 0) {
1829         where->prop = ICAL_ANY_PROPERTY;            
1830     } else {
1831         where->prop = icalenum_string_to_property_kind(propstr);    
1832     }
1833     
1834
1835     if(where->prop == ICAL_NO_PROPERTY){
1836       free(where);
1837       icalerror_set_errno(ICAL_BADARG_ERROR);
1838       return;
1839     }
1840
1841     pvl_push(impl->select,where);
1842 }
1843
1844 static void ssyacc_add_from(struct icalgauge_impl* impl, char* str1)
1845 {
1846     icalcomponent_kind ckind;
1847
1848     ckind = icalenum_string_to_component_kind(str1);
1849
1850     if(ckind == ICAL_NO_COMPONENT){
1851         assert(0);
1852     }
1853
1854     pvl_push(impl->from,(void*)ckind);
1855
1856 }
1857
1858
1859 void sserror(char *s){
1860   fprintf(stderr,"Parse error \'%s\'\n", s);
1861   icalerror_set_errno(ICAL_MALFORMEDDATA_ERROR);
1862 }
1863