yacc.c 70 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103
  1. # -*- C -*-
  2. # Yacc compatible skeleton for Bison
  3. # Copyright (C) 1984, 1989-1990, 2000-2015, 2018-2021 Free Software
  4. # Foundation, Inc.
  5. m4_pushdef([b4_copyright_years],
  6. [1984, 1989-1990, 2000-2015, 2018-2021])
  7. # This program is free software: you can redistribute it and/or modify
  8. # it under the terms of the GNU General Public License as published by
  9. # the Free Software Foundation, either version 3 of the License, or
  10. # (at your option) any later version.
  11. #
  12. # This program is distributed in the hope that it will be useful,
  13. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. # GNU General Public License for more details.
  16. #
  17. # You should have received a copy of the GNU General Public License
  18. # along with this program. If not, see <https://www.gnu.org/licenses/>.
  19. m4_include(b4_skeletonsdir/[c.m4])
  20. ## ---------- ##
  21. ## api.pure. ##
  22. ## ---------- ##
  23. b4_percent_define_default([[api.pure]], [[false]])
  24. b4_percent_define_check_values([[[[api.pure]],
  25. [[false]], [[true]], [[]], [[full]]]])
  26. m4_define([b4_pure_flag], [[0]])
  27. m4_case(b4_percent_define_get([[api.pure]]),
  28. [false], [m4_define([b4_pure_flag], [[0]])],
  29. [true], [m4_define([b4_pure_flag], [[1]])],
  30. [], [m4_define([b4_pure_flag], [[1]])],
  31. [full], [m4_define([b4_pure_flag], [[2]])])
  32. m4_define([b4_pure_if],
  33. [m4_case(b4_pure_flag,
  34. [0], [$2],
  35. [1], [$1],
  36. [2], [$1])])
  37. [m4_fatal([invalid api.pure value: ]$1)])])
  38. ## --------------- ##
  39. ## api.push-pull. ##
  40. ## --------------- ##
  41. # b4_pull_if, b4_push_if
  42. # ----------------------
  43. # Whether the pull/push APIs are needed. Both can be enabled.
  44. b4_percent_define_default([[api.push-pull]], [[pull]])
  45. b4_percent_define_check_values([[[[api.push-pull]],
  46. [[pull]], [[push]], [[both]]]])
  47. b4_define_flag_if([pull]) m4_define([b4_pull_flag], [[1]])
  48. b4_define_flag_if([push]) m4_define([b4_push_flag], [[1]])
  49. m4_case(b4_percent_define_get([[api.push-pull]]),
  50. [pull], [m4_define([b4_push_flag], [[0]])],
  51. [push], [m4_define([b4_pull_flag], [[0]])])
  52. # Handle BISON_USE_PUSH_FOR_PULL for the test suite. So that push parsing
  53. # tests function as written, do not let BISON_USE_PUSH_FOR_PULL modify the
  54. # behavior of Bison at all when push parsing is already requested.
  55. b4_define_flag_if([use_push_for_pull])
  56. b4_use_push_for_pull_if([
  57. b4_push_if([m4_define([b4_use_push_for_pull_flag], [[0]])],
  58. [m4_define([b4_push_flag], [[1]])])])
  59. ## ----------- ##
  60. ## parse.lac. ##
  61. ## ----------- ##
  62. b4_percent_define_default([[parse.lac]], [[none]])
  63. b4_percent_define_default([[parse.lac.es-capacity-initial]], [[20]])
  64. b4_percent_define_default([[parse.lac.memory-trace]], [[failures]])
  65. b4_percent_define_check_values([[[[parse.lac]], [[full]], [[none]]]],
  66. [[[[parse.lac.memory-trace]],
  67. [[failures]], [[full]]]])
  68. b4_define_flag_if([lac])
  69. m4_define([b4_lac_flag],
  70. [m4_if(b4_percent_define_get([[parse.lac]]),
  71. [none], [[0]], [[1]])])
  72. ## ---------------- ##
  73. ## Default values. ##
  74. ## ---------------- ##
  75. # Stack parameters.
  76. m4_define_default([b4_stack_depth_max], [10000])
  77. m4_define_default([b4_stack_depth_init], [200])
  78. # b4_yyerror_arg_loc_if(ARG)
  79. # --------------------------
  80. # Expand ARG iff yyerror is to be given a location as argument.
  81. m4_define([b4_yyerror_arg_loc_if],
  82. [b4_locations_if([m4_case(b4_pure_flag,
  83. [1], [m4_ifset([b4_parse_param], [$1])],
  84. [2], [$1])])])
  85. # b4_yyerror_args
  86. # ---------------
  87. # Arguments passed to yyerror: user args plus yylloc.
  88. m4_define([b4_yyerror_args],
  89. [b4_yyerror_arg_loc_if([&yylloc, ])dnl
  90. m4_ifset([b4_parse_param], [b4_args(b4_parse_param), ])])
  91. ## ----------------- ##
  92. ## Semantic Values. ##
  93. ## ----------------- ##
  94. # b4_lhs_value(SYMBOL-NUM, [TYPE])
  95. # --------------------------------
  96. # See README.
  97. m4_define([b4_lhs_value],
  98. [b4_symbol_value(yyval, [$1], [$2])])
  99. # b4_rhs_value(RULE-LENGTH, POS, [SYMBOL-NUM], [TYPE])
  100. # ----------------------------------------------------
  101. # See README.
  102. m4_define([b4_rhs_value],
  103. [b4_symbol_value([yyvsp@{b4_subtract([$2], [$1])@}], [$3], [$4])])
  104. ## ----------- ##
  105. ## Locations. ##
  106. ## ----------- ##
  107. # b4_lhs_location()
  108. # -----------------
  109. # Expansion of @$.
  110. # Overparenthetized to avoid obscure problems with "foo$$bar = foo$1bar".
  111. m4_define([b4_lhs_location],
  112. [(yyloc)])
  113. # b4_rhs_location(RULE-LENGTH, POS)
  114. # ---------------------------------
  115. # Expansion of @POS, where the current rule has RULE-LENGTH symbols
  116. # on RHS.
  117. # Overparenthetized to avoid obscure problems with "foo$$bar = foo$1bar".
  118. m4_define([b4_rhs_location],
  119. [(yylsp@{b4_subtract([$2], [$1])@})])
  120. ## -------------- ##
  121. ## Declarations. ##
  122. ## -------------- ##
  123. # b4_declare_scanner_communication_variables
  124. # ------------------------------------------
  125. # Declare the variables that are global, or local to YYPARSE if
  126. # pure-parser.
  127. m4_define([b4_declare_scanner_communication_variables], [[
  128. /* Lookahead token kind. */
  129. int yychar;
  130. ]b4_pure_if([[
  131. /* The semantic value of the lookahead symbol. */
  132. /* Default value used for initialization, for pacifying older GCCs
  133. or non-GCC compilers. */
  134. YY_INITIAL_VALUE (static YYSTYPE yyval_default;)
  135. YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default);]b4_locations_if([[
  136. /* Location data for the lookahead symbol. */
  137. static YYLTYPE yyloc_default]b4_yyloc_default[;
  138. YYLTYPE yylloc = yyloc_default;]])],
  139. [[/* The semantic value of the lookahead symbol. */
  140. YYSTYPE yylval;]b4_locations_if([[
  141. /* Location data for the lookahead symbol. */
  142. YYLTYPE yylloc]b4_yyloc_default[;]])[
  143. /* Number of syntax errors so far. */
  144. int yynerrs;]])])
  145. # b4_declare_parser_state_variables([INIT])
  146. # -----------------------------------------
  147. # Declare all the variables that are needed to maintain the parser state
  148. # between calls to yypush_parse.
  149. # If INIT is non-null, initialize these variables.
  150. m4_define([b4_declare_parser_state_variables],
  151. [b4_pure_if([[
  152. /* Number of syntax errors so far. */
  153. int yynerrs]m4_ifval([$1], [ = 0])[;
  154. ]])[
  155. yy_state_fast_t yystate]m4_ifval([$1], [ = 0])[;
  156. /* Number of tokens to shift before error messages enabled. */
  157. int yyerrstatus]m4_ifval([$1], [ = 0])[;
  158. /* Refer to the stacks through separate pointers, to allow yyoverflow
  159. to reallocate them elsewhere. */
  160. /* Their size. */
  161. YYPTRDIFF_T yystacksize]m4_ifval([$1], [ = YYINITDEPTH])[;
  162. /* The state stack: array, bottom, top. */
  163. yy_state_t yyssa[YYINITDEPTH];
  164. yy_state_t *yyss]m4_ifval([$1], [ = yyssa])[;
  165. yy_state_t *yyssp]m4_ifval([$1], [ = yyss])[;
  166. /* The semantic value stack: array, bottom, top. */
  167. YYSTYPE yyvsa[YYINITDEPTH];
  168. YYSTYPE *yyvs]m4_ifval([$1], [ = yyvsa])[;
  169. YYSTYPE *yyvsp]m4_ifval([$1], [ = yyvs])[;]b4_locations_if([[
  170. /* The location stack: array, bottom, top. */
  171. YYLTYPE yylsa[YYINITDEPTH];
  172. YYLTYPE *yyls]m4_ifval([$1], [ = yylsa])[;
  173. YYLTYPE *yylsp]m4_ifval([$1], [ = yyls])[;]])[]b4_lac_if([[
  174. yy_state_t yyesa@{]b4_percent_define_get([[parse.lac.es-capacity-initial]])[@};
  175. yy_state_t *yyes]m4_ifval([$1], [ = yyesa])[;
  176. YYPTRDIFF_T yyes_capacity][]m4_ifval([$1],
  177. [m4_do([ = b4_percent_define_get([[parse.lac.es-capacity-initial]]) < YYMAXDEPTH],
  178. [ ? b4_percent_define_get([[parse.lac.es-capacity-initial]])],
  179. [ : YYMAXDEPTH])])[;]])])
  180. m4_define([b4_macro_define],
  181. [[#]define $1 $2])
  182. m4_define([b4_macro_undef],
  183. [[#]undef $1])
  184. m4_define([b4_pstate_macro_define],
  185. [b4_macro_define([$1], [yyps->$1])])
  186. # b4_parse_state_variable_macros(b4_macro_define|b4_macro_undef)
  187. # --------------------------------------------------------------
  188. m4_define([b4_parse_state_variable_macros],
  189. [b4_pure_if([$1([b4_prefix[]nerrs])])
  190. $1([yystate])
  191. $1([yyerrstatus])
  192. $1([yyssa])
  193. $1([yyss])
  194. $1([yyssp])
  195. $1([yyvsa])
  196. $1([yyvs])
  197. $1([yyvsp])[]b4_locations_if([
  198. $1([yylsa])
  199. $1([yyls])
  200. $1([yylsp])])
  201. $1([yystacksize])[]b4_lac_if([
  202. $1([yyesa])
  203. $1([yyes])
  204. $1([yyes_capacity])])])
  205. # _b4_declare_yyparse_push
  206. # ------------------------
  207. # Declaration of yyparse (and dependencies) when using the push parser
  208. # (including in pull mode).
  209. m4_define([_b4_declare_yyparse_push],
  210. [[#ifndef YYPUSH_MORE_DEFINED
  211. # define YYPUSH_MORE_DEFINED
  212. enum { YYPUSH_MORE = 4 };
  213. #endif
  214. typedef struct ]b4_prefix[pstate ]b4_prefix[pstate;
  215. ]b4_pull_if([[
  216. int ]b4_prefix[parse (]m4_ifset([b4_parse_param], [b4_formals(b4_parse_param)], [void])[);]])[
  217. int ]b4_prefix[push_parse (]b4_prefix[pstate *ps]b4_pure_if([[,
  218. int pushed_char, ]b4_api_PREFIX[STYPE const *pushed_val]b4_locations_if([[, ]b4_api_PREFIX[LTYPE *pushed_loc]])])b4_user_formals[);
  219. ]b4_pull_if([[int ]b4_prefix[pull_parse (]b4_prefix[pstate *ps]b4_user_formals[);]])[
  220. ]b4_prefix[pstate *]b4_prefix[pstate_new (void);
  221. void ]b4_prefix[pstate_delete (]b4_prefix[pstate *ps);
  222. ]])
  223. # _b4_declare_yyparse
  224. # -------------------
  225. # When not the push parser.
  226. m4_define([_b4_declare_yyparse],
  227. [[int ]b4_prefix[parse (]m4_ifset([b4_parse_param], [b4_formals(b4_parse_param)], [void])[);]])
  228. # b4_declare_yyparse
  229. # ------------------
  230. m4_define([b4_declare_yyparse],
  231. [b4_push_if([_b4_declare_yyparse_push],
  232. [_b4_declare_yyparse])[]dnl
  233. ])
  234. # b4_shared_declarations
  235. # ----------------------
  236. # Declaration that might either go into the header (if --defines)
  237. # or open coded in the parser body.
  238. m4_define([b4_shared_declarations],
  239. [b4_cpp_guard_open([b4_spec_mapped_header_file])[
  240. ]b4_declare_yydebug[
  241. ]b4_percent_code_get([[requires]])[
  242. ]b4_token_enums_defines[
  243. ]b4_declare_yylstype[
  244. ]b4_declare_yyparse[
  245. ]b4_percent_code_get([[provides]])[
  246. ]b4_cpp_guard_close([b4_spec_mapped_header_file])[]dnl
  247. ])
  248. # b4_header_include_if(IF-TRUE, IF-FALSE)
  249. # ---------------------------------------
  250. # Run IF-TRUE if we generate an output file and api.header.include
  251. # is defined.
  252. m4_define([b4_header_include_if],
  253. [m4_ifval(m4_quote(b4_spec_header_file),
  254. [b4_percent_define_ifdef([[api.header.include]],
  255. [$1],
  256. [$2])],
  257. [$2])])
  258. m4_if(b4_spec_header_file, [y.tab.h], [],
  259. [b4_percent_define_default([[api.header.include]],
  260. [["@basename(]b4_spec_header_file[@)"]])])
  261. ## -------------- ##
  262. ## Output files. ##
  263. ## -------------- ##
  264. b4_defines_if([[
  265. ]b4_output_begin([b4_spec_header_file])[
  266. ]b4_copyright([Bison interface for Yacc-like parsers in C])[
  267. ]b4_disclaimer[
  268. ]b4_shared_declarations[
  269. ]b4_output_end[
  270. ]])# b4_defines_if
  271. b4_output_begin([b4_parser_file_name])[
  272. ]b4_copyright([Bison implementation for Yacc-like parsers in C])[
  273. /* C LALR(1) parser skeleton written by Richard Stallman, by
  274. simplifying the original so-called "semantic" parser. */
  275. ]b4_disclaimer[
  276. /* All symbols defined below should begin with yy or YY, to avoid
  277. infringing on user name space. This should be done even for local
  278. variables, as they might otherwise be expanded by user macros.
  279. There are some unavoidable exceptions within include files to
  280. define necessary library symbols; they are noted "INFRINGES ON
  281. USER NAME SPACE" below. */
  282. ]b4_identification[
  283. ]b4_percent_code_get([[top]])[]dnl
  284. m4_if(b4_api_prefix, [yy], [],
  285. [[/* Substitute the type names. */
  286. #define YYSTYPE ]b4_api_PREFIX[STYPE]b4_locations_if([[
  287. #define YYLTYPE ]b4_api_PREFIX[LTYPE]])])[
  288. ]m4_if(b4_prefix, [yy], [],
  289. [[/* Substitute the variable and function names. */]b4_pull_if([[
  290. #define yyparse ]b4_prefix[parse]])b4_push_if([[
  291. #define yypush_parse ]b4_prefix[push_parse]b4_pull_if([[
  292. #define yypull_parse ]b4_prefix[pull_parse]])[
  293. #define yypstate_new ]b4_prefix[pstate_new
  294. #define yypstate_clear ]b4_prefix[pstate_clear
  295. #define yypstate_delete ]b4_prefix[pstate_delete
  296. #define yypstate ]b4_prefix[pstate]])[
  297. #define yylex ]b4_prefix[lex
  298. #define yyerror ]b4_prefix[error
  299. #define yydebug ]b4_prefix[debug
  300. #define yynerrs ]b4_prefix[nerrs]]b4_pure_if([], [[
  301. #define yylval ]b4_prefix[lval
  302. #define yychar ]b4_prefix[char]b4_locations_if([[
  303. #define yylloc ]b4_prefix[lloc]])]))[
  304. ]b4_user_pre_prologue[
  305. ]b4_cast_define[
  306. ]b4_null_define[
  307. ]b4_header_include_if([[#include ]b4_percent_define_get([[api.header.include]])],
  308. [m4_ifval(m4_quote(b4_spec_header_file),
  309. [/* Use api.header.include to #include this header
  310. instead of duplicating it here. */
  311. ])b4_shared_declarations])[
  312. ]b4_declare_symbol_enum[
  313. ]b4_user_post_prologue[
  314. ]b4_percent_code_get[
  315. ]b4_c99_int_type_define[
  316. ]b4_sizes_types_define[
  317. /* Stored state numbers (used for stacks). */
  318. typedef ]b4_int_type(0, m4_eval(b4_states_number - 1))[ yy_state_t;
  319. /* State numbers in computations. */
  320. typedef int yy_state_fast_t;
  321. #ifndef YY_
  322. # if defined YYENABLE_NLS && YYENABLE_NLS
  323. # if ENABLE_NLS
  324. # include <libintl.h> /* INFRINGES ON USER NAME SPACE */
  325. # define YY_(Msgid) dgettext ("bison-runtime", Msgid)
  326. # endif
  327. # endif
  328. # ifndef YY_
  329. # define YY_(Msgid) Msgid
  330. # endif
  331. #endif
  332. ]b4_has_translations_if([
  333. #ifndef N_
  334. # define N_(Msgid) Msgid
  335. #endif
  336. ])[
  337. ]b4_attribute_define[
  338. ]b4_parse_assert_if([[#ifdef NDEBUG
  339. # define YY_ASSERT(E) ((void) (0 && (E)))
  340. #else
  341. # include <assert.h> /* INFRINGES ON USER NAME SPACE */
  342. # define YY_ASSERT(E) assert (E)
  343. #endif
  344. ]],
  345. [[#define YY_ASSERT(E) ((void) (0 && (E)))]])[
  346. #if ]b4_lac_if([[1]], [b4_parse_error_case([simple], [[!defined yyoverflow]], [[1]])])[
  347. /* The parser invokes alloca or malloc; define the necessary symbols. */]dnl
  348. b4_push_if([], [b4_lac_if([], [[
  349. # ifdef YYSTACK_USE_ALLOCA
  350. # if YYSTACK_USE_ALLOCA
  351. # ifdef __GNUC__
  352. # define YYSTACK_ALLOC __builtin_alloca
  353. # elif defined __BUILTIN_VA_ARG_INCR
  354. # include <alloca.h> /* INFRINGES ON USER NAME SPACE */
  355. # elif defined _AIX
  356. # define YYSTACK_ALLOC __alloca
  357. # elif defined _MSC_VER
  358. # include <malloc.h> /* INFRINGES ON USER NAME SPACE */
  359. # define alloca _alloca
  360. # else
  361. # define YYSTACK_ALLOC alloca
  362. # if ! defined _ALLOCA_H && ! defined EXIT_SUCCESS
  363. # include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
  364. /* Use EXIT_SUCCESS as a witness for stdlib.h. */
  365. # ifndef EXIT_SUCCESS
  366. # define EXIT_SUCCESS 0
  367. # endif
  368. # endif
  369. # endif
  370. # endif
  371. # endif]])])[
  372. # ifdef YYSTACK_ALLOC
  373. /* Pacify GCC's 'empty if-body' warning. */
  374. # define YYSTACK_FREE(Ptr) do { /* empty */; } while (0)
  375. # ifndef YYSTACK_ALLOC_MAXIMUM
  376. /* The OS might guarantee only one guard page at the bottom of the stack,
  377. and a page size can be as small as 4096 bytes. So we cannot safely
  378. invoke alloca (N) if N exceeds 4096. Use a slightly smaller number
  379. to allow for a few compiler-allocated temporary stack slots. */
  380. # define YYSTACK_ALLOC_MAXIMUM 4032 /* reasonable circa 2006 */
  381. # endif
  382. # else
  383. # define YYSTACK_ALLOC YYMALLOC
  384. # define YYSTACK_FREE YYFREE
  385. # ifndef YYSTACK_ALLOC_MAXIMUM
  386. # define YYSTACK_ALLOC_MAXIMUM YYSIZE_MAXIMUM
  387. # endif
  388. # if (defined __cplusplus && ! defined EXIT_SUCCESS \
  389. && ! ((defined YYMALLOC || defined malloc) \
  390. && (defined YYFREE || defined free)))
  391. # include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
  392. # ifndef EXIT_SUCCESS
  393. # define EXIT_SUCCESS 0
  394. # endif
  395. # endif
  396. # ifndef YYMALLOC
  397. # define YYMALLOC malloc
  398. # if ! defined malloc && ! defined EXIT_SUCCESS
  399. void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */
  400. # endif
  401. # endif
  402. # ifndef YYFREE
  403. # define YYFREE free
  404. # if ! defined free && ! defined EXIT_SUCCESS
  405. void free (void *); /* INFRINGES ON USER NAME SPACE */
  406. # endif
  407. # endif
  408. # endif]b4_lac_if([[
  409. # define YYCOPY_NEEDED 1]])[
  410. #endif /* ]b4_lac_if([[1]], [b4_parse_error_case([simple], [[!defined yyoverflow]], [[1]])])[ */
  411. #if (! defined yyoverflow \
  412. && (! defined __cplusplus \
  413. || (]b4_locations_if([[defined ]b4_api_PREFIX[LTYPE_IS_TRIVIAL && ]b4_api_PREFIX[LTYPE_IS_TRIVIAL \
  414. && ]])[defined ]b4_api_PREFIX[STYPE_IS_TRIVIAL && ]b4_api_PREFIX[STYPE_IS_TRIVIAL)))
  415. /* A type that is properly aligned for any stack member. */
  416. union yyalloc
  417. {
  418. yy_state_t yyss_alloc;
  419. YYSTYPE yyvs_alloc;]b4_locations_if([
  420. YYLTYPE yyls_alloc;])[
  421. };
  422. /* The size of the maximum gap between one aligned stack and the next. */
  423. # define YYSTACK_GAP_MAXIMUM (YYSIZEOF (union yyalloc) - 1)
  424. /* The size of an array large to enough to hold all stacks, each with
  425. N elements. */
  426. ]b4_locations_if(
  427. [# define YYSTACK_BYTES(N) \
  428. ((N) * (YYSIZEOF (yy_state_t) + YYSIZEOF (YYSTYPE) \
  429. + YYSIZEOF (YYLTYPE)) \
  430. + 2 * YYSTACK_GAP_MAXIMUM)],
  431. [# define YYSTACK_BYTES(N) \
  432. ((N) * (YYSIZEOF (yy_state_t) + YYSIZEOF (YYSTYPE)) \
  433. + YYSTACK_GAP_MAXIMUM)])[
  434. # define YYCOPY_NEEDED 1
  435. /* Relocate STACK from its old location to the new one. The
  436. local variables YYSIZE and YYSTACKSIZE give the old and new number of
  437. elements in the stack, and YYPTR gives the new location of the
  438. stack. Advance YYPTR to a properly aligned location for the next
  439. stack. */
  440. # define YYSTACK_RELOCATE(Stack_alloc, Stack) \
  441. do \
  442. { \
  443. YYPTRDIFF_T yynewbytes; \
  444. YYCOPY (&yyptr->Stack_alloc, Stack, yysize); \
  445. Stack = &yyptr->Stack_alloc; \
  446. yynewbytes = yystacksize * YYSIZEOF (*Stack) + YYSTACK_GAP_MAXIMUM; \
  447. yyptr += yynewbytes / YYSIZEOF (*yyptr); \
  448. } \
  449. while (0)
  450. #endif
  451. #if defined YYCOPY_NEEDED && YYCOPY_NEEDED
  452. /* Copy COUNT objects from SRC to DST. The source and destination do
  453. not overlap. */
  454. # ifndef YYCOPY
  455. # if defined __GNUC__ && 1 < __GNUC__
  456. # define YYCOPY(Dst, Src, Count) \
  457. __builtin_memcpy (Dst, Src, YY_CAST (YYSIZE_T, (Count)) * sizeof (*(Src)))
  458. # else
  459. # define YYCOPY(Dst, Src, Count) \
  460. do \
  461. { \
  462. YYPTRDIFF_T yyi; \
  463. for (yyi = 0; yyi < (Count); yyi++) \
  464. (Dst)[yyi] = (Src)[yyi]; \
  465. } \
  466. while (0)
  467. # endif
  468. # endif
  469. #endif /* !YYCOPY_NEEDED */
  470. /* YYFINAL -- State number of the termination state. */
  471. #define YYFINAL ]b4_final_state_number[
  472. /* YYLAST -- Last index in YYTABLE. */
  473. #define YYLAST ]b4_last[
  474. /* YYNTOKENS -- Number of terminals. */
  475. #define YYNTOKENS ]b4_tokens_number[
  476. /* YYNNTS -- Number of nonterminals. */
  477. #define YYNNTS ]b4_nterms_number[
  478. /* YYNRULES -- Number of rules. */
  479. #define YYNRULES ]b4_rules_number[
  480. /* YYNSTATES -- Number of states. */
  481. #define YYNSTATES ]b4_states_number[
  482. /* YYMAXUTOK -- Last valid token kind. */
  483. #define YYMAXUTOK ]b4_code_max[
  484. /* YYTRANSLATE(TOKEN-NUM) -- Symbol number corresponding to TOKEN-NUM
  485. as returned by yylex, with out-of-bounds checking. */
  486. ]b4_api_token_raw_if(dnl
  487. [[#define YYTRANSLATE(YYX) YY_CAST (yysymbol_kind_t, YYX)]],
  488. [[#define YYTRANSLATE(YYX) \
  489. (0 <= (YYX) && (YYX) <= YYMAXUTOK \
  490. ? YY_CAST (yysymbol_kind_t, yytranslate[YYX]) \
  491. : ]b4_symbol_prefix[YYUNDEF)
  492. /* YYTRANSLATE[TOKEN-NUM] -- Symbol number corresponding to TOKEN-NUM
  493. as returned by yylex. */
  494. static const ]b4_int_type_for([b4_translate])[ yytranslate[] =
  495. {
  496. ]b4_translate[
  497. };]])[
  498. #if ]b4_api_PREFIX[DEBUG
  499. ]b4_integral_parser_table_define([rline], [b4_rline],
  500. [[YYRLINE[YYN] -- Source line where rule number YYN was defined.]])[
  501. #endif
  502. /** Accessing symbol of state STATE. */
  503. #define YY_ACCESSING_SYMBOL(State) YY_CAST (yysymbol_kind_t, yystos[State])
  504. #if ]b4_parse_error_case([simple], [b4_api_PREFIX[DEBUG || ]b4_token_table_flag], [[1]])[
  505. /* The user-facing name of the symbol whose (internal) number is
  506. YYSYMBOL. No bounds checking. */
  507. static const char *yysymbol_name (yysymbol_kind_t yysymbol) YY_ATTRIBUTE_UNUSED;
  508. ]b4_parse_error_bmatch([simple\|verbose],
  509. [[/* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
  510. First, the terminals, then, starting at YYNTOKENS, nonterminals. */
  511. static const char *const yytname[] =
  512. {
  513. ]b4_tname[
  514. };
  515. static const char *
  516. yysymbol_name (yysymbol_kind_t yysymbol)
  517. {
  518. return yytname[yysymbol];
  519. }]],
  520. [[static const char *
  521. yysymbol_name (yysymbol_kind_t yysymbol)
  522. {
  523. static const char *const yy_sname[] =
  524. {
  525. ]b4_symbol_names[
  526. };]b4_has_translations_if([[
  527. /* YYTRANSLATABLE[SYMBOL-NUM] -- Whether YY_SNAME[SYMBOL-NUM] is
  528. internationalizable. */
  529. static ]b4_int_type_for([b4_translatable])[ yytranslatable[] =
  530. {
  531. ]b4_translatable[
  532. };
  533. return (yysymbol < YYNTOKENS && yytranslatable[yysymbol]
  534. ? _(yy_sname[yysymbol])
  535. : yy_sname[yysymbol]);]], [[
  536. return yy_sname[yysymbol];]])[
  537. }]])[
  538. #endif
  539. #ifdef YYPRINT
  540. /* YYTOKNUM[NUM] -- (External) token number corresponding to the
  541. (internal) symbol number NUM (which must be that of a token). */
  542. static const ]b4_int_type_for([b4_toknum])[ yytoknum[] =
  543. {
  544. ]b4_toknum[
  545. };
  546. #endif
  547. #define YYPACT_NINF (]b4_pact_ninf[)
  548. #define yypact_value_is_default(Yyn) \
  549. ]b4_table_value_equals([[pact]], [[Yyn]], [b4_pact_ninf], [YYPACT_NINF])[
  550. #define YYTABLE_NINF (]b4_table_ninf[)
  551. #define yytable_value_is_error(Yyn) \
  552. ]b4_table_value_equals([[table]], [[Yyn]], [b4_table_ninf], [YYTABLE_NINF])[
  553. ]b4_parser_tables_define[
  554. enum { YYENOMEM = -2 };
  555. #define yyerrok (yyerrstatus = 0)
  556. #define yyclearin (yychar = ]b4_symbol(-2, id)[)
  557. #define YYACCEPT goto yyacceptlab
  558. #define YYABORT goto yyabortlab
  559. #define YYERROR goto yyerrorlab
  560. #define YYRECOVERING() (!!yyerrstatus)
  561. #define YYBACKUP(Token, Value) \
  562. do \
  563. if (yychar == ]b4_symbol(-2, id)[) \
  564. { \
  565. yychar = (Token); \
  566. yylval = (Value); \
  567. YYPOPSTACK (yylen); \
  568. yystate = *yyssp; \]b4_lac_if([[
  569. YY_LAC_DISCARD ("YYBACKUP"); \]])[
  570. goto yybackup; \
  571. } \
  572. else \
  573. { \
  574. yyerror (]b4_yyerror_args[YY_("syntax error: cannot back up")); \
  575. YYERROR; \
  576. } \
  577. while (0)
  578. /* Backward compatibility with an undocumented macro.
  579. Use ]b4_symbol(1, id)[ or ]b4_symbol(2, id)[. */
  580. #define YYERRCODE ]b4_symbol(2, id)[
  581. ]b4_locations_if([[
  582. ]b4_yylloc_default_define[
  583. #define YYRHSLOC(Rhs, K) ((Rhs)[K])
  584. ]])[
  585. /* Enable debugging if requested. */
  586. #if ]b4_api_PREFIX[DEBUG
  587. # ifndef YYFPRINTF
  588. # include <stdio.h> /* INFRINGES ON USER NAME SPACE */
  589. # define YYFPRINTF fprintf
  590. # endif
  591. # define YYDPRINTF(Args) \
  592. do { \
  593. if (yydebug) \
  594. YYFPRINTF Args; \
  595. } while (0)
  596. ]b4_yy_location_print_define[
  597. # define YY_SYMBOL_PRINT(Title, Kind, Value, Location) \
  598. do { \
  599. if (yydebug) \
  600. { \
  601. YYFPRINTF (stderr, "%s ", Title); \
  602. yy_symbol_print (stderr, \
  603. Kind, Value]b4_locations_if([, Location])[]b4_user_args[); \
  604. YYFPRINTF (stderr, "\n"); \
  605. } \
  606. } while (0)
  607. ]b4_yy_symbol_print_define[
  608. /*------------------------------------------------------------------.
  609. | yy_stack_print -- Print the state stack from its BOTTOM up to its |
  610. | TOP (included). |
  611. `------------------------------------------------------------------*/
  612. static void
  613. yy_stack_print (yy_state_t *yybottom, yy_state_t *yytop)
  614. {
  615. YYFPRINTF (stderr, "Stack now");
  616. for (; yybottom <= yytop; yybottom++)
  617. {
  618. int yybot = *yybottom;
  619. YYFPRINTF (stderr, " %d", yybot);
  620. }
  621. YYFPRINTF (stderr, "\n");
  622. }
  623. # define YY_STACK_PRINT(Bottom, Top) \
  624. do { \
  625. if (yydebug) \
  626. yy_stack_print ((Bottom), (Top)); \
  627. } while (0)
  628. /*------------------------------------------------.
  629. | Report that the YYRULE is going to be reduced. |
  630. `------------------------------------------------*/
  631. static void
  632. yy_reduce_print (yy_state_t *yyssp, YYSTYPE *yyvsp,]b4_locations_if([[ YYLTYPE *yylsp,]])[
  633. int yyrule]b4_user_formals[)
  634. {
  635. int yylno = yyrline[yyrule];
  636. int yynrhs = yyr2[yyrule];
  637. int yyi;
  638. YYFPRINTF (stderr, "Reducing stack by rule %d (line %d):\n",
  639. yyrule - 1, yylno);
  640. /* The symbols being reduced. */
  641. for (yyi = 0; yyi < yynrhs; yyi++)
  642. {
  643. YYFPRINTF (stderr, " $%d = ", yyi + 1);
  644. yy_symbol_print (stderr,
  645. YY_ACCESSING_SYMBOL (+yyssp[yyi + 1 - yynrhs]),
  646. &]b4_rhs_value(yynrhs, yyi + 1)[]b4_locations_if([,
  647. &]b4_rhs_location(yynrhs, yyi + 1))[]b4_user_args[);
  648. YYFPRINTF (stderr, "\n");
  649. }
  650. }
  651. # define YY_REDUCE_PRINT(Rule) \
  652. do { \
  653. if (yydebug) \
  654. yy_reduce_print (yyssp, yyvsp, ]b4_locations_if([yylsp, ])[Rule]b4_user_args[); \
  655. } while (0)
  656. /* Nonzero means print parse trace. It is left uninitialized so that
  657. multiple parsers can coexist. */
  658. int yydebug;
  659. #else /* !]b4_api_PREFIX[DEBUG */
  660. # define YYDPRINTF(Args) ((void) 0)
  661. # define YY_SYMBOL_PRINT(Title, Kind, Value, Location)
  662. # define YY_STACK_PRINT(Bottom, Top)
  663. # define YY_REDUCE_PRINT(Rule)
  664. #endif /* !]b4_api_PREFIX[DEBUG */
  665. /* YYINITDEPTH -- initial size of the parser's stacks. */
  666. #ifndef YYINITDEPTH
  667. # define YYINITDEPTH ]b4_stack_depth_init[
  668. #endif
  669. /* YYMAXDEPTH -- maximum size the stacks can grow to (effective only
  670. if the built-in stack extension method is used).
  671. Do not make this value too large; the results are undefined if
  672. YYSTACK_ALLOC_MAXIMUM < YYSTACK_BYTES (YYMAXDEPTH)
  673. evaluated with infinite-precision integer arithmetic. */
  674. #ifndef YYMAXDEPTH
  675. # define YYMAXDEPTH ]b4_stack_depth_max[
  676. #endif]b4_push_if([[
  677. /* Parser data structure. */
  678. struct yypstate
  679. {]b4_declare_parser_state_variables[
  680. /* Whether this instance has not started parsing yet.
  681. * If 2, it corresponds to a finished parsing. */
  682. int yynew;
  683. };]b4_pure_if([], [[
  684. /* Whether the only allowed instance of yypstate is allocated. */
  685. static char yypstate_allocated = 0;]])])[
  686. ]b4_lac_if([[
  687. /* Given a state stack such that *YYBOTTOM is its bottom, such that
  688. *YYTOP is either its top or is YYTOP_EMPTY to indicate an empty
  689. stack, and such that *YYCAPACITY is the maximum number of elements it
  690. can hold without a reallocation, make sure there is enough room to
  691. store YYADD more elements. If not, allocate a new stack using
  692. YYSTACK_ALLOC, copy the existing elements, and adjust *YYBOTTOM,
  693. *YYTOP, and *YYCAPACITY to reflect the new capacity and memory
  694. location. If *YYBOTTOM != YYBOTTOM_NO_FREE, then free the old stack
  695. using YYSTACK_FREE. Return 0 if successful or if no reallocation is
  696. required. Return YYENOMEM if memory is exhausted. */
  697. static int
  698. yy_lac_stack_realloc (YYPTRDIFF_T *yycapacity, YYPTRDIFF_T yyadd,
  699. #if ]b4_api_PREFIX[DEBUG
  700. char const *yydebug_prefix,
  701. char const *yydebug_suffix,
  702. #endif
  703. yy_state_t **yybottom,
  704. yy_state_t *yybottom_no_free,
  705. yy_state_t **yytop, yy_state_t *yytop_empty)
  706. {
  707. YYPTRDIFF_T yysize_old =
  708. *yytop == yytop_empty ? 0 : *yytop - *yybottom + 1;
  709. YYPTRDIFF_T yysize_new = yysize_old + yyadd;
  710. if (*yycapacity < yysize_new)
  711. {
  712. YYPTRDIFF_T yyalloc = 2 * yysize_new;
  713. yy_state_t *yybottom_new;
  714. /* Use YYMAXDEPTH for maximum stack size given that the stack
  715. should never need to grow larger than the main state stack
  716. needs to grow without LAC. */
  717. if (YYMAXDEPTH < yysize_new)
  718. {
  719. YYDPRINTF ((stderr, "%smax size exceeded%s", yydebug_prefix,
  720. yydebug_suffix));
  721. return YYENOMEM;
  722. }
  723. if (YYMAXDEPTH < yyalloc)
  724. yyalloc = YYMAXDEPTH;
  725. yybottom_new =
  726. YY_CAST (yy_state_t *,
  727. YYSTACK_ALLOC (YY_CAST (YYSIZE_T,
  728. yyalloc * YYSIZEOF (*yybottom_new))));
  729. if (!yybottom_new)
  730. {
  731. YYDPRINTF ((stderr, "%srealloc failed%s", yydebug_prefix,
  732. yydebug_suffix));
  733. return YYENOMEM;
  734. }
  735. if (*yytop != yytop_empty)
  736. {
  737. YYCOPY (yybottom_new, *yybottom, yysize_old);
  738. *yytop = yybottom_new + (yysize_old - 1);
  739. }
  740. if (*yybottom != yybottom_no_free)
  741. YYSTACK_FREE (*yybottom);
  742. *yybottom = yybottom_new;
  743. *yycapacity = yyalloc;]m4_if(b4_percent_define_get([[parse.lac.memory-trace]]),
  744. [full], [[
  745. YY_IGNORE_USELESS_CAST_BEGIN
  746. YYDPRINTF ((stderr, "%srealloc to %ld%s", yydebug_prefix,
  747. YY_CAST (long, yyalloc), yydebug_suffix));
  748. YY_IGNORE_USELESS_CAST_END]])[
  749. }
  750. return 0;
  751. }
  752. /* Establish the initial context for the current lookahead if no initial
  753. context is currently established.
  754. We define a context as a snapshot of the parser stacks. We define
  755. the initial context for a lookahead as the context in which the
  756. parser initially examines that lookahead in order to select a
  757. syntactic action. Thus, if the lookahead eventually proves
  758. syntactically unacceptable (possibly in a later context reached via a
  759. series of reductions), the initial context can be used to determine
  760. the exact set of tokens that would be syntactically acceptable in the
  761. lookahead's place. Moreover, it is the context after which any
  762. further semantic actions would be erroneous because they would be
  763. determined by a syntactically unacceptable token.
  764. YY_LAC_ESTABLISH should be invoked when a reduction is about to be
  765. performed in an inconsistent state (which, for the purposes of LAC,
  766. includes consistent states that don't know they're consistent because
  767. their default reductions have been disabled). Iff there is a
  768. lookahead token, it should also be invoked before reporting a syntax
  769. error. This latter case is for the sake of the debugging output.
  770. For parse.lac=full, the implementation of YY_LAC_ESTABLISH is as
  771. follows. If no initial context is currently established for the
  772. current lookahead, then check if that lookahead can eventually be
  773. shifted if syntactic actions continue from the current context.
  774. Report a syntax error if it cannot. */
  775. #define YY_LAC_ESTABLISH \
  776. do { \
  777. if (!yy_lac_established) \
  778. { \
  779. YYDPRINTF ((stderr, \
  780. "LAC: initial context established for %s\n", \
  781. yysymbol_name (yytoken))); \
  782. yy_lac_established = 1; \
  783. switch (yy_lac (yyesa, &yyes, &yyes_capacity, yyssp, yytoken)) \
  784. { \
  785. case YYENOMEM: \
  786. goto yyexhaustedlab; \
  787. case 1: \
  788. goto yyerrlab; \
  789. } \
  790. } \
  791. } while (0)
  792. /* Discard any previous initial lookahead context because of Event,
  793. which may be a lookahead change or an invalidation of the currently
  794. established initial context for the current lookahead.
  795. The most common example of a lookahead change is a shift. An example
  796. of both cases is syntax error recovery. That is, a syntax error
  797. occurs when the lookahead is syntactically erroneous for the
  798. currently established initial context, so error recovery manipulates
  799. the parser stacks to try to find a new initial context in which the
  800. current lookahead is syntactically acceptable. If it fails to find
  801. such a context, it discards the lookahead. */
  802. #if ]b4_api_PREFIX[DEBUG
  803. # define YY_LAC_DISCARD(Event) \
  804. do { \
  805. if (yy_lac_established) \
  806. { \
  807. YYDPRINTF ((stderr, "LAC: initial context discarded due to " \
  808. Event "\n")); \
  809. yy_lac_established = 0; \
  810. } \
  811. } while (0)
  812. #else
  813. # define YY_LAC_DISCARD(Event) yy_lac_established = 0
  814. #endif
  815. /* Given the stack whose top is *YYSSP, return 0 iff YYTOKEN can
  816. eventually (after perhaps some reductions) be shifted, return 1 if
  817. not, or return YYENOMEM if memory is exhausted. As preconditions and
  818. postconditions: *YYES_CAPACITY is the allocated size of the array to
  819. which *YYES points, and either *YYES = YYESA or *YYES points to an
  820. array allocated with YYSTACK_ALLOC. yy_lac may overwrite the
  821. contents of either array, alter *YYES and *YYES_CAPACITY, and free
  822. any old *YYES other than YYESA. */
  823. static int
  824. yy_lac (yy_state_t *yyesa, yy_state_t **yyes,
  825. YYPTRDIFF_T *yyes_capacity, yy_state_t *yyssp, yysymbol_kind_t yytoken)
  826. {
  827. yy_state_t *yyes_prev = yyssp;
  828. yy_state_t *yyesp = yyes_prev;
  829. /* Reduce until we encounter a shift and thereby accept the token. */
  830. YYDPRINTF ((stderr, "LAC: checking lookahead %s:", yysymbol_name (yytoken)));
  831. if (yytoken == ]b4_symbol_prefix[YYUNDEF)
  832. {
  833. YYDPRINTF ((stderr, " Always Err\n"));
  834. return 1;
  835. }
  836. while (1)
  837. {
  838. int yyrule = yypact[+*yyesp];
  839. if (yypact_value_is_default (yyrule)
  840. || (yyrule += yytoken) < 0 || YYLAST < yyrule
  841. || yycheck[yyrule] != yytoken)
  842. {
  843. /* Use the default action. */
  844. yyrule = yydefact[+*yyesp];
  845. if (yyrule == 0)
  846. {
  847. YYDPRINTF ((stderr, " Err\n"));
  848. return 1;
  849. }
  850. }
  851. else
  852. {
  853. /* Use the action from yytable. */
  854. yyrule = yytable[yyrule];
  855. if (yytable_value_is_error (yyrule))
  856. {
  857. YYDPRINTF ((stderr, " Err\n"));
  858. return 1;
  859. }
  860. if (0 < yyrule)
  861. {
  862. YYDPRINTF ((stderr, " S%d\n", yyrule));
  863. return 0;
  864. }
  865. yyrule = -yyrule;
  866. }
  867. /* By now we know we have to simulate a reduce. */
  868. YYDPRINTF ((stderr, " R%d", yyrule - 1));
  869. {
  870. /* Pop the corresponding number of values from the stack. */
  871. YYPTRDIFF_T yylen = yyr2[yyrule];
  872. /* First pop from the LAC stack as many tokens as possible. */
  873. if (yyesp != yyes_prev)
  874. {
  875. YYPTRDIFF_T yysize = yyesp - *yyes + 1;
  876. if (yylen < yysize)
  877. {
  878. yyesp -= yylen;
  879. yylen = 0;
  880. }
  881. else
  882. {
  883. yyesp = yyes_prev;
  884. yylen -= yysize;
  885. }
  886. }
  887. /* Only afterwards look at the main stack. */
  888. if (yylen)
  889. yyesp = yyes_prev -= yylen;
  890. }
  891. /* Push the resulting state of the reduction. */
  892. {
  893. yy_state_fast_t yystate;
  894. {
  895. const int yylhs = yyr1[yyrule] - YYNTOKENS;
  896. const int yyi = yypgoto[yylhs] + *yyesp;
  897. yystate = (0 <= yyi && yyi <= YYLAST && yycheck[yyi] == *yyesp
  898. ? yytable[yyi]
  899. : yydefgoto[yylhs]);
  900. }
  901. if (yyesp == yyes_prev)
  902. {
  903. yyesp = *yyes;
  904. YY_IGNORE_USELESS_CAST_BEGIN
  905. *yyesp = YY_CAST (yy_state_t, yystate);
  906. YY_IGNORE_USELESS_CAST_END
  907. }
  908. else
  909. {
  910. if (yy_lac_stack_realloc (yyes_capacity, 1,
  911. #if ]b4_api_PREFIX[DEBUG
  912. " (", ")",
  913. #endif
  914. yyes, yyesa, &yyesp, yyes_prev))
  915. {
  916. YYDPRINTF ((stderr, "\n"));
  917. return YYENOMEM;
  918. }
  919. YY_IGNORE_USELESS_CAST_BEGIN
  920. *++yyesp = YY_CAST (yy_state_t, yystate);
  921. YY_IGNORE_USELESS_CAST_END
  922. }
  923. YYDPRINTF ((stderr, " G%d", yystate));
  924. }
  925. }
  926. }]])[
  927. ]b4_parse_error_case([simple], [],
  928. [[/* Context of a parse error. */
  929. typedef struct
  930. {]b4_push_if([[
  931. yypstate* yyps;]], [[
  932. yy_state_t *yyssp;]b4_lac_if([[
  933. yy_state_t *yyesa;
  934. yy_state_t **yyes;
  935. YYPTRDIFF_T *yyes_capacity;]])])[
  936. yysymbol_kind_t yytoken;]b4_locations_if([[
  937. YYLTYPE *yylloc;]])[
  938. } yypcontext_t;
  939. /* Put in YYARG at most YYARGN of the expected tokens given the
  940. current YYCTX, and return the number of tokens stored in YYARG. If
  941. YYARG is null, return the number of expected tokens (guaranteed to
  942. be less than YYNTOKENS). Return YYENOMEM on memory exhaustion.
  943. Return 0 if there are more than YYARGN expected tokens, yet fill
  944. YYARG up to YYARGN. */]b4_push_if([[
  945. static int
  946. yypstate_expected_tokens (yypstate *yyps,
  947. yysymbol_kind_t yyarg[], int yyargn)]], [[
  948. static int
  949. yypcontext_expected_tokens (const yypcontext_t *yyctx,
  950. yysymbol_kind_t yyarg[], int yyargn)]])[
  951. {
  952. /* Actual size of YYARG. */
  953. int yycount = 0;
  954. ]b4_lac_if([[
  955. int yyx;
  956. for (yyx = 0; yyx < YYNTOKENS; ++yyx)
  957. {
  958. yysymbol_kind_t yysym = YY_CAST (yysymbol_kind_t, yyx);
  959. if (yysym != ]b4_symbol(1, kind)[ && yysym != ]b4_symbol_prefix[YYUNDEF)
  960. switch (yy_lac (]b4_push_if([[yyps->yyesa, &yyps->yyes, &yyps->yyes_capacity, yyps->yyssp, yysym]],
  961. [[yyctx->yyesa, yyctx->yyes, yyctx->yyes_capacity, yyctx->yyssp, yysym]])[))
  962. {
  963. case YYENOMEM:
  964. return YYENOMEM;
  965. case 1:
  966. continue;
  967. default:
  968. if (!yyarg)
  969. ++yycount;
  970. else if (yycount == yyargn)
  971. return 0;
  972. else
  973. yyarg[yycount++] = yysym;
  974. }
  975. }]],
  976. [[ int yyn = yypact@{+*]b4_push_if([yyps], [yyctx])[->yyssp@};
  977. if (!yypact_value_is_default (yyn))
  978. {
  979. /* Start YYX at -YYN if negative to avoid negative indexes in
  980. YYCHECK. In other words, skip the first -YYN actions for
  981. this state because they are default actions. */
  982. int yyxbegin = yyn < 0 ? -yyn : 0;
  983. /* Stay within bounds of both yycheck and yytname. */
  984. int yychecklim = YYLAST - yyn + 1;
  985. int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS;
  986. int yyx;
  987. for (yyx = yyxbegin; yyx < yyxend; ++yyx)
  988. if (yycheck[yyx + yyn] == yyx && yyx != ]b4_symbol(1, kind)[
  989. && !yytable_value_is_error (yytable[yyx + yyn]))
  990. {
  991. if (!yyarg)
  992. ++yycount;
  993. else if (yycount == yyargn)
  994. return 0;
  995. else
  996. yyarg[yycount++] = YY_CAST (yysymbol_kind_t, yyx);
  997. }
  998. }]])[
  999. if (yyarg && yycount == 0 && 0 < yyargn)
  1000. yyarg[0] = ]b4_symbol(-2, kind)[;
  1001. return yycount;
  1002. }
  1003. ]b4_push_if([[
  1004. /* Similar to the previous function. */
  1005. static int
  1006. yypcontext_expected_tokens (const yypcontext_t *yyctx,
  1007. yysymbol_kind_t yyarg[], int yyargn)
  1008. {
  1009. return yypstate_expected_tokens (yyctx->yyps, yyarg, yyargn);
  1010. }]])[
  1011. ]])[
  1012. ]b4_parse_error_bmatch(
  1013. [custom],
  1014. [[/* The kind of the lookahead of this context. */
  1015. static yysymbol_kind_t
  1016. yypcontext_token (const yypcontext_t *yyctx) YY_ATTRIBUTE_UNUSED;
  1017. static yysymbol_kind_t
  1018. yypcontext_token (const yypcontext_t *yyctx)
  1019. {
  1020. return yyctx->yytoken;
  1021. }
  1022. ]b4_locations_if([[/* The location of the lookahead of this context. */
  1023. static YYLTYPE *
  1024. yypcontext_location (const yypcontext_t *yyctx) YY_ATTRIBUTE_UNUSED;
  1025. static YYLTYPE *
  1026. yypcontext_location (const yypcontext_t *yyctx)
  1027. {
  1028. return yyctx->yylloc;
  1029. }]])[
  1030. /* User defined function to report a syntax error. */
  1031. static int
  1032. yyreport_syntax_error (const yypcontext_t *yyctx]b4_user_formals[);]],
  1033. [detailed\|verbose],
  1034. [[#ifndef yystrlen
  1035. # if defined __GLIBC__ && defined _STRING_H
  1036. # define yystrlen(S) (YY_CAST (YYPTRDIFF_T, strlen (S)))
  1037. # else
  1038. /* Return the length of YYSTR. */
  1039. static YYPTRDIFF_T
  1040. yystrlen (const char *yystr)
  1041. {
  1042. YYPTRDIFF_T yylen;
  1043. for (yylen = 0; yystr[yylen]; yylen++)
  1044. continue;
  1045. return yylen;
  1046. }
  1047. # endif
  1048. #endif
  1049. #ifndef yystpcpy
  1050. # if defined __GLIBC__ && defined _STRING_H && defined _GNU_SOURCE
  1051. # define yystpcpy stpcpy
  1052. # else
  1053. /* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in
  1054. YYDEST. */
  1055. static char *
  1056. yystpcpy (char *yydest, const char *yysrc)
  1057. {
  1058. char *yyd = yydest;
  1059. const char *yys = yysrc;
  1060. while ((*yyd++ = *yys++) != '\0')
  1061. continue;
  1062. return yyd - 1;
  1063. }
  1064. # endif
  1065. #endif
  1066. ]b4_parse_error_case(
  1067. [verbose],
  1068. [[#ifndef yytnamerr
  1069. /* Copy to YYRES the contents of YYSTR after stripping away unnecessary
  1070. quotes and backslashes, so that it's suitable for yyerror. The
  1071. heuristic is that double-quoting is unnecessary unless the string
  1072. contains an apostrophe, a comma, or backslash (other than
  1073. backslash-backslash). YYSTR is taken from yytname. If YYRES is
  1074. null, do not copy; instead, return the length of what the result
  1075. would have been. */
  1076. static YYPTRDIFF_T
  1077. yytnamerr (char *yyres, const char *yystr)
  1078. {
  1079. if (*yystr == '"')
  1080. {
  1081. YYPTRDIFF_T yyn = 0;
  1082. char const *yyp = yystr;
  1083. for (;;)
  1084. switch (*++yyp)
  1085. {
  1086. case '\'':
  1087. case ',':
  1088. goto do_not_strip_quotes;
  1089. case '\\':
  1090. if (*++yyp != '\\')
  1091. goto do_not_strip_quotes;
  1092. else
  1093. goto append;
  1094. append:
  1095. default:
  1096. if (yyres)
  1097. yyres[yyn] = *yyp;
  1098. yyn++;
  1099. break;
  1100. case '"':
  1101. if (yyres)
  1102. yyres[yyn] = '\0';
  1103. return yyn;
  1104. }
  1105. do_not_strip_quotes: ;
  1106. }
  1107. if (yyres)
  1108. return yystpcpy (yyres, yystr) - yyres;
  1109. else
  1110. return yystrlen (yystr);
  1111. }
  1112. #endif
  1113. ]])[
  1114. static int
  1115. yy_syntax_error_arguments (const yypcontext_t *yyctx,
  1116. yysymbol_kind_t yyarg[], int yyargn)
  1117. {
  1118. /* Actual size of YYARG. */
  1119. int yycount = 0;
  1120. /* There are many possibilities here to consider:
  1121. - If this state is a consistent state with a default action, then
  1122. the only way this function was invoked is if the default action
  1123. is an error action. In that case, don't check for expected
  1124. tokens because there are none.
  1125. - The only way there can be no lookahead present (in yychar) is if
  1126. this state is a consistent state with a default action. Thus,
  1127. detecting the absence of a lookahead is sufficient to determine
  1128. that there is no unexpected or expected token to report. In that
  1129. case, just report a simple "syntax error".
  1130. - Don't assume there isn't a lookahead just because this state is a
  1131. consistent state with a default action. There might have been a
  1132. previous inconsistent state, consistent state with a non-default
  1133. action, or user semantic action that manipulated yychar.]b4_lac_if([[
  1134. In the first two cases, it might appear that the current syntax
  1135. error should have been detected in the previous state when yy_lac
  1136. was invoked. However, at that time, there might have been a
  1137. different syntax error that discarded a different initial context
  1138. during error recovery, leaving behind the current lookahead.]], [[
  1139. - Of course, the expected token list depends on states to have
  1140. correct lookahead information, and it depends on the parser not
  1141. to perform extra reductions after fetching a lookahead from the
  1142. scanner and before detecting a syntax error. Thus, state merging
  1143. (from LALR or IELR) and default reductions corrupt the expected
  1144. token list. However, the list is correct for canonical LR with
  1145. one exception: it will still contain any token that will not be
  1146. accepted due to an error action in a later state.]])[
  1147. */
  1148. if (yyctx->yytoken != ]b4_symbol(-2, kind)[)
  1149. {
  1150. int yyn;]b4_lac_if([[
  1151. YYDPRINTF ((stderr, "Constructing syntax error message\n"));]])[
  1152. if (yyarg)
  1153. yyarg[yycount] = yyctx->yytoken;
  1154. ++yycount;
  1155. yyn = yypcontext_expected_tokens (yyctx,
  1156. yyarg ? yyarg + 1 : yyarg, yyargn - 1);
  1157. if (yyn == YYENOMEM)
  1158. return YYENOMEM;]b4_lac_if([[
  1159. else if (yyn == 0)
  1160. YYDPRINTF ((stderr, "No expected tokens.\n"));]])[
  1161. else
  1162. yycount += yyn;
  1163. }
  1164. return yycount;
  1165. }
  1166. /* Copy into *YYMSG, which is of size *YYMSG_ALLOC, an error message
  1167. about the unexpected token YYTOKEN for the state stack whose top is
  1168. YYSSP.]b4_lac_if([[ In order to see if a particular token T is a
  1169. valid looakhead, invoke yy_lac (YYESA, YYES, YYES_CAPACITY, YYSSP, T).]])[
  1170. Return 0 if *YYMSG was successfully written. Return -1 if *YYMSG is
  1171. not large enough to hold the message. In that case, also set
  1172. *YYMSG_ALLOC to the required number of bytes. Return YYENOMEM if the
  1173. required number of bytes is too large to store]b4_lac_if([[ or if
  1174. yy_lac returned YYENOMEM]])[. */
  1175. static int
  1176. yysyntax_error (YYPTRDIFF_T *yymsg_alloc, char **yymsg,
  1177. const yypcontext_t *yyctx)
  1178. {
  1179. enum { YYARGS_MAX = 5 };
  1180. /* Internationalized format string. */
  1181. const char *yyformat = YY_NULLPTR;
  1182. /* Arguments of yyformat: reported tokens (one for the "unexpected",
  1183. one per "expected"). */
  1184. yysymbol_kind_t yyarg[YYARGS_MAX];
  1185. /* Cumulated lengths of YYARG. */
  1186. YYPTRDIFF_T yysize = 0;
  1187. /* Actual size of YYARG. */
  1188. int yycount = yy_syntax_error_arguments (yyctx, yyarg, YYARGS_MAX);
  1189. if (yycount == YYENOMEM)
  1190. return YYENOMEM;
  1191. switch (yycount)
  1192. {
  1193. #define YYCASE_(N, S) \
  1194. case N: \
  1195. yyformat = S; \
  1196. break
  1197. default: /* Avoid compiler warnings. */
  1198. YYCASE_(0, YY_("syntax error"));
  1199. YYCASE_(1, YY_("syntax error, unexpected %s"));
  1200. YYCASE_(2, YY_("syntax error, unexpected %s, expecting %s"));
  1201. YYCASE_(3, YY_("syntax error, unexpected %s, expecting %s or %s"));
  1202. YYCASE_(4, YY_("syntax error, unexpected %s, expecting %s or %s or %s"));
  1203. YYCASE_(5, YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s"));
  1204. #undef YYCASE_
  1205. }
  1206. /* Compute error message size. Don't count the "%s"s, but reserve
  1207. room for the terminator. */
  1208. yysize = yystrlen (yyformat) - 2 * yycount + 1;
  1209. {
  1210. int yyi;
  1211. for (yyi = 0; yyi < yycount; ++yyi)
  1212. {
  1213. YYPTRDIFF_T yysize1
  1214. = yysize + ]b4_parse_error_case(
  1215. [verbose], [[yytnamerr (YY_NULLPTR, yytname[yyarg[yyi]])]],
  1216. [[yystrlen (yysymbol_name (yyarg[yyi]))]]);[
  1217. if (yysize <= yysize1 && yysize1 <= YYSTACK_ALLOC_MAXIMUM)
  1218. yysize = yysize1;
  1219. else
  1220. return YYENOMEM;
  1221. }
  1222. }
  1223. if (*yymsg_alloc < yysize)
  1224. {
  1225. *yymsg_alloc = 2 * yysize;
  1226. if (! (yysize <= *yymsg_alloc
  1227. && *yymsg_alloc <= YYSTACK_ALLOC_MAXIMUM))
  1228. *yymsg_alloc = YYSTACK_ALLOC_MAXIMUM;
  1229. return -1;
  1230. }
  1231. /* Avoid sprintf, as that infringes on the user's name space.
  1232. Don't have undefined behavior even if the translation
  1233. produced a string with the wrong number of "%s"s. */
  1234. {
  1235. char *yyp = *yymsg;
  1236. int yyi = 0;
  1237. while ((*yyp = *yyformat) != '\0')
  1238. if (*yyp == '%' && yyformat[1] == 's' && yyi < yycount)
  1239. {]b4_parse_error_case([verbose], [[
  1240. yyp += yytnamerr (yyp, yytname[yyarg[yyi++]]);]], [[
  1241. yyp = yystpcpy (yyp, yysymbol_name (yyarg[yyi++]));]])[
  1242. yyformat += 2;
  1243. }
  1244. else
  1245. {
  1246. ++yyp;
  1247. ++yyformat;
  1248. }
  1249. }
  1250. return 0;
  1251. }
  1252. ]])[
  1253. ]b4_yydestruct_define[
  1254. ]b4_pure_if([], [b4_declare_scanner_communication_variables])[
  1255. ]b4_push_if([b4_pull_if([[
  1256. int
  1257. yyparse (]m4_ifset([b4_parse_param], [b4_formals(b4_parse_param)], [void])[)
  1258. {
  1259. yypstate *yyps = yypstate_new ();
  1260. if (!yyps)
  1261. {]b4_pure_if([b4_locations_if([[
  1262. static YYLTYPE yyloc_default][]b4_yyloc_default[;
  1263. YYLTYPE yylloc = yyloc_default;]])[
  1264. yyerror (]b4_yyerror_args[YY_("memory exhausted"));]], [[
  1265. if (!yypstate_allocated)
  1266. yyerror (]b4_yyerror_args[YY_("memory exhausted"));]])[
  1267. return 2;
  1268. }
  1269. int yystatus = yypull_parse (yyps]b4_user_args[);
  1270. yypstate_delete (yyps);
  1271. return yystatus;
  1272. }
  1273. int
  1274. yypull_parse (yypstate *yyps]b4_user_formals[)
  1275. {
  1276. YY_ASSERT (yyps);]b4_pure_if([b4_locations_if([[
  1277. static YYLTYPE yyloc_default][]b4_yyloc_default[;
  1278. YYLTYPE yylloc = yyloc_default;]])])[
  1279. int yystatus;
  1280. do {
  1281. ]b4_pure_if([[ YYSTYPE yylval;
  1282. int ]])[yychar = ]b4_lex[;
  1283. yystatus = yypush_parse (yyps]b4_pure_if([[, yychar, &yylval]b4_locations_if([[, &yylloc]])])m4_ifset([b4_parse_param], [, b4_args(b4_parse_param)])[);
  1284. } while (yystatus == YYPUSH_MORE);
  1285. return yystatus;
  1286. }]])[
  1287. ]b4_parse_state_variable_macros([b4_pstate_macro_define])[
  1288. /* Initialize the parser data structure. */
  1289. static void
  1290. yypstate_clear (yypstate *yyps)
  1291. {
  1292. yynerrs = 0;
  1293. yystate = 0;
  1294. yyerrstatus = 0;
  1295. yyssp = yyss;
  1296. yyvsp = yyvs;]b4_locations_if([[
  1297. yylsp = yyls;]])[
  1298. /* Initialize the state stack, in case yypcontext_expected_tokens is
  1299. called before the first call to yyparse. */
  1300. *yyssp = 0;
  1301. yyps->yynew = 1;
  1302. }
  1303. /* Initialize the parser data structure. */
  1304. yypstate *
  1305. yypstate_new (void)
  1306. {
  1307. yypstate *yyps;]b4_pure_if([], [[
  1308. if (yypstate_allocated)
  1309. return YY_NULLPTR;]])[
  1310. yyps = YY_CAST (yypstate *, YYMALLOC (sizeof *yyps));
  1311. if (!yyps)
  1312. return YY_NULLPTR;]b4_pure_if([], [[
  1313. yypstate_allocated = 1;]])[
  1314. yystacksize = YYINITDEPTH;
  1315. yyss = yyssa;
  1316. yyvs = yyvsa;]b4_locations_if([[
  1317. yyls = yylsa;]])[]b4_lac_if([[
  1318. yyes = yyesa;
  1319. yyes_capacity = ]b4_percent_define_get([[parse.lac.es-capacity-initial]])[;
  1320. if (YYMAXDEPTH < yyes_capacity)
  1321. yyes_capacity = YYMAXDEPTH;]])[
  1322. yypstate_clear (yyps);
  1323. return yyps;
  1324. }
  1325. void
  1326. yypstate_delete (yypstate *yyps)
  1327. {
  1328. if (yyps)
  1329. {
  1330. #ifndef yyoverflow
  1331. /* If the stack was reallocated but the parse did not complete, then the
  1332. stack still needs to be freed. */
  1333. if (yyss != yyssa)
  1334. YYSTACK_FREE (yyss);
  1335. #endif]b4_lac_if([[
  1336. if (yyes != yyesa)
  1337. YYSTACK_FREE (yyes);]])[
  1338. YYFREE (yyps);]b4_pure_if([], [[
  1339. yypstate_allocated = 0;]])[
  1340. }
  1341. }
  1342. ]])[
  1343. ]b4_push_if([[
  1344. /*---------------.
  1345. | yypush_parse. |
  1346. `---------------*/
  1347. int
  1348. yypush_parse (yypstate *yyps]b4_pure_if([[,
  1349. int yypushed_char, YYSTYPE const *yypushed_val]b4_locations_if([[, YYLTYPE *yypushed_loc]])])b4_user_formals[)]],
  1350. [[
  1351. /*----------.
  1352. | yyparse. |
  1353. `----------*/
  1354. int
  1355. yyparse (]m4_ifset([b4_parse_param], [b4_formals(b4_parse_param)], [void])[)]])[
  1356. {]b4_pure_if([b4_declare_scanner_communication_variables
  1357. ])b4_push_if([b4_pure_if([], [[
  1358. int yypushed_char = yychar;
  1359. YYSTYPE yypushed_val = yylval;]b4_locations_if([[
  1360. YYLTYPE yypushed_loc = yylloc;]])
  1361. ])],
  1362. [b4_declare_parser_state_variables([init])
  1363. ])b4_lac_if([[
  1364. /* Whether LAC context is established. A Boolean. */
  1365. int yy_lac_established = 0;]])[
  1366. int yyn;
  1367. /* The return value of yyparse. */
  1368. int yyresult;
  1369. /* Lookahead symbol kind. */
  1370. yysymbol_kind_t yytoken = ]b4_symbol(-2, kind)[;
  1371. /* The variables used to return semantic value and location from the
  1372. action routines. */
  1373. YYSTYPE yyval;]b4_locations_if([[
  1374. YYLTYPE yyloc;
  1375. /* The locations where the error started and ended. */
  1376. YYLTYPE yyerror_range[3];]])[
  1377. ]b4_parse_error_bmatch([detailed\|verbose],
  1378. [[ /* Buffer for error messages, and its allocated size. */
  1379. char yymsgbuf[128];
  1380. char *yymsg = yymsgbuf;
  1381. YYPTRDIFF_T yymsg_alloc = sizeof yymsgbuf;]])[
  1382. #define YYPOPSTACK(N) (yyvsp -= (N), yyssp -= (N)]b4_locations_if([, yylsp -= (N)])[)
  1383. /* The number of symbols on the RHS of the reduced rule.
  1384. Keep to zero when no symbol should be popped. */
  1385. int yylen = 0;]b4_push_if([[
  1386. switch (yyps->yynew)
  1387. {
  1388. case 0:
  1389. yyn = yypact[yystate];
  1390. goto yyread_pushed_token;
  1391. case 2:
  1392. yypstate_clear (yyps);
  1393. break;
  1394. default:
  1395. break;
  1396. }]])[
  1397. YYDPRINTF ((stderr, "Starting parse\n"));
  1398. yychar = ]b4_symbol(-2, id)[; /* Cause a token to be read. */
  1399. ]m4_ifdef([b4_initial_action], [
  1400. b4_dollar_pushdef([m4_define([b4_dollar_dollar_used])yylval], [], [],
  1401. [b4_push_if([b4_pure_if([*])yypushed_loc], [yylloc])])dnl
  1402. b4_user_initial_action
  1403. b4_dollar_popdef[]dnl
  1404. m4_ifdef([b4_dollar_dollar_used],[[ yyvsp[0] = yylval;
  1405. ]])])dnl
  1406. b4_locations_if([[ yylsp[0] = ]b4_push_if([b4_pure_if([*])yypushed_loc], [yylloc])[;
  1407. ]])dnl
  1408. [ goto yysetstate;
  1409. /*------------------------------------------------------------.
  1410. | yynewstate -- push a new state, which is found in yystate. |
  1411. `------------------------------------------------------------*/
  1412. yynewstate:
  1413. /* In all cases, when you get here, the value and location stacks
  1414. have just been pushed. So pushing a state here evens the stacks. */
  1415. yyssp++;
  1416. /*--------------------------------------------------------------------.
  1417. | yysetstate -- set current state (the top of the stack) to yystate. |
  1418. `--------------------------------------------------------------------*/
  1419. yysetstate:
  1420. YYDPRINTF ((stderr, "Entering state %d\n", yystate));
  1421. YY_ASSERT (0 <= yystate && yystate < YYNSTATES);
  1422. YY_IGNORE_USELESS_CAST_BEGIN
  1423. *yyssp = YY_CAST (yy_state_t, yystate);
  1424. YY_IGNORE_USELESS_CAST_END
  1425. YY_STACK_PRINT (yyss, yyssp);
  1426. if (yyss + yystacksize - 1 <= yyssp)
  1427. #if !defined yyoverflow && !defined YYSTACK_RELOCATE
  1428. goto yyexhaustedlab;
  1429. #else
  1430. {
  1431. /* Get the current used size of the three stacks, in elements. */
  1432. YYPTRDIFF_T yysize = yyssp - yyss + 1;
  1433. # if defined yyoverflow
  1434. {
  1435. /* Give user a chance to reallocate the stack. Use copies of
  1436. these so that the &'s don't force the real ones into
  1437. memory. */
  1438. yy_state_t *yyss1 = yyss;
  1439. YYSTYPE *yyvs1 = yyvs;]b4_locations_if([
  1440. YYLTYPE *yyls1 = yyls;])[
  1441. /* Each stack pointer address is followed by the size of the
  1442. data in use in that stack, in bytes. This used to be a
  1443. conditional around just the two extra args, but that might
  1444. be undefined if yyoverflow is a macro. */
  1445. yyoverflow (YY_("memory exhausted"),
  1446. &yyss1, yysize * YYSIZEOF (*yyssp),
  1447. &yyvs1, yysize * YYSIZEOF (*yyvsp),]b4_locations_if([
  1448. &yyls1, yysize * YYSIZEOF (*yylsp),])[
  1449. &yystacksize);
  1450. yyss = yyss1;
  1451. yyvs = yyvs1;]b4_locations_if([
  1452. yyls = yyls1;])[
  1453. }
  1454. # else /* defined YYSTACK_RELOCATE */
  1455. /* Extend the stack our own way. */
  1456. if (YYMAXDEPTH <= yystacksize)
  1457. goto yyexhaustedlab;
  1458. yystacksize *= 2;
  1459. if (YYMAXDEPTH < yystacksize)
  1460. yystacksize = YYMAXDEPTH;
  1461. {
  1462. yy_state_t *yyss1 = yyss;
  1463. union yyalloc *yyptr =
  1464. YY_CAST (union yyalloc *,
  1465. YYSTACK_ALLOC (YY_CAST (YYSIZE_T, YYSTACK_BYTES (yystacksize))));
  1466. if (! yyptr)
  1467. goto yyexhaustedlab;
  1468. YYSTACK_RELOCATE (yyss_alloc, yyss);
  1469. YYSTACK_RELOCATE (yyvs_alloc, yyvs);]b4_locations_if([
  1470. YYSTACK_RELOCATE (yyls_alloc, yyls);])[
  1471. # undef YYSTACK_RELOCATE
  1472. if (yyss1 != yyssa)
  1473. YYSTACK_FREE (yyss1);
  1474. }
  1475. # endif
  1476. yyssp = yyss + yysize - 1;
  1477. yyvsp = yyvs + yysize - 1;]b4_locations_if([
  1478. yylsp = yyls + yysize - 1;])[
  1479. YY_IGNORE_USELESS_CAST_BEGIN
  1480. YYDPRINTF ((stderr, "Stack size increased to %ld\n",
  1481. YY_CAST (long, yystacksize)));
  1482. YY_IGNORE_USELESS_CAST_END
  1483. if (yyss + yystacksize - 1 <= yyssp)
  1484. YYABORT;
  1485. }
  1486. #endif /* !defined yyoverflow && !defined YYSTACK_RELOCATE */
  1487. if (yystate == YYFINAL)
  1488. YYACCEPT;
  1489. goto yybackup;
  1490. /*-----------.
  1491. | yybackup. |
  1492. `-----------*/
  1493. yybackup:
  1494. /* Do appropriate processing given the current state. Read a
  1495. lookahead token if we need one and don't already have one. */
  1496. /* First try to decide what to do without reference to lookahead token. */
  1497. yyn = yypact[yystate];
  1498. if (yypact_value_is_default (yyn))
  1499. goto yydefault;
  1500. /* Not known => get a lookahead token if don't already have one. */
  1501. /* YYCHAR is either empty, or end-of-input, or a valid lookahead. */
  1502. if (yychar == ]b4_symbol(-2, id)[)
  1503. {]b4_push_if([[
  1504. if (!yyps->yynew)
  1505. {]b4_use_push_for_pull_if([], [[
  1506. YYDPRINTF ((stderr, "Return for a new token:\n"));]])[
  1507. yyresult = YYPUSH_MORE;
  1508. goto yypushreturn;
  1509. }
  1510. yyps->yynew = 0;]b4_pure_if([], [[
  1511. /* Restoring the pushed token is only necessary for the first
  1512. yypush_parse invocation since subsequent invocations don't overwrite
  1513. it before jumping to yyread_pushed_token. */
  1514. yychar = yypushed_char;
  1515. yylval = yypushed_val;]b4_locations_if([[
  1516. yylloc = yypushed_loc;]])])[
  1517. yyread_pushed_token:]])[
  1518. YYDPRINTF ((stderr, "Reading a token\n"));]b4_push_if([b4_pure_if([[
  1519. yychar = yypushed_char;
  1520. if (yypushed_val)
  1521. yylval = *yypushed_val;]b4_locations_if([[
  1522. if (yypushed_loc)
  1523. yylloc = *yypushed_loc;]])])], [[
  1524. yychar = ]b4_lex[;]])[
  1525. }
  1526. if (yychar <= ]b4_symbol(0, [id])[)
  1527. {
  1528. yychar = ]b4_symbol(0, [id])[;
  1529. yytoken = ]b4_symbol(0, [kind])[;
  1530. YYDPRINTF ((stderr, "Now at end of input.\n"));
  1531. }
  1532. else if (yychar == ]b4_symbol(1, [id])[)
  1533. {
  1534. /* The scanner already issued an error message, process directly
  1535. to error recovery. But do not keep the error token as
  1536. lookahead, it is too special and may lead us to an endless
  1537. loop in error recovery. */
  1538. yychar = ]b4_symbol(2, [id])[;
  1539. yytoken = ]b4_symbol(1, [kind])[;]b4_locations_if([[
  1540. yyerror_range[1] = yylloc;]])[
  1541. goto yyerrlab1;
  1542. }
  1543. else
  1544. {
  1545. yytoken = YYTRANSLATE (yychar);
  1546. YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc);
  1547. }
  1548. /* If the proper action on seeing token YYTOKEN is to reduce or to
  1549. detect an error, take that action. */
  1550. yyn += yytoken;
  1551. if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken)]b4_lac_if([[
  1552. {
  1553. YY_LAC_ESTABLISH;
  1554. goto yydefault;
  1555. }]], [[
  1556. goto yydefault;]])[
  1557. yyn = yytable[yyn];
  1558. if (yyn <= 0)
  1559. {
  1560. if (yytable_value_is_error (yyn))
  1561. goto yyerrlab;]b4_lac_if([[
  1562. YY_LAC_ESTABLISH;]])[
  1563. yyn = -yyn;
  1564. goto yyreduce;
  1565. }
  1566. /* Count tokens shifted since error; after three, turn off error
  1567. status. */
  1568. if (yyerrstatus)
  1569. yyerrstatus--;
  1570. /* Shift the lookahead token. */
  1571. YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc);
  1572. yystate = yyn;
  1573. YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
  1574. *++yyvsp = yylval;
  1575. YY_IGNORE_MAYBE_UNINITIALIZED_END]b4_locations_if([
  1576. *++yylsp = yylloc;])[
  1577. /* Discard the shifted token. */
  1578. yychar = ]b4_symbol(-2, id)[;]b4_lac_if([[
  1579. YY_LAC_DISCARD ("shift");]])[
  1580. goto yynewstate;
  1581. /*-----------------------------------------------------------.
  1582. | yydefault -- do the default action for the current state. |
  1583. `-----------------------------------------------------------*/
  1584. yydefault:
  1585. yyn = yydefact[yystate];
  1586. if (yyn == 0)
  1587. goto yyerrlab;
  1588. goto yyreduce;
  1589. /*-----------------------------.
  1590. | yyreduce -- do a reduction. |
  1591. `-----------------------------*/
  1592. yyreduce:
  1593. /* yyn is the number of a rule to reduce with. */
  1594. yylen = yyr2[yyn];
  1595. /* If YYLEN is nonzero, implement the default value of the action:
  1596. '$$ = $1'.
  1597. Otherwise, the following line sets YYVAL to garbage.
  1598. This behavior is undocumented and Bison
  1599. users should not rely upon it. Assigning to YYVAL
  1600. unconditionally makes the parser a bit smaller, and it avoids a
  1601. GCC warning that YYVAL may be used uninitialized. */
  1602. yyval = yyvsp[1-yylen];
  1603. ]b4_locations_if(
  1604. [[ /* Default location. */
  1605. YYLLOC_DEFAULT (yyloc, (yylsp - yylen), yylen);
  1606. yyerror_range[1] = yyloc;]])[
  1607. YY_REDUCE_PRINT (yyn);]b4_lac_if([[
  1608. {
  1609. int yychar_backup = yychar;
  1610. switch (yyn)
  1611. {
  1612. ]b4_user_actions[
  1613. default: break;
  1614. }
  1615. if (yychar_backup != yychar)
  1616. YY_LAC_DISCARD ("yychar change");
  1617. }]], [[
  1618. switch (yyn)
  1619. {
  1620. ]b4_user_actions[
  1621. default: break;
  1622. }]])[
  1623. /* User semantic actions sometimes alter yychar, and that requires
  1624. that yytoken be updated with the new translation. We take the
  1625. approach of translating immediately before every use of yytoken.
  1626. One alternative is translating here after every semantic action,
  1627. but that translation would be missed if the semantic action invokes
  1628. YYABORT, YYACCEPT, or YYERROR immediately after altering yychar or
  1629. if it invokes YYBACKUP. In the case of YYABORT or YYACCEPT, an
  1630. incorrect destructor might then be invoked immediately. In the
  1631. case of YYERROR or YYBACKUP, subsequent parser actions might lead
  1632. to an incorrect destructor call or verbose syntax error message
  1633. before the lookahead is translated. */
  1634. YY_SYMBOL_PRINT ("-> $$ =", YY_CAST (yysymbol_kind_t, yyr1[yyn]), &yyval, &yyloc);
  1635. YYPOPSTACK (yylen);
  1636. yylen = 0;
  1637. *++yyvsp = yyval;]b4_locations_if([
  1638. *++yylsp = yyloc;])[
  1639. /* Now 'shift' the result of the reduction. Determine what state
  1640. that goes to, based on the state we popped back to and the rule
  1641. number reduced by. */
  1642. {
  1643. const int yylhs = yyr1[yyn] - YYNTOKENS;
  1644. const int yyi = yypgoto[yylhs] + *yyssp;
  1645. yystate = (0 <= yyi && yyi <= YYLAST && yycheck[yyi] == *yyssp
  1646. ? yytable[yyi]
  1647. : yydefgoto[yylhs]);
  1648. }
  1649. goto yynewstate;
  1650. /*--------------------------------------.
  1651. | yyerrlab -- here on detecting error. |
  1652. `--------------------------------------*/
  1653. yyerrlab:
  1654. /* Make sure we have latest lookahead translation. See comments at
  1655. user semantic actions for why this is necessary. */
  1656. yytoken = yychar == ]b4_symbol(-2, id)[ ? ]b4_symbol(-2, kind)[ : YYTRANSLATE (yychar);
  1657. /* If not already recovering from an error, report this error. */
  1658. if (!yyerrstatus)
  1659. {
  1660. ++yynerrs;
  1661. ]b4_parse_error_case(
  1662. [custom],
  1663. [[ {
  1664. yypcontext_t yyctx
  1665. = {]b4_push_if([[yyps]], [[yyssp]b4_lac_if([[, yyesa, &yyes, &yyes_capacity]])])[, yytoken]b4_locations_if([[, &yylloc]])[};]b4_lac_if([[
  1666. if (yychar != ]b4_symbol(-2, id)[)
  1667. YY_LAC_ESTABLISH;]])[
  1668. if (yyreport_syntax_error (&yyctx]m4_ifset([b4_parse_param],
  1669. [[, ]b4_args(b4_parse_param)])[) == 2)
  1670. goto yyexhaustedlab;
  1671. }]],
  1672. [simple],
  1673. [[ yyerror (]b4_yyerror_args[YY_("syntax error"));]],
  1674. [[ {
  1675. yypcontext_t yyctx
  1676. = {]b4_push_if([[yyps]], [[yyssp]b4_lac_if([[, yyesa, &yyes, &yyes_capacity]])])[, yytoken]b4_locations_if([[, &yylloc]])[};
  1677. char const *yymsgp = YY_("syntax error");
  1678. int yysyntax_error_status;]b4_lac_if([[
  1679. if (yychar != ]b4_symbol(-2, id)[)
  1680. YY_LAC_ESTABLISH;]])[
  1681. yysyntax_error_status = yysyntax_error (&yymsg_alloc, &yymsg, &yyctx);
  1682. if (yysyntax_error_status == 0)
  1683. yymsgp = yymsg;
  1684. else if (yysyntax_error_status == -1)
  1685. {
  1686. if (yymsg != yymsgbuf)
  1687. YYSTACK_FREE (yymsg);
  1688. yymsg = YY_CAST (char *,
  1689. YYSTACK_ALLOC (YY_CAST (YYSIZE_T, yymsg_alloc)));
  1690. if (yymsg)
  1691. {
  1692. yysyntax_error_status
  1693. = yysyntax_error (&yymsg_alloc, &yymsg, &yyctx);
  1694. yymsgp = yymsg;
  1695. }
  1696. else
  1697. {
  1698. yymsg = yymsgbuf;
  1699. yymsg_alloc = sizeof yymsgbuf;
  1700. yysyntax_error_status = YYENOMEM;
  1701. }
  1702. }
  1703. yyerror (]b4_yyerror_args[yymsgp);
  1704. if (yysyntax_error_status == YYENOMEM)
  1705. goto yyexhaustedlab;
  1706. }]])[
  1707. }
  1708. ]b4_locations_if([[
  1709. yyerror_range[1] = yylloc;]])[
  1710. if (yyerrstatus == 3)
  1711. {
  1712. /* If just tried and failed to reuse lookahead token after an
  1713. error, discard it. */
  1714. if (yychar <= ]b4_symbol(0, [id])[)
  1715. {
  1716. /* Return failure if at end of input. */
  1717. if (yychar == ]b4_symbol(0, [id])[)
  1718. YYABORT;
  1719. }
  1720. else
  1721. {
  1722. yydestruct ("Error: discarding",
  1723. yytoken, &yylval]b4_locations_if([, &yylloc])[]b4_user_args[);
  1724. yychar = ]b4_symbol(-2, id)[;
  1725. }
  1726. }
  1727. /* Else will try to reuse lookahead token after shifting the error
  1728. token. */
  1729. goto yyerrlab1;
  1730. /*---------------------------------------------------.
  1731. | yyerrorlab -- error raised explicitly by YYERROR. |
  1732. `---------------------------------------------------*/
  1733. yyerrorlab:
  1734. /* Pacify compilers when the user code never invokes YYERROR and the
  1735. label yyerrorlab therefore never appears in user code. */
  1736. if (0)
  1737. YYERROR;
  1738. /* Do not reclaim the symbols of the rule whose action triggered
  1739. this YYERROR. */
  1740. YYPOPSTACK (yylen);
  1741. yylen = 0;
  1742. YY_STACK_PRINT (yyss, yyssp);
  1743. yystate = *yyssp;
  1744. goto yyerrlab1;
  1745. /*-------------------------------------------------------------.
  1746. | yyerrlab1 -- common code for both syntax error and YYERROR. |
  1747. `-------------------------------------------------------------*/
  1748. yyerrlab1:
  1749. yyerrstatus = 3; /* Each real token shifted decrements this. */
  1750. /* Pop stack until we find a state that shifts the error token. */
  1751. for (;;)
  1752. {
  1753. yyn = yypact[yystate];
  1754. if (!yypact_value_is_default (yyn))
  1755. {
  1756. yyn += ]b4_symbol(1, kind)[;
  1757. if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == ]b4_symbol(1, kind)[)
  1758. {
  1759. yyn = yytable[yyn];
  1760. if (0 < yyn)
  1761. break;
  1762. }
  1763. }
  1764. /* Pop the current state because it cannot handle the error token. */
  1765. if (yyssp == yyss)
  1766. YYABORT;
  1767. ]b4_locations_if([[ yyerror_range[1] = *yylsp;]])[
  1768. yydestruct ("Error: popping",
  1769. YY_ACCESSING_SYMBOL (yystate), yyvsp]b4_locations_if([, yylsp])[]b4_user_args[);
  1770. YYPOPSTACK (1);
  1771. yystate = *yyssp;
  1772. YY_STACK_PRINT (yyss, yyssp);
  1773. }]b4_lac_if([[
  1774. /* If the stack popping above didn't lose the initial context for the
  1775. current lookahead token, the shift below will for sure. */
  1776. YY_LAC_DISCARD ("error recovery");]])[
  1777. YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
  1778. *++yyvsp = yylval;
  1779. YY_IGNORE_MAYBE_UNINITIALIZED_END
  1780. ]b4_locations_if([[
  1781. yyerror_range[2] = yylloc;
  1782. ++yylsp;
  1783. YYLLOC_DEFAULT (*yylsp, yyerror_range, 2);]])[
  1784. /* Shift the error token. */
  1785. YY_SYMBOL_PRINT ("Shifting", YY_ACCESSING_SYMBOL (yyn), yyvsp, yylsp);
  1786. yystate = yyn;
  1787. goto yynewstate;
  1788. /*-------------------------------------.
  1789. | yyacceptlab -- YYACCEPT comes here. |
  1790. `-------------------------------------*/
  1791. yyacceptlab:
  1792. yyresult = 0;
  1793. goto yyreturn;
  1794. /*-----------------------------------.
  1795. | yyabortlab -- YYABORT comes here. |
  1796. `-----------------------------------*/
  1797. yyabortlab:
  1798. yyresult = 1;
  1799. goto yyreturn;
  1800. #if ]b4_lac_if([[1]], [b4_parse_error_case([simple], [[!defined yyoverflow]], [[1]])])[
  1801. /*-------------------------------------------------.
  1802. | yyexhaustedlab -- memory exhaustion comes here. |
  1803. `-------------------------------------------------*/
  1804. yyexhaustedlab:
  1805. yyerror (]b4_yyerror_args[YY_("memory exhausted"));
  1806. yyresult = 2;
  1807. goto yyreturn;
  1808. #endif
  1809. /*-------------------------------------------------------.
  1810. | yyreturn -- parsing is finished, clean up and return. |
  1811. `-------------------------------------------------------*/
  1812. yyreturn:
  1813. if (yychar != ]b4_symbol(-2, id)[)
  1814. {
  1815. /* Make sure we have latest lookahead translation. See comments at
  1816. user semantic actions for why this is necessary. */
  1817. yytoken = YYTRANSLATE (yychar);
  1818. yydestruct ("Cleanup: discarding lookahead",
  1819. yytoken, &yylval]b4_locations_if([, &yylloc])[]b4_user_args[);
  1820. }
  1821. /* Do not reclaim the symbols of the rule whose action triggered
  1822. this YYABORT or YYACCEPT. */
  1823. YYPOPSTACK (yylen);
  1824. YY_STACK_PRINT (yyss, yyssp);
  1825. while (yyssp != yyss)
  1826. {
  1827. yydestruct ("Cleanup: popping",
  1828. YY_ACCESSING_SYMBOL (+*yyssp), yyvsp]b4_locations_if([, yylsp])[]b4_user_args[);
  1829. YYPOPSTACK (1);
  1830. }]b4_push_if([[
  1831. yyps->yynew = 2;
  1832. goto yypushreturn;
  1833. /*-------------------------.
  1834. | yypushreturn -- return. |
  1835. `-------------------------*/
  1836. yypushreturn:]], [[
  1837. #ifndef yyoverflow
  1838. if (yyss != yyssa)
  1839. YYSTACK_FREE (yyss);
  1840. #endif]b4_lac_if([[
  1841. if (yyes != yyesa)
  1842. YYSTACK_FREE (yyes);]])])[
  1843. ]b4_parse_error_bmatch([detailed\|verbose],
  1844. [[ if (yymsg != yymsgbuf)
  1845. YYSTACK_FREE (yymsg);]])[
  1846. return yyresult;
  1847. }
  1848. ]b4_push_if([b4_parse_state_variable_macros([b4_macro_undef])])[
  1849. ]b4_percent_code_get([[epilogue]])[]dnl
  1850. b4_epilogue[]dnl
  1851. b4_output_end