parse-gram.c 119 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562
  1. /* A Bison parser, made by GNU Bison 3.7.6. */
  2. /* Bison implementation for Yacc-like parsers in C
  3. Copyright (C) 1984, 1989-1990, 2000-2015, 2018-2021 Free Software Foundation,
  4. Inc.
  5. This program is free software: you can redistribute it and/or modify
  6. it under the terms of the GNU General Public License as published by
  7. the Free Software Foundation, either version 3 of the License, or
  8. (at your option) any later version.
  9. This program is distributed in the hope that it will be useful,
  10. but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. GNU General Public License for more details.
  13. You should have received a copy of the GNU General Public License
  14. along with this program. If not, see <https://www.gnu.org/licenses/>. */
  15. /* As a special exception, you may create a larger work that contains
  16. part or all of the Bison parser skeleton and distribute that work
  17. under terms of your choice, so long as that work isn't itself a
  18. parser generator using the skeleton or a modified version thereof
  19. as a parser skeleton. Alternatively, if you modify or redistribute
  20. the parser skeleton itself, you may (at your option) remove this
  21. special exception, which will cause the skeleton and the resulting
  22. Bison output files to be licensed under the GNU General Public
  23. License without this special exception.
  24. This special exception was added by the Free Software Foundation in
  25. version 2.2 of Bison. */
  26. /* C LALR(1) parser skeleton written by Richard Stallman, by
  27. simplifying the original so-called "semantic" parser. */
  28. /* DO NOT RELY ON FEATURES THAT ARE NOT DOCUMENTED in the manual,
  29. especially those whose name start with YY_ or yy_. They are
  30. private implementation details that can be changed or removed. */
  31. /* All symbols defined below should begin with yy or YY, to avoid
  32. infringing on user name space. This should be done even for local
  33. variables, as they might otherwise be expanded by user macros.
  34. There are some unavoidable exceptions within include files to
  35. define necessary library symbols; they are noted "INFRINGES ON
  36. USER NAME SPACE" below. */
  37. /* Identify Bison output, and Bison version. */
  38. #define YYBISON 30706
  39. /* Bison version string. */
  40. #define YYBISON_VERSION "3.7.6"
  41. /* Skeleton name. */
  42. #define YYSKELETON_NAME "yacc.c"
  43. /* Pure parsers. */
  44. #define YYPURE 2
  45. /* Push parsers. */
  46. #define YYPUSH 0
  47. /* Pull parsers. */
  48. #define YYPULL 1
  49. /* "%code top" blocks. */
  50. #line 35 "src/parse-gram.y"
  51. /* On column 0 to please syntax-check. */
  52. #include <config.h>
  53. #line 73 "src/parse-gram.c"
  54. /* Substitute the type names. */
  55. #define YYSTYPE GRAM_STYPE
  56. #define YYLTYPE GRAM_LTYPE
  57. /* Substitute the variable and function names. */
  58. #define yyparse gram_parse
  59. #define yylex gram_lex
  60. #define yyerror gram_error
  61. #define yydebug gram_debug
  62. #define yynerrs gram_nerrs
  63. # ifndef YY_CAST
  64. # ifdef __cplusplus
  65. # define YY_CAST(Type, Val) static_cast<Type> (Val)
  66. # define YY_REINTERPRET_CAST(Type, Val) reinterpret_cast<Type> (Val)
  67. # else
  68. # define YY_CAST(Type, Val) ((Type) (Val))
  69. # define YY_REINTERPRET_CAST(Type, Val) ((Type) (Val))
  70. # endif
  71. # endif
  72. # ifndef YY_NULLPTR
  73. # if defined __cplusplus
  74. # if 201103L <= __cplusplus
  75. # define YY_NULLPTR nullptr
  76. # else
  77. # define YY_NULLPTR 0
  78. # endif
  79. # else
  80. # define YY_NULLPTR ((void*)0)
  81. # endif
  82. # endif
  83. #include "parse-gram.h"
  84. /* Symbol kind. */
  85. enum yysymbol_kind_t
  86. {
  87. YYSYMBOL_YYEMPTY = -2,
  88. YYSYMBOL_YYEOF = 0, /* "end of file" */
  89. YYSYMBOL_YYerror = 1, /* error */
  90. YYSYMBOL_YYUNDEF = 2, /* "invalid token" */
  91. YYSYMBOL_STRING = 3, /* "string" */
  92. YYSYMBOL_TSTRING = 4, /* "translatable string" */
  93. YYSYMBOL_PERCENT_TOKEN = 5, /* "%token" */
  94. YYSYMBOL_PERCENT_NTERM = 6, /* "%nterm" */
  95. YYSYMBOL_PERCENT_TYPE = 7, /* "%type" */
  96. YYSYMBOL_PERCENT_DESTRUCTOR = 8, /* "%destructor" */
  97. YYSYMBOL_PERCENT_PRINTER = 9, /* "%printer" */
  98. YYSYMBOL_PERCENT_LEFT = 10, /* "%left" */
  99. YYSYMBOL_PERCENT_RIGHT = 11, /* "%right" */
  100. YYSYMBOL_PERCENT_NONASSOC = 12, /* "%nonassoc" */
  101. YYSYMBOL_PERCENT_PRECEDENCE = 13, /* "%precedence" */
  102. YYSYMBOL_PERCENT_PREC = 14, /* "%prec" */
  103. YYSYMBOL_PERCENT_DPREC = 15, /* "%dprec" */
  104. YYSYMBOL_PERCENT_MERGE = 16, /* "%merge" */
  105. YYSYMBOL_PERCENT_CODE = 17, /* "%code" */
  106. YYSYMBOL_PERCENT_DEFAULT_PREC = 18, /* "%default-prec" */
  107. YYSYMBOL_PERCENT_DEFINE = 19, /* "%define" */
  108. YYSYMBOL_PERCENT_DEFINES = 20, /* "%defines" */
  109. YYSYMBOL_PERCENT_ERROR_VERBOSE = 21, /* "%error-verbose" */
  110. YYSYMBOL_PERCENT_EXPECT = 22, /* "%expect" */
  111. YYSYMBOL_PERCENT_EXPECT_RR = 23, /* "%expect-rr" */
  112. YYSYMBOL_PERCENT_FLAG = 24, /* "%<flag>" */
  113. YYSYMBOL_PERCENT_FILE_PREFIX = 25, /* "%file-prefix" */
  114. YYSYMBOL_PERCENT_GLR_PARSER = 26, /* "%glr-parser" */
  115. YYSYMBOL_PERCENT_INITIAL_ACTION = 27, /* "%initial-action" */
  116. YYSYMBOL_PERCENT_LANGUAGE = 28, /* "%language" */
  117. YYSYMBOL_PERCENT_NAME_PREFIX = 29, /* "%name-prefix" */
  118. YYSYMBOL_PERCENT_NO_DEFAULT_PREC = 30, /* "%no-default-prec" */
  119. YYSYMBOL_PERCENT_NO_LINES = 31, /* "%no-lines" */
  120. YYSYMBOL_PERCENT_NONDETERMINISTIC_PARSER = 32, /* "%nondeterministic-parser" */
  121. YYSYMBOL_PERCENT_OUTPUT = 33, /* "%output" */
  122. YYSYMBOL_PERCENT_PURE_PARSER = 34, /* "%pure-parser" */
  123. YYSYMBOL_PERCENT_REQUIRE = 35, /* "%require" */
  124. YYSYMBOL_PERCENT_SKELETON = 36, /* "%skeleton" */
  125. YYSYMBOL_PERCENT_START = 37, /* "%start" */
  126. YYSYMBOL_PERCENT_TOKEN_TABLE = 38, /* "%token-table" */
  127. YYSYMBOL_PERCENT_VERBOSE = 39, /* "%verbose" */
  128. YYSYMBOL_PERCENT_YACC = 40, /* "%yacc" */
  129. YYSYMBOL_BRACED_CODE = 41, /* "{...}" */
  130. YYSYMBOL_BRACED_PREDICATE = 42, /* "%?{...}" */
  131. YYSYMBOL_BRACKETED_ID = 43, /* "[identifier]" */
  132. YYSYMBOL_CHAR_LITERAL = 44, /* "character literal" */
  133. YYSYMBOL_COLON = 45, /* ":" */
  134. YYSYMBOL_EPILOGUE = 46, /* "epilogue" */
  135. YYSYMBOL_EQUAL = 47, /* "=" */
  136. YYSYMBOL_ID = 48, /* "identifier" */
  137. YYSYMBOL_ID_COLON = 49, /* "identifier:" */
  138. YYSYMBOL_PERCENT_PERCENT = 50, /* "%%" */
  139. YYSYMBOL_PIPE = 51, /* "|" */
  140. YYSYMBOL_PROLOGUE = 52, /* "%{...%}" */
  141. YYSYMBOL_SEMICOLON = 53, /* ";" */
  142. YYSYMBOL_TAG = 54, /* "<tag>" */
  143. YYSYMBOL_TAG_ANY = 55, /* "<*>" */
  144. YYSYMBOL_TAG_NONE = 56, /* "<>" */
  145. YYSYMBOL_INT_LITERAL = 57, /* "integer literal" */
  146. YYSYMBOL_PERCENT_PARAM = 58, /* "%param" */
  147. YYSYMBOL_PERCENT_UNION = 59, /* "%union" */
  148. YYSYMBOL_PERCENT_EMPTY = 60, /* "%empty" */
  149. YYSYMBOL_YYACCEPT = 61, /* $accept */
  150. YYSYMBOL_input = 62, /* input */
  151. YYSYMBOL_prologue_declarations = 63, /* prologue_declarations */
  152. YYSYMBOL_prologue_declaration = 64, /* prologue_declaration */
  153. YYSYMBOL_65_1 = 65, /* $@1 */
  154. YYSYMBOL_params = 66, /* params */
  155. YYSYMBOL_grammar_declaration = 67, /* grammar_declaration */
  156. YYSYMBOL_code_props_type = 68, /* code_props_type */
  157. YYSYMBOL_union_name = 69, /* union_name */
  158. YYSYMBOL_symbol_declaration = 70, /* symbol_declaration */
  159. YYSYMBOL_71_2 = 71, /* $@2 */
  160. YYSYMBOL_72_3 = 72, /* $@3 */
  161. YYSYMBOL_precedence_declarator = 73, /* precedence_declarator */
  162. YYSYMBOL_74_tag_opt = 74, /* tag.opt */
  163. YYSYMBOL_generic_symlist = 75, /* generic_symlist */
  164. YYSYMBOL_generic_symlist_item = 76, /* generic_symlist_item */
  165. YYSYMBOL_tag = 77, /* tag */
  166. YYSYMBOL_nterm_decls = 78, /* nterm_decls */
  167. YYSYMBOL_token_decls = 79, /* token_decls */
  168. YYSYMBOL_80_token_decl_1 = 80, /* token_decl.1 */
  169. YYSYMBOL_token_decl = 81, /* token_decl */
  170. YYSYMBOL_82_int_opt = 82, /* int.opt */
  171. YYSYMBOL_alias = 83, /* alias */
  172. YYSYMBOL_token_decls_for_prec = 84, /* token_decls_for_prec */
  173. YYSYMBOL_85_token_decl_for_prec_1 = 85, /* token_decl_for_prec.1 */
  174. YYSYMBOL_token_decl_for_prec = 86, /* token_decl_for_prec */
  175. YYSYMBOL_symbol_decls = 87, /* symbol_decls */
  176. YYSYMBOL_88_symbol_decl_1 = 88, /* symbol_decl.1 */
  177. YYSYMBOL_grammar = 89, /* grammar */
  178. YYSYMBOL_rules_or_grammar_declaration = 90, /* rules_or_grammar_declaration */
  179. YYSYMBOL_rules = 91, /* rules */
  180. YYSYMBOL_92_4 = 92, /* $@4 */
  181. YYSYMBOL_93_rhses_1 = 93, /* rhses.1 */
  182. YYSYMBOL_rhs = 94, /* rhs */
  183. YYSYMBOL_95_named_ref_opt = 95, /* named_ref.opt */
  184. YYSYMBOL_variable = 96, /* variable */
  185. YYSYMBOL_value = 97, /* value */
  186. YYSYMBOL_id = 98, /* id */
  187. YYSYMBOL_id_colon = 99, /* id_colon */
  188. YYSYMBOL_symbol = 100, /* symbol */
  189. YYSYMBOL_string_as_id = 101, /* string_as_id */
  190. YYSYMBOL_102_epilogue_opt = 102 /* epilogue.opt */
  191. };
  192. typedef enum yysymbol_kind_t yysymbol_kind_t;
  193. /* Unqualified %code blocks. */
  194. #line 41 "src/parse-gram.y"
  195. #include "system.h"
  196. #include <c-ctype.h>
  197. #include <quotearg.h>
  198. #include <vasnprintf.h>
  199. #include <xmemdup0.h>
  200. #include "complain.h"
  201. #include "conflicts.h"
  202. #include "files.h"
  203. #include "getargs.h"
  204. #include "gram.h"
  205. #include "named-ref.h"
  206. #include "reader.h"
  207. #include "scan-code.h"
  208. #include "scan-gram.h"
  209. #include "strversion.h"
  210. /* Pretend to be at least that version, to check features published
  211. in that version while developping it. */
  212. static const char* api_version = "3.7";
  213. static int current_prec = 0;
  214. static location current_lhs_loc;
  215. static named_ref *current_lhs_named_ref;
  216. static symbol *current_lhs_symbol;
  217. static symbol_class current_class = unknown_sym;
  218. /** Set the new current left-hand side symbol, possibly common
  219. * to several right-hand side parts of rule.
  220. */
  221. static void current_lhs (symbol *sym, location loc, named_ref *ref);
  222. #define YYLLOC_DEFAULT(Current, Rhs, N) \
  223. (Current) = lloc_default (Rhs, N)
  224. static YYLTYPE lloc_default (YYLTYPE const *, int);
  225. #define YY_LOCATION_PRINT(File, Loc) \
  226. location_print (Loc, File)
  227. /* Strip initial '{' and final '}' (must be first and last characters).
  228. Return the result. */
  229. static char *strip_braces (char *code);
  230. /* Convert CODE by calling code_props_plain_init if PLAIN, otherwise
  231. code_props_symbol_action_init. Calls
  232. gram_scanner_last_string_free to release the latest string from
  233. the scanner (should be CODE). */
  234. static char const *translate_code (char *code, location loc, bool plain);
  235. /* Convert CODE by calling code_props_plain_init after having
  236. stripped the first and last characters (expected to be '{', and
  237. '}'). Calls gram_scanner_last_string_free to release the latest
  238. string from the scanner (should be CODE). */
  239. static char const *translate_code_braceless (char *code, location loc);
  240. /* Handle a %defines directive. */
  241. static void handle_defines (char const *value);
  242. /* Handle a %error-verbose directive. */
  243. static void handle_error_verbose (location const *loc, char const *directive);
  244. /* Handle a %file-prefix directive. */
  245. static void handle_file_prefix (location const *loc,
  246. location const *dir_loc,
  247. char const *directive, char const *value);
  248. /* Handle a %language directive. */
  249. static void handle_language (location const *loc, char const *lang);
  250. /* Handle a %name-prefix directive. */
  251. static void handle_name_prefix (location const *loc,
  252. char const *directive, char const *value);
  253. /* Handle a %pure-parser directive. */
  254. static void handle_pure_parser (location const *loc, char const *directive);
  255. /* Handle a %require directive. */
  256. static void handle_require (location const *loc, char const *version);
  257. /* Handle a %skeleton directive. */
  258. static void handle_skeleton (location const *loc, char const *skel);
  259. /* Handle a %yacc directive. */
  260. static void handle_yacc (location const *loc);
  261. /* Implementation of yyerror. */
  262. static void gram_error (location const *, char const *);
  263. /* A string that describes a char (e.g., 'a' -> "'a'"). */
  264. static char const *char_name (char);
  265. /* Add style to semantic values in traces. */
  266. static void tron (FILE *yyo);
  267. static void troff (FILE *yyo);
  268. /* Interpret a quoted string (such as `"Hello, \"World\"\n\""`).
  269. Manages the memory of the result. */
  270. static char *unquote (const char *str);
  271. /* Discard the latest unquoted string. */
  272. static void unquote_free (char *last_string);
  273. #line 279 "src/parse-gram.y"
  274. /** Add a lex-param and/or a parse-param.
  275. *
  276. * \param type where to push this formal argument.
  277. * \param decl the formal argument. Destroyed.
  278. * \param loc the location in the source.
  279. */
  280. static void add_param (param_type type, char *decl, location loc);
  281. static param_type current_param = param_none;
  282. #line 335 "src/parse-gram.c"
  283. #ifdef short
  284. # undef short
  285. #endif
  286. /* On compilers that do not define __PTRDIFF_MAX__ etc., make sure
  287. <limits.h> and (if available) <stdint.h> are included
  288. so that the code can choose integer types of a good width. */
  289. #ifndef __PTRDIFF_MAX__
  290. # include <limits.h> /* INFRINGES ON USER NAME SPACE */
  291. # if defined __STDC_VERSION__ && 199901 <= __STDC_VERSION__
  292. # include <stdint.h> /* INFRINGES ON USER NAME SPACE */
  293. # define YY_STDINT_H
  294. # endif
  295. #endif
  296. /* Narrow types that promote to a signed type and that can represent a
  297. signed or unsigned integer of at least N bits. In tables they can
  298. save space and decrease cache pressure. Promoting to a signed type
  299. helps avoid bugs in integer arithmetic. */
  300. #ifdef __INT_LEAST8_MAX__
  301. typedef __INT_LEAST8_TYPE__ yytype_int8;
  302. #elif defined YY_STDINT_H
  303. typedef int_least8_t yytype_int8;
  304. #else
  305. typedef signed char yytype_int8;
  306. #endif
  307. #ifdef __INT_LEAST16_MAX__
  308. typedef __INT_LEAST16_TYPE__ yytype_int16;
  309. #elif defined YY_STDINT_H
  310. typedef int_least16_t yytype_int16;
  311. #else
  312. typedef short yytype_int16;
  313. #endif
  314. /* Work around bug in HP-UX 11.23, which defines these macros
  315. incorrectly for preprocessor constants. This workaround can likely
  316. be removed in 2023, as HPE has promised support for HP-UX 11.23
  317. (aka HP-UX 11i v2) only through the end of 2022; see Table 2 of
  318. <https://h20195.www2.hpe.com/V2/getpdf.aspx/4AA4-7673ENW.pdf>. */
  319. #ifdef __hpux
  320. # undef UINT_LEAST8_MAX
  321. # undef UINT_LEAST16_MAX
  322. # define UINT_LEAST8_MAX 255
  323. # define UINT_LEAST16_MAX 65535
  324. #endif
  325. #if defined __UINT_LEAST8_MAX__ && __UINT_LEAST8_MAX__ <= __INT_MAX__
  326. typedef __UINT_LEAST8_TYPE__ yytype_uint8;
  327. #elif (!defined __UINT_LEAST8_MAX__ && defined YY_STDINT_H \
  328. && UINT_LEAST8_MAX <= INT_MAX)
  329. typedef uint_least8_t yytype_uint8;
  330. #elif !defined __UINT_LEAST8_MAX__ && UCHAR_MAX <= INT_MAX
  331. typedef unsigned char yytype_uint8;
  332. #else
  333. typedef short yytype_uint8;
  334. #endif
  335. #if defined __UINT_LEAST16_MAX__ && __UINT_LEAST16_MAX__ <= __INT_MAX__
  336. typedef __UINT_LEAST16_TYPE__ yytype_uint16;
  337. #elif (!defined __UINT_LEAST16_MAX__ && defined YY_STDINT_H \
  338. && UINT_LEAST16_MAX <= INT_MAX)
  339. typedef uint_least16_t yytype_uint16;
  340. #elif !defined __UINT_LEAST16_MAX__ && USHRT_MAX <= INT_MAX
  341. typedef unsigned short yytype_uint16;
  342. #else
  343. typedef int yytype_uint16;
  344. #endif
  345. #ifndef YYPTRDIFF_T
  346. # if defined __PTRDIFF_TYPE__ && defined __PTRDIFF_MAX__
  347. # define YYPTRDIFF_T __PTRDIFF_TYPE__
  348. # define YYPTRDIFF_MAXIMUM __PTRDIFF_MAX__
  349. # elif defined PTRDIFF_MAX
  350. # ifndef ptrdiff_t
  351. # include <stddef.h> /* INFRINGES ON USER NAME SPACE */
  352. # endif
  353. # define YYPTRDIFF_T ptrdiff_t
  354. # define YYPTRDIFF_MAXIMUM PTRDIFF_MAX
  355. # else
  356. # define YYPTRDIFF_T long
  357. # define YYPTRDIFF_MAXIMUM LONG_MAX
  358. # endif
  359. #endif
  360. #ifndef YYSIZE_T
  361. # ifdef __SIZE_TYPE__
  362. # define YYSIZE_T __SIZE_TYPE__
  363. # elif defined size_t
  364. # define YYSIZE_T size_t
  365. # elif defined __STDC_VERSION__ && 199901 <= __STDC_VERSION__
  366. # include <stddef.h> /* INFRINGES ON USER NAME SPACE */
  367. # define YYSIZE_T size_t
  368. # else
  369. # define YYSIZE_T unsigned
  370. # endif
  371. #endif
  372. #define YYSIZE_MAXIMUM \
  373. YY_CAST (YYPTRDIFF_T, \
  374. (YYPTRDIFF_MAXIMUM < YY_CAST (YYSIZE_T, -1) \
  375. ? YYPTRDIFF_MAXIMUM \
  376. : YY_CAST (YYSIZE_T, -1)))
  377. #define YYSIZEOF(X) YY_CAST (YYPTRDIFF_T, sizeof (X))
  378. /* Stored state numbers (used for stacks). */
  379. typedef yytype_uint8 yy_state_t;
  380. /* State numbers in computations. */
  381. typedef int yy_state_fast_t;
  382. #ifndef YY_
  383. # if defined YYENABLE_NLS && YYENABLE_NLS
  384. # if ENABLE_NLS
  385. # include <libintl.h> /* INFRINGES ON USER NAME SPACE */
  386. # define YY_(Msgid) dgettext ("bison-runtime", Msgid)
  387. # endif
  388. # endif
  389. # ifndef YY_
  390. # define YY_(Msgid) Msgid
  391. # endif
  392. #endif
  393. #ifndef N_
  394. # define N_(Msgid) Msgid
  395. #endif
  396. #ifndef YY_ATTRIBUTE_PURE
  397. # if defined __GNUC__ && 2 < __GNUC__ + (96 <= __GNUC_MINOR__)
  398. # define YY_ATTRIBUTE_PURE __attribute__ ((__pure__))
  399. # else
  400. # define YY_ATTRIBUTE_PURE
  401. # endif
  402. #endif
  403. #ifndef YY_ATTRIBUTE_UNUSED
  404. # if defined __GNUC__ && 2 < __GNUC__ + (7 <= __GNUC_MINOR__)
  405. # define YY_ATTRIBUTE_UNUSED __attribute__ ((__unused__))
  406. # else
  407. # define YY_ATTRIBUTE_UNUSED
  408. # endif
  409. #endif
  410. /* Suppress unused-variable warnings by "using" E. */
  411. #if ! defined lint || defined __GNUC__
  412. # define YY_USE(E) ((void) (E))
  413. #else
  414. # define YY_USE(E) /* empty */
  415. #endif
  416. #if defined __GNUC__ && ! defined __ICC && 407 <= __GNUC__ * 100 + __GNUC_MINOR__
  417. /* Suppress an incorrect diagnostic about yylval being uninitialized. */
  418. # define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN \
  419. _Pragma ("GCC diagnostic push") \
  420. _Pragma ("GCC diagnostic ignored \"-Wuninitialized\"") \
  421. _Pragma ("GCC diagnostic ignored \"-Wmaybe-uninitialized\"")
  422. # define YY_IGNORE_MAYBE_UNINITIALIZED_END \
  423. _Pragma ("GCC diagnostic pop")
  424. #else
  425. # define YY_INITIAL_VALUE(Value) Value
  426. #endif
  427. #ifndef YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
  428. # define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
  429. # define YY_IGNORE_MAYBE_UNINITIALIZED_END
  430. #endif
  431. #ifndef YY_INITIAL_VALUE
  432. # define YY_INITIAL_VALUE(Value) /* Nothing. */
  433. #endif
  434. #if defined __cplusplus && defined __GNUC__ && ! defined __ICC && 6 <= __GNUC__
  435. # define YY_IGNORE_USELESS_CAST_BEGIN \
  436. _Pragma ("GCC diagnostic push") \
  437. _Pragma ("GCC diagnostic ignored \"-Wuseless-cast\"")
  438. # define YY_IGNORE_USELESS_CAST_END \
  439. _Pragma ("GCC diagnostic pop")
  440. #endif
  441. #ifndef YY_IGNORE_USELESS_CAST_BEGIN
  442. # define YY_IGNORE_USELESS_CAST_BEGIN
  443. # define YY_IGNORE_USELESS_CAST_END
  444. #endif
  445. #define YY_ASSERT(E) ((void) (0 && (E)))
  446. #if 1
  447. /* The parser invokes alloca or malloc; define the necessary symbols. */
  448. # ifdef YYSTACK_ALLOC
  449. /* Pacify GCC's 'empty if-body' warning. */
  450. # define YYSTACK_FREE(Ptr) do { /* empty */; } while (0)
  451. # ifndef YYSTACK_ALLOC_MAXIMUM
  452. /* The OS might guarantee only one guard page at the bottom of the stack,
  453. and a page size can be as small as 4096 bytes. So we cannot safely
  454. invoke alloca (N) if N exceeds 4096. Use a slightly smaller number
  455. to allow for a few compiler-allocated temporary stack slots. */
  456. # define YYSTACK_ALLOC_MAXIMUM 4032 /* reasonable circa 2006 */
  457. # endif
  458. # else
  459. # define YYSTACK_ALLOC YYMALLOC
  460. # define YYSTACK_FREE YYFREE
  461. # ifndef YYSTACK_ALLOC_MAXIMUM
  462. # define YYSTACK_ALLOC_MAXIMUM YYSIZE_MAXIMUM
  463. # endif
  464. # if (defined __cplusplus && ! defined EXIT_SUCCESS \
  465. && ! ((defined YYMALLOC || defined malloc) \
  466. && (defined YYFREE || defined free)))
  467. # include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
  468. # ifndef EXIT_SUCCESS
  469. # define EXIT_SUCCESS 0
  470. # endif
  471. # endif
  472. # ifndef YYMALLOC
  473. # define YYMALLOC malloc
  474. # if ! defined malloc && ! defined EXIT_SUCCESS
  475. void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */
  476. # endif
  477. # endif
  478. # ifndef YYFREE
  479. # define YYFREE free
  480. # if ! defined free && ! defined EXIT_SUCCESS
  481. void free (void *); /* INFRINGES ON USER NAME SPACE */
  482. # endif
  483. # endif
  484. # endif
  485. # define YYCOPY_NEEDED 1
  486. #endif /* 1 */
  487. #if (! defined yyoverflow \
  488. && (! defined __cplusplus \
  489. || (defined GRAM_LTYPE_IS_TRIVIAL && GRAM_LTYPE_IS_TRIVIAL \
  490. && defined GRAM_STYPE_IS_TRIVIAL && GRAM_STYPE_IS_TRIVIAL)))
  491. /* A type that is properly aligned for any stack member. */
  492. union yyalloc
  493. {
  494. yy_state_t yyss_alloc;
  495. YYSTYPE yyvs_alloc;
  496. YYLTYPE yyls_alloc;
  497. };
  498. /* The size of the maximum gap between one aligned stack and the next. */
  499. # define YYSTACK_GAP_MAXIMUM (YYSIZEOF (union yyalloc) - 1)
  500. /* The size of an array large to enough to hold all stacks, each with
  501. N elements. */
  502. # define YYSTACK_BYTES(N) \
  503. ((N) * (YYSIZEOF (yy_state_t) + YYSIZEOF (YYSTYPE) \
  504. + YYSIZEOF (YYLTYPE)) \
  505. + 2 * YYSTACK_GAP_MAXIMUM)
  506. # define YYCOPY_NEEDED 1
  507. /* Relocate STACK from its old location to the new one. The
  508. local variables YYSIZE and YYSTACKSIZE give the old and new number of
  509. elements in the stack, and YYPTR gives the new location of the
  510. stack. Advance YYPTR to a properly aligned location for the next
  511. stack. */
  512. # define YYSTACK_RELOCATE(Stack_alloc, Stack) \
  513. do \
  514. { \
  515. YYPTRDIFF_T yynewbytes; \
  516. YYCOPY (&yyptr->Stack_alloc, Stack, yysize); \
  517. Stack = &yyptr->Stack_alloc; \
  518. yynewbytes = yystacksize * YYSIZEOF (*Stack) + YYSTACK_GAP_MAXIMUM; \
  519. yyptr += yynewbytes / YYSIZEOF (*yyptr); \
  520. } \
  521. while (0)
  522. #endif
  523. #if defined YYCOPY_NEEDED && YYCOPY_NEEDED
  524. /* Copy COUNT objects from SRC to DST. The source and destination do
  525. not overlap. */
  526. # ifndef YYCOPY
  527. # if defined __GNUC__ && 1 < __GNUC__
  528. # define YYCOPY(Dst, Src, Count) \
  529. __builtin_memcpy (Dst, Src, YY_CAST (YYSIZE_T, (Count)) * sizeof (*(Src)))
  530. # else
  531. # define YYCOPY(Dst, Src, Count) \
  532. do \
  533. { \
  534. YYPTRDIFF_T yyi; \
  535. for (yyi = 0; yyi < (Count); yyi++) \
  536. (Dst)[yyi] = (Src)[yyi]; \
  537. } \
  538. while (0)
  539. # endif
  540. # endif
  541. #endif /* !YYCOPY_NEEDED */
  542. /* YYFINAL -- State number of the termination state. */
  543. #define YYFINAL 3
  544. /* YYLAST -- Last index in YYTABLE. */
  545. #define YYLAST 234
  546. /* YYNTOKENS -- Number of terminals. */
  547. #define YYNTOKENS 61
  548. /* YYNNTS -- Number of nonterminals. */
  549. #define YYNNTS 42
  550. /* YYNRULES -- Number of rules. */
  551. #define YYNRULES 123
  552. /* YYNSTATES -- Number of states. */
  553. #define YYNSTATES 167
  554. /* YYMAXUTOK -- Last valid token kind. */
  555. #define YYMAXUTOK 315
  556. /* YYTRANSLATE(TOKEN-NUM) -- Symbol number corresponding to TOKEN-NUM
  557. as returned by yylex, with out-of-bounds checking. */
  558. #define YYTRANSLATE(YYX) YY_CAST (yysymbol_kind_t, YYX)
  559. #if GRAM_DEBUG
  560. /* YYRLINE[YYN] -- Source line where rule number YYN was defined. */
  561. static const yytype_int16 yyrline[] =
  562. {
  563. 0, 311, 311, 320, 321, 325, 326, 332, 336, 341,
  564. 342, 343, 344, 345, 346, 347, 352, 357, 358, 359,
  565. 360, 361, 362, 362, 363, 364, 365, 366, 367, 368,
  566. 369, 370, 374, 375, 384, 385, 389, 400, 404, 408,
  567. 416, 426, 427, 437, 438, 444, 457, 457, 462, 462,
  568. 467, 471, 481, 482, 483, 484, 488, 489, 494, 495,
  569. 499, 500, 504, 505, 506, 519, 528, 532, 536, 544,
  570. 545, 549, 562, 563, 568, 569, 570, 588, 592, 596,
  571. 604, 606, 611, 618, 628, 632, 636, 644, 649, 661,
  572. 662, 668, 669, 670, 677, 677, 685, 686, 687, 692,
  573. 695, 697, 699, 701, 703, 705, 707, 709, 711, 716,
  574. 717, 726, 750, 751, 752, 753, 765, 767, 791, 796,
  575. 797, 802, 810, 811
  576. };
  577. #endif
  578. /** Accessing symbol of state STATE. */
  579. #define YY_ACCESSING_SYMBOL(State) YY_CAST (yysymbol_kind_t, yystos[State])
  580. #if 1
  581. /* The user-facing name of the symbol whose (internal) number is
  582. YYSYMBOL. No bounds checking. */
  583. static const char *yysymbol_name (yysymbol_kind_t yysymbol) YY_ATTRIBUTE_UNUSED;
  584. static const char *
  585. yysymbol_name (yysymbol_kind_t yysymbol)
  586. {
  587. static const char *const yy_sname[] =
  588. {
  589. N_("end of file"), N_("error"), N_("invalid token"), N_("string"),
  590. N_("translatable string"), "%token", "%nterm", "%type", "%destructor",
  591. "%printer", "%left", "%right", "%nonassoc", "%precedence", "%prec",
  592. "%dprec", "%merge", "%code", "%default-prec", "%define", "%defines",
  593. "%error-verbose", "%expect", "%expect-rr", "%<flag>", "%file-prefix",
  594. "%glr-parser", "%initial-action", "%language", "%name-prefix",
  595. "%no-default-prec", "%no-lines", "%nondeterministic-parser", "%output",
  596. "%pure-parser", "%require", "%skeleton", "%start", "%token-table",
  597. "%verbose", "%yacc", "{...}", "%?{...}", N_("[identifier]"),
  598. N_("character literal"), ":", N_("epilogue"), "=", N_("identifier"),
  599. N_("identifier:"), "%%", "|", "%{...%}", ";", N_("<tag>"), "<*>", "<>",
  600. N_("integer literal"), "%param", "%union", "%empty", "$accept", "input",
  601. "prologue_declarations", "prologue_declaration", "$@1", "params",
  602. "grammar_declaration", "code_props_type", "union_name",
  603. "symbol_declaration", "$@2", "$@3", "precedence_declarator", "tag.opt",
  604. "generic_symlist", "generic_symlist_item", "tag", "nterm_decls",
  605. "token_decls", "token_decl.1", "token_decl", "int.opt", "alias",
  606. "token_decls_for_prec", "token_decl_for_prec.1", "token_decl_for_prec",
  607. "symbol_decls", "symbol_decl.1", "grammar",
  608. "rules_or_grammar_declaration", "rules", "$@4", "rhses.1", "rhs",
  609. "named_ref.opt", "variable", "value", "id", "id_colon", "symbol",
  610. "string_as_id", "epilogue.opt", YY_NULLPTR
  611. };
  612. /* YYTRANSLATABLE[SYMBOL-NUM] -- Whether YY_SNAME[SYMBOL-NUM] is
  613. internationalizable. */
  614. static yytype_int8 yytranslatable[] =
  615. {
  616. 1, 1, 1, 1, 1, 0, 0, 0, 0, 0,
  617. 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
  618. 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
  619. 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
  620. 0, 0, 0, 1, 1, 0, 1, 0, 1, 1,
  621. 0, 0, 0, 0, 1, 0, 0, 1, 0, 0,
  622. 0
  623. };
  624. return (yysymbol < YYNTOKENS && yytranslatable[yysymbol]
  625. ? _(yy_sname[yysymbol])
  626. : yy_sname[yysymbol]);
  627. }
  628. #endif
  629. #ifdef YYPRINT
  630. /* YYTOKNUM[NUM] -- (External) token number corresponding to the
  631. (internal) symbol number NUM (which must be that of a token). */
  632. static const yytype_int16 yytoknum[] =
  633. {
  634. 0, 256, 257, 258, 259, 260, 261, 262, 263, 264,
  635. 265, 266, 267, 268, 269, 270, 271, 272, 273, 274,
  636. 275, 276, 277, 278, 279, 280, 281, 282, 283, 284,
  637. 285, 286, 287, 288, 289, 290, 291, 292, 293, 294,
  638. 295, 296, 297, 298, 299, 300, 301, 302, 303, 304,
  639. 305, 306, 307, 308, 309, 310, 311, 312, 313, 314,
  640. 315
  641. };
  642. #endif
  643. #define YYPACT_NINF (-80)
  644. #define yypact_value_is_default(Yyn) \
  645. ((Yyn) == YYPACT_NINF)
  646. #define YYTABLE_NINF (-123)
  647. #define yytable_value_is_error(Yyn) \
  648. 0
  649. /* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
  650. STATE-NUM. */
  651. static const yytype_int16 yypact[] =
  652. {
  653. -80, 5, 120, -80, -17, -80, -80, 23, -80, -80,
  654. -80, -80, -80, -80, -7, -80, 10, 58, -80, 6,
  655. 34, -80, 82, -80, 54, 95, 101, -80, -80, -80,
  656. 103, -80, 105, 107, 24, -80, -80, -80, 175, -80,
  657. -80, -80, 64, -80, -80, 75, -80, 61, -80, -15,
  658. -15, -80, -80, -80, 24, 63, 24, -80, -80, -80,
  659. -80, 77, -80, 46, -80, -80, -80, -80, -80, -80,
  660. -80, -80, -80, -80, -80, 67, -80, 69, 7, -80,
  661. -80, 80, 93, -80, 94, -1, 24, 108, 24, -80,
  662. 79, -80, -38, 109, -38, -80, 79, -80, 109, 24,
  663. 24, -80, -80, -80, -80, -80, -80, -80, -80, 115,
  664. -80, -80, -80, -80, -80, 123, -80, -80, -80, -80,
  665. -1, -80, -80, -80, 24, 24, -80, -80, -80, -38,
  666. -38, -80, 28, 24, -80, 121, -80, -80, 24, -38,
  667. -80, -80, -80, -80, -23, 59, -80, -80, 24, 110,
  668. 111, 112, 114, -80, -80, -80, 127, 80, 59, -80,
  669. -80, -80, -80, -80, 80, -80, -80
  670. };
  671. /* YYDEFACT[STATE-NUM] -- Default reduction number in state STATE-NUM.
  672. Performed when YYTABLE does not specify something else to do. Zero
  673. means the default is an error. */
  674. static const yytype_int8 yydefact[] =
  675. {
  676. 3, 0, 0, 1, 0, 48, 46, 0, 41, 42,
  677. 52, 53, 54, 55, 0, 37, 0, 9, 11, 0,
  678. 0, 7, 0, 15, 0, 0, 0, 38, 19, 20,
  679. 0, 24, 0, 0, 0, 27, 28, 29, 0, 6,
  680. 31, 22, 43, 4, 5, 0, 34, 0, 30, 0,
  681. 0, 121, 117, 116, 0, 50, 84, 119, 87, 120,
  682. 39, 0, 111, 112, 10, 12, 13, 14, 16, 17,
  683. 18, 21, 25, 26, 35, 0, 118, 0, 0, 89,
  684. 91, 109, 0, 44, 0, 0, 0, 51, 77, 80,
  685. 72, 83, 0, 49, 66, 69, 72, 47, 65, 85,
  686. 0, 88, 40, 114, 115, 113, 8, 93, 92, 0,
  687. 90, 2, 110, 94, 33, 23, 45, 62, 63, 64,
  688. 36, 58, 61, 60, 78, 0, 81, 73, 82, 67,
  689. 0, 70, 74, 86, 123, 0, 32, 59, 79, 68,
  690. 76, 71, 75, 99, 95, 96, 99, 98, 0, 0,
  691. 0, 0, 0, 102, 57, 103, 0, 109, 97, 104,
  692. 105, 106, 107, 108, 109, 100, 101
  693. };
  694. /* YYPGOTO[NTERM-NUM]. */
  695. static const yytype_int16 yypgoto[] =
  696. {
  697. -80, -80, -80, -80, -80, -80, 172, -80, -80, -80,
  698. -80, -80, -80, -80, -80, 55, -80, -80, 139, -54,
  699. -59, 81, -80, -80, -65, -79, -80, -31, -80, 113,
  700. -80, -80, -80, 44, -67, -80, -80, -46, -80, -34,
  701. -36, -80
  702. };
  703. /* YYDEFGOTO[NTERM-NUM]. */
  704. static const yytype_uint8 yydefgoto[] =
  705. {
  706. 0, 1, 2, 43, 82, 115, 77, 45, 84, 46,
  707. 50, 49, 47, 156, 120, 121, 122, 97, 93, 94,
  708. 95, 128, 141, 87, 88, 89, 55, 56, 78, 79,
  709. 80, 135, 144, 145, 113, 63, 106, 57, 81, 58,
  710. 59, 111
  711. };
  712. /* YYTABLE[YYPACT[STATE-NUM]] -- What to do in state STATE-NUM. If
  713. positive, shift that token. If negative, reduce the rule whose
  714. number is the opposite. If YYTABLE_NINF, syntax error. */
  715. static const yytype_int16 yytable[] =
  716. {
  717. 74, 90, 51, 96, 96, 3, 52, -122, 75, 126,
  718. 53, 91, 5, 6, 7, 8, 9, 10, 11, 12,
  719. 13, 124, 101, 99, 14, 15, 51, 51, 146, 52,
  720. 147, 51, 140, 53, 60, 131, 48, 27, 129, 92,
  721. 90, 61, 90, 52, 34, 126, 96, 53, 96, 103,
  722. 91, 123, 91, 117, 118, 119, 76, 109, 62, 126,
  723. 138, 64, 51, 65, 51, 101, 42, 52, 52, 133,
  724. 131, 53, 53, 148, 149, 150, 139, 54, 90, 90,
  725. 131, 151, 152, 96, 96, 67, 123, 104, 91, 91,
  726. 165, 66, 90, 96, 105, 68, 142, 166, 69, 101,
  727. -56, 153, 91, 52, 70, 52, 71, 53, 72, 53,
  728. 73, 157, 83, 154, 159, 86, 85, 100, 102, 155,
  729. 107, 4, 108, 112, 157, 5, 6, 7, 8, 9,
  730. 10, 11, 12, 13, 114, 116, 127, 14, 15, 16,
  731. 17, 18, 19, 20, 21, 22, 23, 24, 25, 26,
  732. 27, 28, 29, 30, 31, 32, 33, 34, 35, 36,
  733. 37, 134, 125, 130, 136, 161, 143, 160, 164, 162,
  734. 38, 163, 39, 40, 44, 137, 75, 132, 41, 42,
  735. 5, 6, 7, 8, 9, 10, 11, 12, 13, 98,
  736. 158, 110, 14, 15, 0, 0, 0, 0, 0, 0,
  737. 0, 0, 0, 0, 0, 27, 0, 0, 0, 0,
  738. 0, 0, 34, 0, 0, 0, 0, 0, 0, 0,
  739. 0, 0, 0, 0, 76, 0, 0, 0, 0, 0,
  740. 0, 0, 0, 0, 42
  741. };
  742. static const yytype_int16 yycheck[] =
  743. {
  744. 34, 47, 3, 49, 50, 0, 44, 0, 1, 88,
  745. 48, 47, 5, 6, 7, 8, 9, 10, 11, 12,
  746. 13, 86, 56, 54, 17, 18, 3, 3, 51, 44,
  747. 53, 3, 4, 48, 41, 94, 53, 30, 92, 54,
  748. 86, 48, 88, 44, 37, 124, 92, 48, 94, 3,
  749. 86, 85, 88, 54, 55, 56, 49, 50, 48, 138,
  750. 125, 3, 3, 57, 3, 99, 59, 44, 44, 100,
  751. 129, 48, 48, 14, 15, 16, 130, 54, 124, 125,
  752. 139, 22, 23, 129, 130, 3, 120, 41, 124, 125,
  753. 157, 57, 138, 139, 48, 41, 132, 164, 3, 133,
  754. 41, 42, 138, 44, 3, 44, 3, 48, 3, 48,
  755. 3, 145, 48, 54, 148, 54, 41, 54, 41, 60,
  756. 53, 1, 53, 43, 158, 5, 6, 7, 8, 9,
  757. 10, 11, 12, 13, 41, 41, 57, 17, 18, 19,
  758. 20, 21, 22, 23, 24, 25, 26, 27, 28, 29,
  759. 30, 31, 32, 33, 34, 35, 36, 37, 38, 39,
  760. 40, 46, 54, 54, 41, 54, 45, 57, 41, 57,
  761. 50, 57, 52, 53, 2, 120, 1, 96, 58, 59,
  762. 5, 6, 7, 8, 9, 10, 11, 12, 13, 50,
  763. 146, 78, 17, 18, -1, -1, -1, -1, -1, -1,
  764. -1, -1, -1, -1, -1, 30, -1, -1, -1, -1,
  765. -1, -1, 37, -1, -1, -1, -1, -1, -1, -1,
  766. -1, -1, -1, -1, 49, -1, -1, -1, -1, -1,
  767. -1, -1, -1, -1, 59
  768. };
  769. /* YYSTOS[STATE-NUM] -- The (internal number of the) accessing
  770. symbol of state STATE-NUM. */
  771. static const yytype_int8 yystos[] =
  772. {
  773. 0, 62, 63, 0, 1, 5, 6, 7, 8, 9,
  774. 10, 11, 12, 13, 17, 18, 19, 20, 21, 22,
  775. 23, 24, 25, 26, 27, 28, 29, 30, 31, 32,
  776. 33, 34, 35, 36, 37, 38, 39, 40, 50, 52,
  777. 53, 58, 59, 64, 67, 68, 70, 73, 53, 72,
  778. 71, 3, 44, 48, 54, 87, 88, 98, 100, 101,
  779. 41, 48, 48, 96, 3, 57, 57, 3, 41, 3,
  780. 3, 3, 3, 3, 100, 1, 49, 67, 89, 90,
  781. 91, 99, 65, 48, 69, 41, 54, 84, 85, 86,
  782. 98, 101, 54, 79, 80, 81, 98, 78, 79, 88,
  783. 54, 100, 41, 3, 41, 48, 97, 53, 53, 50,
  784. 90, 102, 43, 95, 41, 66, 41, 54, 55, 56,
  785. 75, 76, 77, 100, 85, 54, 86, 57, 82, 80,
  786. 54, 81, 82, 88, 46, 92, 41, 76, 85, 80,
  787. 4, 83, 101, 45, 93, 94, 51, 53, 14, 15,
  788. 16, 22, 23, 42, 54, 60, 74, 100, 94, 100,
  789. 57, 54, 57, 57, 41, 95, 95
  790. };
  791. /* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */
  792. static const yytype_int8 yyr1[] =
  793. {
  794. 0, 61, 62, 63, 63, 64, 64, 64, 64, 64,
  795. 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
  796. 64, 64, 65, 64, 64, 64, 64, 64, 64, 64,
  797. 64, 64, 66, 66, 67, 67, 67, 67, 67, 67,
  798. 67, 68, 68, 69, 69, 67, 71, 70, 72, 70,
  799. 70, 70, 73, 73, 73, 73, 74, 74, 75, 75,
  800. 76, 76, 77, 77, 77, 78, 79, 79, 79, 80,
  801. 80, 81, 82, 82, 83, 83, 83, 84, 84, 84,
  802. 85, 85, 86, 86, 87, 87, 87, 88, 88, 89,
  803. 89, 90, 90, 90, 92, 91, 93, 93, 93, 94,
  804. 94, 94, 94, 94, 94, 94, 94, 94, 94, 95,
  805. 95, 96, 97, 97, 97, 97, 98, 98, 99, 100,
  806. 100, 101, 102, 102
  807. };
  808. /* YYR2[YYN] -- Number of symbols on the right hand side of rule YYN. */
  809. static const yytype_int8 yyr2[] =
  810. {
  811. 0, 2, 4, 0, 2, 1, 1, 1, 3, 1,
  812. 2, 1, 2, 2, 2, 1, 2, 2, 2, 1,
  813. 1, 2, 0, 3, 1, 2, 2, 1, 1, 1,
  814. 2, 1, 2, 1, 1, 2, 3, 1, 1, 2,
  815. 3, 1, 1, 0, 1, 3, 0, 3, 0, 3,
  816. 2, 2, 1, 1, 1, 1, 0, 1, 1, 2,
  817. 1, 1, 1, 1, 1, 1, 1, 2, 3, 1,
  818. 2, 3, 0, 1, 0, 1, 1, 1, 2, 3,
  819. 1, 2, 2, 1, 1, 2, 3, 1, 2, 1,
  820. 2, 1, 2, 2, 0, 5, 1, 3, 2, 0,
  821. 3, 4, 2, 2, 3, 3, 3, 3, 3, 0,
  822. 1, 1, 0, 1, 1, 1, 1, 1, 1, 1,
  823. 1, 1, 0, 2
  824. };
  825. enum { YYENOMEM = -2 };
  826. #define yyerrok (yyerrstatus = 0)
  827. #define yyclearin (yychar = GRAM_EMPTY)
  828. #define YYACCEPT goto yyacceptlab
  829. #define YYABORT goto yyabortlab
  830. #define YYERROR goto yyerrorlab
  831. #define YYRECOVERING() (!!yyerrstatus)
  832. #define YYBACKUP(Token, Value) \
  833. do \
  834. if (yychar == GRAM_EMPTY) \
  835. { \
  836. yychar = (Token); \
  837. yylval = (Value); \
  838. YYPOPSTACK (yylen); \
  839. yystate = *yyssp; \
  840. YY_LAC_DISCARD ("YYBACKUP"); \
  841. goto yybackup; \
  842. } \
  843. else \
  844. { \
  845. yyerror (&yylloc, YY_("syntax error: cannot back up")); \
  846. YYERROR; \
  847. } \
  848. while (0)
  849. /* Backward compatibility with an undocumented macro.
  850. Use GRAM_error or GRAM_UNDEF. */
  851. #define YYERRCODE GRAM_UNDEF
  852. /* YYLLOC_DEFAULT -- Set CURRENT to span from RHS[1] to RHS[N].
  853. If N is 0, then set CURRENT to the empty location which ends
  854. the previous symbol: RHS[0] (always defined). */
  855. #ifndef YYLLOC_DEFAULT
  856. # define YYLLOC_DEFAULT(Current, Rhs, N) \
  857. do \
  858. if (N) \
  859. { \
  860. (Current).first_line = YYRHSLOC (Rhs, 1).first_line; \
  861. (Current).first_column = YYRHSLOC (Rhs, 1).first_column; \
  862. (Current).last_line = YYRHSLOC (Rhs, N).last_line; \
  863. (Current).last_column = YYRHSLOC (Rhs, N).last_column; \
  864. } \
  865. else \
  866. { \
  867. (Current).first_line = (Current).last_line = \
  868. YYRHSLOC (Rhs, 0).last_line; \
  869. (Current).first_column = (Current).last_column = \
  870. YYRHSLOC (Rhs, 0).last_column; \
  871. } \
  872. while (0)
  873. #endif
  874. #define YYRHSLOC(Rhs, K) ((Rhs)[K])
  875. /* Enable debugging if requested. */
  876. #if GRAM_DEBUG
  877. # ifndef YYFPRINTF
  878. # include <stdio.h> /* INFRINGES ON USER NAME SPACE */
  879. # define YYFPRINTF fprintf
  880. # endif
  881. # define YYDPRINTF(Args) \
  882. do { \
  883. if (yydebug) \
  884. YYFPRINTF Args; \
  885. } while (0)
  886. /* YY_LOCATION_PRINT -- Print the location on the stream.
  887. This macro was not mandated originally: define only if we know
  888. we won't break user code: when these are the locations we know. */
  889. # ifndef YY_LOCATION_PRINT
  890. # if defined GRAM_LTYPE_IS_TRIVIAL && GRAM_LTYPE_IS_TRIVIAL
  891. /* Print *YYLOCP on YYO. Private, do not rely on its existence. */
  892. YY_ATTRIBUTE_UNUSED
  893. static int
  894. yy_location_print_ (FILE *yyo, YYLTYPE const * const yylocp)
  895. {
  896. int res = 0;
  897. int end_col = 0 != yylocp->last_column ? yylocp->last_column - 1 : 0;
  898. if (0 <= yylocp->first_line)
  899. {
  900. res += YYFPRINTF (yyo, "%d", yylocp->first_line);
  901. if (0 <= yylocp->first_column)
  902. res += YYFPRINTF (yyo, ".%d", yylocp->first_column);
  903. }
  904. if (0 <= yylocp->last_line)
  905. {
  906. if (yylocp->first_line < yylocp->last_line)
  907. {
  908. res += YYFPRINTF (yyo, "-%d", yylocp->last_line);
  909. if (0 <= end_col)
  910. res += YYFPRINTF (yyo, ".%d", end_col);
  911. }
  912. else if (0 <= end_col && yylocp->first_column < end_col)
  913. res += YYFPRINTF (yyo, "-%d", end_col);
  914. }
  915. return res;
  916. }
  917. # define YY_LOCATION_PRINT(File, Loc) \
  918. yy_location_print_ (File, &(Loc))
  919. # else
  920. # define YY_LOCATION_PRINT(File, Loc) ((void) 0)
  921. # endif
  922. # endif /* !defined YY_LOCATION_PRINT */
  923. # define YY_SYMBOL_PRINT(Title, Kind, Value, Location) \
  924. do { \
  925. if (yydebug) \
  926. { \
  927. YYFPRINTF (stderr, "%s ", Title); \
  928. yy_symbol_print (stderr, \
  929. Kind, Value, Location); \
  930. YYFPRINTF (stderr, "\n"); \
  931. } \
  932. } while (0)
  933. /*-----------------------------------.
  934. | Print this symbol's value on YYO. |
  935. `-----------------------------------*/
  936. static void
  937. yy_symbol_value_print (FILE *yyo,
  938. yysymbol_kind_t yykind, YYSTYPE const * const yyvaluep, YYLTYPE const * const yylocationp)
  939. {
  940. FILE *yyoutput = yyo;
  941. YY_USE (yyoutput);
  942. YY_USE (yylocationp);
  943. if (!yyvaluep)
  944. return;
  945. # ifdef YYPRINT
  946. if (yykind < YYNTOKENS)
  947. YYPRINT (yyo, yytoknum[yykind], *yyvaluep);
  948. # endif
  949. /* "%code pre-printer" blocks. */
  950. #line 231 "src/parse-gram.y"
  951. tron (yyo);
  952. #line 1093 "src/parse-gram.c"
  953. YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
  954. switch (yykind)
  955. {
  956. case YYSYMBOL_STRING: /* "string" */
  957. #line 238 "src/parse-gram.y"
  958. { fputs (((*yyvaluep).STRING), yyo); }
  959. #line 1100 "src/parse-gram.c"
  960. break;
  961. case YYSYMBOL_TSTRING: /* "translatable string" */
  962. #line 238 "src/parse-gram.y"
  963. { fputs (((*yyvaluep).TSTRING), yyo); }
  964. #line 1106 "src/parse-gram.c"
  965. break;
  966. case YYSYMBOL_PERCENT_ERROR_VERBOSE: /* "%error-verbose" */
  967. #line 245 "src/parse-gram.y"
  968. { fputs (((*yyvaluep).PERCENT_ERROR_VERBOSE), yyo); }
  969. #line 1112 "src/parse-gram.c"
  970. break;
  971. case YYSYMBOL_PERCENT_FLAG: /* "%<flag>" */
  972. #line 248 "src/parse-gram.y"
  973. { fprintf (yyo, "%%%s", ((*yyvaluep).PERCENT_FLAG)); }
  974. #line 1118 "src/parse-gram.c"
  975. break;
  976. case YYSYMBOL_PERCENT_FILE_PREFIX: /* "%file-prefix" */
  977. #line 245 "src/parse-gram.y"
  978. { fputs (((*yyvaluep).PERCENT_FILE_PREFIX), yyo); }
  979. #line 1124 "src/parse-gram.c"
  980. break;
  981. case YYSYMBOL_PERCENT_NAME_PREFIX: /* "%name-prefix" */
  982. #line 245 "src/parse-gram.y"
  983. { fputs (((*yyvaluep).PERCENT_NAME_PREFIX), yyo); }
  984. #line 1130 "src/parse-gram.c"
  985. break;
  986. case YYSYMBOL_PERCENT_PURE_PARSER: /* "%pure-parser" */
  987. #line 245 "src/parse-gram.y"
  988. { fputs (((*yyvaluep).PERCENT_PURE_PARSER), yyo); }
  989. #line 1136 "src/parse-gram.c"
  990. break;
  991. case YYSYMBOL_BRACED_CODE: /* "{...}" */
  992. #line 238 "src/parse-gram.y"
  993. { fputs (((*yyvaluep).BRACED_CODE), yyo); }
  994. #line 1142 "src/parse-gram.c"
  995. break;
  996. case YYSYMBOL_BRACED_PREDICATE: /* "%?{...}" */
  997. #line 238 "src/parse-gram.y"
  998. { fputs (((*yyvaluep).BRACED_PREDICATE), yyo); }
  999. #line 1148 "src/parse-gram.c"
  1000. break;
  1001. case YYSYMBOL_BRACKETED_ID: /* "[identifier]" */
  1002. #line 246 "src/parse-gram.y"
  1003. { fprintf (yyo, "[%s]", ((*yyvaluep).BRACKETED_ID)); }
  1004. #line 1154 "src/parse-gram.c"
  1005. break;
  1006. case YYSYMBOL_CHAR_LITERAL: /* "character literal" */
  1007. #line 235 "src/parse-gram.y"
  1008. { fputs (char_name (((*yyvaluep).CHAR_LITERAL)), yyo); }
  1009. #line 1160 "src/parse-gram.c"
  1010. break;
  1011. case YYSYMBOL_EPILOGUE: /* "epilogue" */
  1012. #line 238 "src/parse-gram.y"
  1013. { fputs (((*yyvaluep).EPILOGUE), yyo); }
  1014. #line 1166 "src/parse-gram.c"
  1015. break;
  1016. case YYSYMBOL_ID: /* "identifier" */
  1017. #line 245 "src/parse-gram.y"
  1018. { fputs (((*yyvaluep).ID), yyo); }
  1019. #line 1172 "src/parse-gram.c"
  1020. break;
  1021. case YYSYMBOL_ID_COLON: /* "identifier:" */
  1022. #line 247 "src/parse-gram.y"
  1023. { fprintf (yyo, "%s:", ((*yyvaluep).ID_COLON)); }
  1024. #line 1178 "src/parse-gram.c"
  1025. break;
  1026. case YYSYMBOL_PROLOGUE: /* "%{...%}" */
  1027. #line 238 "src/parse-gram.y"
  1028. { fputs (((*yyvaluep).PROLOGUE), yyo); }
  1029. #line 1184 "src/parse-gram.c"
  1030. break;
  1031. case YYSYMBOL_TAG: /* "<tag>" */
  1032. #line 249 "src/parse-gram.y"
  1033. { fprintf (yyo, "<%s>", ((*yyvaluep).TAG)); }
  1034. #line 1190 "src/parse-gram.c"
  1035. break;
  1036. case YYSYMBOL_INT_LITERAL: /* "integer literal" */
  1037. #line 252 "src/parse-gram.y"
  1038. { fprintf (yyo, "%d", ((*yyvaluep).INT_LITERAL)); }
  1039. #line 1196 "src/parse-gram.c"
  1040. break;
  1041. case YYSYMBOL_PERCENT_PARAM: /* "%param" */
  1042. #line 291 "src/parse-gram.y"
  1043. {
  1044. switch (((*yyvaluep).PERCENT_PARAM))
  1045. {
  1046. #define CASE(In, Out) \
  1047. case param_ ## In: fputs ("%" #Out, yyo); break
  1048. CASE (lex, lex-param);
  1049. CASE (parse, parse-param);
  1050. CASE (both, param);
  1051. #undef CASE
  1052. case param_none: aver (false); break;
  1053. }
  1054. }
  1055. #line 1213 "src/parse-gram.c"
  1056. break;
  1057. case YYSYMBOL_code_props_type: /* code_props_type */
  1058. #line 424 "src/parse-gram.y"
  1059. { fprintf (yyo, "%s", code_props_type_string (((*yyvaluep).code_props_type))); }
  1060. #line 1219 "src/parse-gram.c"
  1061. break;
  1062. case YYSYMBOL_74_tag_opt: /* tag.opt */
  1063. #line 245 "src/parse-gram.y"
  1064. { fputs (((*yyvaluep).yykind_74), yyo); }
  1065. #line 1225 "src/parse-gram.c"
  1066. break;
  1067. case YYSYMBOL_generic_symlist: /* generic_symlist */
  1068. #line 261 "src/parse-gram.y"
  1069. { symbol_list_syms_print (((*yyvaluep).generic_symlist), yyo); }
  1070. #line 1231 "src/parse-gram.c"
  1071. break;
  1072. case YYSYMBOL_generic_symlist_item: /* generic_symlist_item */
  1073. #line 261 "src/parse-gram.y"
  1074. { symbol_list_syms_print (((*yyvaluep).generic_symlist_item), yyo); }
  1075. #line 1237 "src/parse-gram.c"
  1076. break;
  1077. case YYSYMBOL_tag: /* tag */
  1078. #line 249 "src/parse-gram.y"
  1079. { fprintf (yyo, "<%s>", ((*yyvaluep).tag)); }
  1080. #line 1243 "src/parse-gram.c"
  1081. break;
  1082. case YYSYMBOL_nterm_decls: /* nterm_decls */
  1083. #line 261 "src/parse-gram.y"
  1084. { symbol_list_syms_print (((*yyvaluep).nterm_decls), yyo); }
  1085. #line 1249 "src/parse-gram.c"
  1086. break;
  1087. case YYSYMBOL_token_decls: /* token_decls */
  1088. #line 261 "src/parse-gram.y"
  1089. { symbol_list_syms_print (((*yyvaluep).token_decls), yyo); }
  1090. #line 1255 "src/parse-gram.c"
  1091. break;
  1092. case YYSYMBOL_80_token_decl_1: /* token_decl.1 */
  1093. #line 261 "src/parse-gram.y"
  1094. { symbol_list_syms_print (((*yyvaluep).yykind_80), yyo); }
  1095. #line 1261 "src/parse-gram.c"
  1096. break;
  1097. case YYSYMBOL_token_decl: /* token_decl */
  1098. #line 255 "src/parse-gram.y"
  1099. { fprintf (yyo, "%s", ((*yyvaluep).token_decl) ? ((*yyvaluep).token_decl)->tag : "<NULL>"); }
  1100. #line 1267 "src/parse-gram.c"
  1101. break;
  1102. case YYSYMBOL_82_int_opt: /* int.opt */
  1103. #line 252 "src/parse-gram.y"
  1104. { fprintf (yyo, "%d", ((*yyvaluep).yykind_82)); }
  1105. #line 1273 "src/parse-gram.c"
  1106. break;
  1107. case YYSYMBOL_alias: /* alias */
  1108. #line 255 "src/parse-gram.y"
  1109. { fprintf (yyo, "%s", ((*yyvaluep).alias) ? ((*yyvaluep).alias)->tag : "<NULL>"); }
  1110. #line 1279 "src/parse-gram.c"
  1111. break;
  1112. case YYSYMBOL_token_decls_for_prec: /* token_decls_for_prec */
  1113. #line 261 "src/parse-gram.y"
  1114. { symbol_list_syms_print (((*yyvaluep).token_decls_for_prec), yyo); }
  1115. #line 1285 "src/parse-gram.c"
  1116. break;
  1117. case YYSYMBOL_85_token_decl_for_prec_1: /* token_decl_for_prec.1 */
  1118. #line 261 "src/parse-gram.y"
  1119. { symbol_list_syms_print (((*yyvaluep).yykind_85), yyo); }
  1120. #line 1291 "src/parse-gram.c"
  1121. break;
  1122. case YYSYMBOL_token_decl_for_prec: /* token_decl_for_prec */
  1123. #line 255 "src/parse-gram.y"
  1124. { fprintf (yyo, "%s", ((*yyvaluep).token_decl_for_prec) ? ((*yyvaluep).token_decl_for_prec)->tag : "<NULL>"); }
  1125. #line 1297 "src/parse-gram.c"
  1126. break;
  1127. case YYSYMBOL_symbol_decls: /* symbol_decls */
  1128. #line 261 "src/parse-gram.y"
  1129. { symbol_list_syms_print (((*yyvaluep).symbol_decls), yyo); }
  1130. #line 1303 "src/parse-gram.c"
  1131. break;
  1132. case YYSYMBOL_88_symbol_decl_1: /* symbol_decl.1 */
  1133. #line 261 "src/parse-gram.y"
  1134. { symbol_list_syms_print (((*yyvaluep).yykind_88), yyo); }
  1135. #line 1309 "src/parse-gram.c"
  1136. break;
  1137. case YYSYMBOL_variable: /* variable */
  1138. #line 245 "src/parse-gram.y"
  1139. { fputs (((*yyvaluep).variable), yyo); }
  1140. #line 1315 "src/parse-gram.c"
  1141. break;
  1142. case YYSYMBOL_value: /* value */
  1143. #line 740 "src/parse-gram.y"
  1144. {
  1145. switch (((*yyvaluep).value).kind)
  1146. {
  1147. case muscle_code: fprintf (yyo, "{%s}", ((*yyvaluep).value).chars); break;
  1148. case muscle_keyword: fprintf (yyo, "%s", ((*yyvaluep).value).chars); break;
  1149. case muscle_string: fprintf (yyo, "\"%s\"", ((*yyvaluep).value).chars); break;
  1150. }
  1151. }
  1152. #line 1328 "src/parse-gram.c"
  1153. break;
  1154. case YYSYMBOL_id: /* id */
  1155. #line 255 "src/parse-gram.y"
  1156. { fprintf (yyo, "%s", ((*yyvaluep).id) ? ((*yyvaluep).id)->tag : "<NULL>"); }
  1157. #line 1334 "src/parse-gram.c"
  1158. break;
  1159. case YYSYMBOL_id_colon: /* id_colon */
  1160. #line 256 "src/parse-gram.y"
  1161. { fprintf (yyo, "%s:", ((*yyvaluep).id_colon)->tag); }
  1162. #line 1340 "src/parse-gram.c"
  1163. break;
  1164. case YYSYMBOL_symbol: /* symbol */
  1165. #line 255 "src/parse-gram.y"
  1166. { fprintf (yyo, "%s", ((*yyvaluep).symbol) ? ((*yyvaluep).symbol)->tag : "<NULL>"); }
  1167. #line 1346 "src/parse-gram.c"
  1168. break;
  1169. case YYSYMBOL_string_as_id: /* string_as_id */
  1170. #line 255 "src/parse-gram.y"
  1171. { fprintf (yyo, "%s", ((*yyvaluep).string_as_id) ? ((*yyvaluep).string_as_id)->tag : "<NULL>"); }
  1172. #line 1352 "src/parse-gram.c"
  1173. break;
  1174. default:
  1175. break;
  1176. }
  1177. YY_IGNORE_MAYBE_UNINITIALIZED_END
  1178. /* "%code post-printer" blocks. */
  1179. #line 232 "src/parse-gram.y"
  1180. troff (yyo);
  1181. #line 1363 "src/parse-gram.c"
  1182. }
  1183. /*---------------------------.
  1184. | Print this symbol on YYO. |
  1185. `---------------------------*/
  1186. static void
  1187. yy_symbol_print (FILE *yyo,
  1188. yysymbol_kind_t yykind, YYSTYPE const * const yyvaluep, YYLTYPE const * const yylocationp)
  1189. {
  1190. YYFPRINTF (yyo, "%s %s (",
  1191. yykind < YYNTOKENS ? "token" : "nterm", yysymbol_name (yykind));
  1192. YY_LOCATION_PRINT (yyo, *yylocationp);
  1193. YYFPRINTF (yyo, ": ");
  1194. yy_symbol_value_print (yyo, yykind, yyvaluep, yylocationp);
  1195. YYFPRINTF (yyo, ")");
  1196. }
  1197. /*------------------------------------------------------------------.
  1198. | yy_stack_print -- Print the state stack from its BOTTOM up to its |
  1199. | TOP (included). |
  1200. `------------------------------------------------------------------*/
  1201. static void
  1202. yy_stack_print (yy_state_t *yybottom, yy_state_t *yytop)
  1203. {
  1204. YYFPRINTF (stderr, "Stack now");
  1205. for (; yybottom <= yytop; yybottom++)
  1206. {
  1207. int yybot = *yybottom;
  1208. YYFPRINTF (stderr, " %d", yybot);
  1209. }
  1210. YYFPRINTF (stderr, "\n");
  1211. }
  1212. # define YY_STACK_PRINT(Bottom, Top) \
  1213. do { \
  1214. if (yydebug) \
  1215. yy_stack_print ((Bottom), (Top)); \
  1216. } while (0)
  1217. /*------------------------------------------------.
  1218. | Report that the YYRULE is going to be reduced. |
  1219. `------------------------------------------------*/
  1220. static void
  1221. yy_reduce_print (yy_state_t *yyssp, YYSTYPE *yyvsp, YYLTYPE *yylsp,
  1222. int yyrule)
  1223. {
  1224. int yylno = yyrline[yyrule];
  1225. int yynrhs = yyr2[yyrule];
  1226. int yyi;
  1227. YYFPRINTF (stderr, "Reducing stack by rule %d (line %d):\n",
  1228. yyrule - 1, yylno);
  1229. /* The symbols being reduced. */
  1230. for (yyi = 0; yyi < yynrhs; yyi++)
  1231. {
  1232. YYFPRINTF (stderr, " $%d = ", yyi + 1);
  1233. yy_symbol_print (stderr,
  1234. YY_ACCESSING_SYMBOL (+yyssp[yyi + 1 - yynrhs]),
  1235. &yyvsp[(yyi + 1) - (yynrhs)],
  1236. &(yylsp[(yyi + 1) - (yynrhs)]));
  1237. YYFPRINTF (stderr, "\n");
  1238. }
  1239. }
  1240. # define YY_REDUCE_PRINT(Rule) \
  1241. do { \
  1242. if (yydebug) \
  1243. yy_reduce_print (yyssp, yyvsp, yylsp, Rule); \
  1244. } while (0)
  1245. /* Nonzero means print parse trace. It is left uninitialized so that
  1246. multiple parsers can coexist. */
  1247. int yydebug;
  1248. #else /* !GRAM_DEBUG */
  1249. # define YYDPRINTF(Args) ((void) 0)
  1250. # define YY_SYMBOL_PRINT(Title, Kind, Value, Location)
  1251. # define YY_STACK_PRINT(Bottom, Top)
  1252. # define YY_REDUCE_PRINT(Rule)
  1253. #endif /* !GRAM_DEBUG */
  1254. /* YYINITDEPTH -- initial size of the parser's stacks. */
  1255. #ifndef YYINITDEPTH
  1256. # define YYINITDEPTH 200
  1257. #endif
  1258. /* YYMAXDEPTH -- maximum size the stacks can grow to (effective only
  1259. if the built-in stack extension method is used).
  1260. Do not make this value too large; the results are undefined if
  1261. YYSTACK_ALLOC_MAXIMUM < YYSTACK_BYTES (YYMAXDEPTH)
  1262. evaluated with infinite-precision integer arithmetic. */
  1263. #ifndef YYMAXDEPTH
  1264. # define YYMAXDEPTH 10000
  1265. #endif
  1266. /* Given a state stack such that *YYBOTTOM is its bottom, such that
  1267. *YYTOP is either its top or is YYTOP_EMPTY to indicate an empty
  1268. stack, and such that *YYCAPACITY is the maximum number of elements it
  1269. can hold without a reallocation, make sure there is enough room to
  1270. store YYADD more elements. If not, allocate a new stack using
  1271. YYSTACK_ALLOC, copy the existing elements, and adjust *YYBOTTOM,
  1272. *YYTOP, and *YYCAPACITY to reflect the new capacity and memory
  1273. location. If *YYBOTTOM != YYBOTTOM_NO_FREE, then free the old stack
  1274. using YYSTACK_FREE. Return 0 if successful or if no reallocation is
  1275. required. Return YYENOMEM if memory is exhausted. */
  1276. static int
  1277. yy_lac_stack_realloc (YYPTRDIFF_T *yycapacity, YYPTRDIFF_T yyadd,
  1278. #if GRAM_DEBUG
  1279. char const *yydebug_prefix,
  1280. char const *yydebug_suffix,
  1281. #endif
  1282. yy_state_t **yybottom,
  1283. yy_state_t *yybottom_no_free,
  1284. yy_state_t **yytop, yy_state_t *yytop_empty)
  1285. {
  1286. YYPTRDIFF_T yysize_old =
  1287. *yytop == yytop_empty ? 0 : *yytop - *yybottom + 1;
  1288. YYPTRDIFF_T yysize_new = yysize_old + yyadd;
  1289. if (*yycapacity < yysize_new)
  1290. {
  1291. YYPTRDIFF_T yyalloc = 2 * yysize_new;
  1292. yy_state_t *yybottom_new;
  1293. /* Use YYMAXDEPTH for maximum stack size given that the stack
  1294. should never need to grow larger than the main state stack
  1295. needs to grow without LAC. */
  1296. if (YYMAXDEPTH < yysize_new)
  1297. {
  1298. YYDPRINTF ((stderr, "%smax size exceeded%s", yydebug_prefix,
  1299. yydebug_suffix));
  1300. return YYENOMEM;
  1301. }
  1302. if (YYMAXDEPTH < yyalloc)
  1303. yyalloc = YYMAXDEPTH;
  1304. yybottom_new =
  1305. YY_CAST (yy_state_t *,
  1306. YYSTACK_ALLOC (YY_CAST (YYSIZE_T,
  1307. yyalloc * YYSIZEOF (*yybottom_new))));
  1308. if (!yybottom_new)
  1309. {
  1310. YYDPRINTF ((stderr, "%srealloc failed%s", yydebug_prefix,
  1311. yydebug_suffix));
  1312. return YYENOMEM;
  1313. }
  1314. if (*yytop != yytop_empty)
  1315. {
  1316. YYCOPY (yybottom_new, *yybottom, yysize_old);
  1317. *yytop = yybottom_new + (yysize_old - 1);
  1318. }
  1319. if (*yybottom != yybottom_no_free)
  1320. YYSTACK_FREE (*yybottom);
  1321. *yybottom = yybottom_new;
  1322. *yycapacity = yyalloc;
  1323. }
  1324. return 0;
  1325. }
  1326. /* Establish the initial context for the current lookahead if no initial
  1327. context is currently established.
  1328. We define a context as a snapshot of the parser stacks. We define
  1329. the initial context for a lookahead as the context in which the
  1330. parser initially examines that lookahead in order to select a
  1331. syntactic action. Thus, if the lookahead eventually proves
  1332. syntactically unacceptable (possibly in a later context reached via a
  1333. series of reductions), the initial context can be used to determine
  1334. the exact set of tokens that would be syntactically acceptable in the
  1335. lookahead's place. Moreover, it is the context after which any
  1336. further semantic actions would be erroneous because they would be
  1337. determined by a syntactically unacceptable token.
  1338. YY_LAC_ESTABLISH should be invoked when a reduction is about to be
  1339. performed in an inconsistent state (which, for the purposes of LAC,
  1340. includes consistent states that don't know they're consistent because
  1341. their default reductions have been disabled). Iff there is a
  1342. lookahead token, it should also be invoked before reporting a syntax
  1343. error. This latter case is for the sake of the debugging output.
  1344. For parse.lac=full, the implementation of YY_LAC_ESTABLISH is as
  1345. follows. If no initial context is currently established for the
  1346. current lookahead, then check if that lookahead can eventually be
  1347. shifted if syntactic actions continue from the current context.
  1348. Report a syntax error if it cannot. */
  1349. #define YY_LAC_ESTABLISH \
  1350. do { \
  1351. if (!yy_lac_established) \
  1352. { \
  1353. YYDPRINTF ((stderr, \
  1354. "LAC: initial context established for %s\n", \
  1355. yysymbol_name (yytoken))); \
  1356. yy_lac_established = 1; \
  1357. switch (yy_lac (yyesa, &yyes, &yyes_capacity, yyssp, yytoken)) \
  1358. { \
  1359. case YYENOMEM: \
  1360. goto yyexhaustedlab; \
  1361. case 1: \
  1362. goto yyerrlab; \
  1363. } \
  1364. } \
  1365. } while (0)
  1366. /* Discard any previous initial lookahead context because of Event,
  1367. which may be a lookahead change or an invalidation of the currently
  1368. established initial context for the current lookahead.
  1369. The most common example of a lookahead change is a shift. An example
  1370. of both cases is syntax error recovery. That is, a syntax error
  1371. occurs when the lookahead is syntactically erroneous for the
  1372. currently established initial context, so error recovery manipulates
  1373. the parser stacks to try to find a new initial context in which the
  1374. current lookahead is syntactically acceptable. If it fails to find
  1375. such a context, it discards the lookahead. */
  1376. #if GRAM_DEBUG
  1377. # define YY_LAC_DISCARD(Event) \
  1378. do { \
  1379. if (yy_lac_established) \
  1380. { \
  1381. YYDPRINTF ((stderr, "LAC: initial context discarded due to " \
  1382. Event "\n")); \
  1383. yy_lac_established = 0; \
  1384. } \
  1385. } while (0)
  1386. #else
  1387. # define YY_LAC_DISCARD(Event) yy_lac_established = 0
  1388. #endif
  1389. /* Given the stack whose top is *YYSSP, return 0 iff YYTOKEN can
  1390. eventually (after perhaps some reductions) be shifted, return 1 if
  1391. not, or return YYENOMEM if memory is exhausted. As preconditions and
  1392. postconditions: *YYES_CAPACITY is the allocated size of the array to
  1393. which *YYES points, and either *YYES = YYESA or *YYES points to an
  1394. array allocated with YYSTACK_ALLOC. yy_lac may overwrite the
  1395. contents of either array, alter *YYES and *YYES_CAPACITY, and free
  1396. any old *YYES other than YYESA. */
  1397. static int
  1398. yy_lac (yy_state_t *yyesa, yy_state_t **yyes,
  1399. YYPTRDIFF_T *yyes_capacity, yy_state_t *yyssp, yysymbol_kind_t yytoken)
  1400. {
  1401. yy_state_t *yyes_prev = yyssp;
  1402. yy_state_t *yyesp = yyes_prev;
  1403. /* Reduce until we encounter a shift and thereby accept the token. */
  1404. YYDPRINTF ((stderr, "LAC: checking lookahead %s:", yysymbol_name (yytoken)));
  1405. if (yytoken == YYSYMBOL_YYUNDEF)
  1406. {
  1407. YYDPRINTF ((stderr, " Always Err\n"));
  1408. return 1;
  1409. }
  1410. while (1)
  1411. {
  1412. int yyrule = yypact[+*yyesp];
  1413. if (yypact_value_is_default (yyrule)
  1414. || (yyrule += yytoken) < 0 || YYLAST < yyrule
  1415. || yycheck[yyrule] != yytoken)
  1416. {
  1417. /* Use the default action. */
  1418. yyrule = yydefact[+*yyesp];
  1419. if (yyrule == 0)
  1420. {
  1421. YYDPRINTF ((stderr, " Err\n"));
  1422. return 1;
  1423. }
  1424. }
  1425. else
  1426. {
  1427. /* Use the action from yytable. */
  1428. yyrule = yytable[yyrule];
  1429. if (yytable_value_is_error (yyrule))
  1430. {
  1431. YYDPRINTF ((stderr, " Err\n"));
  1432. return 1;
  1433. }
  1434. if (0 < yyrule)
  1435. {
  1436. YYDPRINTF ((stderr, " S%d\n", yyrule));
  1437. return 0;
  1438. }
  1439. yyrule = -yyrule;
  1440. }
  1441. /* By now we know we have to simulate a reduce. */
  1442. YYDPRINTF ((stderr, " R%d", yyrule - 1));
  1443. {
  1444. /* Pop the corresponding number of values from the stack. */
  1445. YYPTRDIFF_T yylen = yyr2[yyrule];
  1446. /* First pop from the LAC stack as many tokens as possible. */
  1447. if (yyesp != yyes_prev)
  1448. {
  1449. YYPTRDIFF_T yysize = yyesp - *yyes + 1;
  1450. if (yylen < yysize)
  1451. {
  1452. yyesp -= yylen;
  1453. yylen = 0;
  1454. }
  1455. else
  1456. {
  1457. yyesp = yyes_prev;
  1458. yylen -= yysize;
  1459. }
  1460. }
  1461. /* Only afterwards look at the main stack. */
  1462. if (yylen)
  1463. yyesp = yyes_prev -= yylen;
  1464. }
  1465. /* Push the resulting state of the reduction. */
  1466. {
  1467. yy_state_fast_t yystate;
  1468. {
  1469. const int yylhs = yyr1[yyrule] - YYNTOKENS;
  1470. const int yyi = yypgoto[yylhs] + *yyesp;
  1471. yystate = (0 <= yyi && yyi <= YYLAST && yycheck[yyi] == *yyesp
  1472. ? yytable[yyi]
  1473. : yydefgoto[yylhs]);
  1474. }
  1475. if (yyesp == yyes_prev)
  1476. {
  1477. yyesp = *yyes;
  1478. YY_IGNORE_USELESS_CAST_BEGIN
  1479. *yyesp = YY_CAST (yy_state_t, yystate);
  1480. YY_IGNORE_USELESS_CAST_END
  1481. }
  1482. else
  1483. {
  1484. if (yy_lac_stack_realloc (yyes_capacity, 1,
  1485. #if GRAM_DEBUG
  1486. " (", ")",
  1487. #endif
  1488. yyes, yyesa, &yyesp, yyes_prev))
  1489. {
  1490. YYDPRINTF ((stderr, "\n"));
  1491. return YYENOMEM;
  1492. }
  1493. YY_IGNORE_USELESS_CAST_BEGIN
  1494. *++yyesp = YY_CAST (yy_state_t, yystate);
  1495. YY_IGNORE_USELESS_CAST_END
  1496. }
  1497. YYDPRINTF ((stderr, " G%d", yystate));
  1498. }
  1499. }
  1500. }
  1501. /* Context of a parse error. */
  1502. typedef struct
  1503. {
  1504. yy_state_t *yyssp;
  1505. yy_state_t *yyesa;
  1506. yy_state_t **yyes;
  1507. YYPTRDIFF_T *yyes_capacity;
  1508. yysymbol_kind_t yytoken;
  1509. YYLTYPE *yylloc;
  1510. } yypcontext_t;
  1511. /* Put in YYARG at most YYARGN of the expected tokens given the
  1512. current YYCTX, and return the number of tokens stored in YYARG. If
  1513. YYARG is null, return the number of expected tokens (guaranteed to
  1514. be less than YYNTOKENS). Return YYENOMEM on memory exhaustion.
  1515. Return 0 if there are more than YYARGN expected tokens, yet fill
  1516. YYARG up to YYARGN. */
  1517. static int
  1518. yypcontext_expected_tokens (const yypcontext_t *yyctx,
  1519. yysymbol_kind_t yyarg[], int yyargn)
  1520. {
  1521. /* Actual size of YYARG. */
  1522. int yycount = 0;
  1523. int yyx;
  1524. for (yyx = 0; yyx < YYNTOKENS; ++yyx)
  1525. {
  1526. yysymbol_kind_t yysym = YY_CAST (yysymbol_kind_t, yyx);
  1527. if (yysym != YYSYMBOL_YYerror && yysym != YYSYMBOL_YYUNDEF)
  1528. switch (yy_lac (yyctx->yyesa, yyctx->yyes, yyctx->yyes_capacity, yyctx->yyssp, yysym))
  1529. {
  1530. case YYENOMEM:
  1531. return YYENOMEM;
  1532. case 1:
  1533. continue;
  1534. default:
  1535. if (!yyarg)
  1536. ++yycount;
  1537. else if (yycount == yyargn)
  1538. return 0;
  1539. else
  1540. yyarg[yycount++] = yysym;
  1541. }
  1542. }
  1543. if (yyarg && yycount == 0 && 0 < yyargn)
  1544. yyarg[0] = YYSYMBOL_YYEMPTY;
  1545. return yycount;
  1546. }
  1547. /* The kind of the lookahead of this context. */
  1548. static yysymbol_kind_t
  1549. yypcontext_token (const yypcontext_t *yyctx) YY_ATTRIBUTE_UNUSED;
  1550. static yysymbol_kind_t
  1551. yypcontext_token (const yypcontext_t *yyctx)
  1552. {
  1553. return yyctx->yytoken;
  1554. }
  1555. /* The location of the lookahead of this context. */
  1556. static YYLTYPE *
  1557. yypcontext_location (const yypcontext_t *yyctx) YY_ATTRIBUTE_UNUSED;
  1558. static YYLTYPE *
  1559. yypcontext_location (const yypcontext_t *yyctx)
  1560. {
  1561. return yyctx->yylloc;
  1562. }
  1563. /* User defined function to report a syntax error. */
  1564. static int
  1565. yyreport_syntax_error (const yypcontext_t *yyctx);
  1566. /*-----------------------------------------------.
  1567. | Release the memory associated to this symbol. |
  1568. `-----------------------------------------------*/
  1569. static void
  1570. yydestruct (const char *yymsg,
  1571. yysymbol_kind_t yykind, YYSTYPE *yyvaluep, YYLTYPE *yylocationp)
  1572. {
  1573. YY_USE (yyvaluep);
  1574. YY_USE (yylocationp);
  1575. if (!yymsg)
  1576. yymsg = "Deleting";
  1577. YY_SYMBOL_PRINT (yymsg, yykind, yyvaluep, yylocationp);
  1578. YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
  1579. switch (yykind)
  1580. {
  1581. case YYSYMBOL_generic_symlist: /* generic_symlist */
  1582. #line 260 "src/parse-gram.y"
  1583. { symbol_list_free (((*yyvaluep).generic_symlist)); }
  1584. #line 1806 "src/parse-gram.c"
  1585. break;
  1586. case YYSYMBOL_generic_symlist_item: /* generic_symlist_item */
  1587. #line 260 "src/parse-gram.y"
  1588. { symbol_list_free (((*yyvaluep).generic_symlist_item)); }
  1589. #line 1812 "src/parse-gram.c"
  1590. break;
  1591. case YYSYMBOL_nterm_decls: /* nterm_decls */
  1592. #line 260 "src/parse-gram.y"
  1593. { symbol_list_free (((*yyvaluep).nterm_decls)); }
  1594. #line 1818 "src/parse-gram.c"
  1595. break;
  1596. case YYSYMBOL_token_decls: /* token_decls */
  1597. #line 260 "src/parse-gram.y"
  1598. { symbol_list_free (((*yyvaluep).token_decls)); }
  1599. #line 1824 "src/parse-gram.c"
  1600. break;
  1601. case YYSYMBOL_80_token_decl_1: /* token_decl.1 */
  1602. #line 260 "src/parse-gram.y"
  1603. { symbol_list_free (((*yyvaluep).yykind_80)); }
  1604. #line 1830 "src/parse-gram.c"
  1605. break;
  1606. case YYSYMBOL_token_decls_for_prec: /* token_decls_for_prec */
  1607. #line 260 "src/parse-gram.y"
  1608. { symbol_list_free (((*yyvaluep).token_decls_for_prec)); }
  1609. #line 1836 "src/parse-gram.c"
  1610. break;
  1611. case YYSYMBOL_85_token_decl_for_prec_1: /* token_decl_for_prec.1 */
  1612. #line 260 "src/parse-gram.y"
  1613. { symbol_list_free (((*yyvaluep).yykind_85)); }
  1614. #line 1842 "src/parse-gram.c"
  1615. break;
  1616. case YYSYMBOL_symbol_decls: /* symbol_decls */
  1617. #line 260 "src/parse-gram.y"
  1618. { symbol_list_free (((*yyvaluep).symbol_decls)); }
  1619. #line 1848 "src/parse-gram.c"
  1620. break;
  1621. case YYSYMBOL_88_symbol_decl_1: /* symbol_decl.1 */
  1622. #line 260 "src/parse-gram.y"
  1623. { symbol_list_free (((*yyvaluep).yykind_88)); }
  1624. #line 1854 "src/parse-gram.c"
  1625. break;
  1626. default:
  1627. break;
  1628. }
  1629. YY_IGNORE_MAYBE_UNINITIALIZED_END
  1630. }
  1631. /*----------.
  1632. | yyparse. |
  1633. `----------*/
  1634. int
  1635. yyparse (void)
  1636. {
  1637. /* Lookahead token kind. */
  1638. int yychar;
  1639. /* The semantic value of the lookahead symbol. */
  1640. /* Default value used for initialization, for pacifying older GCCs
  1641. or non-GCC compilers. */
  1642. YY_INITIAL_VALUE (static YYSTYPE yyval_default;)
  1643. YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default);
  1644. /* Location data for the lookahead symbol. */
  1645. static YYLTYPE yyloc_default
  1646. # if defined GRAM_LTYPE_IS_TRIVIAL && GRAM_LTYPE_IS_TRIVIAL
  1647. = { 1, 1, 1, 1 }
  1648. # endif
  1649. ;
  1650. YYLTYPE yylloc = yyloc_default;
  1651. /* Number of syntax errors so far. */
  1652. int yynerrs = 0;
  1653. yy_state_fast_t yystate = 0;
  1654. /* Number of tokens to shift before error messages enabled. */
  1655. int yyerrstatus = 0;
  1656. /* Refer to the stacks through separate pointers, to allow yyoverflow
  1657. to reallocate them elsewhere. */
  1658. /* Their size. */
  1659. YYPTRDIFF_T yystacksize = YYINITDEPTH;
  1660. /* The state stack: array, bottom, top. */
  1661. yy_state_t yyssa[YYINITDEPTH];
  1662. yy_state_t *yyss = yyssa;
  1663. yy_state_t *yyssp = yyss;
  1664. /* The semantic value stack: array, bottom, top. */
  1665. YYSTYPE yyvsa[YYINITDEPTH];
  1666. YYSTYPE *yyvs = yyvsa;
  1667. YYSTYPE *yyvsp = yyvs;
  1668. /* The location stack: array, bottom, top. */
  1669. YYLTYPE yylsa[YYINITDEPTH];
  1670. YYLTYPE *yyls = yylsa;
  1671. YYLTYPE *yylsp = yyls;
  1672. yy_state_t yyesa[20];
  1673. yy_state_t *yyes = yyesa;
  1674. YYPTRDIFF_T yyes_capacity = 20 < YYMAXDEPTH ? 20 : YYMAXDEPTH;
  1675. /* Whether LAC context is established. A Boolean. */
  1676. int yy_lac_established = 0;
  1677. int yyn;
  1678. /* The return value of yyparse. */
  1679. int yyresult;
  1680. /* Lookahead symbol kind. */
  1681. yysymbol_kind_t yytoken = YYSYMBOL_YYEMPTY;
  1682. /* The variables used to return semantic value and location from the
  1683. action routines. */
  1684. YYSTYPE yyval;
  1685. YYLTYPE yyloc;
  1686. /* The locations where the error started and ended. */
  1687. YYLTYPE yyerror_range[3];
  1688. #define YYPOPSTACK(N) (yyvsp -= (N), yyssp -= (N), yylsp -= (N))
  1689. /* The number of symbols on the RHS of the reduced rule.
  1690. Keep to zero when no symbol should be popped. */
  1691. int yylen = 0;
  1692. YYDPRINTF ((stderr, "Starting parse\n"));
  1693. yychar = GRAM_EMPTY; /* Cause a token to be read. */
  1694. /* User initialization code. */
  1695. #line 160 "src/parse-gram.y"
  1696. {
  1697. /* Bison's grammar can initial empty locations, hence a default
  1698. location is needed. */
  1699. boundary_set (&yylloc.start, grammar_file, 1, 1, 1);
  1700. boundary_set (&yylloc.end, grammar_file, 1, 1, 1);
  1701. }
  1702. #line 1961 "src/parse-gram.c"
  1703. yylsp[0] = yylloc;
  1704. goto yysetstate;
  1705. /*------------------------------------------------------------.
  1706. | yynewstate -- push a new state, which is found in yystate. |
  1707. `------------------------------------------------------------*/
  1708. yynewstate:
  1709. /* In all cases, when you get here, the value and location stacks
  1710. have just been pushed. So pushing a state here evens the stacks. */
  1711. yyssp++;
  1712. /*--------------------------------------------------------------------.
  1713. | yysetstate -- set current state (the top of the stack) to yystate. |
  1714. `--------------------------------------------------------------------*/
  1715. yysetstate:
  1716. YYDPRINTF ((stderr, "Entering state %d\n", yystate));
  1717. YY_ASSERT (0 <= yystate && yystate < YYNSTATES);
  1718. YY_IGNORE_USELESS_CAST_BEGIN
  1719. *yyssp = YY_CAST (yy_state_t, yystate);
  1720. YY_IGNORE_USELESS_CAST_END
  1721. YY_STACK_PRINT (yyss, yyssp);
  1722. if (yyss + yystacksize - 1 <= yyssp)
  1723. #if !defined yyoverflow && !defined YYSTACK_RELOCATE
  1724. goto yyexhaustedlab;
  1725. #else
  1726. {
  1727. /* Get the current used size of the three stacks, in elements. */
  1728. YYPTRDIFF_T yysize = yyssp - yyss + 1;
  1729. # if defined yyoverflow
  1730. {
  1731. /* Give user a chance to reallocate the stack. Use copies of
  1732. these so that the &'s don't force the real ones into
  1733. memory. */
  1734. yy_state_t *yyss1 = yyss;
  1735. YYSTYPE *yyvs1 = yyvs;
  1736. YYLTYPE *yyls1 = yyls;
  1737. /* Each stack pointer address is followed by the size of the
  1738. data in use in that stack, in bytes. This used to be a
  1739. conditional around just the two extra args, but that might
  1740. be undefined if yyoverflow is a macro. */
  1741. yyoverflow (YY_("memory exhausted"),
  1742. &yyss1, yysize * YYSIZEOF (*yyssp),
  1743. &yyvs1, yysize * YYSIZEOF (*yyvsp),
  1744. &yyls1, yysize * YYSIZEOF (*yylsp),
  1745. &yystacksize);
  1746. yyss = yyss1;
  1747. yyvs = yyvs1;
  1748. yyls = yyls1;
  1749. }
  1750. # else /* defined YYSTACK_RELOCATE */
  1751. /* Extend the stack our own way. */
  1752. if (YYMAXDEPTH <= yystacksize)
  1753. goto yyexhaustedlab;
  1754. yystacksize *= 2;
  1755. if (YYMAXDEPTH < yystacksize)
  1756. yystacksize = YYMAXDEPTH;
  1757. {
  1758. yy_state_t *yyss1 = yyss;
  1759. union yyalloc *yyptr =
  1760. YY_CAST (union yyalloc *,
  1761. YYSTACK_ALLOC (YY_CAST (YYSIZE_T, YYSTACK_BYTES (yystacksize))));
  1762. if (! yyptr)
  1763. goto yyexhaustedlab;
  1764. YYSTACK_RELOCATE (yyss_alloc, yyss);
  1765. YYSTACK_RELOCATE (yyvs_alloc, yyvs);
  1766. YYSTACK_RELOCATE (yyls_alloc, yyls);
  1767. # undef YYSTACK_RELOCATE
  1768. if (yyss1 != yyssa)
  1769. YYSTACK_FREE (yyss1);
  1770. }
  1771. # endif
  1772. yyssp = yyss + yysize - 1;
  1773. yyvsp = yyvs + yysize - 1;
  1774. yylsp = yyls + yysize - 1;
  1775. YY_IGNORE_USELESS_CAST_BEGIN
  1776. YYDPRINTF ((stderr, "Stack size increased to %ld\n",
  1777. YY_CAST (long, yystacksize)));
  1778. YY_IGNORE_USELESS_CAST_END
  1779. if (yyss + yystacksize - 1 <= yyssp)
  1780. YYABORT;
  1781. }
  1782. #endif /* !defined yyoverflow && !defined YYSTACK_RELOCATE */
  1783. if (yystate == YYFINAL)
  1784. YYACCEPT;
  1785. goto yybackup;
  1786. /*-----------.
  1787. | yybackup. |
  1788. `-----------*/
  1789. yybackup:
  1790. /* Do appropriate processing given the current state. Read a
  1791. lookahead token if we need one and don't already have one. */
  1792. /* First try to decide what to do without reference to lookahead token. */
  1793. yyn = yypact[yystate];
  1794. if (yypact_value_is_default (yyn))
  1795. goto yydefault;
  1796. /* Not known => get a lookahead token if don't already have one. */
  1797. /* YYCHAR is either empty, or end-of-input, or a valid lookahead. */
  1798. if (yychar == GRAM_EMPTY)
  1799. {
  1800. YYDPRINTF ((stderr, "Reading a token\n"));
  1801. yychar = yylex (&yylval, &yylloc);
  1802. }
  1803. if (yychar <= GRAM_EOF)
  1804. {
  1805. yychar = GRAM_EOF;
  1806. yytoken = YYSYMBOL_YYEOF;
  1807. YYDPRINTF ((stderr, "Now at end of input.\n"));
  1808. }
  1809. else if (yychar == GRAM_error)
  1810. {
  1811. /* The scanner already issued an error message, process directly
  1812. to error recovery. But do not keep the error token as
  1813. lookahead, it is too special and may lead us to an endless
  1814. loop in error recovery. */
  1815. yychar = GRAM_UNDEF;
  1816. yytoken = YYSYMBOL_YYerror;
  1817. yyerror_range[1] = yylloc;
  1818. goto yyerrlab1;
  1819. }
  1820. else
  1821. {
  1822. yytoken = YYTRANSLATE (yychar);
  1823. YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc);
  1824. }
  1825. /* If the proper action on seeing token YYTOKEN is to reduce or to
  1826. detect an error, take that action. */
  1827. yyn += yytoken;
  1828. if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken)
  1829. {
  1830. YY_LAC_ESTABLISH;
  1831. goto yydefault;
  1832. }
  1833. yyn = yytable[yyn];
  1834. if (yyn <= 0)
  1835. {
  1836. if (yytable_value_is_error (yyn))
  1837. goto yyerrlab;
  1838. YY_LAC_ESTABLISH;
  1839. yyn = -yyn;
  1840. goto yyreduce;
  1841. }
  1842. /* Count tokens shifted since error; after three, turn off error
  1843. status. */
  1844. if (yyerrstatus)
  1845. yyerrstatus--;
  1846. /* Shift the lookahead token. */
  1847. YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc);
  1848. yystate = yyn;
  1849. YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
  1850. *++yyvsp = yylval;
  1851. YY_IGNORE_MAYBE_UNINITIALIZED_END
  1852. *++yylsp = yylloc;
  1853. /* Discard the shifted token. */
  1854. yychar = GRAM_EMPTY;
  1855. YY_LAC_DISCARD ("shift");
  1856. goto yynewstate;
  1857. /*-----------------------------------------------------------.
  1858. | yydefault -- do the default action for the current state. |
  1859. `-----------------------------------------------------------*/
  1860. yydefault:
  1861. yyn = yydefact[yystate];
  1862. if (yyn == 0)
  1863. goto yyerrlab;
  1864. goto yyreduce;
  1865. /*-----------------------------.
  1866. | yyreduce -- do a reduction. |
  1867. `-----------------------------*/
  1868. yyreduce:
  1869. /* yyn is the number of a rule to reduce with. */
  1870. yylen = yyr2[yyn];
  1871. /* If YYLEN is nonzero, implement the default value of the action:
  1872. '$$ = $1'.
  1873. Otherwise, the following line sets YYVAL to garbage.
  1874. This behavior is undocumented and Bison
  1875. users should not rely upon it. Assigning to YYVAL
  1876. unconditionally makes the parser a bit smaller, and it avoids a
  1877. GCC warning that YYVAL may be used uninitialized. */
  1878. yyval = yyvsp[1-yylen];
  1879. /* Default location. */
  1880. YYLLOC_DEFAULT (yyloc, (yylsp - yylen), yylen);
  1881. yyerror_range[1] = yyloc;
  1882. YY_REDUCE_PRINT (yyn);
  1883. {
  1884. int yychar_backup = yychar;
  1885. switch (yyn)
  1886. {
  1887. case 6: /* prologue_declaration: "%{...%}" */
  1888. #line 327 "src/parse-gram.y"
  1889. {
  1890. muscle_code_grow (union_seen ? "post_prologue" : "pre_prologue",
  1891. translate_code ((yyvsp[0].PROLOGUE), (yylsp[0]), true), (yylsp[0]));
  1892. code_scanner_last_string_free ();
  1893. }
  1894. #line 2184 "src/parse-gram.c"
  1895. break;
  1896. case 7: /* prologue_declaration: "%<flag>" */
  1897. #line 333 "src/parse-gram.y"
  1898. {
  1899. muscle_percent_define_ensure ((yyvsp[0].PERCENT_FLAG), (yylsp[0]), true);
  1900. }
  1901. #line 2192 "src/parse-gram.c"
  1902. break;
  1903. case 8: /* prologue_declaration: "%define" variable value */
  1904. #line 337 "src/parse-gram.y"
  1905. {
  1906. muscle_percent_define_insert ((yyvsp[-1].variable), (yyloc), (yyvsp[0].value).kind, (yyvsp[0].value).chars,
  1907. MUSCLE_PERCENT_DEFINE_GRAMMAR_FILE);
  1908. }
  1909. #line 2201 "src/parse-gram.c"
  1910. break;
  1911. case 9: /* prologue_declaration: "%defines" */
  1912. #line 341 "src/parse-gram.y"
  1913. { defines_flag = true; }
  1914. #line 2207 "src/parse-gram.c"
  1915. break;
  1916. case 10: /* prologue_declaration: "%defines" "string" */
  1917. #line 342 "src/parse-gram.y"
  1918. { handle_defines ((yyvsp[0].STRING)); }
  1919. #line 2213 "src/parse-gram.c"
  1920. break;
  1921. case 11: /* prologue_declaration: "%error-verbose" */
  1922. #line 343 "src/parse-gram.y"
  1923. { handle_error_verbose (&(yyloc), (yyvsp[0].PERCENT_ERROR_VERBOSE)); }
  1924. #line 2219 "src/parse-gram.c"
  1925. break;
  1926. case 12: /* prologue_declaration: "%expect" "integer literal" */
  1927. #line 344 "src/parse-gram.y"
  1928. { expected_sr_conflicts = (yyvsp[0].INT_LITERAL); }
  1929. #line 2225 "src/parse-gram.c"
  1930. break;
  1931. case 13: /* prologue_declaration: "%expect-rr" "integer literal" */
  1932. #line 345 "src/parse-gram.y"
  1933. { expected_rr_conflicts = (yyvsp[0].INT_LITERAL); }
  1934. #line 2231 "src/parse-gram.c"
  1935. break;
  1936. case 14: /* prologue_declaration: "%file-prefix" "string" */
  1937. #line 346 "src/parse-gram.y"
  1938. { handle_file_prefix (&(yyloc), &(yylsp[-1]), (yyvsp[-1].PERCENT_FILE_PREFIX), (yyvsp[0].STRING)); }
  1939. #line 2237 "src/parse-gram.c"
  1940. break;
  1941. case 15: /* prologue_declaration: "%glr-parser" */
  1942. #line 348 "src/parse-gram.y"
  1943. {
  1944. nondeterministic_parser = true;
  1945. glr_parser = true;
  1946. }
  1947. #line 2246 "src/parse-gram.c"
  1948. break;
  1949. case 16: /* prologue_declaration: "%initial-action" "{...}" */
  1950. #line 353 "src/parse-gram.y"
  1951. {
  1952. muscle_code_grow ("initial_action", translate_code ((yyvsp[0].BRACED_CODE), (yylsp[0]), false), (yylsp[0]));
  1953. code_scanner_last_string_free ();
  1954. }
  1955. #line 2255 "src/parse-gram.c"
  1956. break;
  1957. case 17: /* prologue_declaration: "%language" "string" */
  1958. #line 357 "src/parse-gram.y"
  1959. { handle_language (&(yylsp[-1]), (yyvsp[0].STRING)); }
  1960. #line 2261 "src/parse-gram.c"
  1961. break;
  1962. case 18: /* prologue_declaration: "%name-prefix" "string" */
  1963. #line 358 "src/parse-gram.y"
  1964. { handle_name_prefix (&(yyloc), (yyvsp[-1].PERCENT_NAME_PREFIX), (yyvsp[0].STRING)); }
  1965. #line 2267 "src/parse-gram.c"
  1966. break;
  1967. case 19: /* prologue_declaration: "%no-lines" */
  1968. #line 359 "src/parse-gram.y"
  1969. { no_lines_flag = true; }
  1970. #line 2273 "src/parse-gram.c"
  1971. break;
  1972. case 20: /* prologue_declaration: "%nondeterministic-parser" */
  1973. #line 360 "src/parse-gram.y"
  1974. { nondeterministic_parser = true; }
  1975. #line 2279 "src/parse-gram.c"
  1976. break;
  1977. case 21: /* prologue_declaration: "%output" "string" */
  1978. #line 361 "src/parse-gram.y"
  1979. { spec_outfile = unquote ((yyvsp[0].STRING)); gram_scanner_last_string_free (); }
  1980. #line 2285 "src/parse-gram.c"
  1981. break;
  1982. case 22: /* $@1: %empty */
  1983. #line 362 "src/parse-gram.y"
  1984. { current_param = (yyvsp[0].PERCENT_PARAM); }
  1985. #line 2291 "src/parse-gram.c"
  1986. break;
  1987. case 23: /* prologue_declaration: "%param" $@1 params */
  1988. #line 362 "src/parse-gram.y"
  1989. { current_param = param_none; }
  1990. #line 2297 "src/parse-gram.c"
  1991. break;
  1992. case 24: /* prologue_declaration: "%pure-parser" */
  1993. #line 363 "src/parse-gram.y"
  1994. { handle_pure_parser (&(yyloc), (yyvsp[0].PERCENT_PURE_PARSER)); }
  1995. #line 2303 "src/parse-gram.c"
  1996. break;
  1997. case 25: /* prologue_declaration: "%require" "string" */
  1998. #line 364 "src/parse-gram.y"
  1999. { handle_require (&(yylsp[0]), (yyvsp[0].STRING)); }
  2000. #line 2309 "src/parse-gram.c"
  2001. break;
  2002. case 26: /* prologue_declaration: "%skeleton" "string" */
  2003. #line 365 "src/parse-gram.y"
  2004. { handle_skeleton (&(yylsp[0]), (yyvsp[0].STRING)); }
  2005. #line 2315 "src/parse-gram.c"
  2006. break;
  2007. case 27: /* prologue_declaration: "%token-table" */
  2008. #line 366 "src/parse-gram.y"
  2009. { token_table_flag = true; }
  2010. #line 2321 "src/parse-gram.c"
  2011. break;
  2012. case 28: /* prologue_declaration: "%verbose" */
  2013. #line 367 "src/parse-gram.y"
  2014. { report_flag |= report_states; }
  2015. #line 2327 "src/parse-gram.c"
  2016. break;
  2017. case 29: /* prologue_declaration: "%yacc" */
  2018. #line 368 "src/parse-gram.y"
  2019. { handle_yacc (&(yyloc)); }
  2020. #line 2333 "src/parse-gram.c"
  2021. break;
  2022. case 30: /* prologue_declaration: error ";" */
  2023. #line 369 "src/parse-gram.y"
  2024. { current_class = unknown_sym; yyerrok; }
  2025. #line 2339 "src/parse-gram.c"
  2026. break;
  2027. case 32: /* params: params "{...}" */
  2028. #line 374 "src/parse-gram.y"
  2029. { add_param (current_param, (yyvsp[0].BRACED_CODE), (yylsp[0])); }
  2030. #line 2345 "src/parse-gram.c"
  2031. break;
  2032. case 33: /* params: "{...}" */
  2033. #line 375 "src/parse-gram.y"
  2034. { add_param (current_param, (yyvsp[0].BRACED_CODE), (yylsp[0])); }
  2035. #line 2351 "src/parse-gram.c"
  2036. break;
  2037. case 35: /* grammar_declaration: "%start" symbol */
  2038. #line 386 "src/parse-gram.y"
  2039. {
  2040. grammar_start_symbol_set ((yyvsp[0].symbol), (yylsp[0]));
  2041. }
  2042. #line 2359 "src/parse-gram.c"
  2043. break;
  2044. case 36: /* grammar_declaration: code_props_type "{...}" generic_symlist */
  2045. #line 390 "src/parse-gram.y"
  2046. {
  2047. code_props code;
  2048. code_props_symbol_action_init (&code, (yyvsp[-1].BRACED_CODE), (yylsp[-1]));
  2049. code_props_translate_code (&code);
  2050. {
  2051. for (symbol_list *list = (yyvsp[0].generic_symlist); list; list = list->next)
  2052. symbol_list_code_props_set (list, (yyvsp[-2].code_props_type), &code);
  2053. symbol_list_free ((yyvsp[0].generic_symlist));
  2054. }
  2055. }
  2056. #line 2374 "src/parse-gram.c"
  2057. break;
  2058. case 37: /* grammar_declaration: "%default-prec" */
  2059. #line 401 "src/parse-gram.y"
  2060. {
  2061. default_prec = true;
  2062. }
  2063. #line 2382 "src/parse-gram.c"
  2064. break;
  2065. case 38: /* grammar_declaration: "%no-default-prec" */
  2066. #line 405 "src/parse-gram.y"
  2067. {
  2068. default_prec = false;
  2069. }
  2070. #line 2390 "src/parse-gram.c"
  2071. break;
  2072. case 39: /* grammar_declaration: "%code" "{...}" */
  2073. #line 409 "src/parse-gram.y"
  2074. {
  2075. /* Do not invoke muscle_percent_code_grow here since it invokes
  2076. muscle_user_name_list_grow. */
  2077. muscle_code_grow ("percent_code()",
  2078. translate_code_braceless ((yyvsp[0].BRACED_CODE), (yylsp[0])), (yylsp[0]));
  2079. code_scanner_last_string_free ();
  2080. }
  2081. #line 2402 "src/parse-gram.c"
  2082. break;
  2083. case 40: /* grammar_declaration: "%code" "identifier" "{...}" */
  2084. #line 417 "src/parse-gram.y"
  2085. {
  2086. muscle_percent_code_grow ((yyvsp[-1].ID), (yylsp[-1]), translate_code_braceless ((yyvsp[0].BRACED_CODE), (yylsp[0])), (yylsp[0]));
  2087. code_scanner_last_string_free ();
  2088. }
  2089. #line 2411 "src/parse-gram.c"
  2090. break;
  2091. case 41: /* code_props_type: "%destructor" */
  2092. #line 426 "src/parse-gram.y"
  2093. { (yyval.code_props_type) = destructor; }
  2094. #line 2417 "src/parse-gram.c"
  2095. break;
  2096. case 42: /* code_props_type: "%printer" */
  2097. #line 427 "src/parse-gram.y"
  2098. { (yyval.code_props_type) = printer; }
  2099. #line 2423 "src/parse-gram.c"
  2100. break;
  2101. case 43: /* union_name: %empty */
  2102. #line 437 "src/parse-gram.y"
  2103. {}
  2104. #line 2429 "src/parse-gram.c"
  2105. break;
  2106. case 44: /* union_name: "identifier" */
  2107. #line 438 "src/parse-gram.y"
  2108. { muscle_percent_define_insert ("api.value.union.name",
  2109. (yylsp[0]), muscle_keyword, (yyvsp[0].ID),
  2110. MUSCLE_PERCENT_DEFINE_GRAMMAR_FILE); }
  2111. #line 2437 "src/parse-gram.c"
  2112. break;
  2113. case 45: /* grammar_declaration: "%union" union_name "{...}" */
  2114. #line 445 "src/parse-gram.y"
  2115. {
  2116. union_seen = true;
  2117. muscle_code_grow ("union_members", translate_code_braceless ((yyvsp[0].BRACED_CODE), (yylsp[0])), (yylsp[0]));
  2118. code_scanner_last_string_free ();
  2119. }
  2120. #line 2447 "src/parse-gram.c"
  2121. break;
  2122. case 46: /* $@2: %empty */
  2123. #line 457 "src/parse-gram.y"
  2124. { current_class = nterm_sym; }
  2125. #line 2453 "src/parse-gram.c"
  2126. break;
  2127. case 47: /* symbol_declaration: "%nterm" $@2 nterm_decls */
  2128. #line 458 "src/parse-gram.y"
  2129. {
  2130. current_class = unknown_sym;
  2131. symbol_list_free ((yyvsp[0].nterm_decls));
  2132. }
  2133. #line 2462 "src/parse-gram.c"
  2134. break;
  2135. case 48: /* $@3: %empty */
  2136. #line 462 "src/parse-gram.y"
  2137. { current_class = token_sym; }
  2138. #line 2468 "src/parse-gram.c"
  2139. break;
  2140. case 49: /* symbol_declaration: "%token" $@3 token_decls */
  2141. #line 463 "src/parse-gram.y"
  2142. {
  2143. current_class = unknown_sym;
  2144. symbol_list_free ((yyvsp[0].token_decls));
  2145. }
  2146. #line 2477 "src/parse-gram.c"
  2147. break;
  2148. case 50: /* symbol_declaration: "%type" symbol_decls */
  2149. #line 468 "src/parse-gram.y"
  2150. {
  2151. symbol_list_free ((yyvsp[0].symbol_decls));
  2152. }
  2153. #line 2485 "src/parse-gram.c"
  2154. break;
  2155. case 51: /* symbol_declaration: precedence_declarator token_decls_for_prec */
  2156. #line 472 "src/parse-gram.y"
  2157. {
  2158. ++current_prec;
  2159. for (symbol_list *list = (yyvsp[0].token_decls_for_prec); list; list = list->next)
  2160. symbol_precedence_set (list->content.sym, current_prec, (yyvsp[-1].precedence_declarator), (yylsp[-1]));
  2161. symbol_list_free ((yyvsp[0].token_decls_for_prec));
  2162. }
  2163. #line 2496 "src/parse-gram.c"
  2164. break;
  2165. case 52: /* precedence_declarator: "%left" */
  2166. #line 481 "src/parse-gram.y"
  2167. { (yyval.precedence_declarator) = left_assoc; }
  2168. #line 2502 "src/parse-gram.c"
  2169. break;
  2170. case 53: /* precedence_declarator: "%right" */
  2171. #line 482 "src/parse-gram.y"
  2172. { (yyval.precedence_declarator) = right_assoc; }
  2173. #line 2508 "src/parse-gram.c"
  2174. break;
  2175. case 54: /* precedence_declarator: "%nonassoc" */
  2176. #line 483 "src/parse-gram.y"
  2177. { (yyval.precedence_declarator) = non_assoc; }
  2178. #line 2514 "src/parse-gram.c"
  2179. break;
  2180. case 55: /* precedence_declarator: "%precedence" */
  2181. #line 484 "src/parse-gram.y"
  2182. { (yyval.precedence_declarator) = precedence_assoc; }
  2183. #line 2520 "src/parse-gram.c"
  2184. break;
  2185. case 56: /* tag.opt: %empty */
  2186. #line 488 "src/parse-gram.y"
  2187. { (yyval.yykind_74) = NULL; }
  2188. #line 2526 "src/parse-gram.c"
  2189. break;
  2190. case 57: /* tag.opt: "<tag>" */
  2191. #line 489 "src/parse-gram.y"
  2192. { (yyval.yykind_74) = (yyvsp[0].TAG); }
  2193. #line 2532 "src/parse-gram.c"
  2194. break;
  2195. case 59: /* generic_symlist: generic_symlist generic_symlist_item */
  2196. #line 495 "src/parse-gram.y"
  2197. { (yyval.generic_symlist) = symbol_list_append ((yyvsp[-1].generic_symlist), (yyvsp[0].generic_symlist_item)); }
  2198. #line 2538 "src/parse-gram.c"
  2199. break;
  2200. case 60: /* generic_symlist_item: symbol */
  2201. #line 499 "src/parse-gram.y"
  2202. { (yyval.generic_symlist_item) = symbol_list_sym_new ((yyvsp[0].symbol), (yylsp[0])); }
  2203. #line 2544 "src/parse-gram.c"
  2204. break;
  2205. case 61: /* generic_symlist_item: tag */
  2206. #line 500 "src/parse-gram.y"
  2207. { (yyval.generic_symlist_item) = symbol_list_type_new ((yyvsp[0].tag), (yylsp[0])); }
  2208. #line 2550 "src/parse-gram.c"
  2209. break;
  2210. case 63: /* tag: "<*>" */
  2211. #line 505 "src/parse-gram.y"
  2212. { (yyval.tag) = uniqstr_new ("*"); }
  2213. #line 2556 "src/parse-gram.c"
  2214. break;
  2215. case 64: /* tag: "<>" */
  2216. #line 506 "src/parse-gram.y"
  2217. { (yyval.tag) = uniqstr_new (""); }
  2218. #line 2562 "src/parse-gram.c"
  2219. break;
  2220. case 66: /* token_decls: token_decl.1 */
  2221. #line 529 "src/parse-gram.y"
  2222. {
  2223. (yyval.token_decls) = (yyvsp[0].yykind_80);
  2224. }
  2225. #line 2570 "src/parse-gram.c"
  2226. break;
  2227. case 67: /* token_decls: "<tag>" token_decl.1 */
  2228. #line 533 "src/parse-gram.y"
  2229. {
  2230. (yyval.token_decls) = symbol_list_type_set ((yyvsp[0].yykind_80), (yyvsp[-1].TAG));
  2231. }
  2232. #line 2578 "src/parse-gram.c"
  2233. break;
  2234. case 68: /* token_decls: token_decls "<tag>" token_decl.1 */
  2235. #line 537 "src/parse-gram.y"
  2236. {
  2237. (yyval.token_decls) = symbol_list_append ((yyvsp[-2].token_decls), symbol_list_type_set ((yyvsp[0].yykind_80), (yyvsp[-1].TAG)));
  2238. }
  2239. #line 2586 "src/parse-gram.c"
  2240. break;
  2241. case 69: /* token_decl.1: token_decl */
  2242. #line 544 "src/parse-gram.y"
  2243. { (yyval.yykind_80) = symbol_list_sym_new ((yyvsp[0].token_decl), (yylsp[0])); }
  2244. #line 2592 "src/parse-gram.c"
  2245. break;
  2246. case 70: /* token_decl.1: token_decl.1 token_decl */
  2247. #line 545 "src/parse-gram.y"
  2248. { (yyval.yykind_80) = symbol_list_append ((yyvsp[-1].yykind_80), symbol_list_sym_new ((yyvsp[0].token_decl), (yylsp[0]))); }
  2249. #line 2598 "src/parse-gram.c"
  2250. break;
  2251. case 71: /* token_decl: id int.opt alias */
  2252. #line 550 "src/parse-gram.y"
  2253. {
  2254. (yyval.token_decl) = (yyvsp[-2].id);
  2255. symbol_class_set ((yyvsp[-2].id), current_class, (yylsp[-2]), true);
  2256. if (0 <= (yyvsp[-1].yykind_82))
  2257. symbol_code_set ((yyvsp[-2].id), (yyvsp[-1].yykind_82), (yylsp[-1]));
  2258. if ((yyvsp[0].alias))
  2259. symbol_make_alias ((yyvsp[-2].id), (yyvsp[0].alias), (yylsp[0]));
  2260. }
  2261. #line 2611 "src/parse-gram.c"
  2262. break;
  2263. case 72: /* int.opt: %empty */
  2264. #line 562 "src/parse-gram.y"
  2265. { (yyval.yykind_82) = -1; }
  2266. #line 2617 "src/parse-gram.c"
  2267. break;
  2268. case 74: /* alias: %empty */
  2269. #line 568 "src/parse-gram.y"
  2270. { (yyval.alias) = NULL; }
  2271. #line 2623 "src/parse-gram.c"
  2272. break;
  2273. case 75: /* alias: string_as_id */
  2274. #line 569 "src/parse-gram.y"
  2275. { (yyval.alias) = (yyvsp[0].string_as_id); }
  2276. #line 2629 "src/parse-gram.c"
  2277. break;
  2278. case 76: /* alias: "translatable string" */
  2279. #line 571 "src/parse-gram.y"
  2280. {
  2281. (yyval.alias) = symbol_get ((yyvsp[0].TSTRING), (yylsp[0]));
  2282. symbol_class_set ((yyval.alias), token_sym, (yylsp[0]), false);
  2283. (yyval.alias)->translatable = true;
  2284. }
  2285. #line 2639 "src/parse-gram.c"
  2286. break;
  2287. case 77: /* token_decls_for_prec: token_decl_for_prec.1 */
  2288. #line 589 "src/parse-gram.y"
  2289. {
  2290. (yyval.token_decls_for_prec) = (yyvsp[0].yykind_85);
  2291. }
  2292. #line 2647 "src/parse-gram.c"
  2293. break;
  2294. case 78: /* token_decls_for_prec: "<tag>" token_decl_for_prec.1 */
  2295. #line 593 "src/parse-gram.y"
  2296. {
  2297. (yyval.token_decls_for_prec) = symbol_list_type_set ((yyvsp[0].yykind_85), (yyvsp[-1].TAG));
  2298. }
  2299. #line 2655 "src/parse-gram.c"
  2300. break;
  2301. case 79: /* token_decls_for_prec: token_decls_for_prec "<tag>" token_decl_for_prec.1 */
  2302. #line 597 "src/parse-gram.y"
  2303. {
  2304. (yyval.token_decls_for_prec) = symbol_list_append ((yyvsp[-2].token_decls_for_prec), symbol_list_type_set ((yyvsp[0].yykind_85), (yyvsp[-1].TAG)));
  2305. }
  2306. #line 2663 "src/parse-gram.c"
  2307. break;
  2308. case 80: /* token_decl_for_prec.1: token_decl_for_prec */
  2309. #line 605 "src/parse-gram.y"
  2310. { (yyval.yykind_85) = symbol_list_sym_new ((yyvsp[0].token_decl_for_prec), (yylsp[0])); }
  2311. #line 2669 "src/parse-gram.c"
  2312. break;
  2313. case 81: /* token_decl_for_prec.1: token_decl_for_prec.1 token_decl_for_prec */
  2314. #line 607 "src/parse-gram.y"
  2315. { (yyval.yykind_85) = symbol_list_append ((yyvsp[-1].yykind_85), symbol_list_sym_new ((yyvsp[0].token_decl_for_prec), (yylsp[0]))); }
  2316. #line 2675 "src/parse-gram.c"
  2317. break;
  2318. case 82: /* token_decl_for_prec: id int.opt */
  2319. #line 612 "src/parse-gram.y"
  2320. {
  2321. (yyval.token_decl_for_prec) = (yyvsp[-1].id);
  2322. symbol_class_set ((yyvsp[-1].id), token_sym, (yylsp[-1]), false);
  2323. if (0 <= (yyvsp[0].yykind_82))
  2324. symbol_code_set ((yyvsp[-1].id), (yyvsp[0].yykind_82), (yylsp[0]));
  2325. }
  2326. #line 2686 "src/parse-gram.c"
  2327. break;
  2328. case 84: /* symbol_decls: symbol_decl.1 */
  2329. #line 629 "src/parse-gram.y"
  2330. {
  2331. (yyval.symbol_decls) = (yyvsp[0].yykind_88);
  2332. }
  2333. #line 2694 "src/parse-gram.c"
  2334. break;
  2335. case 85: /* symbol_decls: "<tag>" symbol_decl.1 */
  2336. #line 633 "src/parse-gram.y"
  2337. {
  2338. (yyval.symbol_decls) = symbol_list_type_set ((yyvsp[0].yykind_88), (yyvsp[-1].TAG));
  2339. }
  2340. #line 2702 "src/parse-gram.c"
  2341. break;
  2342. case 86: /* symbol_decls: symbol_decls "<tag>" symbol_decl.1 */
  2343. #line 637 "src/parse-gram.y"
  2344. {
  2345. (yyval.symbol_decls) = symbol_list_append ((yyvsp[-2].symbol_decls), symbol_list_type_set ((yyvsp[0].yykind_88), (yyvsp[-1].TAG)));
  2346. }
  2347. #line 2710 "src/parse-gram.c"
  2348. break;
  2349. case 87: /* symbol_decl.1: symbol */
  2350. #line 645 "src/parse-gram.y"
  2351. {
  2352. symbol_class_set ((yyvsp[0].symbol), pct_type_sym, (yylsp[0]), false);
  2353. (yyval.yykind_88) = symbol_list_sym_new ((yyvsp[0].symbol), (yylsp[0]));
  2354. }
  2355. #line 2719 "src/parse-gram.c"
  2356. break;
  2357. case 88: /* symbol_decl.1: symbol_decl.1 symbol */
  2358. #line 650 "src/parse-gram.y"
  2359. {
  2360. symbol_class_set ((yyvsp[0].symbol), pct_type_sym, (yylsp[0]), false);
  2361. (yyval.yykind_88) = symbol_list_append ((yyvsp[-1].yykind_88), symbol_list_sym_new ((yyvsp[0].symbol), (yylsp[0])));
  2362. }
  2363. #line 2728 "src/parse-gram.c"
  2364. break;
  2365. case 93: /* rules_or_grammar_declaration: error ";" */
  2366. #line 671 "src/parse-gram.y"
  2367. {
  2368. yyerrok;
  2369. }
  2370. #line 2736 "src/parse-gram.c"
  2371. break;
  2372. case 94: /* $@4: %empty */
  2373. #line 677 "src/parse-gram.y"
  2374. { current_lhs ((yyvsp[-1].id_colon), (yylsp[-1]), (yyvsp[0].yykind_95)); }
  2375. #line 2742 "src/parse-gram.c"
  2376. break;
  2377. case 95: /* rules: id_colon named_ref.opt $@4 ":" rhses.1 */
  2378. #line 678 "src/parse-gram.y"
  2379. {
  2380. /* Free the current lhs. */
  2381. current_lhs (0, (yylsp[-4]), 0);
  2382. }
  2383. #line 2751 "src/parse-gram.c"
  2384. break;
  2385. case 96: /* rhses.1: rhs */
  2386. #line 685 "src/parse-gram.y"
  2387. { grammar_current_rule_end ((yylsp[0])); }
  2388. #line 2757 "src/parse-gram.c"
  2389. break;
  2390. case 97: /* rhses.1: rhses.1 "|" rhs */
  2391. #line 686 "src/parse-gram.y"
  2392. { grammar_current_rule_end ((yylsp[0])); }
  2393. #line 2763 "src/parse-gram.c"
  2394. break;
  2395. case 99: /* rhs: %empty */
  2396. #line 693 "src/parse-gram.y"
  2397. { grammar_current_rule_begin (current_lhs_symbol, current_lhs_loc,
  2398. current_lhs_named_ref); }
  2399. #line 2770 "src/parse-gram.c"
  2400. break;
  2401. case 100: /* rhs: rhs symbol named_ref.opt */
  2402. #line 696 "src/parse-gram.y"
  2403. { grammar_current_rule_symbol_append ((yyvsp[-1].symbol), (yylsp[-1]), (yyvsp[0].yykind_95)); }
  2404. #line 2776 "src/parse-gram.c"
  2405. break;
  2406. case 101: /* rhs: rhs tag.opt "{...}" named_ref.opt */
  2407. #line 698 "src/parse-gram.y"
  2408. { grammar_current_rule_action_append ((yyvsp[-1].BRACED_CODE), (yylsp[-1]), (yyvsp[0].yykind_95), (yyvsp[-2].yykind_74)); }
  2409. #line 2782 "src/parse-gram.c"
  2410. break;
  2411. case 102: /* rhs: rhs "%?{...}" */
  2412. #line 700 "src/parse-gram.y"
  2413. { grammar_current_rule_predicate_append ((yyvsp[0].BRACED_PREDICATE), (yylsp[0])); }
  2414. #line 2788 "src/parse-gram.c"
  2415. break;
  2416. case 103: /* rhs: rhs "%empty" */
  2417. #line 702 "src/parse-gram.y"
  2418. { grammar_current_rule_empty_set ((yylsp[0])); }
  2419. #line 2794 "src/parse-gram.c"
  2420. break;
  2421. case 104: /* rhs: rhs "%prec" symbol */
  2422. #line 704 "src/parse-gram.y"
  2423. { grammar_current_rule_prec_set ((yyvsp[0].symbol), (yylsp[0])); }
  2424. #line 2800 "src/parse-gram.c"
  2425. break;
  2426. case 105: /* rhs: rhs "%dprec" "integer literal" */
  2427. #line 706 "src/parse-gram.y"
  2428. { grammar_current_rule_dprec_set ((yyvsp[0].INT_LITERAL), (yylsp[0])); }
  2429. #line 2806 "src/parse-gram.c"
  2430. break;
  2431. case 106: /* rhs: rhs "%merge" "<tag>" */
  2432. #line 708 "src/parse-gram.y"
  2433. { grammar_current_rule_merge_set ((yyvsp[0].TAG), (yylsp[0])); }
  2434. #line 2812 "src/parse-gram.c"
  2435. break;
  2436. case 107: /* rhs: rhs "%expect" "integer literal" */
  2437. #line 710 "src/parse-gram.y"
  2438. { grammar_current_rule_expect_sr ((yyvsp[0].INT_LITERAL), (yylsp[0])); }
  2439. #line 2818 "src/parse-gram.c"
  2440. break;
  2441. case 108: /* rhs: rhs "%expect-rr" "integer literal" */
  2442. #line 712 "src/parse-gram.y"
  2443. { grammar_current_rule_expect_rr ((yyvsp[0].INT_LITERAL), (yylsp[0])); }
  2444. #line 2824 "src/parse-gram.c"
  2445. break;
  2446. case 109: /* named_ref.opt: %empty */
  2447. #line 716 "src/parse-gram.y"
  2448. { (yyval.yykind_95) = NULL; }
  2449. #line 2830 "src/parse-gram.c"
  2450. break;
  2451. case 110: /* named_ref.opt: "[identifier]" */
  2452. #line 717 "src/parse-gram.y"
  2453. { (yyval.yykind_95) = named_ref_new ((yyvsp[0].BRACKETED_ID), (yylsp[0])); }
  2454. #line 2836 "src/parse-gram.c"
  2455. break;
  2456. case 112: /* value: %empty */
  2457. #line 750 "src/parse-gram.y"
  2458. { (yyval.value).kind = muscle_keyword; (yyval.value).chars = ""; }
  2459. #line 2842 "src/parse-gram.c"
  2460. break;
  2461. case 113: /* value: "identifier" */
  2462. #line 751 "src/parse-gram.y"
  2463. { (yyval.value).kind = muscle_keyword; (yyval.value).chars = (yyvsp[0].ID); }
  2464. #line 2848 "src/parse-gram.c"
  2465. break;
  2466. case 114: /* value: "string" */
  2467. #line 752 "src/parse-gram.y"
  2468. { (yyval.value).kind = muscle_string; (yyval.value).chars = unquote ((yyvsp[0].STRING)); gram_scanner_last_string_free ();}
  2469. #line 2854 "src/parse-gram.c"
  2470. break;
  2471. case 115: /* value: "{...}" */
  2472. #line 753 "src/parse-gram.y"
  2473. { (yyval.value).kind = muscle_code; (yyval.value).chars = strip_braces ((yyvsp[0].BRACED_CODE)); gram_scanner_last_string_free (); }
  2474. #line 2860 "src/parse-gram.c"
  2475. break;
  2476. case 116: /* id: "identifier" */
  2477. #line 766 "src/parse-gram.y"
  2478. { (yyval.id) = symbol_from_uniqstr ((yyvsp[0].ID), (yylsp[0])); }
  2479. #line 2866 "src/parse-gram.c"
  2480. break;
  2481. case 117: /* id: "character literal" */
  2482. #line 768 "src/parse-gram.y"
  2483. {
  2484. const char *var = "api.token.raw";
  2485. if (current_class == nterm_sym)
  2486. {
  2487. complain (&(yylsp[0]), complaint,
  2488. _("character literals cannot be nonterminals"));
  2489. YYERROR;
  2490. }
  2491. if (muscle_percent_define_ifdef (var))
  2492. {
  2493. complain (&(yylsp[0]), complaint,
  2494. _("character literals cannot be used together"
  2495. " with %s"), var);
  2496. location loc = muscle_percent_define_get_loc (var);
  2497. subcomplain (&loc, complaint, _("definition of %s"), var);
  2498. }
  2499. (yyval.id) = symbol_get (char_name ((yyvsp[0].CHAR_LITERAL)), (yylsp[0]));
  2500. symbol_class_set ((yyval.id), token_sym, (yylsp[0]), false);
  2501. symbol_code_set ((yyval.id), (yyvsp[0].CHAR_LITERAL), (yylsp[0]));
  2502. }
  2503. #line 2891 "src/parse-gram.c"
  2504. break;
  2505. case 118: /* id_colon: "identifier:" */
  2506. #line 791 "src/parse-gram.y"
  2507. { (yyval.id_colon) = symbol_from_uniqstr ((yyvsp[0].ID_COLON), (yylsp[0])); }
  2508. #line 2897 "src/parse-gram.c"
  2509. break;
  2510. case 121: /* string_as_id: "string" */
  2511. #line 803 "src/parse-gram.y"
  2512. {
  2513. (yyval.string_as_id) = symbol_get ((yyvsp[0].STRING), (yylsp[0]));
  2514. symbol_class_set ((yyval.string_as_id), token_sym, (yylsp[0]), false);
  2515. }
  2516. #line 2906 "src/parse-gram.c"
  2517. break;
  2518. case 123: /* epilogue.opt: "%%" "epilogue" */
  2519. #line 812 "src/parse-gram.y"
  2520. {
  2521. muscle_code_grow ("epilogue", translate_code ((yyvsp[0].EPILOGUE), (yylsp[0]), true), (yylsp[0]));
  2522. code_scanner_last_string_free ();
  2523. }
  2524. #line 2915 "src/parse-gram.c"
  2525. break;
  2526. #line 2919 "src/parse-gram.c"
  2527. default: break;
  2528. }
  2529. if (yychar_backup != yychar)
  2530. YY_LAC_DISCARD ("yychar change");
  2531. }
  2532. /* User semantic actions sometimes alter yychar, and that requires
  2533. that yytoken be updated with the new translation. We take the
  2534. approach of translating immediately before every use of yytoken.
  2535. One alternative is translating here after every semantic action,
  2536. but that translation would be missed if the semantic action invokes
  2537. YYABORT, YYACCEPT, or YYERROR immediately after altering yychar or
  2538. if it invokes YYBACKUP. In the case of YYABORT or YYACCEPT, an
  2539. incorrect destructor might then be invoked immediately. In the
  2540. case of YYERROR or YYBACKUP, subsequent parser actions might lead
  2541. to an incorrect destructor call or verbose syntax error message
  2542. before the lookahead is translated. */
  2543. YY_SYMBOL_PRINT ("-> $$ =", YY_CAST (yysymbol_kind_t, yyr1[yyn]), &yyval, &yyloc);
  2544. YYPOPSTACK (yylen);
  2545. yylen = 0;
  2546. *++yyvsp = yyval;
  2547. *++yylsp = yyloc;
  2548. /* Now 'shift' the result of the reduction. Determine what state
  2549. that goes to, based on the state we popped back to and the rule
  2550. number reduced by. */
  2551. {
  2552. const int yylhs = yyr1[yyn] - YYNTOKENS;
  2553. const int yyi = yypgoto[yylhs] + *yyssp;
  2554. yystate = (0 <= yyi && yyi <= YYLAST && yycheck[yyi] == *yyssp
  2555. ? yytable[yyi]
  2556. : yydefgoto[yylhs]);
  2557. }
  2558. goto yynewstate;
  2559. /*--------------------------------------.
  2560. | yyerrlab -- here on detecting error. |
  2561. `--------------------------------------*/
  2562. yyerrlab:
  2563. /* Make sure we have latest lookahead translation. See comments at
  2564. user semantic actions for why this is necessary. */
  2565. yytoken = yychar == GRAM_EMPTY ? YYSYMBOL_YYEMPTY : YYTRANSLATE (yychar);
  2566. /* If not already recovering from an error, report this error. */
  2567. if (!yyerrstatus)
  2568. {
  2569. ++yynerrs;
  2570. {
  2571. yypcontext_t yyctx
  2572. = {yyssp, yyesa, &yyes, &yyes_capacity, yytoken, &yylloc};
  2573. if (yychar != GRAM_EMPTY)
  2574. YY_LAC_ESTABLISH;
  2575. if (yyreport_syntax_error (&yyctx) == 2)
  2576. goto yyexhaustedlab;
  2577. }
  2578. }
  2579. yyerror_range[1] = yylloc;
  2580. if (yyerrstatus == 3)
  2581. {
  2582. /* If just tried and failed to reuse lookahead token after an
  2583. error, discard it. */
  2584. if (yychar <= GRAM_EOF)
  2585. {
  2586. /* Return failure if at end of input. */
  2587. if (yychar == GRAM_EOF)
  2588. YYABORT;
  2589. }
  2590. else
  2591. {
  2592. yydestruct ("Error: discarding",
  2593. yytoken, &yylval, &yylloc);
  2594. yychar = GRAM_EMPTY;
  2595. }
  2596. }
  2597. /* Else will try to reuse lookahead token after shifting the error
  2598. token. */
  2599. goto yyerrlab1;
  2600. /*---------------------------------------------------.
  2601. | yyerrorlab -- error raised explicitly by YYERROR. |
  2602. `---------------------------------------------------*/
  2603. yyerrorlab:
  2604. /* Pacify compilers when the user code never invokes YYERROR and the
  2605. label yyerrorlab therefore never appears in user code. */
  2606. if (0)
  2607. YYERROR;
  2608. /* Do not reclaim the symbols of the rule whose action triggered
  2609. this YYERROR. */
  2610. YYPOPSTACK (yylen);
  2611. yylen = 0;
  2612. YY_STACK_PRINT (yyss, yyssp);
  2613. yystate = *yyssp;
  2614. goto yyerrlab1;
  2615. /*-------------------------------------------------------------.
  2616. | yyerrlab1 -- common code for both syntax error and YYERROR. |
  2617. `-------------------------------------------------------------*/
  2618. yyerrlab1:
  2619. yyerrstatus = 3; /* Each real token shifted decrements this. */
  2620. /* Pop stack until we find a state that shifts the error token. */
  2621. for (;;)
  2622. {
  2623. yyn = yypact[yystate];
  2624. if (!yypact_value_is_default (yyn))
  2625. {
  2626. yyn += YYSYMBOL_YYerror;
  2627. if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYSYMBOL_YYerror)
  2628. {
  2629. yyn = yytable[yyn];
  2630. if (0 < yyn)
  2631. break;
  2632. }
  2633. }
  2634. /* Pop the current state because it cannot handle the error token. */
  2635. if (yyssp == yyss)
  2636. YYABORT;
  2637. yyerror_range[1] = *yylsp;
  2638. yydestruct ("Error: popping",
  2639. YY_ACCESSING_SYMBOL (yystate), yyvsp, yylsp);
  2640. YYPOPSTACK (1);
  2641. yystate = *yyssp;
  2642. YY_STACK_PRINT (yyss, yyssp);
  2643. }
  2644. /* If the stack popping above didn't lose the initial context for the
  2645. current lookahead token, the shift below will for sure. */
  2646. YY_LAC_DISCARD ("error recovery");
  2647. YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
  2648. *++yyvsp = yylval;
  2649. YY_IGNORE_MAYBE_UNINITIALIZED_END
  2650. yyerror_range[2] = yylloc;
  2651. ++yylsp;
  2652. YYLLOC_DEFAULT (*yylsp, yyerror_range, 2);
  2653. /* Shift the error token. */
  2654. YY_SYMBOL_PRINT ("Shifting", YY_ACCESSING_SYMBOL (yyn), yyvsp, yylsp);
  2655. yystate = yyn;
  2656. goto yynewstate;
  2657. /*-------------------------------------.
  2658. | yyacceptlab -- YYACCEPT comes here. |
  2659. `-------------------------------------*/
  2660. yyacceptlab:
  2661. yyresult = 0;
  2662. goto yyreturn;
  2663. /*-----------------------------------.
  2664. | yyabortlab -- YYABORT comes here. |
  2665. `-----------------------------------*/
  2666. yyabortlab:
  2667. yyresult = 1;
  2668. goto yyreturn;
  2669. #if 1
  2670. /*-------------------------------------------------.
  2671. | yyexhaustedlab -- memory exhaustion comes here. |
  2672. `-------------------------------------------------*/
  2673. yyexhaustedlab:
  2674. yyerror (&yylloc, YY_("memory exhausted"));
  2675. yyresult = 2;
  2676. goto yyreturn;
  2677. #endif
  2678. /*-------------------------------------------------------.
  2679. | yyreturn -- parsing is finished, clean up and return. |
  2680. `-------------------------------------------------------*/
  2681. yyreturn:
  2682. if (yychar != GRAM_EMPTY)
  2683. {
  2684. /* Make sure we have latest lookahead translation. See comments at
  2685. user semantic actions for why this is necessary. */
  2686. yytoken = YYTRANSLATE (yychar);
  2687. yydestruct ("Cleanup: discarding lookahead",
  2688. yytoken, &yylval, &yylloc);
  2689. }
  2690. /* Do not reclaim the symbols of the rule whose action triggered
  2691. this YYABORT or YYACCEPT. */
  2692. YYPOPSTACK (yylen);
  2693. YY_STACK_PRINT (yyss, yyssp);
  2694. while (yyssp != yyss)
  2695. {
  2696. yydestruct ("Cleanup: popping",
  2697. YY_ACCESSING_SYMBOL (+*yyssp), yyvsp, yylsp);
  2698. YYPOPSTACK (1);
  2699. }
  2700. #ifndef yyoverflow
  2701. if (yyss != yyssa)
  2702. YYSTACK_FREE (yyss);
  2703. #endif
  2704. if (yyes != yyesa)
  2705. YYSTACK_FREE (yyes);
  2706. return yyresult;
  2707. }
  2708. #line 818 "src/parse-gram.y"
  2709. int
  2710. yyreport_syntax_error (const yypcontext_t *ctx)
  2711. {
  2712. int res = 0;
  2713. /* Arguments of format: reported tokens (one for the "unexpected",
  2714. one per "expected"). */
  2715. enum { ARGS_MAX = 5 };
  2716. const char *argv[ARGS_MAX];
  2717. int argc = 0;
  2718. yysymbol_kind_t unexpected = yypcontext_token (ctx);
  2719. if (unexpected != YYSYMBOL_YYEMPTY)
  2720. {
  2721. argv[argc++] = yysymbol_name (unexpected);
  2722. yysymbol_kind_t expected[ARGS_MAX - 1];
  2723. int nexpected = yypcontext_expected_tokens (ctx, expected, ARGS_MAX - 1);
  2724. if (nexpected < 0)
  2725. res = nexpected;
  2726. else
  2727. for (int i = 0; i < nexpected; ++i)
  2728. argv[argc++] = yysymbol_name (expected[i]);
  2729. }
  2730. syntax_error (*yypcontext_location (ctx), argc, argv);
  2731. return res;
  2732. }
  2733. /* Return the location of the left-hand side of a rule whose
  2734. right-hand side is RHS[1] ... RHS[N]. Ignore empty nonterminals in
  2735. the right-hand side, and return an empty location equal to the end
  2736. boundary of RHS[0] if the right-hand side is empty. */
  2737. static YYLTYPE
  2738. lloc_default (YYLTYPE const *rhs, int n)
  2739. {
  2740. YYLTYPE loc;
  2741. /* SGI MIPSpro 7.4.1m miscompiles "loc.start = loc.end = rhs[n].end;".
  2742. The bug is fixed in 7.4.2m, but play it safe for now. */
  2743. loc.start = rhs[n].end;
  2744. loc.end = rhs[n].end;
  2745. /* Ignore empty nonterminals the start of the right-hand side.
  2746. Do not bother to ignore them at the end of the right-hand side,
  2747. since empty nonterminals have the same end as their predecessors. */
  2748. for (int i = 1; i <= n; i++)
  2749. if (! equal_boundaries (rhs[i].start, rhs[i].end))
  2750. {
  2751. loc.start = rhs[i].start;
  2752. break;
  2753. }
  2754. return loc;
  2755. }
  2756. static
  2757. char *strip_braces (char *code)
  2758. {
  2759. code[strlen (code) - 1] = 0;
  2760. return code + 1;
  2761. }
  2762. static
  2763. char const *
  2764. translate_code (char *code, location loc, bool plain)
  2765. {
  2766. code_props plain_code;
  2767. if (plain)
  2768. code_props_plain_init (&plain_code, code, loc);
  2769. else
  2770. code_props_symbol_action_init (&plain_code, code, loc);
  2771. code_props_translate_code (&plain_code);
  2772. gram_scanner_last_string_free ();
  2773. return plain_code.code;
  2774. }
  2775. static
  2776. char const *
  2777. translate_code_braceless (char *code, location loc)
  2778. {
  2779. return translate_code (strip_braces (code), loc, true);
  2780. }
  2781. static void
  2782. add_param (param_type type, char *decl, location loc)
  2783. {
  2784. static char const alphanum[26 + 26 + 1 + 10 + 1] =
  2785. "abcdefghijklmnopqrstuvwxyz"
  2786. "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
  2787. "_"
  2788. "0123456789";
  2789. char const *name_start = NULL;
  2790. {
  2791. char *p;
  2792. /* Stop on last actual character. */
  2793. for (p = decl; p[1]; p++)
  2794. if ((p == decl
  2795. || ! memchr (alphanum, p[-1], sizeof alphanum - 1))
  2796. && memchr (alphanum, p[0], sizeof alphanum - 10 - 1))
  2797. name_start = p;
  2798. /* Strip the surrounding '{' and '}', and any blanks just inside
  2799. the braces. */
  2800. --p;
  2801. while (c_isspace ((unsigned char) *p))
  2802. --p;
  2803. p[1] = '\0';
  2804. ++decl;
  2805. while (c_isspace ((unsigned char) *decl))
  2806. ++decl;
  2807. }
  2808. if (! name_start)
  2809. complain (&loc, complaint, _("missing identifier in parameter declaration"));
  2810. else
  2811. {
  2812. char *name = xmemdup0 (name_start, strspn (name_start, alphanum));
  2813. if (type & param_lex)
  2814. muscle_pair_list_grow ("lex_param", decl, name);
  2815. if (type & param_parse)
  2816. muscle_pair_list_grow ("parse_param", decl, name);
  2817. free (name);
  2818. }
  2819. gram_scanner_last_string_free ();
  2820. }
  2821. static void
  2822. handle_defines (char const *value)
  2823. {
  2824. defines_flag = true;
  2825. char *file = unquote (value);
  2826. spec_header_file = xstrdup (file);
  2827. gram_scanner_last_string_free ();
  2828. unquote_free (file);
  2829. }
  2830. static void
  2831. handle_error_verbose (location const *loc, char const *directive)
  2832. {
  2833. bison_directive (loc, directive);
  2834. muscle_percent_define_insert (directive, *loc, muscle_keyword, "",
  2835. MUSCLE_PERCENT_DEFINE_GRAMMAR_FILE);
  2836. }
  2837. static void
  2838. handle_file_prefix (location const *loc,
  2839. location const *dir_loc,
  2840. char const *directive, char const *value_quoted)
  2841. {
  2842. char *value = unquote (value_quoted);
  2843. bison_directive (loc, directive);
  2844. bool warned = false;
  2845. if (location_empty (spec_file_prefix_loc))
  2846. {
  2847. spec_file_prefix_loc = *loc;
  2848. spec_file_prefix = value;
  2849. }
  2850. else
  2851. {
  2852. duplicate_directive (directive, spec_file_prefix_loc, *loc);
  2853. warned = true;
  2854. }
  2855. if (!warned
  2856. && STRNEQ (directive, "%file-prefix"))
  2857. deprecated_directive (dir_loc, directive, "%file-prefix");
  2858. }
  2859. static void
  2860. handle_language (location const *loc, char const *lang)
  2861. {
  2862. language_argmatch (unquote (lang), grammar_prio, *loc);
  2863. }
  2864. static void
  2865. handle_name_prefix (location const *loc,
  2866. char const *directive, char const *value_quoted)
  2867. {
  2868. char *value = unquote (value_quoted);
  2869. bison_directive (loc, directive);
  2870. char buf1[1024];
  2871. size_t len1 = sizeof (buf1);
  2872. char *old = asnprintf (buf1, &len1, "%s\"%s\"", directive, value);
  2873. if (!old)
  2874. xalloc_die ();
  2875. if (location_empty (spec_name_prefix_loc))
  2876. {
  2877. spec_name_prefix = value;
  2878. spec_name_prefix_loc = *loc;
  2879. char buf2[1024];
  2880. size_t len2 = sizeof (buf2);
  2881. char *new = asnprintf (buf2, &len2, "%%define api.prefix {%s}", value);
  2882. if (!new)
  2883. xalloc_die ();
  2884. deprecated_directive (loc, old, new);
  2885. if (new != buf2)
  2886. free (new);
  2887. }
  2888. else
  2889. duplicate_directive (old, spec_file_prefix_loc, *loc);
  2890. if (old != buf1)
  2891. free (old);
  2892. }
  2893. static void
  2894. handle_pure_parser (location const *loc, char const *directive)
  2895. {
  2896. bison_directive (loc, directive);
  2897. deprecated_directive (loc, directive, "%define api.pure");
  2898. muscle_percent_define_insert ("api.pure", *loc, muscle_keyword, "",
  2899. MUSCLE_PERCENT_DEFINE_GRAMMAR_FILE);
  2900. }
  2901. static void
  2902. handle_require (location const *loc, char const *version_quoted)
  2903. {
  2904. char *version = unquote (version_quoted);
  2905. required_version = strversion_to_int (version);
  2906. if (required_version == -1)
  2907. {
  2908. complain (loc, complaint, _("invalid version requirement: %s"),
  2909. version);
  2910. required_version = 0;
  2911. }
  2912. else
  2913. {
  2914. const char* package_version =
  2915. 0 < strverscmp (api_version, PACKAGE_VERSION)
  2916. ? api_version : PACKAGE_VERSION;
  2917. if (0 < strverscmp (version, package_version))
  2918. {
  2919. complain (loc, complaint, _("require bison %s, but have %s"),
  2920. version, package_version);
  2921. exit (EX_MISMATCH);
  2922. }
  2923. }
  2924. unquote_free (version);
  2925. gram_scanner_last_string_free ();
  2926. }
  2927. static void
  2928. handle_skeleton (location const *loc, char const *skel_quoted)
  2929. {
  2930. char *skel = unquote (skel_quoted);
  2931. char const *skeleton_user = skel;
  2932. if (strchr (skeleton_user, '/'))
  2933. {
  2934. size_t dir_length = strlen (grammar_file);
  2935. while (dir_length && grammar_file[dir_length - 1] != '/')
  2936. --dir_length;
  2937. while (dir_length && grammar_file[dir_length - 1] == '/')
  2938. --dir_length;
  2939. char *skeleton_build =
  2940. xmalloc (dir_length + 1 + strlen (skeleton_user) + 1);
  2941. if (dir_length > 0)
  2942. {
  2943. memcpy (skeleton_build, grammar_file, dir_length);
  2944. skeleton_build[dir_length++] = '/';
  2945. }
  2946. strcpy (skeleton_build + dir_length, skeleton_user);
  2947. skeleton_user = uniqstr_new (skeleton_build);
  2948. free (skeleton_build);
  2949. }
  2950. skeleton_arg (skeleton_user, grammar_prio, *loc);
  2951. }
  2952. static void
  2953. handle_yacc (location const *loc)
  2954. {
  2955. const char *directive = "%yacc";
  2956. bison_directive (loc, directive);
  2957. if (location_empty (yacc_loc))
  2958. yacc_loc = *loc;
  2959. else
  2960. duplicate_directive (directive, yacc_loc, *loc);
  2961. }
  2962. static void
  2963. gram_error (location const *loc, char const *msg)
  2964. {
  2965. complain (loc, complaint, "%s", msg);
  2966. }
  2967. static char const *
  2968. char_name (char c)
  2969. {
  2970. if (c == '\'')
  2971. return "'\\''";
  2972. else
  2973. {
  2974. char buf[4];
  2975. buf[0] = '\''; buf[1] = c; buf[2] = '\''; buf[3] = '\0';
  2976. return quotearg_style (escape_quoting_style, buf);
  2977. }
  2978. }
  2979. static void
  2980. current_lhs (symbol *sym, location loc, named_ref *ref)
  2981. {
  2982. current_lhs_symbol = sym;
  2983. current_lhs_loc = loc;
  2984. if (sym)
  2985. symbol_location_as_lhs_set (sym, loc);
  2986. /* In order to simplify memory management, named references for lhs
  2987. are always assigned by deep copy into the current symbol_list
  2988. node. This is because a single named-ref in the grammar may
  2989. result in several uses when the user factors lhs between several
  2990. rules using "|". Therefore free the parser's original copy. */
  2991. free (current_lhs_named_ref);
  2992. current_lhs_named_ref = ref;
  2993. }
  2994. static void tron (FILE *yyo)
  2995. {
  2996. begin_use_class ("value", yyo);
  2997. }
  2998. static void troff (FILE *yyo)
  2999. {
  3000. end_use_class ("value", yyo);
  3001. }
  3002. /*----------.
  3003. | Unquote. |
  3004. `----------*/
  3005. struct obstack obstack_for_unquote;
  3006. void
  3007. parser_init (void)
  3008. {
  3009. obstack_init (&obstack_for_unquote);
  3010. }
  3011. void
  3012. parser_free (void)
  3013. {
  3014. obstack_free (&obstack_for_unquote, 0);
  3015. }
  3016. static void
  3017. unquote_free (char *last_string)
  3018. {
  3019. obstack_free (&obstack_for_unquote, last_string);
  3020. }
  3021. static char *
  3022. unquote (const char *cp)
  3023. {
  3024. #define GROW(Char) \
  3025. obstack_1grow (&obstack_for_unquote, Char);
  3026. for (++cp; *cp && *cp != '"'; ++cp)
  3027. switch (*cp)
  3028. {
  3029. case '"':
  3030. break;
  3031. case '\\':
  3032. ++cp;
  3033. switch (*cp)
  3034. {
  3035. case '0': case '1': case '2': case '3': case '4':
  3036. case '5': case '6': case '7': case '8': case '9':
  3037. {
  3038. int c = cp[0] - '0';
  3039. if (c_isdigit (cp[1]))
  3040. {
  3041. ++cp;
  3042. c = c * 8 + cp[0] - '0';
  3043. }
  3044. if (c_isdigit (cp[1]))
  3045. {
  3046. ++cp;
  3047. c = c * 8 + cp[0] - '0';
  3048. }
  3049. GROW (c);
  3050. }
  3051. break;
  3052. case 'a': GROW ('\a'); break;
  3053. case 'b': GROW ('\b'); break;
  3054. case 'f': GROW ('\f'); break;
  3055. case 'n': GROW ('\n'); break;
  3056. case 'r': GROW ('\r'); break;
  3057. case 't': GROW ('\t'); break;
  3058. case 'v': GROW ('\v'); break;
  3059. case 'x':
  3060. {
  3061. int c = 0;
  3062. while (c_isxdigit (cp[1]))
  3063. {
  3064. ++cp;
  3065. c = (c * 16 + (c_isdigit (cp[0]) ? cp[0] - '0'
  3066. : c_isupper (cp[0]) ? cp[0] - 'A'
  3067. : cp[0] - '0'));
  3068. }
  3069. GROW (c);
  3070. break;
  3071. }
  3072. }
  3073. break;
  3074. default:
  3075. GROW (*cp);
  3076. break;
  3077. }
  3078. assert (*cp == '"');
  3079. ++cp;
  3080. assert (*cp == '\0');
  3081. #undef GROW
  3082. return obstack_finish0 (&obstack_for_unquote);
  3083. }