thrifty.cc 93 KB

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