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