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 4 "thrift/thrifty.yy" /* yacc.c:339  */
66 
67 /*
68  * Licensed to the Apache Software Foundation (ASF) under one
69  * or more contributor license agreements. See the NOTICE file
70  * distributed with this work for additional information
71  * regarding copyright ownership. The ASF licenses this file
72  * to you under the Apache License, Version 2.0 (the
73  * "License"); you may not use this file except in compliance
74  * with the License. You may obtain a copy of the License at
75  *
76  *   http://www.apache.org/licenses/LICENSE-2.0
77  *
78  * Unless required by applicable law or agreed to in writing,
79  * software distributed under the License is distributed on an
80  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
81  * KIND, either express or implied. See the License for the
82  * specific language governing permissions and limitations
83  * under the License.
84  */
85 
86 /**
87  * Thrift parser.
88  *
89  * This parser is used on a thrift definition file.
90  *
91  */
92 
93 #ifndef __STDC_LIMIT_MACROS
94 #define __STDC_LIMIT_MACROS
95 #endif
96 #ifndef __STDC_FORMAT_MACROS
97 #define __STDC_FORMAT_MACROS
98 #endif
99 #include <stdio.h>
100 #include <string.h>
101 #ifndef _MSC_VER
102 #include <inttypes.h>
103 #else
104 #include <stdint.h>
105 #endif
106 #include <limits.h>
107 #ifdef _MSC_VER
108 #include "thrift/windows/config.h"
109 #endif
110 #include "thrift/main.h"
111 #include "thrift/common.h"
112 #include "thrift/globals.h"
113 #include "thrift/parse/t_program.h"
114 #include "thrift/parse/t_scope.h"
115 
116 #ifdef _MSC_VER
117 //warning C4065: switch statement contains 'default' but no 'case' labels
118 #pragma warning(disable:4065)
119 #endif
120 
121 /**
122  * This global variable is used for automatic numbering of field indices etc.
123  * when parsing the members of a struct. Field values are automatically
124  * assigned starting from -1 and working their way down.
125  */
126 int y_field_val = -1;
127 /**
128  * This global variable is used for automatic numbering of enum values.
129  * y_enum_val is the last value assigned; the next auto-assigned value will be
130  * y_enum_val+1, and then it continues working upwards.  Explicitly specified
131  * enum values reset y_enum_val to that value.
132  */
133 int32_t y_enum_val = -1;
134 int g_arglist = 0;
135 const int struct_is_struct = 0;
136 const int struct_is_union = 1;
137 
138 
139 #line 140 "thrift/thrifty.cc" /* yacc.c:339  */
140 
141 # ifndef YY_NULLPTR
142 #  if defined __cplusplus && 201103L <= __cplusplus
143 #   define YY_NULLPTR nullptr
144 #  else
145 #   define YY_NULLPTR 0
146 #  endif
147 # endif
148 
149 /* Enabling verbose error messages.  */
150 #ifdef YYERROR_VERBOSE
151 # undef YYERROR_VERBOSE
152 # define YYERROR_VERBOSE 1
153 #else
154 # define YYERROR_VERBOSE 0
155 #endif
156 
157 /* In a future release of Bison, this section will be replaced
158    by #include "y.tab.h".  */
159 #ifndef YY_YY_THRIFT_THRIFTY_HH_INCLUDED
160 # define YY_YY_THRIFT_THRIFTY_HH_INCLUDED
161 /* Debug traces.  */
162 #ifndef YYDEBUG
163 # define YYDEBUG 0
164 #endif
165 #if YYDEBUG
166 extern int yydebug;
167 #endif
168 /* "%code requires" blocks.  */
169 #line 1 "thrift/thrifty.yy" /* yacc.c:355  */
170 
171 #include "thrift/parse/t_program.h"
172 
173 #line 174 "thrift/thrifty.cc" /* yacc.c:355  */
174 
175 /* Token type.  */
176 #ifndef YYTOKENTYPE
177 # define YYTOKENTYPE
178   enum yytokentype
179   {
180     tok_identifier = 258,
181     tok_literal = 259,
182     tok_doctext = 260,
183     tok_int_constant = 261,
184     tok_dub_constant = 262,
185     tok_include = 263,
186     tok_namespace = 264,
187     tok_cpp_include = 265,
188     tok_cpp_type = 266,
189     tok_xsd_all = 267,
190     tok_xsd_optional = 268,
191     tok_xsd_nillable = 269,
192     tok_xsd_attrs = 270,
193     tok_void = 271,
194     tok_bool = 272,
195     tok_string = 273,
196     tok_binary = 274,
197     tok_slist = 275,
198     tok_senum = 276,
199     tok_i8 = 277,
200     tok_i16 = 278,
201     tok_i32 = 279,
202     tok_i64 = 280,
203     tok_double = 281,
204     tok_map = 282,
205     tok_list = 283,
206     tok_set = 284,
207     tok_oneway = 285,
208     tok_typedef = 286,
209     tok_struct = 287,
210     tok_xception = 288,
211     tok_throws = 289,
212     tok_extends = 290,
213     tok_service = 291,
214     tok_enum = 292,
215     tok_const = 293,
216     tok_required = 294,
217     tok_optional = 295,
218     tok_union = 296,
219     tok_reference = 297
220   };
221 #endif
222 /* Tokens.  */
223 #define tok_identifier 258
224 #define tok_literal 259
225 #define tok_doctext 260
226 #define tok_int_constant 261
227 #define tok_dub_constant 262
228 #define tok_include 263
229 #define tok_namespace 264
230 #define tok_cpp_include 265
231 #define tok_cpp_type 266
232 #define tok_xsd_all 267
233 #define tok_xsd_optional 268
234 #define tok_xsd_nillable 269
235 #define tok_xsd_attrs 270
236 #define tok_void 271
237 #define tok_bool 272
238 #define tok_string 273
239 #define tok_binary 274
240 #define tok_slist 275
241 #define tok_senum 276
242 #define tok_i8 277
243 #define tok_i16 278
244 #define tok_i32 279
245 #define tok_i64 280
246 #define tok_double 281
247 #define tok_map 282
248 #define tok_list 283
249 #define tok_set 284
250 #define tok_oneway 285
251 #define tok_typedef 286
252 #define tok_struct 287
253 #define tok_xception 288
254 #define tok_throws 289
255 #define tok_extends 290
256 #define tok_service 291
257 #define tok_enum 292
258 #define tok_const 293
259 #define tok_required 294
260 #define tok_optional 295
261 #define tok_union 296
262 #define tok_reference 297
263 
264 /* Value type.  */
265 #if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
266 
267 union YYSTYPE
268 {
269 #line 82 "thrift/thrifty.yy" /* yacc.c:355  */
270 
271   char*          id;
272   int64_t        iconst;
273   double         dconst;
274   bool           tbool;
275   t_doc*         tdoc;
276   t_type*        ttype;
277   t_base_type*   tbase;
278   t_typedef*     ttypedef;
279   t_enum*        tenum;
280   t_enum_value*  tenumv;
281   t_const*       tconst;
282   t_const_value* tconstv;
283   t_struct*      tstruct;
284   t_service*     tservice;
285   t_function*    tfunction;
286   t_field*       tfield;
287   char*          dtext;
288   t_field::e_req ereq;
289   t_annotation*  tannot;
290   t_field_id     tfieldid;
291 
292 #line 293 "thrift/thrifty.cc" /* yacc.c:355  */
293 };
294 
295 typedef union YYSTYPE YYSTYPE;
296 # define YYSTYPE_IS_TRIVIAL 1
297 # define YYSTYPE_IS_DECLARED 1
298 #endif
299 
300 
301 extern YYSTYPE yylval;
302 
303 int yyparse (void);
304 
305 #endif /* !YY_YY_THRIFT_THRIFTY_HH_INCLUDED  */
306 
307 /* Copy the second part of user declarations.  */
308 
309 #line 310 "thrift/thrifty.cc" /* yacc.c:358  */
310 
311 #ifdef short
312 # undef short
313 #endif
314 
315 #ifdef YYTYPE_UINT8
316 typedef YYTYPE_UINT8 yytype_uint8;
317 #else
318 typedef unsigned char yytype_uint8;
319 #endif
320 
321 #ifdef YYTYPE_INT8
322 typedef YYTYPE_INT8 yytype_int8;
323 #else
324 typedef signed char yytype_int8;
325 #endif
326 
327 #ifdef YYTYPE_UINT16
328 typedef YYTYPE_UINT16 yytype_uint16;
329 #else
330 typedef unsigned short int yytype_uint16;
331 #endif
332 
333 #ifdef YYTYPE_INT16
334 typedef YYTYPE_INT16 yytype_int16;
335 #else
336 typedef short int yytype_int16;
337 #endif
338 
339 #ifndef YYSIZE_T
340 # ifdef __SIZE_TYPE__
341 #  define YYSIZE_T __SIZE_TYPE__
342 # elif defined size_t
343 #  define YYSIZE_T size_t
344 # elif ! defined YYSIZE_T
345 #  include <stddef.h> /* INFRINGES ON USER NAME SPACE */
346 #  define YYSIZE_T size_t
347 # else
348 #  define YYSIZE_T unsigned int
349 # endif
350 #endif
351 
352 #define YYSIZE_MAXIMUM ((YYSIZE_T) -1)
353 
354 #ifndef YY_
355 # if defined YYENABLE_NLS && YYENABLE_NLS
356 #  if ENABLE_NLS
357 #   include <libintl.h> /* INFRINGES ON USER NAME SPACE */
358 #   define YY_(Msgid) dgettext ("bison-runtime", Msgid)
359 #  endif
360 # endif
361 # ifndef YY_
362 #  define YY_(Msgid) Msgid
363 # endif
364 #endif
365 
366 #ifndef YY_ATTRIBUTE
367 # if (defined __GNUC__                                               \
368       && (2 < __GNUC__ || (__GNUC__ == 2 && 96 <= __GNUC_MINOR__)))  \
369      || defined __SUNPRO_C && 0x5110 <= __SUNPRO_C
370 #  define YY_ATTRIBUTE(Spec) __attribute__(Spec)
371 # else
372 #  define YY_ATTRIBUTE(Spec) /* empty */
373 # endif
374 #endif
375 
376 #ifndef YY_ATTRIBUTE_PURE
377 # define YY_ATTRIBUTE_PURE   YY_ATTRIBUTE ((__pure__))
378 #endif
379 
380 #ifndef YY_ATTRIBUTE_UNUSED
381 # define YY_ATTRIBUTE_UNUSED YY_ATTRIBUTE ((__unused__))
382 #endif
383 
384 #if !defined _Noreturn \
385      && (!defined __STDC_VERSION__ || __STDC_VERSION__ < 201112)
386 # if defined _MSC_VER && 1200 <= _MSC_VER
387 #  define _Noreturn __declspec (noreturn)
388 # else
389 #  define _Noreturn YY_ATTRIBUTE ((__noreturn__))
390 # endif
391 #endif
392 
393 /* Suppress unused-variable warnings by "using" E.  */
394 #if ! defined lint || defined __GNUC__
395 # define YYUSE(E) ((void) (E))
396 #else
397 # define YYUSE(E) /* empty */
398 #endif
399 
400 #if defined __GNUC__ && 407 <= __GNUC__ * 100 + __GNUC_MINOR__
401 /* Suppress an incorrect diagnostic about yylval being uninitialized.  */
402 # define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN \
403     _Pragma ("GCC diagnostic push") \
404     _Pragma ("GCC diagnostic ignored \"-Wuninitialized\"")\
405     _Pragma ("GCC diagnostic ignored \"-Wmaybe-uninitialized\"")
406 # define YY_IGNORE_MAYBE_UNINITIALIZED_END \
407     _Pragma ("GCC diagnostic pop")
408 #else
409 # define YY_INITIAL_VALUE(Value) Value
410 #endif
411 #ifndef YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
412 # define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
413 # define YY_IGNORE_MAYBE_UNINITIALIZED_END
414 #endif
415 #ifndef YY_INITIAL_VALUE
416 # define YY_INITIAL_VALUE(Value) /* Nothing. */
417 #endif
418 
419 
420 #if ! defined yyoverflow || YYERROR_VERBOSE
421 
422 /* The parser invokes alloca or malloc; define the necessary symbols.  */
423 
424 # ifdef YYSTACK_USE_ALLOCA
425 #  if YYSTACK_USE_ALLOCA
426 #   ifdef __GNUC__
427 #    define YYSTACK_ALLOC __builtin_alloca
428 #   elif defined __BUILTIN_VA_ARG_INCR
429 #    include <alloca.h> /* INFRINGES ON USER NAME SPACE */
430 #   elif defined _AIX
431 #    define YYSTACK_ALLOC __alloca
432 #   elif defined _MSC_VER
433 #    include <malloc.h> /* INFRINGES ON USER NAME SPACE */
434 #    define alloca _alloca
435 #   else
436 #    define YYSTACK_ALLOC alloca
437 #    if ! defined _ALLOCA_H && ! defined EXIT_SUCCESS
438 #     include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
439       /* Use EXIT_SUCCESS as a witness for stdlib.h.  */
440 #     ifndef EXIT_SUCCESS
441 #      define EXIT_SUCCESS 0
442 #     endif
443 #    endif
444 #   endif
445 #  endif
446 # endif
447 
448 # ifdef YYSTACK_ALLOC
449    /* Pacify GCC's 'empty if-body' warning.  */
450 #  define YYSTACK_FREE(Ptr) do { /* empty */; } while (0)
451 #  ifndef YYSTACK_ALLOC_MAXIMUM
452     /* The OS might guarantee only one guard page at the bottom of the stack,
453        and a page size can be as small as 4096 bytes.  So we cannot safely
454        invoke alloca (N) if N exceeds 4096.  Use a slightly smaller number
455        to allow for a few compiler-allocated temporary stack slots.  */
456 #   define YYSTACK_ALLOC_MAXIMUM 4032 /* reasonable circa 2006 */
457 #  endif
458 # else
459 #  define YYSTACK_ALLOC YYMALLOC
460 #  define YYSTACK_FREE YYFREE
461 #  ifndef YYSTACK_ALLOC_MAXIMUM
462 #   define YYSTACK_ALLOC_MAXIMUM YYSIZE_MAXIMUM
463 #  endif
464 #  if (defined __cplusplus && ! defined EXIT_SUCCESS \
465        && ! ((defined YYMALLOC || defined malloc) \
466              && (defined YYFREE || defined free)))
467 #   include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
468 #   ifndef EXIT_SUCCESS
469 #    define EXIT_SUCCESS 0
470 #   endif
471 #  endif
472 #  ifndef YYMALLOC
473 #   define YYMALLOC malloc
474 #   if ! defined malloc && ! defined EXIT_SUCCESS
475 void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */
476 #   endif
477 #  endif
478 #  ifndef YYFREE
479 #   define YYFREE free
480 #   if ! defined free && ! defined EXIT_SUCCESS
481 void free (void *); /* INFRINGES ON USER NAME SPACE */
482 #   endif
483 #  endif
484 # endif
485 #endif /* ! defined yyoverflow || YYERROR_VERBOSE */
486 
487 
488 #if (! defined yyoverflow \
489      && (! defined __cplusplus \
490          || (defined YYSTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL)))
491 
492 /* A type that is properly aligned for any stack member.  */
493 union yyalloc
494 {
495   yytype_int16 yyss_alloc;
496   YYSTYPE yyvs_alloc;
497 };
498 
499 /* The size of the maximum gap between one aligned stack and the next.  */
500 # define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1)
501 
502 /* The size of an array large to enough to hold all stacks, each with
503    N elements.  */
504 # define YYSTACK_BYTES(N) \
505      ((N) * (sizeof (yytype_int16) + sizeof (YYSTYPE)) \
506       + YYSTACK_GAP_MAXIMUM)
507 
508 # define YYCOPY_NEEDED 1
509 
510 /* Relocate STACK from its old location to the new one.  The
511    local variables YYSIZE and YYSTACKSIZE give the old and new number of
512    elements in the stack, and YYPTR gives the new location of the
513    stack.  Advance YYPTR to a properly aligned location for the next
514    stack.  */
515 # define YYSTACK_RELOCATE(Stack_alloc, Stack)                           \
516     do                                                                  \
517       {                                                                 \
518         YYSIZE_T yynewbytes;                                            \
519         YYCOPY (&yyptr->Stack_alloc, Stack, yysize);                    \
520         Stack = &yyptr->Stack_alloc;                                    \
521         yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \
522         yyptr += yynewbytes / sizeof (*yyptr);                          \
523       }                                                                 \
524     while (0)
525 
526 #endif
527 
528 #if defined YYCOPY_NEEDED && YYCOPY_NEEDED
529 /* Copy COUNT objects from SRC to DST.  The source and destination do
530    not overlap.  */
531 # ifndef YYCOPY
532 #  if defined __GNUC__ && 1 < __GNUC__
533 #   define YYCOPY(Dst, Src, Count) \
534       __builtin_memcpy (Dst, Src, (Count) * sizeof (*(Src)))
535 #  else
536 #   define YYCOPY(Dst, Src, Count)              \
537       do                                        \
538         {                                       \
539           YYSIZE_T yyi;                         \
540           for (yyi = 0; yyi < (Count); yyi++)   \
541             (Dst)[yyi] = (Src)[yyi];            \
542         }                                       \
543       while (0)
544 #  endif
545 # endif
546 #endif /* !YYCOPY_NEEDED */
547 
548 /* YYFINAL -- State number of the termination state.  */
549 #define YYFINAL  3
550 /* YYLAST -- Last index in YYTABLE.  */
551 #define YYLAST   173
552 
553 /* YYNTOKENS -- Number of terminals.  */
554 #define YYNTOKENS  56
555 /* YYNNTS -- Number of nonterminals.  */
556 #define YYNNTS  60
557 /* YYNRULES -- Number of rules.  */
558 #define YYNRULES  115
559 /* YYNSTATES -- Number of states.  */
560 #define YYNSTATES  200
561 
562 /* YYTRANSLATE[YYX] -- Symbol number corresponding to YYX as returned
563    by yylex, with out-of-bounds checking.  */
564 #define YYUNDEFTOK  2
565 #define YYMAXUTOK   297
566 
567 #define YYTRANSLATE(YYX)                                                \
568   ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK)
569 
570 /* YYTRANSLATE[TOKEN-NUM] -- Symbol number corresponding to TOKEN-NUM
571    as returned by yylex, without out-of-bounds checking.  */
572 static const yytype_uint8 yytranslate[] =
573 {
574        0,     2,     2,     2,     2,     2,     2,     2,     2,     2,
575        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
576        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
577        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
578       52,    53,    43,     2,    44,     2,     2,     2,     2,     2,
579        2,     2,     2,     2,     2,     2,     2,     2,    51,    45,
580       54,    48,    55,     2,     2,     2,     2,     2,     2,     2,
581        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
582        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
583        2,    49,     2,    50,     2,     2,     2,     2,     2,     2,
584        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
585        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
586        2,     2,     2,    46,     2,    47,     2,     2,     2,     2,
587        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
588        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
589        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
590        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
591        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
592        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
593        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
594        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
595        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
596        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
597        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
598        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
599        2,     2,     2,     2,     2,     2,     1,     2,     3,     4,
600        5,     6,     7,     8,     9,    10,    11,    12,    13,    14,
601       15,    16,    17,    18,    19,    20,    21,    22,    23,    24,
602       25,    26,    27,    28,    29,    30,    31,    32,    33,    34,
603       35,    36,    37,    38,    39,    40,    41,    42
604 };
605 
606 #if YYDEBUG
607   /* YYRLINE[YYN] -- Source line where rule number YYN was defined.  */
608 static const yytype_uint16 yyrline[] =
609 {
610        0,   250,   250,   262,   273,   282,   287,   292,   296,   308,
611      316,   326,   339,   347,   352,   360,   375,   393,   400,   407,
612      414,   421,   430,   432,   435,   438,   451,   479,   486,   493,
613      507,   522,   534,   546,   553,   560,   567,   586,   595,   601,
614      606,   612,   617,   624,   631,   638,   645,   652,   659,   666,
615      670,   676,   691,   696,   701,   706,   711,   716,   721,   726,
616      731,   745,   759,   764,   769,   782,   787,   794,   800,   815,
617      820,   825,   835,   840,   850,   857,   891,   931,   941,   946,
618      951,   955,   967,   972,   981,   986,   991,   998,  1017,  1022,
619     1028,  1041,  1046,  1051,  1056,  1061,  1066,  1071,  1076,  1081,
620     1087,  1098,  1103,  1108,  1115,  1125,  1135,  1146,  1151,  1156,
621     1162,  1167,  1175,  1181,  1190,  1196
622 };
623 #endif
624 
625 #if YYDEBUG || YYERROR_VERBOSE || 0
626 /* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
627    First, the terminals, then, starting at YYNTOKENS, nonterminals.  */
628 static const char *const yytname[] =
629 {
630   "$end", "error", "$undefined", "tok_identifier", "tok_literal",
631   "tok_doctext", "tok_int_constant", "tok_dub_constant", "tok_include",
632   "tok_namespace", "tok_cpp_include", "tok_cpp_type", "tok_xsd_all",
633   "tok_xsd_optional", "tok_xsd_nillable", "tok_xsd_attrs", "tok_void",
634   "tok_bool", "tok_string", "tok_binary", "tok_slist", "tok_senum",
635   "tok_i8", "tok_i16", "tok_i32", "tok_i64", "tok_double", "tok_map",
636   "tok_list", "tok_set", "tok_oneway", "tok_typedef", "tok_struct",
637   "tok_xception", "tok_throws", "tok_extends", "tok_service", "tok_enum",
638   "tok_const", "tok_required", "tok_optional", "tok_union",
639   "tok_reference", "'*'", "','", "';'", "'{'", "'}'", "'='", "'['", "']'",
640   "':'", "'('", "')'", "'<'", "'>'", "$accept", "Program",
641   "CaptureDocText", "DestroyDocText", "HeaderList", "Header", "Include",
642   "DefinitionList", "Definition", "TypeDefinition",
643   "CommaOrSemicolonOptional", "Typedef", "Enum", "EnumDefList", "EnumDef",
644   "EnumValue", "Senum", "SenumDefList", "SenumDef", "Const", "ConstValue",
645   "ConstList", "ConstListContents", "ConstMap", "ConstMapContents",
646   "StructHead", "Struct", "XsdAll", "XsdOptional", "XsdNillable",
647   "XsdAttributes", "Xception", "Service", "FlagArgs", "UnflagArgs",
648   "Extends", "FunctionList", "Function", "Oneway", "Throws", "FieldList",
649   "Field", "FieldIdentifier", "FieldReference", "FieldRequiredness",
650   "FieldValue", "FunctionType", "FieldType", "BaseType", "SimpleBaseType",
651   "ContainerType", "SimpleContainerType", "MapType", "SetType", "ListType",
652   "CppType", "TypeAnnotations", "TypeAnnotationList", "TypeAnnotation",
653   "TypeAnnotationValue", YY_NULLPTR
654 };
655 #endif
656 
657 # ifdef YYPRINT
658 /* YYTOKNUM[NUM] -- (External) token number corresponding to the
659    (internal) symbol number NUM (which must be that of a token).  */
660 static const yytype_uint16 yytoknum[] =
661 {
662        0,   256,   257,   258,   259,   260,   261,   262,   263,   264,
663      265,   266,   267,   268,   269,   270,   271,   272,   273,   274,
664      275,   276,   277,   278,   279,   280,   281,   282,   283,   284,
665      285,   286,   287,   288,   289,   290,   291,   292,   293,   294,
666      295,   296,   297,    42,    44,    59,   123,   125,    61,    91,
667       93,    58,    40,    41,    60,    62
668 };
669 # endif
670 
671 #define YYPACT_NINF -124
672 
673 #define yypact_value_is_default(Yystate) \
674   (!!((Yystate) == (-124)))
675 
676 #define YYTABLE_NINF -64
677 
678 #define yytable_value_is_error(Yytable_value) \
679   0
680 
681   /* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
682      STATE-NUM.  */
683 static const yytype_int16 yypact[] =
684 {
685     -124,    15,     9,  -124,    26,    33,    35,    13,    36,  -124,
686     -124,   132,  -124,    39,    40,  -124,    41,   123,  -124,    42,
687       45,    46,   123,  -124,  -124,  -124,  -124,  -124,  -124,  -124,
688       61,  -124,  -124,  -124,    16,  -124,    19,  -124,  -124,  -124,
689     -124,  -124,  -124,  -124,  -124,  -124,  -124,    56,    18,    56,
690       70,  -124,    16,  -124,    16,  -124,  -124,  -124,    29,    43,
691       30,    74,    68,  -124,  -124,  -124,    77,    28,   123,    34,
692       16,  -124,  -124,  -124,    80,    38,  -124,    44,  -124,    48,
693        7,     3,  -124,   123,    32,   123,   -23,    49,  -124,  -124,
694       50,    25,  -124,    47,  -124,  -124,   -23,    16,  -124,    55,
695       56,    65,  -124,  -124,  -124,    16,    84,  -124,  -124,    16,
696       98,  -124,  -124,  -124,  -124,  -124,  -124,  -124,   -23,  -124,
697     -124,    75,   117,   -23,  -124,  -124,   123,  -124,  -124,  -124,
698       51,    -2,    76,  -124,    79,    16,     5,    20,  -124,    16,
699     -124,  -124,    78,  -124,  -124,  -124,   123,    95,    82,  -124,
700      124,   -23,  -124,    81,  -124,   -23,  -124,  -124,    89,  -124,
701       90,    16,  -124,  -124,    25,  -124,  -124,   131,  -124,   133,
702     -124,  -124,   -23,    87,    92,  -124,    25,   141,  -124,  -124,
703     -124,   142,   102,  -124,   143,   125,   111,    16,   108,    16,
704     -124,   -23,  -124,   -23,   114,  -124,   109,  -124,  -124,  -124
705 };
706 
707   /* YYDEFACT[STATE-NUM] -- Default reduction number in state STATE-NUM.
708      Performed when YYTABLE does not specify something else to do.  Zero
709      means the default is an error.  */
710 static const yytype_uint8 yydefact[] =
711 {
712        6,     0,    13,     1,     0,     3,     0,     0,     0,     5,
713        7,     0,    11,     0,     0,    10,     0,     0,    49,     0,
714        0,     0,     0,    50,    12,    15,    17,    18,    19,    14,
715        0,    20,    21,    16,   110,     9,     0,    87,    94,    91,
716       92,    93,    95,    96,    97,    98,    99,   108,     0,   108,
717        0,    88,   110,    89,   110,   101,   102,   103,     0,    65,
718        0,     0,    53,   112,     8,    34,     0,     0,     0,     0,
719      110,    90,   100,    74,     0,     0,    28,     0,    52,     0,
720        0,     0,   107,     0,     0,     0,    24,     3,    64,    62,
721        3,     0,    74,   115,   109,   111,    24,   110,    33,     0,
722      108,     0,    22,    23,    25,   110,    77,    73,    67,   110,
723        0,    27,    40,    39,    37,    38,    48,    45,    24,    41,
724       42,     3,     0,    24,    35,    32,     0,   106,   105,    60,
725        0,    82,     3,    26,    31,   110,     0,     0,    36,   110,
726      114,   113,     0,    76,    80,    81,     0,    70,     0,    66,
727        0,    24,    46,     0,    43,    24,    51,   104,    79,    69,
728        0,   110,    30,    29,     0,    44,    78,     0,    86,     0,
729       85,    61,    24,    84,     0,    47,     0,    55,    74,    83,
730       54,    57,     3,    56,    59,    72,     0,   110,     0,   110,
731       74,    24,    74,    24,     3,    75,     3,    68,    58,    71
732 };
733 
734   /* YYPGOTO[NTERM-NUM].  */
735 static const yytype_int8 yypgoto[] =
736 {
737     -124,  -124,    -4,  -124,  -124,  -124,  -124,  -124,  -124,  -124,
738      -93,  -124,  -124,  -124,  -124,  -124,  -124,  -124,  -124,  -124,
739     -123,  -124,  -124,  -124,  -124,  -124,  -124,  -124,  -124,  -124,
740     -124,  -124,  -124,  -124,  -124,  -124,  -124,  -124,  -124,  -124,
741      -87,  -124,  -124,  -124,  -124,  -124,  -124,   -22,  -124,  -124,
742     -124,  -124,  -124,  -124,  -124,   -43,   -50,  -124,  -124,  -124
743 };
744 
745   /* YYDEFGOTO[NTERM-NUM].  */
746 static const yytype_int16 yydefgoto[] =
747 {
748       -1,     1,   106,     4,     2,     9,    10,     5,    24,    25,
749      104,    26,    27,    90,   111,   135,    28,    81,    98,    29,
750      118,   119,   137,   120,   136,    30,    31,    79,   181,   184,
751      187,    32,    33,   108,   148,    75,   132,   149,   160,   189,
752       87,   107,   131,   167,   146,   177,   169,    50,    51,    52,
753       53,    54,    55,    56,    57,    67,    64,    80,    95,   123
754 };
755 
756   /* YYTABLE[YYPACT[STATE-NUM]] -- What to do in state STATE-NUM.  If
757      positive, shift that token.  If negative, reduce the rule whose
758      number is the opposite.  If YYTABLE_NINF, syntax error.  */
759 static const yytype_int16 yytable[] =
760 {
761       61,    11,    71,   124,    72,   121,    69,    96,   112,   113,
762       93,   114,   115,   153,   155,     3,    13,    -4,    -4,    -4,
763       86,   102,   103,   112,   113,   138,   114,   115,   112,   113,
764      141,   114,   115,    -2,     6,     7,     8,   144,   145,    12,
765       15,   172,    34,    35,    36,    58,    84,   125,    59,    60,
766       97,   116,   152,   179,   117,   129,    14,   127,   163,   133,
767       94,    99,   165,   101,    62,    65,   116,    66,    63,   117,
768      154,   116,    68,    70,   117,    73,    76,    77,    74,   175,
769       78,    82,    83,    88,    89,   151,   110,   100,    85,   156,
770      130,   182,    91,    37,    92,   122,   105,   109,   195,   126,
771      197,   134,   143,   194,   142,   196,   168,    38,    39,    40,
772       41,   171,    42,    43,    44,    45,    46,    47,    48,    49,
773      128,   140,   139,   -63,   158,   159,    37,   150,   147,   161,
774      162,   166,   164,   157,   173,   176,   174,   191,   170,   193,
775       38,    39,    40,    41,   178,    42,    43,    44,    45,    46,
776       47,    48,    49,    16,   180,   185,   183,   190,   186,   188,
777      192,   198,   199,    17,    18,    19,     0,     0,    20,    21,
778       22,     0,     0,    23
779 };
780 
781 static const yytype_int16 yycheck[] =
782 {
783       22,     5,    52,    96,    54,    92,    49,     4,     3,     4,
784        3,     6,     7,   136,   137,     0,     3,     8,     9,    10,
785       70,    44,    45,     3,     4,   118,     6,     7,     3,     4,
786      123,     6,     7,     0,     8,     9,    10,    39,    40,     4,
787        4,   164,     3,     3,     3,     3,    68,    97,     3,     3,
788       47,    46,    47,   176,    49,   105,    43,   100,   151,   109,
789       53,    83,   155,    85,     3,    46,    46,    11,    52,    49,
790       50,    46,    54,     3,    49,    46,    46,     3,    35,   172,
791       12,     4,    54,     3,    46,   135,    90,    55,    54,   139,
792        6,   178,    48,     3,    46,    48,    47,    47,   191,    44,
793      193,     3,    51,   190,   126,   192,    16,    17,    18,    19,
794       20,   161,    22,    23,    24,    25,    26,    27,    28,    29,
795       55,     4,    47,    47,   146,    30,     3,    48,   132,    47,
796        6,    42,    51,    55,     3,    48,     3,   187,   160,   189,
797       17,    18,    19,    20,    52,    22,    23,    24,    25,    26,
798       27,    28,    29,    21,    13,    53,    14,    46,    15,    34,
799       52,    47,    53,    31,    32,    33,    -1,    -1,    36,    37,
800       38,    -1,    -1,    41
801 };
802 
803   /* YYSTOS[STATE-NUM] -- The (internal number of the) accessing
804      symbol of state STATE-NUM.  */
805 static const yytype_uint8 yystos[] =
806 {
807        0,    57,    60,     0,    59,    63,     8,     9,    10,    61,
808       62,    58,     4,     3,    43,     4,    21,    31,    32,    33,
809       36,    37,    38,    41,    64,    65,    67,    68,    72,    75,
810       81,    82,    87,    88,     3,     3,     3,     3,    17,    18,
811       19,    20,    22,    23,    24,    25,    26,    27,    28,    29,
812      103,   104,   105,   106,   107,   108,   109,   110,     3,     3,
813        3,   103,     3,    52,   112,    46,    11,   111,    54,   111,
814        3,   112,   112,    46,    35,    91,    46,     3,    12,    83,
815      113,    73,     4,    54,   103,    54,   112,    96,     3,    46,
816       69,    48,    46,     3,    53,   114,     4,    47,    74,   103,
817       55,   103,    44,    45,    66,    47,    58,    97,    89,    47,
818       58,    70,     3,     4,     6,     7,    46,    49,    76,    77,
819       79,    96,    48,   115,    66,   112,    44,   111,    55,   112,
820        6,    98,    92,   112,     3,    71,    80,    78,    66,    47,
821        4,    66,   103,    51,    39,    40,   100,    58,    90,    93,
822       48,   112,    47,    76,    50,    76,   112,    55,   103,    30,
823       94,    47,     6,    66,    51,    66,    42,    99,    16,   102,
824      103,   112,    76,     3,     3,    66,    48,   101,    52,    76,
825       13,    84,    96,    14,    85,    53,    15,    86,    34,    95,
826       46,   112,    52,   112,    96,    66,    96,    66,    47,    53
827 };
828 
829   /* YYR1[YYN] -- Symbol number of symbol that rule YYN derives.  */
830 static const yytype_uint8 yyr1[] =
831 {
832        0,    56,    57,    58,    59,    60,    60,    61,    61,    61,
833       61,    62,    63,    63,    64,    64,    64,    65,    65,    65,
834       65,    65,    66,    66,    66,    67,    68,    69,    69,    70,
835       71,    71,    72,    73,    73,    74,    75,    76,    76,    76,
836       76,    76,    76,    77,    78,    78,    79,    80,    80,    81,
837       81,    82,    83,    83,    84,    84,    85,    85,    86,    86,
838       87,    88,    89,    90,    91,    91,    92,    92,    93,    94,
839       94,    95,    95,    96,    96,    97,    98,    98,    99,    99,
840      100,   100,   100,   101,   101,   102,   102,   103,   103,   103,
841      104,   105,   105,   105,   105,   105,   105,   105,   105,   105,
842      106,   107,   107,   107,   108,   109,   110,   111,   111,   112,
843      112,   113,   113,   114,   115,   115
844 };
845 
846   /* YYR2[YYN] -- Number of symbols on the right hand side of rule YYN.  */
847 static const yytype_uint8 yyr2[] =
848 {
849        0,     2,     2,     0,     0,     3,     0,     1,     4,     3,
850        2,     2,     3,     0,     1,     1,     1,     1,     1,     1,
851        1,     1,     1,     1,     0,     5,     6,     2,     0,     4,
852        3,     1,     6,     2,     0,     2,     6,     1,     1,     1,
853        1,     1,     1,     3,     3,     0,     3,     5,     0,     1,
854        1,     7,     1,     0,     1,     0,     1,     0,     4,     0,
855        6,     9,     0,     0,     2,     0,     2,     0,    10,     1,
856        0,     4,     0,     2,     0,    12,     2,     0,     1,     0,
857        1,     1,     0,     2,     0,     1,     1,     1,     1,     1,
858        2,     1,     1,     1,     1,     1,     1,     1,     1,     1,
859        2,     1,     1,     1,     7,     5,     5,     2,     0,     3,
860        0,     2,     0,     3,     2,     0
861 };
862 
863 
864 #define yyerrok         (yyerrstatus = 0)
865 #define yyclearin       (yychar = YYEMPTY)
866 #define YYEMPTY         (-2)
867 #define YYEOF           0
868 
869 #define YYACCEPT        goto yyacceptlab
870 #define YYABORT         goto yyabortlab
871 #define YYERROR         goto yyerrorlab
872 
873 
874 #define YYRECOVERING()  (!!yyerrstatus)
875 
876 #define YYBACKUP(Token, Value)                                  \
877 do                                                              \
878   if (yychar == YYEMPTY)                                        \
879     {                                                           \
880       yychar = (Token);                                         \
881       yylval = (Value);                                         \
882       YYPOPSTACK (yylen);                                       \
883       yystate = *yyssp;                                         \
884       goto yybackup;                                            \
885     }                                                           \
886   else                                                          \
887     {                                                           \
888       yyerror (YY_("syntax error: cannot back up")); \
889       YYERROR;                                                  \
890     }                                                           \
891 while (0)
892 
893 /* Error token number */
894 #define YYTERROR        1
895 #define YYERRCODE       256
896 
897 
898 
899 /* Enable debugging if requested.  */
900 #if YYDEBUG
901 
902 # ifndef YYFPRINTF
903 #  include <stdio.h> /* INFRINGES ON USER NAME SPACE */
904 #  define YYFPRINTF fprintf
905 # endif
906 
907 # define YYDPRINTF(Args)                        \
908 do {                                            \
909   if (yydebug)                                  \
910     YYFPRINTF Args;                             \
911 } while (0)
912 
913 /* This macro is provided for backward compatibility. */
914 #ifndef YY_LOCATION_PRINT
915 # define YY_LOCATION_PRINT(File, Loc) ((void) 0)
916 #endif
917 
918 
919 # define YY_SYMBOL_PRINT(Title, Type, Value, Location)                    \
920 do {                                                                      \
921   if (yydebug)                                                            \
922     {                                                                     \
923       YYFPRINTF (stderr, "%s ", Title);                                   \
924       yy_symbol_print (stderr,                                            \
925                   Type, Value); \
926       YYFPRINTF (stderr, "\n");                                           \
927     }                                                                     \
928 } while (0)
929 
930 
931 /*----------------------------------------.
932 | Print this symbol's value on YYOUTPUT.  |
933 `----------------------------------------*/
934 
935 static void
yy_symbol_value_print(FILE * yyoutput,int yytype,YYSTYPE const * const yyvaluep)936 yy_symbol_value_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep)
937 {
938   FILE *yyo = yyoutput;
939   YYUSE (yyo);
940   if (!yyvaluep)
941     return;
942 # ifdef YYPRINT
943   if (yytype < YYNTOKENS)
944     YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep);
945 # endif
946   YYUSE (yytype);
947 }
948 
949 
950 /*--------------------------------.
951 | Print this symbol on YYOUTPUT.  |
952 `--------------------------------*/
953 
954 static void
yy_symbol_print(FILE * yyoutput,int yytype,YYSTYPE const * const yyvaluep)955 yy_symbol_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep)
956 {
957   YYFPRINTF (yyoutput, "%s %s (",
958              yytype < YYNTOKENS ? "token" : "nterm", yytname[yytype]);
959 
960   yy_symbol_value_print (yyoutput, yytype, yyvaluep);
961   YYFPRINTF (yyoutput, ")");
962 }
963 
964 /*------------------------------------------------------------------.
965 | yy_stack_print -- Print the state stack from its BOTTOM up to its |
966 | TOP (included).                                                   |
967 `------------------------------------------------------------------*/
968 
969 static void
yy_stack_print(yytype_int16 * yybottom,yytype_int16 * yytop)970 yy_stack_print (yytype_int16 *yybottom, yytype_int16 *yytop)
971 {
972   YYFPRINTF (stderr, "Stack now");
973   for (; yybottom <= yytop; yybottom++)
974     {
975       int yybot = *yybottom;
976       YYFPRINTF (stderr, " %d", yybot);
977     }
978   YYFPRINTF (stderr, "\n");
979 }
980 
981 # define YY_STACK_PRINT(Bottom, Top)                            \
982 do {                                                            \
983   if (yydebug)                                                  \
984     yy_stack_print ((Bottom), (Top));                           \
985 } while (0)
986 
987 
988 /*------------------------------------------------.
989 | Report that the YYRULE is going to be reduced.  |
990 `------------------------------------------------*/
991 
992 static void
yy_reduce_print(yytype_int16 * yyssp,YYSTYPE * yyvsp,int yyrule)993 yy_reduce_print (yytype_int16 *yyssp, YYSTYPE *yyvsp, int yyrule)
994 {
995   unsigned long int yylno = yyrline[yyrule];
996   int yynrhs = yyr2[yyrule];
997   int yyi;
998   YYFPRINTF (stderr, "Reducing stack by rule %d (line %lu):\n",
999              yyrule - 1, yylno);
1000   /* The symbols being reduced.  */
1001   for (yyi = 0; yyi < yynrhs; yyi++)
1002     {
1003       YYFPRINTF (stderr, "   $%d = ", yyi + 1);
1004       yy_symbol_print (stderr,
1005                        yystos[yyssp[yyi + 1 - yynrhs]],
1006                        &(yyvsp[(yyi + 1) - (yynrhs)])
1007                                               );
1008       YYFPRINTF (stderr, "\n");
1009     }
1010 }
1011 
1012 # define YY_REDUCE_PRINT(Rule)          \
1013 do {                                    \
1014   if (yydebug)                          \
1015     yy_reduce_print (yyssp, yyvsp, Rule); \
1016 } while (0)
1017 
1018 /* Nonzero means print parse trace.  It is left uninitialized so that
1019    multiple parsers can coexist.  */
1020 int yydebug;
1021 #else /* !YYDEBUG */
1022 # define YYDPRINTF(Args)
1023 # define YY_SYMBOL_PRINT(Title, Type, Value, Location)
1024 # define YY_STACK_PRINT(Bottom, Top)
1025 # define YY_REDUCE_PRINT(Rule)
1026 #endif /* !YYDEBUG */
1027 
1028 
1029 /* YYINITDEPTH -- initial size of the parser's stacks.  */
1030 #ifndef YYINITDEPTH
1031 # define YYINITDEPTH 200
1032 #endif
1033 
1034 /* YYMAXDEPTH -- maximum size the stacks can grow to (effective only
1035    if the built-in stack extension method is used).
1036 
1037    Do not make this value too large; the results are undefined if
1038    YYSTACK_ALLOC_MAXIMUM < YYSTACK_BYTES (YYMAXDEPTH)
1039    evaluated with infinite-precision integer arithmetic.  */
1040 
1041 #ifndef YYMAXDEPTH
1042 # define YYMAXDEPTH 10000
1043 #endif
1044 
1045 
1046 #if YYERROR_VERBOSE
1047 
1048 # ifndef yystrlen
1049 #  if defined __GLIBC__ && defined _STRING_H
1050 #   define yystrlen strlen
1051 #  else
1052 /* Return the length of YYSTR.  */
1053 static YYSIZE_T
yystrlen(const char * yystr)1054 yystrlen (const char *yystr)
1055 {
1056   YYSIZE_T yylen;
1057   for (yylen = 0; yystr[yylen]; yylen++)
1058     continue;
1059   return yylen;
1060 }
1061 #  endif
1062 # endif
1063 
1064 # ifndef yystpcpy
1065 #  if defined __GLIBC__ && defined _STRING_H && defined _GNU_SOURCE
1066 #   define yystpcpy stpcpy
1067 #  else
1068 /* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in
1069    YYDEST.  */
1070 static char *
yystpcpy(char * yydest,const char * yysrc)1071 yystpcpy (char *yydest, const char *yysrc)
1072 {
1073   char *yyd = yydest;
1074   const char *yys = yysrc;
1075 
1076   while ((*yyd++ = *yys++) != '\0')
1077     continue;
1078 
1079   return yyd - 1;
1080 }
1081 #  endif
1082 # endif
1083 
1084 # ifndef yytnamerr
1085 /* Copy to YYRES the contents of YYSTR after stripping away unnecessary
1086    quotes and backslashes, so that it's suitable for yyerror.  The
1087    heuristic is that double-quoting is unnecessary unless the string
1088    contains an apostrophe, a comma, or backslash (other than
1089    backslash-backslash).  YYSTR is taken from yytname.  If YYRES is
1090    null, do not copy; instead, return the length of what the result
1091    would have been.  */
1092 static YYSIZE_T
yytnamerr(char * yyres,const char * yystr)1093 yytnamerr (char *yyres, const char *yystr)
1094 {
1095   if (*yystr == '"')
1096     {
1097       YYSIZE_T yyn = 0;
1098       char const *yyp = yystr;
1099 
1100       for (;;)
1101         switch (*++yyp)
1102           {
1103           case '\'':
1104           case ',':
1105             goto do_not_strip_quotes;
1106 
1107           case '\\':
1108             if (*++yyp != '\\')
1109               goto do_not_strip_quotes;
1110             /* Fall through.  */
1111           default:
1112             if (yyres)
1113               yyres[yyn] = *yyp;
1114             yyn++;
1115             break;
1116 
1117           case '"':
1118             if (yyres)
1119               yyres[yyn] = '\0';
1120             return yyn;
1121           }
1122     do_not_strip_quotes: ;
1123     }
1124 
1125   if (! yyres)
1126     return yystrlen (yystr);
1127 
1128   return yystpcpy (yyres, yystr) - yyres;
1129 }
1130 # endif
1131 
1132 /* Copy into *YYMSG, which is of size *YYMSG_ALLOC, an error message
1133    about the unexpected token YYTOKEN for the state stack whose top is
1134    YYSSP.
1135 
1136    Return 0 if *YYMSG was successfully written.  Return 1 if *YYMSG is
1137    not large enough to hold the message.  In that case, also set
1138    *YYMSG_ALLOC to the required number of bytes.  Return 2 if the
1139    required number of bytes is too large to store.  */
1140 static int
yysyntax_error(YYSIZE_T * yymsg_alloc,char ** yymsg,yytype_int16 * yyssp,int yytoken)1141 yysyntax_error (YYSIZE_T *yymsg_alloc, char **yymsg,
1142                 yytype_int16 *yyssp, int yytoken)
1143 {
1144   YYSIZE_T yysize0 = yytnamerr (YY_NULLPTR, yytname[yytoken]);
1145   YYSIZE_T yysize = yysize0;
1146   enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 };
1147   /* Internationalized format string. */
1148   const char *yyformat = YY_NULLPTR;
1149   /* Arguments of yyformat. */
1150   char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM];
1151   /* Number of reported tokens (one for the "unexpected", one per
1152      "expected"). */
1153   int yycount = 0;
1154 
1155   /* There are many possibilities here to consider:
1156      - If this state is a consistent state with a default action, then
1157        the only way this function was invoked is if the default action
1158        is an error action.  In that case, don't check for expected
1159        tokens because there are none.
1160      - The only way there can be no lookahead present (in yychar) is if
1161        this state is a consistent state with a default action.  Thus,
1162        detecting the absence of a lookahead is sufficient to determine
1163        that there is no unexpected or expected token to report.  In that
1164        case, just report a simple "syntax error".
1165      - Don't assume there isn't a lookahead just because this state is a
1166        consistent state with a default action.  There might have been a
1167        previous inconsistent state, consistent state with a non-default
1168        action, or user semantic action that manipulated yychar.
1169      - Of course, the expected token list depends on states to have
1170        correct lookahead information, and it depends on the parser not
1171        to perform extra reductions after fetching a lookahead from the
1172        scanner and before detecting a syntax error.  Thus, state merging
1173        (from LALR or IELR) and default reductions corrupt the expected
1174        token list.  However, the list is correct for canonical LR with
1175        one exception: it will still contain any token that will not be
1176        accepted due to an error action in a later state.
1177   */
1178   if (yytoken != YYEMPTY)
1179     {
1180       int yyn = yypact[*yyssp];
1181       yyarg[yycount++] = yytname[yytoken];
1182       if (!yypact_value_is_default (yyn))
1183         {
1184           /* Start YYX at -YYN if negative to avoid negative indexes in
1185              YYCHECK.  In other words, skip the first -YYN actions for
1186              this state because they are default actions.  */
1187           int yyxbegin = yyn < 0 ? -yyn : 0;
1188           /* Stay within bounds of both yycheck and yytname.  */
1189           int yychecklim = YYLAST - yyn + 1;
1190           int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS;
1191           int yyx;
1192 
1193           for (yyx = yyxbegin; yyx < yyxend; ++yyx)
1194             if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR
1195                 && !yytable_value_is_error (yytable[yyx + yyn]))
1196               {
1197                 if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM)
1198                   {
1199                     yycount = 1;
1200                     yysize = yysize0;
1201                     break;
1202                   }
1203                 yyarg[yycount++] = yytname[yyx];
1204                 {
1205                   YYSIZE_T yysize1 = yysize + yytnamerr (YY_NULLPTR, yytname[yyx]);
1206                   if (! (yysize <= yysize1
1207                          && yysize1 <= YYSTACK_ALLOC_MAXIMUM))
1208                     return 2;
1209                   yysize = yysize1;
1210                 }
1211               }
1212         }
1213     }
1214 
1215   switch (yycount)
1216     {
1217 # define YYCASE_(N, S)                      \
1218       case N:                               \
1219         yyformat = S;                       \
1220       break
1221       YYCASE_(0, YY_("syntax error"));
1222       YYCASE_(1, YY_("syntax error, unexpected %s"));
1223       YYCASE_(2, YY_("syntax error, unexpected %s, expecting %s"));
1224       YYCASE_(3, YY_("syntax error, unexpected %s, expecting %s or %s"));
1225       YYCASE_(4, YY_("syntax error, unexpected %s, expecting %s or %s or %s"));
1226       YYCASE_(5, YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s"));
1227 # undef YYCASE_
1228     }
1229 
1230   {
1231     YYSIZE_T yysize1 = yysize + yystrlen (yyformat);
1232     if (! (yysize <= yysize1 && yysize1 <= YYSTACK_ALLOC_MAXIMUM))
1233       return 2;
1234     yysize = yysize1;
1235   }
1236 
1237   if (*yymsg_alloc < yysize)
1238     {
1239       *yymsg_alloc = 2 * yysize;
1240       if (! (yysize <= *yymsg_alloc
1241              && *yymsg_alloc <= YYSTACK_ALLOC_MAXIMUM))
1242         *yymsg_alloc = YYSTACK_ALLOC_MAXIMUM;
1243       return 1;
1244     }
1245 
1246   /* Avoid sprintf, as that infringes on the user's name space.
1247      Don't have undefined behavior even if the translation
1248      produced a string with the wrong number of "%s"s.  */
1249   {
1250     char *yyp = *yymsg;
1251     int yyi = 0;
1252     while ((*yyp = *yyformat) != '\0')
1253       if (*yyp == '%' && yyformat[1] == 's' && yyi < yycount)
1254         {
1255           yyp += yytnamerr (yyp, yyarg[yyi++]);
1256           yyformat += 2;
1257         }
1258       else
1259         {
1260           yyp++;
1261           yyformat++;
1262         }
1263   }
1264   return 0;
1265 }
1266 #endif /* YYERROR_VERBOSE */
1267 
1268 /*-----------------------------------------------.
1269 | Release the memory associated to this symbol.  |
1270 `-----------------------------------------------*/
1271 
1272 static void
yydestruct(const char * yymsg,int yytype,YYSTYPE * yyvaluep)1273 yydestruct (const char *yymsg, int yytype, YYSTYPE *yyvaluep)
1274 {
1275   YYUSE (yyvaluep);
1276   if (!yymsg)
1277     yymsg = "Deleting";
1278   YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp);
1279 
1280   YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
1281   YYUSE (yytype);
1282   YY_IGNORE_MAYBE_UNINITIALIZED_END
1283 }
1284 
1285 
1286 
1287 
1288 /* The lookahead symbol.  */
1289 int yychar;
1290 
1291 /* The semantic value of the lookahead symbol.  */
1292 YYSTYPE yylval;
1293 /* Number of syntax errors so far.  */
1294 int yynerrs;
1295 
1296 
1297 /*----------.
1298 | yyparse.  |
1299 `----------*/
1300 
1301 int
yyparse(void)1302 yyparse (void)
1303 {
1304     int yystate;
1305     /* Number of tokens to shift before error messages enabled.  */
1306     int yyerrstatus;
1307 
1308     /* The stacks and their tools:
1309        'yyss': related to states.
1310        'yyvs': related to semantic values.
1311 
1312        Refer to the stacks through separate pointers, to allow yyoverflow
1313        to reallocate them elsewhere.  */
1314 
1315     /* The state stack.  */
1316     yytype_int16 yyssa[YYINITDEPTH];
1317     yytype_int16 *yyss;
1318     yytype_int16 *yyssp;
1319 
1320     /* The semantic value stack.  */
1321     YYSTYPE yyvsa[YYINITDEPTH];
1322     YYSTYPE *yyvs;
1323     YYSTYPE *yyvsp;
1324 
1325     YYSIZE_T yystacksize;
1326 
1327   int yyn;
1328   int yyresult;
1329   /* Lookahead token as an internal (translated) token number.  */
1330   int yytoken = 0;
1331   /* The variables used to return semantic value and location from the
1332      action routines.  */
1333   YYSTYPE yyval;
1334 
1335 #if YYERROR_VERBOSE
1336   /* Buffer for error messages, and its allocated size.  */
1337   char yymsgbuf[128];
1338   char *yymsg = yymsgbuf;
1339   YYSIZE_T yymsg_alloc = sizeof yymsgbuf;
1340 #endif
1341 
1342 #define YYPOPSTACK(N)   (yyvsp -= (N), yyssp -= (N))
1343 
1344   /* The number of symbols on the RHS of the reduced rule.
1345      Keep to zero when no symbol should be popped.  */
1346   int yylen = 0;
1347 
1348   yyssp = yyss = yyssa;
1349   yyvsp = yyvs = yyvsa;
1350   yystacksize = YYINITDEPTH;
1351 
1352   YYDPRINTF ((stderr, "Starting parse\n"));
1353 
1354   yystate = 0;
1355   yyerrstatus = 0;
1356   yynerrs = 0;
1357   yychar = YYEMPTY; /* Cause a token to be read.  */
1358   goto yysetstate;
1359 
1360 /*------------------------------------------------------------.
1361 | yynewstate -- Push a new state, which is found in yystate.  |
1362 `------------------------------------------------------------*/
1363  yynewstate:
1364   /* In all cases, when you get here, the value and location stacks
1365      have just been pushed.  So pushing a state here evens the stacks.  */
1366   yyssp++;
1367 
1368  yysetstate:
1369   *yyssp = yystate;
1370 
1371   if (yyss + yystacksize - 1 <= yyssp)
1372     {
1373       /* Get the current used size of the three stacks, in elements.  */
1374       YYSIZE_T yysize = yyssp - yyss + 1;
1375 
1376 #ifdef yyoverflow
1377       {
1378         /* Give user a chance to reallocate the stack.  Use copies of
1379            these so that the &'s don't force the real ones into
1380            memory.  */
1381         YYSTYPE *yyvs1 = yyvs;
1382         yytype_int16 *yyss1 = yyss;
1383 
1384         /* Each stack pointer address is followed by the size of the
1385            data in use in that stack, in bytes.  This used to be a
1386            conditional around just the two extra args, but that might
1387            be undefined if yyoverflow is a macro.  */
1388         yyoverflow (YY_("memory exhausted"),
1389                     &yyss1, yysize * sizeof (*yyssp),
1390                     &yyvs1, yysize * sizeof (*yyvsp),
1391                     &yystacksize);
1392 
1393         yyss = yyss1;
1394         yyvs = yyvs1;
1395       }
1396 #else /* no yyoverflow */
1397 # ifndef YYSTACK_RELOCATE
1398       goto yyexhaustedlab;
1399 # else
1400       /* Extend the stack our own way.  */
1401       if (YYMAXDEPTH <= yystacksize)
1402         goto yyexhaustedlab;
1403       yystacksize *= 2;
1404       if (YYMAXDEPTH < yystacksize)
1405         yystacksize = YYMAXDEPTH;
1406 
1407       {
1408         yytype_int16 *yyss1 = yyss;
1409         union yyalloc *yyptr =
1410           (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize));
1411         if (! yyptr)
1412           goto yyexhaustedlab;
1413         YYSTACK_RELOCATE (yyss_alloc, yyss);
1414         YYSTACK_RELOCATE (yyvs_alloc, yyvs);
1415 #  undef YYSTACK_RELOCATE
1416         if (yyss1 != yyssa)
1417           YYSTACK_FREE (yyss1);
1418       }
1419 # endif
1420 #endif /* no yyoverflow */
1421 
1422       yyssp = yyss + yysize - 1;
1423       yyvsp = yyvs + yysize - 1;
1424 
1425       YYDPRINTF ((stderr, "Stack size increased to %lu\n",
1426                   (unsigned long int) yystacksize));
1427 
1428       if (yyss + yystacksize - 1 <= yyssp)
1429         YYABORT;
1430     }
1431 
1432   YYDPRINTF ((stderr, "Entering state %d\n", yystate));
1433 
1434   if (yystate == YYFINAL)
1435     YYACCEPT;
1436 
1437   goto yybackup;
1438 
1439 /*-----------.
1440 | yybackup.  |
1441 `-----------*/
1442 yybackup:
1443 
1444   /* Do appropriate processing given the current state.  Read a
1445      lookahead token if we need one and don't already have one.  */
1446 
1447   /* First try to decide what to do without reference to lookahead token.  */
1448   yyn = yypact[yystate];
1449   if (yypact_value_is_default (yyn))
1450     goto yydefault;
1451 
1452   /* Not known => get a lookahead token if don't already have one.  */
1453 
1454   /* YYCHAR is either YYEMPTY or YYEOF or a valid lookahead symbol.  */
1455   if (yychar == YYEMPTY)
1456     {
1457       YYDPRINTF ((stderr, "Reading a token: "));
1458       yychar = yylex ();
1459     }
1460 
1461   if (yychar <= YYEOF)
1462     {
1463       yychar = yytoken = YYEOF;
1464       YYDPRINTF ((stderr, "Now at end of input.\n"));
1465     }
1466   else
1467     {
1468       yytoken = YYTRANSLATE (yychar);
1469       YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc);
1470     }
1471 
1472   /* If the proper action on seeing token YYTOKEN is to reduce or to
1473      detect an error, take that action.  */
1474   yyn += yytoken;
1475   if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken)
1476     goto yydefault;
1477   yyn = yytable[yyn];
1478   if (yyn <= 0)
1479     {
1480       if (yytable_value_is_error (yyn))
1481         goto yyerrlab;
1482       yyn = -yyn;
1483       goto yyreduce;
1484     }
1485 
1486   /* Count tokens shifted since error; after three, turn off error
1487      status.  */
1488   if (yyerrstatus)
1489     yyerrstatus--;
1490 
1491   /* Shift the lookahead token.  */
1492   YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc);
1493 
1494   /* Discard the shifted token.  */
1495   yychar = YYEMPTY;
1496 
1497   yystate = yyn;
1498   YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
1499   *++yyvsp = yylval;
1500   YY_IGNORE_MAYBE_UNINITIALIZED_END
1501 
1502   goto yynewstate;
1503 
1504 
1505 /*-----------------------------------------------------------.
1506 | yydefault -- do the default action for the current state.  |
1507 `-----------------------------------------------------------*/
1508 yydefault:
1509   yyn = yydefact[yystate];
1510   if (yyn == 0)
1511     goto yyerrlab;
1512   goto yyreduce;
1513 
1514 
1515 /*-----------------------------.
1516 | yyreduce -- Do a reduction.  |
1517 `-----------------------------*/
1518 yyreduce:
1519   /* yyn is the number of a rule to reduce with.  */
1520   yylen = yyr2[yyn];
1521 
1522   /* If YYLEN is nonzero, implement the default value of the action:
1523      '$$ = $1'.
1524 
1525      Otherwise, the following line sets YYVAL to garbage.
1526      This behavior is undocumented and Bison
1527      users should not rely upon it.  Assigning to YYVAL
1528      unconditionally makes the parser a bit smaller, and it avoids a
1529      GCC warning that YYVAL may be used uninitialized.  */
1530   yyval = yyvsp[1-yylen];
1531 
1532 
1533   YY_REDUCE_PRINT (yyn);
1534   switch (yyn)
1535     {
1536         case 2:
1537 #line 251 "thrift/thrifty.yy" /* yacc.c:1646  */
1538     {
1539       pdebug("Program -> Headers DefinitionList");
1540       if((g_program_doctext_candidate != nullptr) && (g_program_doctext_status != ALREADY_PROCESSED))
1541       {
1542         g_program->set_doc(g_program_doctext_candidate);
1543         g_program_doctext_status = ALREADY_PROCESSED;
1544       }
1545       clear_doctext();
1546     }
1547 #line 1548 "thrift/thrifty.cc" /* yacc.c:1646  */
1548     break;
1549 
1550   case 3:
1551 #line 262 "thrift/thrifty.yy" /* yacc.c:1646  */
1552     {
1553       if (g_parse_mode == PROGRAM) {
1554         (yyval.dtext) = g_doctext;
1555         g_doctext = nullptr;
1556       } else {
1557         (yyval.dtext) = nullptr;
1558       }
1559     }
1560 #line 1561 "thrift/thrifty.cc" /* yacc.c:1646  */
1561     break;
1562 
1563   case 4:
1564 #line 273 "thrift/thrifty.yy" /* yacc.c:1646  */
1565     {
1566       if (g_parse_mode == PROGRAM) {
1567         clear_doctext();
1568       }
1569     }
1570 #line 1571 "thrift/thrifty.cc" /* yacc.c:1646  */
1571     break;
1572 
1573   case 5:
1574 #line 283 "thrift/thrifty.yy" /* yacc.c:1646  */
1575     {
1576       pdebug("HeaderList -> HeaderList Header");
1577     }
1578 #line 1579 "thrift/thrifty.cc" /* yacc.c:1646  */
1579     break;
1580 
1581   case 6:
1582 #line 287 "thrift/thrifty.yy" /* yacc.c:1646  */
1583     {
1584       pdebug("HeaderList -> ");
1585     }
1586 #line 1587 "thrift/thrifty.cc" /* yacc.c:1646  */
1587     break;
1588 
1589   case 7:
1590 #line 293 "thrift/thrifty.yy" /* yacc.c:1646  */
1591     {
1592       pdebug("Header -> Include");
1593     }
1594 #line 1595 "thrift/thrifty.cc" /* yacc.c:1646  */
1595     break;
1596 
1597   case 8:
1598 #line 297 "thrift/thrifty.yy" /* yacc.c:1646  */
1599     {
1600       pdebug("Header -> tok_namespace tok_identifier tok_identifier");
1601       declare_valid_program_doctext();
1602       if (g_parse_mode == PROGRAM) {
1603         g_program->set_namespace((yyvsp[-2].id), (yyvsp[-1].id));
1604       }
1605       if ((yyvsp[0].ttype) != nullptr) {
1606         g_program->set_namespace_annotations((yyvsp[-2].id), (yyvsp[0].ttype)->annotations_);
1607         delete (yyvsp[0].ttype);
1608       }
1609     }
1610 #line 1611 "thrift/thrifty.cc" /* yacc.c:1646  */
1611     break;
1612 
1613   case 9:
1614 #line 309 "thrift/thrifty.yy" /* yacc.c:1646  */
1615     {
1616       pdebug("Header -> tok_namespace * tok_identifier");
1617       declare_valid_program_doctext();
1618       if (g_parse_mode == PROGRAM) {
1619         g_program->set_namespace("*", (yyvsp[0].id));
1620       }
1621     }
1622 #line 1623 "thrift/thrifty.cc" /* yacc.c:1646  */
1623     break;
1624 
1625   case 10:
1626 #line 317 "thrift/thrifty.yy" /* yacc.c:1646  */
1627     {
1628       pdebug("Header -> tok_cpp_include tok_literal");
1629       declare_valid_program_doctext();
1630       if (g_parse_mode == PROGRAM) {
1631         g_program->add_cpp_include((yyvsp[0].id));
1632       }
1633     }
1634 #line 1635 "thrift/thrifty.cc" /* yacc.c:1646  */
1635     break;
1636 
1637   case 11:
1638 #line 327 "thrift/thrifty.yy" /* yacc.c:1646  */
1639     {
1640       pdebug("Include -> tok_include tok_literal");
1641       declare_valid_program_doctext();
1642       if (g_parse_mode == INCLUDES) {
1643         std::string path = include_file(std::string((yyvsp[0].id)));
1644         if (!path.empty()) {
1645           g_program->add_include(path, std::string((yyvsp[0].id)));
1646         }
1647       }
1648     }
1649 #line 1650 "thrift/thrifty.cc" /* yacc.c:1646  */
1650     break;
1651 
1652   case 12:
1653 #line 340 "thrift/thrifty.yy" /* yacc.c:1646  */
1654     {
1655       pdebug("DefinitionList -> DefinitionList Definition");
1656       if ((yyvsp[-1].dtext) != nullptr && (yyvsp[0].tdoc) != nullptr) {
1657         (yyvsp[0].tdoc)->set_doc((yyvsp[-1].dtext));
1658       }
1659     }
1660 #line 1661 "thrift/thrifty.cc" /* yacc.c:1646  */
1661     break;
1662 
1663   case 13:
1664 #line 347 "thrift/thrifty.yy" /* yacc.c:1646  */
1665     {
1666       pdebug("DefinitionList -> ");
1667     }
1668 #line 1669 "thrift/thrifty.cc" /* yacc.c:1646  */
1669     break;
1670 
1671   case 14:
1672 #line 353 "thrift/thrifty.yy" /* yacc.c:1646  */
1673     {
1674       pdebug("Definition -> Const");
1675       if (g_parse_mode == PROGRAM) {
1676         g_program->add_const((yyvsp[0].tconst));
1677       }
1678       (yyval.tdoc) = (yyvsp[0].tconst);
1679     }
1680 #line 1681 "thrift/thrifty.cc" /* yacc.c:1646  */
1681     break;
1682 
1683   case 15:
1684 #line 361 "thrift/thrifty.yy" /* yacc.c:1646  */
1685     {
1686       pdebug("Definition -> TypeDefinition");
1687       if (g_parse_mode == PROGRAM) {
1688         g_scope->add_type((yyvsp[0].ttype)->get_name(), (yyvsp[0].ttype));
1689         if (g_parent_scope != nullptr) {
1690           g_parent_scope->add_type(g_parent_prefix + (yyvsp[0].ttype)->get_name(), (yyvsp[0].ttype));
1691         }
1692         if (! g_program->is_unique_typename((yyvsp[0].ttype))) {
1693           yyerror("Type \"%s\" is already defined.", (yyvsp[0].ttype)->get_name().c_str());
1694           exit(1);
1695         }
1696       }
1697       (yyval.tdoc) = (yyvsp[0].ttype);
1698     }
1699 #line 1700 "thrift/thrifty.cc" /* yacc.c:1646  */
1700     break;
1701 
1702   case 16:
1703 #line 376 "thrift/thrifty.yy" /* yacc.c:1646  */
1704     {
1705       pdebug("Definition -> Service");
1706       if (g_parse_mode == PROGRAM) {
1707         g_scope->add_service((yyvsp[0].tservice)->get_name(), (yyvsp[0].tservice));
1708         if (g_parent_scope != nullptr) {
1709           g_parent_scope->add_service(g_parent_prefix + (yyvsp[0].tservice)->get_name(), (yyvsp[0].tservice));
1710         }
1711         g_program->add_service((yyvsp[0].tservice));
1712         if (! g_program->is_unique_typename((yyvsp[0].tservice))) {
1713           yyerror("Type \"%s\" is already defined.", (yyvsp[0].tservice)->get_name().c_str());
1714           exit(1);
1715         }
1716       }
1717       (yyval.tdoc) = (yyvsp[0].tservice);
1718     }
1719 #line 1720 "thrift/thrifty.cc" /* yacc.c:1646  */
1720     break;
1721 
1722   case 17:
1723 #line 394 "thrift/thrifty.yy" /* yacc.c:1646  */
1724     {
1725       pdebug("TypeDefinition -> Typedef");
1726       if (g_parse_mode == PROGRAM) {
1727         g_program->add_typedef((yyvsp[0].ttypedef));
1728       }
1729     }
1730 #line 1731 "thrift/thrifty.cc" /* yacc.c:1646  */
1731     break;
1732 
1733   case 18:
1734 #line 401 "thrift/thrifty.yy" /* yacc.c:1646  */
1735     {
1736       pdebug("TypeDefinition -> Enum");
1737       if (g_parse_mode == PROGRAM) {
1738         g_program->add_enum((yyvsp[0].tenum));
1739       }
1740     }
1741 #line 1742 "thrift/thrifty.cc" /* yacc.c:1646  */
1742     break;
1743 
1744   case 19:
1745 #line 408 "thrift/thrifty.yy" /* yacc.c:1646  */
1746     {
1747       pdebug("TypeDefinition -> Senum");
1748       if (g_parse_mode == PROGRAM) {
1749         g_program->add_typedef((yyvsp[0].ttypedef));
1750       }
1751     }
1752 #line 1753 "thrift/thrifty.cc" /* yacc.c:1646  */
1753     break;
1754 
1755   case 20:
1756 #line 415 "thrift/thrifty.yy" /* yacc.c:1646  */
1757     {
1758       pdebug("TypeDefinition -> Struct");
1759       if (g_parse_mode == PROGRAM) {
1760         g_program->add_struct((yyvsp[0].tstruct));
1761       }
1762     }
1763 #line 1764 "thrift/thrifty.cc" /* yacc.c:1646  */
1764     break;
1765 
1766   case 21:
1767 #line 422 "thrift/thrifty.yy" /* yacc.c:1646  */
1768     {
1769       pdebug("TypeDefinition -> Xception");
1770       if (g_parse_mode == PROGRAM) {
1771         g_program->add_xception((yyvsp[0].tstruct));
1772       }
1773     }
1774 #line 1775 "thrift/thrifty.cc" /* yacc.c:1646  */
1775     break;
1776 
1777   case 22:
1778 #line 431 "thrift/thrifty.yy" /* yacc.c:1646  */
1779     {}
1780 #line 1781 "thrift/thrifty.cc" /* yacc.c:1646  */
1781     break;
1782 
1783   case 23:
1784 #line 433 "thrift/thrifty.yy" /* yacc.c:1646  */
1785     {}
1786 #line 1787 "thrift/thrifty.cc" /* yacc.c:1646  */
1787     break;
1788 
1789   case 24:
1790 #line 435 "thrift/thrifty.yy" /* yacc.c:1646  */
1791     {}
1792 #line 1793 "thrift/thrifty.cc" /* yacc.c:1646  */
1793     break;
1794 
1795   case 25:
1796 #line 439 "thrift/thrifty.yy" /* yacc.c:1646  */
1797     {
1798       pdebug("TypeDef -> tok_typedef FieldType tok_identifier");
1799       validate_simple_identifier( (yyvsp[-2].id));
1800       t_typedef *td = new t_typedef(g_program, (yyvsp[-3].ttype), (yyvsp[-2].id));
1801       (yyval.ttypedef) = td;
1802       if ((yyvsp[-1].ttype) != nullptr) {
1803         (yyval.ttypedef)->annotations_ = (yyvsp[-1].ttype)->annotations_;
1804         delete (yyvsp[-1].ttype);
1805       }
1806     }
1807 #line 1808 "thrift/thrifty.cc" /* yacc.c:1646  */
1808     break;
1809 
1810   case 26:
1811 #line 452 "thrift/thrifty.yy" /* yacc.c:1646  */
1812     {
1813       pdebug("Enum -> tok_enum tok_identifier { EnumDefList }");
1814       (yyval.tenum) = (yyvsp[-2].tenum);
1815       validate_simple_identifier( (yyvsp[-4].id));
1816       (yyval.tenum)->set_name((yyvsp[-4].id));
1817       if ((yyvsp[0].ttype) != nullptr) {
1818         (yyval.tenum)->annotations_ = (yyvsp[0].ttype)->annotations_;
1819         delete (yyvsp[0].ttype);
1820       }
1821 
1822       // make constants for all the enum values
1823       if (g_parse_mode == PROGRAM) {
1824         const std::vector<t_enum_value*>& enum_values = (yyval.tenum)->get_constants();
1825         std::vector<t_enum_value*>::const_iterator c_iter;
1826         for (c_iter = enum_values.begin(); c_iter != enum_values.end(); ++c_iter) {
1827           std::string const_name = (yyval.tenum)->get_name() + "." + (*c_iter)->get_name();
1828           t_const_value* const_val = new t_const_value((*c_iter)->get_value());
1829           const_val->set_enum((yyval.tenum));
1830           g_scope->add_constant(const_name, new t_const(g_type_i32, (*c_iter)->get_name(), const_val));
1831           if (g_parent_scope != nullptr) {
1832             g_parent_scope->add_constant(g_parent_prefix + const_name, new t_const(g_type_i32, (*c_iter)->get_name(), const_val));
1833           }
1834         }
1835       }
1836     }
1837 #line 1838 "thrift/thrifty.cc" /* yacc.c:1646  */
1838     break;
1839 
1840   case 27:
1841 #line 480 "thrift/thrifty.yy" /* yacc.c:1646  */
1842     {
1843       pdebug("EnumDefList -> EnumDefList EnumDef");
1844       (yyval.tenum) = (yyvsp[-1].tenum);
1845       (yyval.tenum)->append((yyvsp[0].tenumv));
1846     }
1847 #line 1848 "thrift/thrifty.cc" /* yacc.c:1646  */
1848     break;
1849 
1850   case 28:
1851 #line 486 "thrift/thrifty.yy" /* yacc.c:1646  */
1852     {
1853       pdebug("EnumDefList -> ");
1854       (yyval.tenum) = new t_enum(g_program);
1855       y_enum_val = -1;
1856     }
1857 #line 1858 "thrift/thrifty.cc" /* yacc.c:1646  */
1858     break;
1859 
1860   case 29:
1861 #line 494 "thrift/thrifty.yy" /* yacc.c:1646  */
1862     {
1863       pdebug("EnumDef -> EnumValue");
1864       (yyval.tenumv) = (yyvsp[-2].tenumv);
1865       if ((yyvsp[-3].dtext) != nullptr) {
1866         (yyval.tenumv)->set_doc((yyvsp[-3].dtext));
1867       }
1868 	  if ((yyvsp[-1].ttype) != nullptr) {
1869         (yyval.tenumv)->annotations_ = (yyvsp[-1].ttype)->annotations_;
1870         delete (yyvsp[-1].ttype);
1871       }
1872     }
1873 #line 1874 "thrift/thrifty.cc" /* yacc.c:1646  */
1874     break;
1875 
1876   case 30:
1877 #line 508 "thrift/thrifty.yy" /* yacc.c:1646  */
1878     {
1879       pdebug("EnumValue -> tok_identifier = tok_int_constant");
1880       if ((yyvsp[0].iconst) < INT32_MIN || (yyvsp[0].iconst) > INT32_MAX) {
1881         // Note: this used to be just a warning.  However, since thrift always
1882         // treats enums as i32 values, I'm changing it to a fatal error.
1883         // I doubt this will affect many people, but users who run into this
1884         // will have to update their thrift files to manually specify the
1885         // truncated i32 value that thrift has always been using anyway.
1886         failure("64-bit value supplied for enum %s will be truncated.", (yyvsp[-2].id));
1887       }
1888       y_enum_val = static_cast<int32_t>((yyvsp[0].iconst));
1889       (yyval.tenumv) = new t_enum_value((yyvsp[-2].id), y_enum_val);
1890     }
1891 #line 1892 "thrift/thrifty.cc" /* yacc.c:1646  */
1892     break;
1893 
1894   case 31:
1895 #line 523 "thrift/thrifty.yy" /* yacc.c:1646  */
1896     {
1897       pdebug("EnumValue -> tok_identifier");
1898       validate_simple_identifier( (yyvsp[0].id));
1899       if (y_enum_val == INT32_MAX) {
1900         failure("enum value overflow at enum %s", (yyvsp[0].id));
1901       }
1902       ++y_enum_val;
1903       (yyval.tenumv) = new t_enum_value((yyvsp[0].id), y_enum_val);
1904     }
1905 #line 1906 "thrift/thrifty.cc" /* yacc.c:1646  */
1906     break;
1907 
1908   case 32:
1909 #line 535 "thrift/thrifty.yy" /* yacc.c:1646  */
1910     {
1911       pdebug("Senum -> tok_senum tok_identifier { SenumDefList }");
1912       validate_simple_identifier( (yyvsp[-4].id));
1913       (yyval.ttypedef) = new t_typedef(g_program, (yyvsp[-2].tbase), (yyvsp[-4].id));
1914       if ((yyvsp[0].ttype) != nullptr) {
1915         (yyval.ttypedef)->annotations_ = (yyvsp[0].ttype)->annotations_;
1916         delete (yyvsp[0].ttype);
1917       }
1918     }
1919 #line 1920 "thrift/thrifty.cc" /* yacc.c:1646  */
1920     break;
1921 
1922   case 33:
1923 #line 547 "thrift/thrifty.yy" /* yacc.c:1646  */
1924     {
1925       pdebug("SenumDefList -> SenumDefList SenumDef");
1926       (yyval.tbase) = (yyvsp[-1].tbase);
1927       (yyval.tbase)->add_string_enum_val((yyvsp[0].id));
1928     }
1929 #line 1930 "thrift/thrifty.cc" /* yacc.c:1646  */
1930     break;
1931 
1932   case 34:
1933 #line 553 "thrift/thrifty.yy" /* yacc.c:1646  */
1934     {
1935       pdebug("SenumDefList -> ");
1936       (yyval.tbase) = new t_base_type("string", t_base_type::TYPE_STRING);
1937       (yyval.tbase)->set_string_enum(true);
1938     }
1939 #line 1940 "thrift/thrifty.cc" /* yacc.c:1646  */
1940     break;
1941 
1942   case 35:
1943 #line 561 "thrift/thrifty.yy" /* yacc.c:1646  */
1944     {
1945       pdebug("SenumDef -> tok_literal");
1946       (yyval.id) = (yyvsp[-1].id);
1947     }
1948 #line 1949 "thrift/thrifty.cc" /* yacc.c:1646  */
1949     break;
1950 
1951   case 36:
1952 #line 568 "thrift/thrifty.yy" /* yacc.c:1646  */
1953     {
1954       pdebug("Const -> tok_const FieldType tok_identifier = ConstValue");
1955       if (g_parse_mode == PROGRAM) {
1956         validate_simple_identifier( (yyvsp[-3].id));
1957         g_scope->resolve_const_value((yyvsp[-1].tconstv), (yyvsp[-4].ttype));
1958         (yyval.tconst) = new t_const((yyvsp[-4].ttype), (yyvsp[-3].id), (yyvsp[-1].tconstv));
1959         validate_const_type((yyval.tconst));
1960 
1961         g_scope->add_constant((yyvsp[-3].id), (yyval.tconst));
1962         if (g_parent_scope != nullptr) {
1963           g_parent_scope->add_constant(g_parent_prefix + (yyvsp[-3].id), (yyval.tconst));
1964         }
1965       } else {
1966         (yyval.tconst) = nullptr;
1967       }
1968     }
1969 #line 1970 "thrift/thrifty.cc" /* yacc.c:1646  */
1970     break;
1971 
1972   case 37:
1973 #line 587 "thrift/thrifty.yy" /* yacc.c:1646  */
1974     {
1975       pdebug("ConstValue => tok_int_constant");
1976       (yyval.tconstv) = new t_const_value();
1977       (yyval.tconstv)->set_integer((yyvsp[0].iconst));
1978       if (!g_allow_64bit_consts && ((yyvsp[0].iconst) < INT32_MIN || (yyvsp[0].iconst) > INT32_MAX)) {
1979         pwarning(1, "64-bit constant \"%" PRIi64"\" may not work in all languages.\n", (yyvsp[0].iconst));
1980       }
1981     }
1982 #line 1983 "thrift/thrifty.cc" /* yacc.c:1646  */
1983     break;
1984 
1985   case 38:
1986 #line 596 "thrift/thrifty.yy" /* yacc.c:1646  */
1987     {
1988       pdebug("ConstValue => tok_dub_constant");
1989       (yyval.tconstv) = new t_const_value();
1990       (yyval.tconstv)->set_double((yyvsp[0].dconst));
1991     }
1992 #line 1993 "thrift/thrifty.cc" /* yacc.c:1646  */
1993     break;
1994 
1995   case 39:
1996 #line 602 "thrift/thrifty.yy" /* yacc.c:1646  */
1997     {
1998       pdebug("ConstValue => tok_literal");
1999       (yyval.tconstv) = new t_const_value((yyvsp[0].id));
2000     }
2001 #line 2002 "thrift/thrifty.cc" /* yacc.c:1646  */
2002     break;
2003 
2004   case 40:
2005 #line 607 "thrift/thrifty.yy" /* yacc.c:1646  */
2006     {
2007       pdebug("ConstValue => tok_identifier");
2008       (yyval.tconstv) = new t_const_value();
2009       (yyval.tconstv)->set_identifier((yyvsp[0].id));
2010     }
2011 #line 2012 "thrift/thrifty.cc" /* yacc.c:1646  */
2012     break;
2013 
2014   case 41:
2015 #line 613 "thrift/thrifty.yy" /* yacc.c:1646  */
2016     {
2017       pdebug("ConstValue => ConstList");
2018       (yyval.tconstv) = (yyvsp[0].tconstv);
2019     }
2020 #line 2021 "thrift/thrifty.cc" /* yacc.c:1646  */
2021     break;
2022 
2023   case 42:
2024 #line 618 "thrift/thrifty.yy" /* yacc.c:1646  */
2025     {
2026       pdebug("ConstValue => ConstMap");
2027       (yyval.tconstv) = (yyvsp[0].tconstv);
2028     }
2029 #line 2030 "thrift/thrifty.cc" /* yacc.c:1646  */
2030     break;
2031 
2032   case 43:
2033 #line 625 "thrift/thrifty.yy" /* yacc.c:1646  */
2034     {
2035       pdebug("ConstList => [ ConstListContents ]");
2036       (yyval.tconstv) = (yyvsp[-1].tconstv);
2037     }
2038 #line 2039 "thrift/thrifty.cc" /* yacc.c:1646  */
2039     break;
2040 
2041   case 44:
2042 #line 632 "thrift/thrifty.yy" /* yacc.c:1646  */
2043     {
2044       pdebug("ConstListContents => ConstListContents ConstValue CommaOrSemicolonOptional");
2045       (yyval.tconstv) = (yyvsp[-2].tconstv);
2046       (yyval.tconstv)->add_list((yyvsp[-1].tconstv));
2047     }
2048 #line 2049 "thrift/thrifty.cc" /* yacc.c:1646  */
2049     break;
2050 
2051   case 45:
2052 #line 638 "thrift/thrifty.yy" /* yacc.c:1646  */
2053     {
2054       pdebug("ConstListContents =>");
2055       (yyval.tconstv) = new t_const_value();
2056       (yyval.tconstv)->set_list();
2057     }
2058 #line 2059 "thrift/thrifty.cc" /* yacc.c:1646  */
2059     break;
2060 
2061   case 46:
2062 #line 646 "thrift/thrifty.yy" /* yacc.c:1646  */
2063     {
2064       pdebug("ConstMap => { ConstMapContents }");
2065       (yyval.tconstv) = (yyvsp[-1].tconstv);
2066     }
2067 #line 2068 "thrift/thrifty.cc" /* yacc.c:1646  */
2068     break;
2069 
2070   case 47:
2071 #line 653 "thrift/thrifty.yy" /* yacc.c:1646  */
2072     {
2073       pdebug("ConstMapContents => ConstMapContents ConstValue CommaOrSemicolonOptional");
2074       (yyval.tconstv) = (yyvsp[-4].tconstv);
2075       (yyval.tconstv)->add_map((yyvsp[-3].tconstv), (yyvsp[-1].tconstv));
2076     }
2077 #line 2078 "thrift/thrifty.cc" /* yacc.c:1646  */
2078     break;
2079 
2080   case 48:
2081 #line 659 "thrift/thrifty.yy" /* yacc.c:1646  */
2082     {
2083       pdebug("ConstMapContents =>");
2084       (yyval.tconstv) = new t_const_value();
2085       (yyval.tconstv)->set_map();
2086     }
2087 #line 2088 "thrift/thrifty.cc" /* yacc.c:1646  */
2088     break;
2089 
2090   case 49:
2091 #line 667 "thrift/thrifty.yy" /* yacc.c:1646  */
2092     {
2093       (yyval.iconst) = struct_is_struct;
2094     }
2095 #line 2096 "thrift/thrifty.cc" /* yacc.c:1646  */
2096     break;
2097 
2098   case 50:
2099 #line 671 "thrift/thrifty.yy" /* yacc.c:1646  */
2100     {
2101       (yyval.iconst) = struct_is_union;
2102     }
2103 #line 2104 "thrift/thrifty.cc" /* yacc.c:1646  */
2104     break;
2105 
2106   case 51:
2107 #line 677 "thrift/thrifty.yy" /* yacc.c:1646  */
2108     {
2109       pdebug("Struct -> tok_struct tok_identifier { FieldList }");
2110       validate_simple_identifier( (yyvsp[-5].id));
2111       (yyvsp[-2].tstruct)->set_xsd_all((yyvsp[-4].tbool));
2112       (yyvsp[-2].tstruct)->set_union((yyvsp[-6].iconst) == struct_is_union);
2113       (yyval.tstruct) = (yyvsp[-2].tstruct);
2114       (yyval.tstruct)->set_name((yyvsp[-5].id));
2115       if ((yyvsp[0].ttype) != nullptr) {
2116         (yyval.tstruct)->annotations_ = (yyvsp[0].ttype)->annotations_;
2117         delete (yyvsp[0].ttype);
2118       }
2119     }
2120 #line 2121 "thrift/thrifty.cc" /* yacc.c:1646  */
2121     break;
2122 
2123   case 52:
2124 #line 692 "thrift/thrifty.yy" /* yacc.c:1646  */
2125     {
2126       (yyval.tbool) = true;
2127     }
2128 #line 2129 "thrift/thrifty.cc" /* yacc.c:1646  */
2129     break;
2130 
2131   case 53:
2132 #line 696 "thrift/thrifty.yy" /* yacc.c:1646  */
2133     {
2134       (yyval.tbool) = false;
2135     }
2136 #line 2137 "thrift/thrifty.cc" /* yacc.c:1646  */
2137     break;
2138 
2139   case 54:
2140 #line 702 "thrift/thrifty.yy" /* yacc.c:1646  */
2141     {
2142       (yyval.tbool) = true;
2143     }
2144 #line 2145 "thrift/thrifty.cc" /* yacc.c:1646  */
2145     break;
2146 
2147   case 55:
2148 #line 706 "thrift/thrifty.yy" /* yacc.c:1646  */
2149     {
2150       (yyval.tbool) = false;
2151     }
2152 #line 2153 "thrift/thrifty.cc" /* yacc.c:1646  */
2153     break;
2154 
2155   case 56:
2156 #line 712 "thrift/thrifty.yy" /* yacc.c:1646  */
2157     {
2158       (yyval.tbool) = true;
2159     }
2160 #line 2161 "thrift/thrifty.cc" /* yacc.c:1646  */
2161     break;
2162 
2163   case 57:
2164 #line 716 "thrift/thrifty.yy" /* yacc.c:1646  */
2165     {
2166       (yyval.tbool) = false;
2167     }
2168 #line 2169 "thrift/thrifty.cc" /* yacc.c:1646  */
2169     break;
2170 
2171   case 58:
2172 #line 722 "thrift/thrifty.yy" /* yacc.c:1646  */
2173     {
2174       (yyval.tstruct) = (yyvsp[-1].tstruct);
2175     }
2176 #line 2177 "thrift/thrifty.cc" /* yacc.c:1646  */
2177     break;
2178 
2179   case 59:
2180 #line 726 "thrift/thrifty.yy" /* yacc.c:1646  */
2181     {
2182       (yyval.tstruct) = nullptr;
2183     }
2184 #line 2185 "thrift/thrifty.cc" /* yacc.c:1646  */
2185     break;
2186 
2187   case 60:
2188 #line 732 "thrift/thrifty.yy" /* yacc.c:1646  */
2189     {
2190       pdebug("Xception -> tok_xception tok_identifier { FieldList }");
2191       validate_simple_identifier( (yyvsp[-4].id));
2192       (yyvsp[-2].tstruct)->set_name((yyvsp[-4].id));
2193       (yyvsp[-2].tstruct)->set_xception(true);
2194       (yyval.tstruct) = (yyvsp[-2].tstruct);
2195       if ((yyvsp[0].ttype) != nullptr) {
2196         (yyval.tstruct)->annotations_ = (yyvsp[0].ttype)->annotations_;
2197         delete (yyvsp[0].ttype);
2198       }
2199     }
2200 #line 2201 "thrift/thrifty.cc" /* yacc.c:1646  */
2201     break;
2202 
2203   case 61:
2204 #line 746 "thrift/thrifty.yy" /* yacc.c:1646  */
2205     {
2206       pdebug("Service -> tok_service tok_identifier { FunctionList }");
2207       validate_simple_identifier( (yyvsp[-7].id));
2208       (yyval.tservice) = (yyvsp[-3].tservice);
2209       (yyval.tservice)->set_name((yyvsp[-7].id));
2210       (yyval.tservice)->set_extends((yyvsp[-6].tservice));
2211       if ((yyvsp[0].ttype) != nullptr) {
2212         (yyval.tservice)->annotations_ = (yyvsp[0].ttype)->annotations_;
2213         delete (yyvsp[0].ttype);
2214       }
2215     }
2216 #line 2217 "thrift/thrifty.cc" /* yacc.c:1646  */
2217     break;
2218 
2219   case 62:
2220 #line 759 "thrift/thrifty.yy" /* yacc.c:1646  */
2221     {
2222        g_arglist = 1;
2223     }
2224 #line 2225 "thrift/thrifty.cc" /* yacc.c:1646  */
2225     break;
2226 
2227   case 63:
2228 #line 764 "thrift/thrifty.yy" /* yacc.c:1646  */
2229     {
2230        g_arglist = 0;
2231     }
2232 #line 2233 "thrift/thrifty.cc" /* yacc.c:1646  */
2233     break;
2234 
2235   case 64:
2236 #line 770 "thrift/thrifty.yy" /* yacc.c:1646  */
2237     {
2238       pdebug("Extends -> tok_extends tok_identifier");
2239       (yyval.tservice) = nullptr;
2240       if (g_parse_mode == PROGRAM) {
2241         (yyval.tservice) = g_scope->get_service((yyvsp[0].id));
2242         if ((yyval.tservice) == nullptr) {
2243           yyerror("Service \"%s\" has not been defined.", (yyvsp[0].id));
2244           exit(1);
2245         }
2246       }
2247     }
2248 #line 2249 "thrift/thrifty.cc" /* yacc.c:1646  */
2249     break;
2250 
2251   case 65:
2252 #line 782 "thrift/thrifty.yy" /* yacc.c:1646  */
2253     {
2254       (yyval.tservice) = nullptr;
2255     }
2256 #line 2257 "thrift/thrifty.cc" /* yacc.c:1646  */
2257     break;
2258 
2259   case 66:
2260 #line 788 "thrift/thrifty.yy" /* yacc.c:1646  */
2261     {
2262       pdebug("FunctionList -> FunctionList Function");
2263       (yyval.tservice) = (yyvsp[-1].tservice);
2264       (yyvsp[-1].tservice)->add_function((yyvsp[0].tfunction));
2265     }
2266 #line 2267 "thrift/thrifty.cc" /* yacc.c:1646  */
2267     break;
2268 
2269   case 67:
2270 #line 794 "thrift/thrifty.yy" /* yacc.c:1646  */
2271     {
2272       pdebug("FunctionList -> ");
2273       (yyval.tservice) = new t_service(g_program);
2274     }
2275 #line 2276 "thrift/thrifty.cc" /* yacc.c:1646  */
2276     break;
2277 
2278   case 68:
2279 #line 801 "thrift/thrifty.yy" /* yacc.c:1646  */
2280     {
2281       validate_simple_identifier( (yyvsp[-6].id));
2282       (yyvsp[-4].tstruct)->set_name(std::string((yyvsp[-6].id)) + "_args");
2283       (yyval.tfunction) = new t_function((yyvsp[-7].ttype), (yyvsp[-6].id), (yyvsp[-4].tstruct), (yyvsp[-2].tstruct), (yyvsp[-8].tbool));
2284       if ((yyvsp[-9].dtext) != nullptr) {
2285         (yyval.tfunction)->set_doc((yyvsp[-9].dtext));
2286       }
2287       if ((yyvsp[-1].ttype) != nullptr) {
2288         (yyval.tfunction)->annotations_ = (yyvsp[-1].ttype)->annotations_;
2289         delete (yyvsp[-1].ttype);
2290       }
2291     }
2292 #line 2293 "thrift/thrifty.cc" /* yacc.c:1646  */
2293     break;
2294 
2295   case 69:
2296 #line 816 "thrift/thrifty.yy" /* yacc.c:1646  */
2297     {
2298       (yyval.tbool) = true;
2299     }
2300 #line 2301 "thrift/thrifty.cc" /* yacc.c:1646  */
2301     break;
2302 
2303   case 70:
2304 #line 820 "thrift/thrifty.yy" /* yacc.c:1646  */
2305     {
2306       (yyval.tbool) = false;
2307     }
2308 #line 2309 "thrift/thrifty.cc" /* yacc.c:1646  */
2309     break;
2310 
2311   case 71:
2312 #line 826 "thrift/thrifty.yy" /* yacc.c:1646  */
2313     {
2314       pdebug("Throws -> tok_throws ( FieldList )");
2315       (yyval.tstruct) = (yyvsp[-1].tstruct);
2316       if (g_parse_mode == PROGRAM && !validate_throws((yyval.tstruct))) {
2317         yyerror("Throws clause may not contain non-exception types");
2318         exit(1);
2319       }
2320     }
2321 #line 2322 "thrift/thrifty.cc" /* yacc.c:1646  */
2322     break;
2323 
2324   case 72:
2325 #line 835 "thrift/thrifty.yy" /* yacc.c:1646  */
2326     {
2327       (yyval.tstruct) = new t_struct(g_program);
2328     }
2329 #line 2330 "thrift/thrifty.cc" /* yacc.c:1646  */
2330     break;
2331 
2332   case 73:
2333 #line 841 "thrift/thrifty.yy" /* yacc.c:1646  */
2334     {
2335       pdebug("FieldList -> FieldList , Field");
2336       (yyval.tstruct) = (yyvsp[-1].tstruct);
2337       if (!((yyval.tstruct)->append((yyvsp[0].tfield)))) {
2338         yyerror("\"%d: %s\" - field identifier/name has already been used", (yyvsp[0].tfield)->get_key(), (yyvsp[0].tfield)->get_name().c_str());
2339         exit(1);
2340       }
2341     }
2342 #line 2343 "thrift/thrifty.cc" /* yacc.c:1646  */
2343     break;
2344 
2345   case 74:
2346 #line 850 "thrift/thrifty.yy" /* yacc.c:1646  */
2347     {
2348       pdebug("FieldList -> ");
2349       y_field_val = -1;
2350       (yyval.tstruct) = new t_struct(g_program);
2351     }
2352 #line 2353 "thrift/thrifty.cc" /* yacc.c:1646  */
2353     break;
2354 
2355   case 75:
2356 #line 858 "thrift/thrifty.yy" /* yacc.c:1646  */
2357     {
2358       pdebug("tok_int_constant : Field -> FieldType tok_identifier");
2359       if ((yyvsp[-10].tfieldid).auto_assigned) {
2360         pwarning(1, "No field key specified for %s, resulting protocol may have conflicts or not be backwards compatible!\n", (yyvsp[-6].id));
2361         if (g_strict >= 192) {
2362           yyerror("Implicit field keys are deprecated and not allowed with -strict");
2363           exit(1);
2364         }
2365       }
2366       validate_simple_identifier((yyvsp[-6].id));
2367       (yyval.tfield) = new t_field((yyvsp[-8].ttype), (yyvsp[-6].id), (yyvsp[-10].tfieldid).value);
2368       (yyval.tfield)->set_reference((yyvsp[-7].tbool));
2369       (yyval.tfield)->set_req((yyvsp[-9].ereq));
2370       if ((yyvsp[-5].tconstv) != nullptr) {
2371         g_scope->resolve_const_value((yyvsp[-5].tconstv), (yyvsp[-8].ttype));
2372         validate_field_value((yyval.tfield), (yyvsp[-5].tconstv));
2373         (yyval.tfield)->set_value((yyvsp[-5].tconstv));
2374       }
2375       (yyval.tfield)->set_xsd_optional((yyvsp[-4].tbool));
2376       (yyval.tfield)->set_xsd_nillable((yyvsp[-3].tbool));
2377       if ((yyvsp[-11].dtext) != nullptr) {
2378         (yyval.tfield)->set_doc((yyvsp[-11].dtext));
2379       }
2380       if ((yyvsp[-2].tstruct) != nullptr) {
2381         (yyval.tfield)->set_xsd_attrs((yyvsp[-2].tstruct));
2382       }
2383       if ((yyvsp[-1].ttype) != nullptr) {
2384         (yyval.tfield)->annotations_ = (yyvsp[-1].ttype)->annotations_;
2385         delete (yyvsp[-1].ttype);
2386       }
2387     }
2388 #line 2389 "thrift/thrifty.cc" /* yacc.c:1646  */
2389     break;
2390 
2391   case 76:
2392 #line 892 "thrift/thrifty.yy" /* yacc.c:1646  */
2393     {
2394       if ((yyvsp[-1].iconst) <= 0) {
2395         if (g_allow_neg_field_keys) {
2396           /*
2397            * g_allow_neg_field_keys exists to allow users to add explicitly
2398            * specified key values to old .thrift files without breaking
2399            * protocol compatibility.
2400            */
2401           if ((yyvsp[-1].iconst) != y_field_val) {
2402             /*
2403              * warn if the user-specified negative value isn't what
2404              * thrift would have auto-assigned.
2405              */
2406             pwarning(1, "Nonpositive field key (%" PRIi64") differs from what would be "
2407                      "auto-assigned by thrift (%d).\n", (yyvsp[-1].iconst), y_field_val);
2408           }
2409           /*
2410            * Leave $1 as-is, and update y_field_val to be one less than $1.
2411            * The FieldList parsing will catch any duplicate key values.
2412            */
2413           y_field_val = static_cast<int32_t>((yyvsp[-1].iconst) - 1);
2414           (yyval.tfieldid).value = static_cast<int32_t>((yyvsp[-1].iconst));
2415           (yyval.tfieldid).auto_assigned = false;
2416         } else {
2417           pwarning(1, "Nonpositive value (%d) not allowed as a field key.\n",
2418                    (yyvsp[-1].iconst));
2419           (yyval.tfieldid).value = y_field_val--;
2420           (yyval.tfieldid).auto_assigned = true;
2421         }
2422       } else {
2423         (yyval.tfieldid).value = static_cast<int32_t>((yyvsp[-1].iconst));
2424         (yyval.tfieldid).auto_assigned = false;
2425       }
2426       if( (SHRT_MIN > (yyval.tfieldid).value) || ((yyval.tfieldid).value > SHRT_MAX)) {
2427         pwarning(1, "Field key (%d) exceeds allowed range (%d..%d).\n",
2428                  (yyval.tfieldid).value, SHRT_MIN, SHRT_MAX);
2429       }
2430     }
2431 #line 2432 "thrift/thrifty.cc" /* yacc.c:1646  */
2432     break;
2433 
2434   case 77:
2435 #line 931 "thrift/thrifty.yy" /* yacc.c:1646  */
2436     {
2437       (yyval.tfieldid).value = y_field_val--;
2438       (yyval.tfieldid).auto_assigned = true;
2439       if( (SHRT_MIN > (yyval.tfieldid).value) || ((yyval.tfieldid).value > SHRT_MAX)) {
2440         pwarning(1, "Field key (%d) exceeds allowed range (%d..%d).\n",
2441                  (yyval.tfieldid).value, SHRT_MIN, SHRT_MAX);
2442       }
2443     }
2444 #line 2445 "thrift/thrifty.cc" /* yacc.c:1646  */
2445     break;
2446 
2447   case 78:
2448 #line 942 "thrift/thrifty.yy" /* yacc.c:1646  */
2449     {
2450       (yyval.tbool) = true;
2451     }
2452 #line 2453 "thrift/thrifty.cc" /* yacc.c:1646  */
2453     break;
2454 
2455   case 79:
2456 #line 946 "thrift/thrifty.yy" /* yacc.c:1646  */
2457     {
2458      (yyval.tbool) = false;
2459    }
2460 #line 2461 "thrift/thrifty.cc" /* yacc.c:1646  */
2461     break;
2462 
2463   case 80:
2464 #line 952 "thrift/thrifty.yy" /* yacc.c:1646  */
2465     {
2466       (yyval.ereq) = t_field::T_REQUIRED;
2467     }
2468 #line 2469 "thrift/thrifty.cc" /* yacc.c:1646  */
2469     break;
2470 
2471   case 81:
2472 #line 956 "thrift/thrifty.yy" /* yacc.c:1646  */
2473     {
2474       if (g_arglist) {
2475         if (g_parse_mode == PROGRAM) {
2476           pwarning(1, "optional keyword is ignored in argument lists.\n");
2477         }
2478         (yyval.ereq) = t_field::T_OPT_IN_REQ_OUT;
2479       } else {
2480         (yyval.ereq) = t_field::T_OPTIONAL;
2481       }
2482     }
2483 #line 2484 "thrift/thrifty.cc" /* yacc.c:1646  */
2484     break;
2485 
2486   case 82:
2487 #line 967 "thrift/thrifty.yy" /* yacc.c:1646  */
2488     {
2489       (yyval.ereq) = t_field::T_OPT_IN_REQ_OUT;
2490     }
2491 #line 2492 "thrift/thrifty.cc" /* yacc.c:1646  */
2492     break;
2493 
2494   case 83:
2495 #line 973 "thrift/thrifty.yy" /* yacc.c:1646  */
2496     {
2497       if (g_parse_mode == PROGRAM) {
2498         (yyval.tconstv) = (yyvsp[0].tconstv);
2499       } else {
2500         (yyval.tconstv) = nullptr;
2501       }
2502     }
2503 #line 2504 "thrift/thrifty.cc" /* yacc.c:1646  */
2504     break;
2505 
2506   case 84:
2507 #line 981 "thrift/thrifty.yy" /* yacc.c:1646  */
2508     {
2509       (yyval.tconstv) = nullptr;
2510     }
2511 #line 2512 "thrift/thrifty.cc" /* yacc.c:1646  */
2512     break;
2513 
2514   case 85:
2515 #line 987 "thrift/thrifty.yy" /* yacc.c:1646  */
2516     {
2517       pdebug("FunctionType -> FieldType");
2518       (yyval.ttype) = (yyvsp[0].ttype);
2519     }
2520 #line 2521 "thrift/thrifty.cc" /* yacc.c:1646  */
2521     break;
2522 
2523   case 86:
2524 #line 992 "thrift/thrifty.yy" /* yacc.c:1646  */
2525     {
2526       pdebug("FunctionType -> tok_void");
2527       (yyval.ttype) = g_type_void;
2528     }
2529 #line 2530 "thrift/thrifty.cc" /* yacc.c:1646  */
2530     break;
2531 
2532   case 87:
2533 #line 999 "thrift/thrifty.yy" /* yacc.c:1646  */
2534     {
2535       pdebug("FieldType -> tok_identifier");
2536       if (g_parse_mode == INCLUDES) {
2537         // Ignore identifiers in include mode
2538         (yyval.ttype) = nullptr;
2539       } else {
2540         // Lookup the identifier in the current scope
2541         (yyval.ttype) = g_scope->get_type((yyvsp[0].id));
2542         if ((yyval.ttype) == nullptr) {
2543           /*
2544            * Either this type isn't yet declared, or it's never
2545              declared.  Either way allow it and we'll figure it out
2546              during generation.
2547            */
2548           (yyval.ttype) = new t_typedef(g_program, (yyvsp[0].id), true);
2549         }
2550       }
2551     }
2552 #line 2553 "thrift/thrifty.cc" /* yacc.c:1646  */
2553     break;
2554 
2555   case 88:
2556 #line 1018 "thrift/thrifty.yy" /* yacc.c:1646  */
2557     {
2558       pdebug("FieldType -> BaseType");
2559       (yyval.ttype) = (yyvsp[0].ttype);
2560     }
2561 #line 2562 "thrift/thrifty.cc" /* yacc.c:1646  */
2562     break;
2563 
2564   case 89:
2565 #line 1023 "thrift/thrifty.yy" /* yacc.c:1646  */
2566     {
2567       pdebug("FieldType -> ContainerType");
2568       (yyval.ttype) = (yyvsp[0].ttype);
2569     }
2570 #line 2571 "thrift/thrifty.cc" /* yacc.c:1646  */
2571     break;
2572 
2573   case 90:
2574 #line 1029 "thrift/thrifty.yy" /* yacc.c:1646  */
2575     {
2576       pdebug("BaseType -> SimpleBaseType TypeAnnotations");
2577       if ((yyvsp[0].ttype) != nullptr) {
2578         (yyval.ttype) = new t_base_type(*static_cast<t_base_type*>((yyvsp[-1].ttype)));
2579         (yyval.ttype)->annotations_ = (yyvsp[0].ttype)->annotations_;
2580         delete (yyvsp[0].ttype);
2581       } else {
2582         (yyval.ttype) = (yyvsp[-1].ttype);
2583       }
2584     }
2585 #line 2586 "thrift/thrifty.cc" /* yacc.c:1646  */
2586     break;
2587 
2588   case 91:
2589 #line 1042 "thrift/thrifty.yy" /* yacc.c:1646  */
2590     {
2591       pdebug("BaseType -> tok_string");
2592       (yyval.ttype) = g_type_string;
2593     }
2594 #line 2595 "thrift/thrifty.cc" /* yacc.c:1646  */
2595     break;
2596 
2597   case 92:
2598 #line 1047 "thrift/thrifty.yy" /* yacc.c:1646  */
2599     {
2600       pdebug("BaseType -> tok_binary");
2601       (yyval.ttype) = g_type_binary;
2602     }
2603 #line 2604 "thrift/thrifty.cc" /* yacc.c:1646  */
2604     break;
2605 
2606   case 93:
2607 #line 1052 "thrift/thrifty.yy" /* yacc.c:1646  */
2608     {
2609       pdebug("BaseType -> tok_slist");
2610       (yyval.ttype) = g_type_slist;
2611     }
2612 #line 2613 "thrift/thrifty.cc" /* yacc.c:1646  */
2613     break;
2614 
2615   case 94:
2616 #line 1057 "thrift/thrifty.yy" /* yacc.c:1646  */
2617     {
2618       pdebug("BaseType -> tok_bool");
2619       (yyval.ttype) = g_type_bool;
2620     }
2621 #line 2622 "thrift/thrifty.cc" /* yacc.c:1646  */
2622     break;
2623 
2624   case 95:
2625 #line 1062 "thrift/thrifty.yy" /* yacc.c:1646  */
2626     {
2627       pdebug("BaseType -> tok_i8");
2628       (yyval.ttype) = g_type_i8;
2629     }
2630 #line 2631 "thrift/thrifty.cc" /* yacc.c:1646  */
2631     break;
2632 
2633   case 96:
2634 #line 1067 "thrift/thrifty.yy" /* yacc.c:1646  */
2635     {
2636       pdebug("BaseType -> tok_i16");
2637       (yyval.ttype) = g_type_i16;
2638     }
2639 #line 2640 "thrift/thrifty.cc" /* yacc.c:1646  */
2640     break;
2641 
2642   case 97:
2643 #line 1072 "thrift/thrifty.yy" /* yacc.c:1646  */
2644     {
2645       pdebug("BaseType -> tok_i32");
2646       (yyval.ttype) = g_type_i32;
2647     }
2648 #line 2649 "thrift/thrifty.cc" /* yacc.c:1646  */
2649     break;
2650 
2651   case 98:
2652 #line 1077 "thrift/thrifty.yy" /* yacc.c:1646  */
2653     {
2654       pdebug("BaseType -> tok_i64");
2655       (yyval.ttype) = g_type_i64;
2656     }
2657 #line 2658 "thrift/thrifty.cc" /* yacc.c:1646  */
2658     break;
2659 
2660   case 99:
2661 #line 1082 "thrift/thrifty.yy" /* yacc.c:1646  */
2662     {
2663       pdebug("BaseType -> tok_double");
2664       (yyval.ttype) = g_type_double;
2665     }
2666 #line 2667 "thrift/thrifty.cc" /* yacc.c:1646  */
2667     break;
2668 
2669   case 100:
2670 #line 1088 "thrift/thrifty.yy" /* yacc.c:1646  */
2671     {
2672       pdebug("ContainerType -> SimpleContainerType TypeAnnotations");
2673       (yyval.ttype) = (yyvsp[-1].ttype);
2674       if ((yyvsp[0].ttype) != nullptr) {
2675         (yyval.ttype)->annotations_ = (yyvsp[0].ttype)->annotations_;
2676         delete (yyvsp[0].ttype);
2677       }
2678     }
2679 #line 2680 "thrift/thrifty.cc" /* yacc.c:1646  */
2680     break;
2681 
2682   case 101:
2683 #line 1099 "thrift/thrifty.yy" /* yacc.c:1646  */
2684     {
2685       pdebug("SimpleContainerType -> MapType");
2686       (yyval.ttype) = (yyvsp[0].ttype);
2687     }
2688 #line 2689 "thrift/thrifty.cc" /* yacc.c:1646  */
2689     break;
2690 
2691   case 102:
2692 #line 1104 "thrift/thrifty.yy" /* yacc.c:1646  */
2693     {
2694       pdebug("SimpleContainerType -> SetType");
2695       (yyval.ttype) = (yyvsp[0].ttype);
2696     }
2697 #line 2698 "thrift/thrifty.cc" /* yacc.c:1646  */
2698     break;
2699 
2700   case 103:
2701 #line 1109 "thrift/thrifty.yy" /* yacc.c:1646  */
2702     {
2703       pdebug("SimpleContainerType -> ListType");
2704       (yyval.ttype) = (yyvsp[0].ttype);
2705     }
2706 #line 2707 "thrift/thrifty.cc" /* yacc.c:1646  */
2707     break;
2708 
2709   case 104:
2710 #line 1116 "thrift/thrifty.yy" /* yacc.c:1646  */
2711     {
2712       pdebug("MapType -> tok_map <FieldType, FieldType>");
2713       (yyval.ttype) = new t_map((yyvsp[-3].ttype), (yyvsp[-1].ttype));
2714       if ((yyvsp[-5].id) != nullptr) {
2715         ((t_container*)(yyval.ttype))->set_cpp_name(std::string((yyvsp[-5].id)));
2716       }
2717     }
2718 #line 2719 "thrift/thrifty.cc" /* yacc.c:1646  */
2719     break;
2720 
2721   case 105:
2722 #line 1126 "thrift/thrifty.yy" /* yacc.c:1646  */
2723     {
2724       pdebug("SetType -> tok_set<FieldType>");
2725       (yyval.ttype) = new t_set((yyvsp[-1].ttype));
2726       if ((yyvsp[-3].id) != nullptr) {
2727         ((t_container*)(yyval.ttype))->set_cpp_name(std::string((yyvsp[-3].id)));
2728       }
2729     }
2730 #line 2731 "thrift/thrifty.cc" /* yacc.c:1646  */
2731     break;
2732 
2733   case 106:
2734 #line 1136 "thrift/thrifty.yy" /* yacc.c:1646  */
2735     {
2736       pdebug("ListType -> tok_list<FieldType>");
2737       check_for_list_of_bytes((yyvsp[-2].ttype));
2738       (yyval.ttype) = new t_list((yyvsp[-2].ttype));
2739       if ((yyvsp[0].id) != nullptr) {
2740         ((t_container*)(yyval.ttype))->set_cpp_name(std::string((yyvsp[0].id)));
2741       }
2742     }
2743 #line 2744 "thrift/thrifty.cc" /* yacc.c:1646  */
2744     break;
2745 
2746   case 107:
2747 #line 1147 "thrift/thrifty.yy" /* yacc.c:1646  */
2748     {
2749       (yyval.id) = (yyvsp[0].id);
2750     }
2751 #line 2752 "thrift/thrifty.cc" /* yacc.c:1646  */
2752     break;
2753 
2754   case 108:
2755 #line 1151 "thrift/thrifty.yy" /* yacc.c:1646  */
2756     {
2757       (yyval.id) = nullptr;
2758     }
2759 #line 2760 "thrift/thrifty.cc" /* yacc.c:1646  */
2760     break;
2761 
2762   case 109:
2763 #line 1157 "thrift/thrifty.yy" /* yacc.c:1646  */
2764     {
2765       pdebug("TypeAnnotations -> ( TypeAnnotationList )");
2766       (yyval.ttype) = (yyvsp[-1].ttype);
2767     }
2768 #line 2769 "thrift/thrifty.cc" /* yacc.c:1646  */
2769     break;
2770 
2771   case 110:
2772 #line 1162 "thrift/thrifty.yy" /* yacc.c:1646  */
2773     {
2774       (yyval.ttype) = nullptr;
2775     }
2776 #line 2777 "thrift/thrifty.cc" /* yacc.c:1646  */
2777     break;
2778 
2779   case 111:
2780 #line 1168 "thrift/thrifty.yy" /* yacc.c:1646  */
2781     {
2782       pdebug("TypeAnnotationList -> TypeAnnotationList , TypeAnnotation");
2783       (yyval.ttype) = (yyvsp[-1].ttype);
2784       (yyval.ttype)->annotations_[(yyvsp[0].tannot)->key] = (yyvsp[0].tannot)->val;
2785       delete (yyvsp[0].tannot);
2786     }
2787 #line 2788 "thrift/thrifty.cc" /* yacc.c:1646  */
2788     break;
2789 
2790   case 112:
2791 #line 1175 "thrift/thrifty.yy" /* yacc.c:1646  */
2792     {
2793       /* Just use a dummy structure to hold the annotations. */
2794       (yyval.ttype) = new t_struct(g_program);
2795     }
2796 #line 2797 "thrift/thrifty.cc" /* yacc.c:1646  */
2797     break;
2798 
2799   case 113:
2800 #line 1182 "thrift/thrifty.yy" /* yacc.c:1646  */
2801     {
2802       pdebug("TypeAnnotation -> TypeAnnotationValue");
2803       (yyval.tannot) = new t_annotation;
2804       (yyval.tannot)->key = (yyvsp[-2].id);
2805       (yyval.tannot)->val = (yyvsp[-1].id);
2806     }
2807 #line 2808 "thrift/thrifty.cc" /* yacc.c:1646  */
2808     break;
2809 
2810   case 114:
2811 #line 1191 "thrift/thrifty.yy" /* yacc.c:1646  */
2812     {
2813       pdebug("TypeAnnotationValue -> = tok_literal");
2814       (yyval.id) = (yyvsp[0].id);
2815     }
2816 #line 2817 "thrift/thrifty.cc" /* yacc.c:1646  */
2817     break;
2818 
2819   case 115:
2820 #line 1196 "thrift/thrifty.yy" /* yacc.c:1646  */
2821     {
2822       pdebug("TypeAnnotationValue ->");
2823       (yyval.id) = strdup("1");
2824     }
2825 #line 2826 "thrift/thrifty.cc" /* yacc.c:1646  */
2826     break;
2827 
2828 
2829 #line 2830 "thrift/thrifty.cc" /* yacc.c:1646  */
2830       default: break;
2831     }
2832   /* User semantic actions sometimes alter yychar, and that requires
2833      that yytoken be updated with the new translation.  We take the
2834      approach of translating immediately before every use of yytoken.
2835      One alternative is translating here after every semantic action,
2836      but that translation would be missed if the semantic action invokes
2837      YYABORT, YYACCEPT, or YYERROR immediately after altering yychar or
2838      if it invokes YYBACKUP.  In the case of YYABORT or YYACCEPT, an
2839      incorrect destructor might then be invoked immediately.  In the
2840      case of YYERROR or YYBACKUP, subsequent parser actions might lead
2841      to an incorrect destructor call or verbose syntax error message
2842      before the lookahead is translated.  */
2843   YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc);
2844 
2845   YYPOPSTACK (yylen);
2846   yylen = 0;
2847   YY_STACK_PRINT (yyss, yyssp);
2848 
2849   *++yyvsp = yyval;
2850 
2851   /* Now 'shift' the result of the reduction.  Determine what state
2852      that goes to, based on the state we popped back to and the rule
2853      number reduced by.  */
2854 
2855   yyn = yyr1[yyn];
2856 
2857   yystate = yypgoto[yyn - YYNTOKENS] + *yyssp;
2858   if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp)
2859     yystate = yytable[yystate];
2860   else
2861     yystate = yydefgoto[yyn - YYNTOKENS];
2862 
2863   goto yynewstate;
2864 
2865 
2866 /*--------------------------------------.
2867 | yyerrlab -- here on detecting error.  |
2868 `--------------------------------------*/
2869 yyerrlab:
2870   /* Make sure we have latest lookahead translation.  See comments at
2871      user semantic actions for why this is necessary.  */
2872   yytoken = yychar == YYEMPTY ? YYEMPTY : YYTRANSLATE (yychar);
2873 
2874   /* If not already recovering from an error, report this error.  */
2875   if (!yyerrstatus)
2876     {
2877       ++yynerrs;
2878 #if ! YYERROR_VERBOSE
2879       yyerror (YY_("syntax error"));
2880 #else
2881 # define YYSYNTAX_ERROR yysyntax_error (&yymsg_alloc, &yymsg, \
2882                                         yyssp, yytoken)
2883       {
2884         char const *yymsgp = YY_("syntax error");
2885         int yysyntax_error_status;
2886         yysyntax_error_status = YYSYNTAX_ERROR;
2887         if (yysyntax_error_status == 0)
2888           yymsgp = yymsg;
2889         else if (yysyntax_error_status == 1)
2890           {
2891             if (yymsg != yymsgbuf)
2892               YYSTACK_FREE (yymsg);
2893             yymsg = (char *) YYSTACK_ALLOC (yymsg_alloc);
2894             if (!yymsg)
2895               {
2896                 yymsg = yymsgbuf;
2897                 yymsg_alloc = sizeof yymsgbuf;
2898                 yysyntax_error_status = 2;
2899               }
2900             else
2901               {
2902                 yysyntax_error_status = YYSYNTAX_ERROR;
2903                 yymsgp = yymsg;
2904               }
2905           }
2906         yyerror (yymsgp);
2907         if (yysyntax_error_status == 2)
2908           goto yyexhaustedlab;
2909       }
2910 # undef YYSYNTAX_ERROR
2911 #endif
2912     }
2913 
2914 
2915 
2916   if (yyerrstatus == 3)
2917     {
2918       /* If just tried and failed to reuse lookahead token after an
2919          error, discard it.  */
2920 
2921       if (yychar <= YYEOF)
2922         {
2923           /* Return failure if at end of input.  */
2924           if (yychar == YYEOF)
2925             YYABORT;
2926         }
2927       else
2928         {
2929           yydestruct ("Error: discarding",
2930                       yytoken, &yylval);
2931           yychar = YYEMPTY;
2932         }
2933     }
2934 
2935   /* Else will try to reuse lookahead token after shifting the error
2936      token.  */
2937   goto yyerrlab1;
2938 
2939 
2940 /*---------------------------------------------------.
2941 | yyerrorlab -- error raised explicitly by YYERROR.  |
2942 `---------------------------------------------------*/
2943 yyerrorlab:
2944 
2945   /* Pacify compilers like GCC when the user code never invokes
2946      YYERROR and the label yyerrorlab therefore never appears in user
2947      code.  */
2948   if (/*CONSTCOND*/ 0)
2949      goto yyerrorlab;
2950 
2951   /* Do not reclaim the symbols of the rule whose action triggered
2952      this YYERROR.  */
2953   YYPOPSTACK (yylen);
2954   yylen = 0;
2955   YY_STACK_PRINT (yyss, yyssp);
2956   yystate = *yyssp;
2957   goto yyerrlab1;
2958 
2959 
2960 /*-------------------------------------------------------------.
2961 | yyerrlab1 -- common code for both syntax error and YYERROR.  |
2962 `-------------------------------------------------------------*/
2963 yyerrlab1:
2964   yyerrstatus = 3;      /* Each real token shifted decrements this.  */
2965 
2966   for (;;)
2967     {
2968       yyn = yypact[yystate];
2969       if (!yypact_value_is_default (yyn))
2970         {
2971           yyn += YYTERROR;
2972           if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR)
2973             {
2974               yyn = yytable[yyn];
2975               if (0 < yyn)
2976                 break;
2977             }
2978         }
2979 
2980       /* Pop the current state because it cannot handle the error token.  */
2981       if (yyssp == yyss)
2982         YYABORT;
2983 
2984 
2985       yydestruct ("Error: popping",
2986                   yystos[yystate], yyvsp);
2987       YYPOPSTACK (1);
2988       yystate = *yyssp;
2989       YY_STACK_PRINT (yyss, yyssp);
2990     }
2991 
2992   YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
2993   *++yyvsp = yylval;
2994   YY_IGNORE_MAYBE_UNINITIALIZED_END
2995 
2996 
2997   /* Shift the error token.  */
2998   YY_SYMBOL_PRINT ("Shifting", yystos[yyn], yyvsp, yylsp);
2999 
3000   yystate = yyn;
3001   goto yynewstate;
3002 
3003 
3004 /*-------------------------------------.
3005 | yyacceptlab -- YYACCEPT comes here.  |
3006 `-------------------------------------*/
3007 yyacceptlab:
3008   yyresult = 0;
3009   goto yyreturn;
3010 
3011 /*-----------------------------------.
3012 | yyabortlab -- YYABORT comes here.  |
3013 `-----------------------------------*/
3014 yyabortlab:
3015   yyresult = 1;
3016   goto yyreturn;
3017 
3018 #if !defined yyoverflow || YYERROR_VERBOSE
3019 /*-------------------------------------------------.
3020 | yyexhaustedlab -- memory exhaustion comes here.  |
3021 `-------------------------------------------------*/
3022 yyexhaustedlab:
3023   yyerror (YY_("memory exhausted"));
3024   yyresult = 2;
3025   /* Fall through.  */
3026 #endif
3027 
3028 yyreturn:
3029   if (yychar != YYEMPTY)
3030     {
3031       /* Make sure we have latest lookahead translation.  See comments at
3032          user semantic actions for why this is necessary.  */
3033       yytoken = YYTRANSLATE (yychar);
3034       yydestruct ("Cleanup: discarding lookahead",
3035                   yytoken, &yylval);
3036     }
3037   /* Do not reclaim the symbols of the rule whose action triggered
3038      this YYABORT or YYACCEPT.  */
3039   YYPOPSTACK (yylen);
3040   YY_STACK_PRINT (yyss, yyssp);
3041   while (yyssp != yyss)
3042     {
3043       yydestruct ("Cleanup: popping",
3044                   yystos[*yyssp], yyvsp);
3045       YYPOPSTACK (1);
3046     }
3047 #ifndef yyoverflow
3048   if (yyss != yyssa)
3049     YYSTACK_FREE (yyss);
3050 #endif
3051 #if YYERROR_VERBOSE
3052   if (yymsg != yymsgbuf)
3053     YYSTACK_FREE (yymsg);
3054 #endif
3055   return yyresult;
3056 }
3057 #line 1201 "thrift/thrifty.yy" /* yacc.c:1906  */
3058 
3059