parser.tab.c 72 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189
  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 0
  45. /* Push parsers. */
  46. #define YYPUSH 0
  47. /* Pull parsers. */
  48. #define YYPULL 1
  49. /* First part of user prologue. */
  50. #include <ctype.h>
  51. #include <stdarg.h>
  52. #include <stdio.h>
  53. #include <stdlib.h>
  54. #include <string.h>
  55. #include <stdbool.h>
  56. #include "lkc.h"
  57. #include "internal.h"
  58. #define printd(mask, fmt...) if (cdebug & (mask)) printf(fmt)
  59. #define PRINTD 0x0001
  60. #define DEBUG_PARSE 0x0002
  61. int cdebug = PRINTD;
  62. static void yyerror(const char *err);
  63. static void zconfprint(const char *err, ...);
  64. static void zconf_error(const char *err, ...);
  65. static bool zconf_endtoken(const char *tokenname,
  66. const char *expected_tokenname);
  67. struct symbol *symbol_hash[SYMBOL_HASHSIZE];
  68. struct menu *current_menu, *current_entry;
  69. # ifndef YY_CAST
  70. # ifdef __cplusplus
  71. # define YY_CAST(Type, Val) static_cast<Type> (Val)
  72. # define YY_REINTERPRET_CAST(Type, Val) reinterpret_cast<Type> (Val)
  73. # else
  74. # define YY_CAST(Type, Val) ((Type) (Val))
  75. # define YY_REINTERPRET_CAST(Type, Val) ((Type) (Val))
  76. # endif
  77. # endif
  78. # ifndef YY_NULLPTR
  79. # if defined __cplusplus
  80. # if 201103L <= __cplusplus
  81. # define YY_NULLPTR nullptr
  82. # else
  83. # define YY_NULLPTR 0
  84. # endif
  85. # else
  86. # define YY_NULLPTR ((void*)0)
  87. # endif
  88. # endif
  89. #include "parser.tab.h"
  90. /* Symbol kind. */
  91. enum yysymbol_kind_t
  92. {
  93. YYSYMBOL_YYEMPTY = -2,
  94. YYSYMBOL_YYEOF = 0, /* "end of file" */
  95. YYSYMBOL_YYerror = 1, /* error */
  96. YYSYMBOL_YYUNDEF = 2, /* "invalid token" */
  97. YYSYMBOL_T_HELPTEXT = 3, /* T_HELPTEXT */
  98. YYSYMBOL_T_WORD = 4, /* T_WORD */
  99. YYSYMBOL_T_WORD_QUOTE = 5, /* T_WORD_QUOTE */
  100. YYSYMBOL_T_BOOL = 6, /* T_BOOL */
  101. YYSYMBOL_T_CHOICE = 7, /* T_CHOICE */
  102. YYSYMBOL_T_CLOSE_PAREN = 8, /* T_CLOSE_PAREN */
  103. YYSYMBOL_T_COLON_EQUAL = 9, /* T_COLON_EQUAL */
  104. YYSYMBOL_T_COMMENT = 10, /* T_COMMENT */
  105. YYSYMBOL_T_CONFIG = 11, /* T_CONFIG */
  106. YYSYMBOL_T_DEFAULT = 12, /* T_DEFAULT */
  107. YYSYMBOL_T_DEF_BOOL = 13, /* T_DEF_BOOL */
  108. YYSYMBOL_T_DEF_TRISTATE = 14, /* T_DEF_TRISTATE */
  109. YYSYMBOL_T_DEPENDS = 15, /* T_DEPENDS */
  110. YYSYMBOL_T_ENDCHOICE = 16, /* T_ENDCHOICE */
  111. YYSYMBOL_T_ENDIF = 17, /* T_ENDIF */
  112. YYSYMBOL_T_ENDMENU = 18, /* T_ENDMENU */
  113. YYSYMBOL_T_HELP = 19, /* T_HELP */
  114. YYSYMBOL_T_HEX = 20, /* T_HEX */
  115. YYSYMBOL_T_IF = 21, /* T_IF */
  116. YYSYMBOL_T_IMPLY = 22, /* T_IMPLY */
  117. YYSYMBOL_T_INT = 23, /* T_INT */
  118. YYSYMBOL_T_MAINMENU = 24, /* T_MAINMENU */
  119. YYSYMBOL_T_MENU = 25, /* T_MENU */
  120. YYSYMBOL_T_MENUCONFIG = 26, /* T_MENUCONFIG */
  121. YYSYMBOL_T_MODULES = 27, /* T_MODULES */
  122. YYSYMBOL_T_ON = 28, /* T_ON */
  123. YYSYMBOL_T_OPEN_PAREN = 29, /* T_OPEN_PAREN */
  124. YYSYMBOL_T_OPTIONAL = 30, /* T_OPTIONAL */
  125. YYSYMBOL_T_PLUS_EQUAL = 31, /* T_PLUS_EQUAL */
  126. YYSYMBOL_T_PROMPT = 32, /* T_PROMPT */
  127. YYSYMBOL_T_RANGE = 33, /* T_RANGE */
  128. YYSYMBOL_T_RESET = 34, /* T_RESET */
  129. YYSYMBOL_T_SELECT = 35, /* T_SELECT */
  130. YYSYMBOL_T_SOURCE = 36, /* T_SOURCE */
  131. YYSYMBOL_T_STRING = 37, /* T_STRING */
  132. YYSYMBOL_T_TRISTATE = 38, /* T_TRISTATE */
  133. YYSYMBOL_T_VISIBLE = 39, /* T_VISIBLE */
  134. YYSYMBOL_T_EOL = 40, /* T_EOL */
  135. YYSYMBOL_T_ASSIGN_VAL = 41, /* T_ASSIGN_VAL */
  136. YYSYMBOL_T_OR = 42, /* T_OR */
  137. YYSYMBOL_T_AND = 43, /* T_AND */
  138. YYSYMBOL_T_EQUAL = 44, /* T_EQUAL */
  139. YYSYMBOL_T_UNEQUAL = 45, /* T_UNEQUAL */
  140. YYSYMBOL_T_LESS = 46, /* T_LESS */
  141. YYSYMBOL_T_LESS_EQUAL = 47, /* T_LESS_EQUAL */
  142. YYSYMBOL_T_GREATER = 48, /* T_GREATER */
  143. YYSYMBOL_T_GREATER_EQUAL = 49, /* T_GREATER_EQUAL */
  144. YYSYMBOL_T_NOT = 50, /* T_NOT */
  145. YYSYMBOL_YYACCEPT = 51, /* $accept */
  146. YYSYMBOL_input = 52, /* input */
  147. YYSYMBOL_mainmenu_stmt = 53, /* mainmenu_stmt */
  148. YYSYMBOL_stmt_list = 54, /* stmt_list */
  149. YYSYMBOL_stmt_list_in_choice = 55, /* stmt_list_in_choice */
  150. YYSYMBOL_config_entry_start = 56, /* config_entry_start */
  151. YYSYMBOL_config_stmt = 57, /* config_stmt */
  152. YYSYMBOL_menuconfig_entry_start = 58, /* menuconfig_entry_start */
  153. YYSYMBOL_menuconfig_stmt = 59, /* menuconfig_stmt */
  154. YYSYMBOL_config_option_list = 60, /* config_option_list */
  155. YYSYMBOL_config_option = 61, /* config_option */
  156. YYSYMBOL_choice = 62, /* choice */
  157. YYSYMBOL_choice_entry = 63, /* choice_entry */
  158. YYSYMBOL_choice_end = 64, /* choice_end */
  159. YYSYMBOL_choice_stmt = 65, /* choice_stmt */
  160. YYSYMBOL_choice_option_list = 66, /* choice_option_list */
  161. YYSYMBOL_choice_option = 67, /* choice_option */
  162. YYSYMBOL_type = 68, /* type */
  163. YYSYMBOL_logic_type = 69, /* logic_type */
  164. YYSYMBOL_default = 70, /* default */
  165. YYSYMBOL_if_entry = 71, /* if_entry */
  166. YYSYMBOL_if_end = 72, /* if_end */
  167. YYSYMBOL_if_stmt = 73, /* if_stmt */
  168. YYSYMBOL_if_stmt_in_choice = 74, /* if_stmt_in_choice */
  169. YYSYMBOL_menu = 75, /* menu */
  170. YYSYMBOL_menu_entry = 76, /* menu_entry */
  171. YYSYMBOL_menu_end = 77, /* menu_end */
  172. YYSYMBOL_menu_stmt = 78, /* menu_stmt */
  173. YYSYMBOL_menu_option_list = 79, /* menu_option_list */
  174. YYSYMBOL_source_stmt = 80, /* source_stmt */
  175. YYSYMBOL_comment = 81, /* comment */
  176. YYSYMBOL_comment_stmt = 82, /* comment_stmt */
  177. YYSYMBOL_comment_option_list = 83, /* comment_option_list */
  178. YYSYMBOL_help_start = 84, /* help_start */
  179. YYSYMBOL_help = 85, /* help */
  180. YYSYMBOL_depends = 86, /* depends */
  181. YYSYMBOL_visible = 87, /* visible */
  182. YYSYMBOL_prompt_stmt_opt = 88, /* prompt_stmt_opt */
  183. YYSYMBOL_end = 89, /* end */
  184. YYSYMBOL_if_expr = 90, /* if_expr */
  185. YYSYMBOL_expr = 91, /* expr */
  186. YYSYMBOL_nonconst_symbol = 92, /* nonconst_symbol */
  187. YYSYMBOL_symbol = 93, /* symbol */
  188. YYSYMBOL_word_opt = 94, /* word_opt */
  189. YYSYMBOL_assignment_stmt = 95, /* assignment_stmt */
  190. YYSYMBOL_assign_op = 96, /* assign_op */
  191. YYSYMBOL_assign_val = 97 /* assign_val */
  192. };
  193. typedef enum yysymbol_kind_t yysymbol_kind_t;
  194. #ifdef short
  195. # undef short
  196. #endif
  197. /* On compilers that do not define __PTRDIFF_MAX__ etc., make sure
  198. <limits.h> and (if available) <stdint.h> are included
  199. so that the code can choose integer types of a good width. */
  200. #ifndef __PTRDIFF_MAX__
  201. # include <limits.h> /* INFRINGES ON USER NAME SPACE */
  202. # if defined __STDC_VERSION__ && 199901 <= __STDC_VERSION__
  203. # include <stdint.h> /* INFRINGES ON USER NAME SPACE */
  204. # define YY_STDINT_H
  205. # endif
  206. #endif
  207. /* Narrow types that promote to a signed type and that can represent a
  208. signed or unsigned integer of at least N bits. In tables they can
  209. save space and decrease cache pressure. Promoting to a signed type
  210. helps avoid bugs in integer arithmetic. */
  211. #ifdef __INT_LEAST8_MAX__
  212. typedef __INT_LEAST8_TYPE__ yytype_int8;
  213. #elif defined YY_STDINT_H
  214. typedef int_least8_t yytype_int8;
  215. #else
  216. typedef signed char yytype_int8;
  217. #endif
  218. #ifdef __INT_LEAST16_MAX__
  219. typedef __INT_LEAST16_TYPE__ yytype_int16;
  220. #elif defined YY_STDINT_H
  221. typedef int_least16_t yytype_int16;
  222. #else
  223. typedef short yytype_int16;
  224. #endif
  225. /* Work around bug in HP-UX 11.23, which defines these macros
  226. incorrectly for preprocessor constants. This workaround can likely
  227. be removed in 2023, as HPE has promised support for HP-UX 11.23
  228. (aka HP-UX 11i v2) only through the end of 2022; see Table 2 of
  229. <https://h20195.www2.hpe.com/V2/getpdf.aspx/4AA4-7673ENW.pdf>. */
  230. #ifdef __hpux
  231. # undef UINT_LEAST8_MAX
  232. # undef UINT_LEAST16_MAX
  233. # define UINT_LEAST8_MAX 255
  234. # define UINT_LEAST16_MAX 65535
  235. #endif
  236. #if defined __UINT_LEAST8_MAX__ && __UINT_LEAST8_MAX__ <= __INT_MAX__
  237. typedef __UINT_LEAST8_TYPE__ yytype_uint8;
  238. #elif (!defined __UINT_LEAST8_MAX__ && defined YY_STDINT_H \
  239. && UINT_LEAST8_MAX <= INT_MAX)
  240. typedef uint_least8_t yytype_uint8;
  241. #elif !defined __UINT_LEAST8_MAX__ && UCHAR_MAX <= INT_MAX
  242. typedef unsigned char yytype_uint8;
  243. #else
  244. typedef short yytype_uint8;
  245. #endif
  246. #if defined __UINT_LEAST16_MAX__ && __UINT_LEAST16_MAX__ <= __INT_MAX__
  247. typedef __UINT_LEAST16_TYPE__ yytype_uint16;
  248. #elif (!defined __UINT_LEAST16_MAX__ && defined YY_STDINT_H \
  249. && UINT_LEAST16_MAX <= INT_MAX)
  250. typedef uint_least16_t yytype_uint16;
  251. #elif !defined __UINT_LEAST16_MAX__ && USHRT_MAX <= INT_MAX
  252. typedef unsigned short yytype_uint16;
  253. #else
  254. typedef int yytype_uint16;
  255. #endif
  256. #ifndef YYPTRDIFF_T
  257. # if defined __PTRDIFF_TYPE__ && defined __PTRDIFF_MAX__
  258. # define YYPTRDIFF_T __PTRDIFF_TYPE__
  259. # define YYPTRDIFF_MAXIMUM __PTRDIFF_MAX__
  260. # elif defined PTRDIFF_MAX
  261. # ifndef ptrdiff_t
  262. # include <stddef.h> /* INFRINGES ON USER NAME SPACE */
  263. # endif
  264. # define YYPTRDIFF_T ptrdiff_t
  265. # define YYPTRDIFF_MAXIMUM PTRDIFF_MAX
  266. # else
  267. # define YYPTRDIFF_T long
  268. # define YYPTRDIFF_MAXIMUM LONG_MAX
  269. # endif
  270. #endif
  271. #ifndef YYSIZE_T
  272. # ifdef __SIZE_TYPE__
  273. # define YYSIZE_T __SIZE_TYPE__
  274. # elif defined size_t
  275. # define YYSIZE_T size_t
  276. # elif defined __STDC_VERSION__ && 199901 <= __STDC_VERSION__
  277. # include <stddef.h> /* INFRINGES ON USER NAME SPACE */
  278. # define YYSIZE_T size_t
  279. # else
  280. # define YYSIZE_T unsigned
  281. # endif
  282. #endif
  283. #define YYSIZE_MAXIMUM \
  284. YY_CAST (YYPTRDIFF_T, \
  285. (YYPTRDIFF_MAXIMUM < YY_CAST (YYSIZE_T, -1) \
  286. ? YYPTRDIFF_MAXIMUM \
  287. : YY_CAST (YYSIZE_T, -1)))
  288. #define YYSIZEOF(X) YY_CAST (YYPTRDIFF_T, sizeof (X))
  289. /* Stored state numbers (used for stacks). */
  290. typedef yytype_uint8 yy_state_t;
  291. /* State numbers in computations. */
  292. typedef int yy_state_fast_t;
  293. #ifndef YY_
  294. # if defined YYENABLE_NLS && YYENABLE_NLS
  295. # if ENABLE_NLS
  296. # include <libintl.h> /* INFRINGES ON USER NAME SPACE */
  297. # define YY_(Msgid) dgettext ("bison-runtime", Msgid)
  298. # endif
  299. # endif
  300. # ifndef YY_
  301. # define YY_(Msgid) Msgid
  302. # endif
  303. #endif
  304. #ifndef YY_ATTRIBUTE_PURE
  305. # if defined __GNUC__ && 2 < __GNUC__ + (96 <= __GNUC_MINOR__)
  306. # define YY_ATTRIBUTE_PURE __attribute__ ((__pure__))
  307. # else
  308. # define YY_ATTRIBUTE_PURE
  309. # endif
  310. #endif
  311. #ifndef YY_ATTRIBUTE_UNUSED
  312. # if defined __GNUC__ && 2 < __GNUC__ + (7 <= __GNUC_MINOR__)
  313. # define YY_ATTRIBUTE_UNUSED __attribute__ ((__unused__))
  314. # else
  315. # define YY_ATTRIBUTE_UNUSED
  316. # endif
  317. #endif
  318. /* Suppress unused-variable warnings by "using" E. */
  319. #if ! defined lint || defined __GNUC__
  320. # define YY_USE(E) ((void) (E))
  321. #else
  322. # define YY_USE(E) /* empty */
  323. #endif
  324. #if defined __GNUC__ && ! defined __ICC && 407 <= __GNUC__ * 100 + __GNUC_MINOR__
  325. /* Suppress an incorrect diagnostic about yylval being uninitialized. */
  326. # define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN \
  327. _Pragma ("GCC diagnostic push") \
  328. _Pragma ("GCC diagnostic ignored \"-Wuninitialized\"") \
  329. _Pragma ("GCC diagnostic ignored \"-Wmaybe-uninitialized\"")
  330. # define YY_IGNORE_MAYBE_UNINITIALIZED_END \
  331. _Pragma ("GCC diagnostic pop")
  332. #else
  333. # define YY_INITIAL_VALUE(Value) Value
  334. #endif
  335. #ifndef YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
  336. # define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
  337. # define YY_IGNORE_MAYBE_UNINITIALIZED_END
  338. #endif
  339. #ifndef YY_INITIAL_VALUE
  340. # define YY_INITIAL_VALUE(Value) /* Nothing. */
  341. #endif
  342. #if defined __cplusplus && defined __GNUC__ && ! defined __ICC && 6 <= __GNUC__
  343. # define YY_IGNORE_USELESS_CAST_BEGIN \
  344. _Pragma ("GCC diagnostic push") \
  345. _Pragma ("GCC diagnostic ignored \"-Wuseless-cast\"")
  346. # define YY_IGNORE_USELESS_CAST_END \
  347. _Pragma ("GCC diagnostic pop")
  348. #endif
  349. #ifndef YY_IGNORE_USELESS_CAST_BEGIN
  350. # define YY_IGNORE_USELESS_CAST_BEGIN
  351. # define YY_IGNORE_USELESS_CAST_END
  352. #endif
  353. #define YY_ASSERT(E) ((void) (0 && (E)))
  354. #if !defined yyoverflow
  355. /* The parser invokes alloca or malloc; define the necessary symbols. */
  356. # ifdef YYSTACK_USE_ALLOCA
  357. # if YYSTACK_USE_ALLOCA
  358. # ifdef __GNUC__
  359. # define YYSTACK_ALLOC __builtin_alloca
  360. # elif defined __BUILTIN_VA_ARG_INCR
  361. # include <alloca.h> /* INFRINGES ON USER NAME SPACE */
  362. # elif defined _AIX
  363. # define YYSTACK_ALLOC __alloca
  364. # elif defined _MSC_VER
  365. # include <malloc.h> /* INFRINGES ON USER NAME SPACE */
  366. # define alloca _alloca
  367. # else
  368. # define YYSTACK_ALLOC alloca
  369. # if ! defined _ALLOCA_H && ! defined EXIT_SUCCESS
  370. # include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
  371. /* Use EXIT_SUCCESS as a witness for stdlib.h. */
  372. # ifndef EXIT_SUCCESS
  373. # define EXIT_SUCCESS 0
  374. # endif
  375. # endif
  376. # endif
  377. # endif
  378. # endif
  379. # ifdef YYSTACK_ALLOC
  380. /* Pacify GCC's 'empty if-body' warning. */
  381. # define YYSTACK_FREE(Ptr) do { /* empty */; } while (0)
  382. # ifndef YYSTACK_ALLOC_MAXIMUM
  383. /* The OS might guarantee only one guard page at the bottom of the stack,
  384. and a page size can be as small as 4096 bytes. So we cannot safely
  385. invoke alloca (N) if N exceeds 4096. Use a slightly smaller number
  386. to allow for a few compiler-allocated temporary stack slots. */
  387. # define YYSTACK_ALLOC_MAXIMUM 4032 /* reasonable circa 2006 */
  388. # endif
  389. # else
  390. # define YYSTACK_ALLOC YYMALLOC
  391. # define YYSTACK_FREE YYFREE
  392. # ifndef YYSTACK_ALLOC_MAXIMUM
  393. # define YYSTACK_ALLOC_MAXIMUM YYSIZE_MAXIMUM
  394. # endif
  395. # if (defined __cplusplus && ! defined EXIT_SUCCESS \
  396. && ! ((defined YYMALLOC || defined malloc) \
  397. && (defined YYFREE || defined free)))
  398. # include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
  399. # ifndef EXIT_SUCCESS
  400. # define EXIT_SUCCESS 0
  401. # endif
  402. # endif
  403. # ifndef YYMALLOC
  404. # define YYMALLOC malloc
  405. # if ! defined malloc && ! defined EXIT_SUCCESS
  406. void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */
  407. # endif
  408. # endif
  409. # ifndef YYFREE
  410. # define YYFREE free
  411. # if ! defined free && ! defined EXIT_SUCCESS
  412. void free (void *); /* INFRINGES ON USER NAME SPACE */
  413. # endif
  414. # endif
  415. # endif
  416. #endif /* !defined yyoverflow */
  417. #if (! defined yyoverflow \
  418. && (! defined __cplusplus \
  419. || (defined YYSTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL)))
  420. /* A type that is properly aligned for any stack member. */
  421. union yyalloc
  422. {
  423. yy_state_t yyss_alloc;
  424. YYSTYPE yyvs_alloc;
  425. };
  426. /* The size of the maximum gap between one aligned stack and the next. */
  427. # define YYSTACK_GAP_MAXIMUM (YYSIZEOF (union yyalloc) - 1)
  428. /* The size of an array large to enough to hold all stacks, each with
  429. N elements. */
  430. # define YYSTACK_BYTES(N) \
  431. ((N) * (YYSIZEOF (yy_state_t) + YYSIZEOF (YYSTYPE)) \
  432. + YYSTACK_GAP_MAXIMUM)
  433. # define YYCOPY_NEEDED 1
  434. /* Relocate STACK from its old location to the new one. The
  435. local variables YYSIZE and YYSTACKSIZE give the old and new number of
  436. elements in the stack, and YYPTR gives the new location of the
  437. stack. Advance YYPTR to a properly aligned location for the next
  438. stack. */
  439. # define YYSTACK_RELOCATE(Stack_alloc, Stack) \
  440. do \
  441. { \
  442. YYPTRDIFF_T yynewbytes; \
  443. YYCOPY (&yyptr->Stack_alloc, Stack, yysize); \
  444. Stack = &yyptr->Stack_alloc; \
  445. yynewbytes = yystacksize * YYSIZEOF (*Stack) + YYSTACK_GAP_MAXIMUM; \
  446. yyptr += yynewbytes / YYSIZEOF (*yyptr); \
  447. } \
  448. while (0)
  449. #endif
  450. #if defined YYCOPY_NEEDED && YYCOPY_NEEDED
  451. /* Copy COUNT objects from SRC to DST. The source and destination do
  452. not overlap. */
  453. # ifndef YYCOPY
  454. # if defined __GNUC__ && 1 < __GNUC__
  455. # define YYCOPY(Dst, Src, Count) \
  456. __builtin_memcpy (Dst, Src, YY_CAST (YYSIZE_T, (Count)) * sizeof (*(Src)))
  457. # else
  458. # define YYCOPY(Dst, Src, Count) \
  459. do \
  460. { \
  461. YYPTRDIFF_T yyi; \
  462. for (yyi = 0; yyi < (Count); yyi++) \
  463. (Dst)[yyi] = (Src)[yyi]; \
  464. } \
  465. while (0)
  466. # endif
  467. # endif
  468. #endif /* !YYCOPY_NEEDED */
  469. /* YYFINAL -- State number of the termination state. */
  470. #define YYFINAL 6
  471. /* YYLAST -- Last index in YYTABLE. */
  472. #define YYLAST 194
  473. /* YYNTOKENS -- Number of terminals. */
  474. #define YYNTOKENS 51
  475. /* YYNNTS -- Number of nonterminals. */
  476. #define YYNNTS 47
  477. /* YYNRULES -- Number of rules. */
  478. #define YYNRULES 106
  479. /* YYNSTATES -- Number of states. */
  480. #define YYNSTATES 187
  481. /* YYMAXUTOK -- Last valid token kind. */
  482. #define YYMAXUTOK 305
  483. /* YYTRANSLATE(TOKEN-NUM) -- Symbol number corresponding to TOKEN-NUM
  484. as returned by yylex, with out-of-bounds checking. */
  485. #define YYTRANSLATE(YYX) \
  486. (0 <= (YYX) && (YYX) <= YYMAXUTOK \
  487. ? YY_CAST (yysymbol_kind_t, yytranslate[YYX]) \
  488. : YYSYMBOL_YYUNDEF)
  489. /* YYTRANSLATE[TOKEN-NUM] -- Symbol number corresponding to TOKEN-NUM
  490. as returned by yylex. */
  491. static const yytype_int8 yytranslate[] =
  492. {
  493. 0, 2, 2, 2, 2, 2, 2, 2, 2, 2,
  494. 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
  495. 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
  496. 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
  497. 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
  498. 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
  499. 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
  500. 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
  501. 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
  502. 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
  503. 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
  504. 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
  505. 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
  506. 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
  507. 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
  508. 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
  509. 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
  510. 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
  511. 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
  512. 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
  513. 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
  514. 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
  515. 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
  516. 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
  517. 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
  518. 2, 2, 2, 2, 2, 2, 1, 2, 3, 4,
  519. 5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
  520. 15, 16, 17, 18, 19, 20, 21, 22, 23, 24,
  521. 25, 26, 27, 28, 29, 30, 31, 32, 33, 34,
  522. 35, 36, 37, 38, 39, 40, 41, 42, 43, 44,
  523. 45, 46, 47, 48, 49, 50
  524. };
  525. #if YYDEBUG
  526. /* YYRLINE[YYN] -- Source line where rule number YYN was defined. */
  527. static const yytype_int16 yyrline[] =
  528. {
  529. 0, 110, 110, 110, 114, 119, 121, 122, 123, 124,
  530. 125, 126, 127, 128, 129, 130, 133, 135, 136, 137,
  531. 138, 143, 150, 155, 162, 171, 173, 174, 175, 178,
  532. 186, 192, 202, 208, 214, 220, 230, 240, 245, 253,
  533. 256, 258, 259, 260, 263, 269, 276, 282, 287, 295,
  534. 296, 297, 298, 301, 302, 305, 306, 307, 311, 319,
  535. 327, 330, 335, 342, 347, 355, 358, 360, 361, 364,
  536. 373, 380, 383, 385, 390, 396, 408, 415, 422, 424,
  537. 429, 430, 431, 434, 435, 438, 439, 440, 441, 442,
  538. 443, 444, 445, 446, 447, 448, 452, 454, 455, 458,
  539. 459, 463, 466, 467, 468, 472, 473
  540. };
  541. #endif
  542. /** Accessing symbol of state STATE. */
  543. #define YY_ACCESSING_SYMBOL(State) YY_CAST (yysymbol_kind_t, yystos[State])
  544. #if YYDEBUG || 0
  545. /* The user-facing name of the symbol whose (internal) number is
  546. YYSYMBOL. No bounds checking. */
  547. static const char *yysymbol_name (yysymbol_kind_t yysymbol) YY_ATTRIBUTE_UNUSED;
  548. /* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
  549. First, the terminals, then, starting at YYNTOKENS, nonterminals. */
  550. static const char *const yytname[] =
  551. {
  552. "\"end of file\"", "error", "\"invalid token\"", "T_HELPTEXT", "T_WORD",
  553. "T_WORD_QUOTE", "T_BOOL", "T_CHOICE", "T_CLOSE_PAREN", "T_COLON_EQUAL",
  554. "T_COMMENT", "T_CONFIG", "T_DEFAULT", "T_DEF_BOOL", "T_DEF_TRISTATE",
  555. "T_DEPENDS", "T_ENDCHOICE", "T_ENDIF", "T_ENDMENU", "T_HELP", "T_HEX",
  556. "T_IF", "T_IMPLY", "T_INT", "T_MAINMENU", "T_MENU", "T_MENUCONFIG",
  557. "T_MODULES", "T_ON", "T_OPEN_PAREN", "T_OPTIONAL", "T_PLUS_EQUAL",
  558. "T_PROMPT", "T_RANGE", "T_RESET", "T_SELECT", "T_SOURCE", "T_STRING",
  559. "T_TRISTATE", "T_VISIBLE", "T_EOL", "T_ASSIGN_VAL", "T_OR", "T_AND",
  560. "T_EQUAL", "T_UNEQUAL", "T_LESS", "T_LESS_EQUAL", "T_GREATER",
  561. "T_GREATER_EQUAL", "T_NOT", "$accept", "input", "mainmenu_stmt",
  562. "stmt_list", "stmt_list_in_choice", "config_entry_start", "config_stmt",
  563. "menuconfig_entry_start", "menuconfig_stmt", "config_option_list",
  564. "config_option", "choice", "choice_entry", "choice_end", "choice_stmt",
  565. "choice_option_list", "choice_option", "type", "logic_type", "default",
  566. "if_entry", "if_end", "if_stmt", "if_stmt_in_choice", "menu",
  567. "menu_entry", "menu_end", "menu_stmt", "menu_option_list", "source_stmt",
  568. "comment", "comment_stmt", "comment_option_list", "help_start", "help",
  569. "depends", "visible", "prompt_stmt_opt", "end", "if_expr", "expr",
  570. "nonconst_symbol", "symbol", "word_opt", "assignment_stmt", "assign_op",
  571. "assign_val", YY_NULLPTR
  572. };
  573. static const char *
  574. yysymbol_name (yysymbol_kind_t yysymbol)
  575. {
  576. return yytname[yysymbol];
  577. }
  578. #endif
  579. #ifdef YYPRINT
  580. /* YYTOKNUM[NUM] -- (External) token number corresponding to the
  581. (internal) symbol number NUM (which must be that of a token). */
  582. static const yytype_int16 yytoknum[] =
  583. {
  584. 0, 256, 257, 258, 259, 260, 261, 262, 263, 264,
  585. 265, 266, 267, 268, 269, 270, 271, 272, 273, 274,
  586. 275, 276, 277, 278, 279, 280, 281, 282, 283, 284,
  587. 285, 286, 287, 288, 289, 290, 291, 292, 293, 294,
  588. 295, 296, 297, 298, 299, 300, 301, 302, 303, 304,
  589. 305
  590. };
  591. #endif
  592. #define YYPACT_NINF (-105)
  593. #define yypact_value_is_default(Yyn) \
  594. ((Yyn) == YYPACT_NINF)
  595. #define YYTABLE_NINF (-4)
  596. #define yytable_value_is_error(Yyn) \
  597. 0
  598. /* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
  599. STATE-NUM. */
  600. static const yytype_int16 yypact[] =
  601. {
  602. -5, 17, 37, -105, 57, 8, -105, 91, 39, 15,
  603. 46, 72, 80, 10, 82, 80, 83, -105, -105, -105,
  604. -105, -105, -105, -105, -105, -105, -105, -105, -105, -105,
  605. -105, -105, -105, -105, -105, 45, -105, -105, -105, 48,
  606. -105, 50, 59, -105, 60, -105, 10, 10, -7, -105,
  607. 25, 63, 64, 65, 132, 132, 156, 162, 114, 14,
  608. 114, 95, -105, -105, 71, -105, -105, -105, 9, -105,
  609. -105, 10, 10, 27, 27, 27, 27, 27, 27, -105,
  610. -105, -105, -105, -105, -105, -105, 69, 73, -105, 80,
  611. -105, 74, 115, 27, 80, -105, -105, -105, 117, -105,
  612. 10, 116, -105, -105, 80, 86, 118, 107, -105, 117,
  613. -105, -105, 89, 93, 94, 96, -105, -105, -105, -105,
  614. -105, -105, -105, -105, 107, -105, -105, -105, -105, -105,
  615. -105, -105, 98, -105, -105, -105, -105, -105, -105, -105,
  616. 10, -105, 107, -105, 107, 27, 107, 107, 97, 13,
  617. -105, 107, -105, 107, 10, 102, 103, -105, -105, -105,
  618. -105, 162, 108, 23, 109, 113, 107, 120, -105, -105,
  619. 121, 126, 134, 33, -105, -105, -105, -105, -105, -105,
  620. -105, 136, -105, -105, -105, -105, -105
  621. };
  622. /* YYDEFACT[STATE-NUM] -- Default reduction number in state STATE-NUM.
  623. Performed when YYTABLE does not specify something else to do. Zero
  624. means the default is an error. */
  625. static const yytype_int8 yydefact[] =
  626. {
  627. 5, 0, 0, 5, 0, 0, 1, 0, 0, 0,
  628. 99, 0, 0, 0, 0, 0, 0, 25, 9, 25,
  629. 12, 40, 16, 7, 5, 10, 66, 5, 11, 13,
  630. 72, 8, 6, 4, 15, 0, 103, 104, 102, 105,
  631. 100, 0, 0, 96, 0, 98, 0, 0, 0, 97,
  632. 85, 0, 0, 0, 22, 24, 37, 0, 0, 63,
  633. 0, 71, 14, 106, 0, 36, 70, 21, 0, 93,
  634. 58, 0, 0, 0, 0, 0, 0, 0, 0, 62,
  635. 23, 69, 53, 55, 56, 57, 0, 0, 51, 0,
  636. 50, 0, 0, 0, 0, 52, 54, 26, 78, 49,
  637. 0, 0, 28, 27, 0, 0, 0, 83, 41, 78,
  638. 43, 42, 0, 0, 0, 0, 18, 39, 16, 19,
  639. 17, 38, 60, 59, 83, 68, 67, 65, 64, 73,
  640. 101, 92, 94, 95, 90, 91, 86, 87, 88, 89,
  641. 0, 74, 83, 35, 83, 0, 83, 83, 0, 83,
  642. 75, 83, 46, 83, 0, 0, 0, 20, 81, 82,
  643. 80, 0, 0, 0, 0, 0, 83, 0, 79, 29,
  644. 0, 0, 0, 84, 47, 45, 61, 77, 76, 33,
  645. 30, 0, 32, 31, 48, 44, 34
  646. };
  647. /* YYPGOTO[NTERM-NUM]. */
  648. static const yytype_int16 yypgoto[] =
  649. {
  650. -105, -105, -105, 3, 38, -105, -55, -105, -105, 138,
  651. -105, -105, -105, -105, -105, -105, -105, -105, 125, -105,
  652. -54, -3, -105, -105, -105, -105, -105, -105, -105, -105,
  653. -105, -52, -105, -105, 128, -38, -105, 68, -16, -104,
  654. -46, -8, -65, -105, -105, -105, -105
  655. };
  656. /* YYDEFGOTO[NTERM-NUM]. */
  657. static const yytype_uint8 yydefgoto[] =
  658. {
  659. 0, 2, 3, 4, 57, 17, 18, 19, 20, 54,
  660. 97, 21, 22, 117, 23, 56, 108, 98, 99, 100,
  661. 24, 122, 25, 119, 26, 27, 127, 28, 59, 29,
  662. 30, 31, 61, 101, 102, 103, 126, 148, 123, 155,
  663. 48, 49, 50, 41, 32, 39, 64
  664. };
  665. /* YYTABLE[YYPACT[STATE-NUM]] -- What to do in state STATE-NUM. If
  666. positive, shift that token. If negative, reduce the rule whose
  667. number is the opposite. If YYTABLE_NINF, syntax error. */
  668. static const yytype_int16 yytable[] =
  669. {
  670. 68, 69, 116, 118, 44, 120, 7, 52, 134, 135,
  671. 136, 137, 138, 139, 43, 45, 35, 131, 111, 1,
  672. 162, 125, 5, 129, 36, 132, 133, 58, 145, 86,
  673. 60, 43, 45, 70, 154, 71, 72, 6, 164, 46,
  674. 165, 121, 167, 168, 128, 170, 37, 171, 33, 172,
  675. 40, 71, 72, 124, 149, 71, 72, -3, 8, 38,
  676. 47, 9, 181, 178, 10, 71, 72, 11, 12, 73,
  677. 74, 75, 76, 77, 78, 71, 72, 42, 13, 34,
  678. 166, 142, 14, 15, 43, 62, 146, 51, 53, 63,
  679. 65, -2, 8, 16, 163, 9, 151, 140, 10, 66,
  680. 67, 11, 12, 79, 80, 81, 116, 118, 173, 120,
  681. 86, 130, 13, 141, 143, 8, 14, 15, 9, 150,
  682. 144, 10, 147, 153, 11, 12, 152, 16, 154, 157,
  683. 113, 114, 115, 158, 159, 13, 160, 169, 82, 14,
  684. 15, 72, 174, 175, 83, 84, 85, 86, 177, 179,
  685. 16, 87, 88, 180, 89, 90, 161, 55, 176, 91,
  686. 182, 183, 82, 112, 92, 93, 184, 94, 104, 95,
  687. 96, 86, 11, 12, 185, 87, 186, 156, 113, 114,
  688. 115, 109, 0, 13, 110, 0, 105, 0, 106, 0,
  689. 107, 0, 0, 0, 96
  690. };
  691. static const yytype_int16 yycheck[] =
  692. {
  693. 46, 47, 57, 57, 12, 57, 3, 15, 73, 74,
  694. 75, 76, 77, 78, 4, 5, 1, 8, 56, 24,
  695. 124, 59, 5, 61, 9, 71, 72, 24, 93, 15,
  696. 27, 4, 5, 40, 21, 42, 43, 0, 142, 29,
  697. 144, 57, 146, 147, 60, 149, 31, 151, 40, 153,
  698. 4, 42, 43, 39, 100, 42, 43, 0, 1, 44,
  699. 50, 4, 166, 40, 7, 42, 43, 10, 11, 44,
  700. 45, 46, 47, 48, 49, 42, 43, 5, 21, 40,
  701. 145, 89, 25, 26, 4, 40, 94, 5, 5, 41,
  702. 40, 0, 1, 36, 140, 4, 104, 28, 7, 40,
  703. 40, 10, 11, 40, 40, 40, 161, 161, 154, 161,
  704. 15, 40, 21, 40, 40, 1, 25, 26, 4, 3,
  705. 5, 7, 5, 5, 10, 11, 40, 36, 21, 40,
  706. 16, 17, 18, 40, 40, 21, 40, 40, 6, 25,
  707. 26, 43, 40, 40, 12, 13, 14, 15, 40, 40,
  708. 36, 19, 20, 40, 22, 23, 118, 19, 161, 27,
  709. 40, 40, 6, 1, 32, 33, 40, 35, 12, 37,
  710. 38, 15, 10, 11, 40, 19, 40, 109, 16, 17,
  711. 18, 56, -1, 21, 56, -1, 30, -1, 32, -1,
  712. 34, -1, -1, -1, 38
  713. };
  714. /* YYSTOS[STATE-NUM] -- The (internal number of the) accessing
  715. symbol of state STATE-NUM. */
  716. static const yytype_int8 yystos[] =
  717. {
  718. 0, 24, 52, 53, 54, 5, 0, 54, 1, 4,
  719. 7, 10, 11, 21, 25, 26, 36, 56, 57, 58,
  720. 59, 62, 63, 65, 71, 73, 75, 76, 78, 80,
  721. 81, 82, 95, 40, 40, 1, 9, 31, 44, 96,
  722. 4, 94, 5, 4, 92, 5, 29, 50, 91, 92,
  723. 93, 5, 92, 5, 60, 60, 66, 55, 54, 79,
  724. 54, 83, 40, 41, 97, 40, 40, 40, 91, 91,
  725. 40, 42, 43, 44, 45, 46, 47, 48, 49, 40,
  726. 40, 40, 6, 12, 13, 14, 15, 19, 20, 22,
  727. 23, 27, 32, 33, 35, 37, 38, 61, 68, 69,
  728. 70, 84, 85, 86, 12, 30, 32, 34, 67, 69,
  729. 85, 86, 1, 16, 17, 18, 57, 64, 71, 74,
  730. 82, 89, 72, 89, 39, 86, 87, 77, 89, 86,
  731. 40, 8, 91, 91, 93, 93, 93, 93, 93, 93,
  732. 28, 40, 92, 40, 5, 93, 92, 5, 88, 91,
  733. 3, 92, 40, 5, 21, 90, 88, 40, 40, 40,
  734. 40, 55, 90, 91, 90, 90, 93, 90, 90, 40,
  735. 90, 90, 90, 91, 40, 40, 72, 40, 40, 40,
  736. 40, 90, 40, 40, 40, 40, 40
  737. };
  738. /* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */
  739. static const yytype_int8 yyr1[] =
  740. {
  741. 0, 51, 52, 52, 53, 54, 54, 54, 54, 54,
  742. 54, 54, 54, 54, 54, 54, 55, 55, 55, 55,
  743. 55, 56, 57, 58, 59, 60, 60, 60, 60, 61,
  744. 61, 61, 61, 61, 61, 61, 62, 63, 64, 65,
  745. 66, 66, 66, 66, 67, 67, 67, 67, 67, 68,
  746. 68, 68, 68, 69, 69, 70, 70, 70, 71, 72,
  747. 73, 74, 75, 76, 77, 78, 79, 79, 79, 80,
  748. 81, 82, 83, 83, 84, 85, 86, 87, 88, 88,
  749. 89, 89, 89, 90, 90, 91, 91, 91, 91, 91,
  750. 91, 91, 91, 91, 91, 91, 92, 93, 93, 94,
  751. 94, 95, 96, 96, 96, 97, 97
  752. };
  753. /* YYR2[YYN] -- Number of symbols on the right hand side of rule YYN. */
  754. static const yytype_int8 yyr2[] =
  755. {
  756. 0, 2, 2, 1, 3, 0, 2, 2, 2, 2,
  757. 2, 2, 2, 2, 4, 3, 0, 2, 2, 2,
  758. 3, 3, 2, 3, 2, 0, 2, 2, 2, 3,
  759. 4, 4, 4, 4, 5, 2, 3, 2, 1, 3,
  760. 0, 2, 2, 2, 4, 3, 2, 3, 4, 1,
  761. 1, 1, 1, 1, 1, 1, 1, 1, 3, 1,
  762. 3, 3, 3, 2, 1, 3, 0, 2, 2, 3,
  763. 3, 2, 0, 2, 2, 2, 4, 3, 0, 2,
  764. 2, 2, 2, 0, 2, 1, 3, 3, 3, 3,
  765. 3, 3, 3, 2, 3, 3, 1, 1, 1, 0,
  766. 1, 4, 1, 1, 1, 0, 1
  767. };
  768. enum { YYENOMEM = -2 };
  769. #define yyerrok (yyerrstatus = 0)
  770. #define yyclearin (yychar = YYEMPTY)
  771. #define YYACCEPT goto yyacceptlab
  772. #define YYABORT goto yyabortlab
  773. #define YYERROR goto yyerrorlab
  774. #define YYRECOVERING() (!!yyerrstatus)
  775. #define YYBACKUP(Token, Value) \
  776. do \
  777. if (yychar == YYEMPTY) \
  778. { \
  779. yychar = (Token); \
  780. yylval = (Value); \
  781. YYPOPSTACK (yylen); \
  782. yystate = *yyssp; \
  783. goto yybackup; \
  784. } \
  785. else \
  786. { \
  787. yyerror (YY_("syntax error: cannot back up")); \
  788. YYERROR; \
  789. } \
  790. while (0)
  791. /* Backward compatibility with an undocumented macro.
  792. Use YYerror or YYUNDEF. */
  793. #define YYERRCODE YYUNDEF
  794. /* Enable debugging if requested. */
  795. #if YYDEBUG
  796. # ifndef YYFPRINTF
  797. # include <stdio.h> /* INFRINGES ON USER NAME SPACE */
  798. # define YYFPRINTF fprintf
  799. # endif
  800. # define YYDPRINTF(Args) \
  801. do { \
  802. if (yydebug) \
  803. YYFPRINTF Args; \
  804. } while (0)
  805. /* This macro is provided for backward compatibility. */
  806. # ifndef YY_LOCATION_PRINT
  807. # define YY_LOCATION_PRINT(File, Loc) ((void) 0)
  808. # endif
  809. # define YY_SYMBOL_PRINT(Title, Kind, Value, Location) \
  810. do { \
  811. if (yydebug) \
  812. { \
  813. YYFPRINTF (stderr, "%s ", Title); \
  814. yy_symbol_print (stderr, \
  815. Kind, Value); \
  816. YYFPRINTF (stderr, "\n"); \
  817. } \
  818. } while (0)
  819. /*-----------------------------------.
  820. | Print this symbol's value on YYO. |
  821. `-----------------------------------*/
  822. static void
  823. yy_symbol_value_print (FILE *yyo,
  824. yysymbol_kind_t yykind, YYSTYPE const * const yyvaluep)
  825. {
  826. FILE *yyoutput = yyo;
  827. YY_USE (yyoutput);
  828. if (!yyvaluep)
  829. return;
  830. # ifdef YYPRINT
  831. if (yykind < YYNTOKENS)
  832. YYPRINT (yyo, yytoknum[yykind], *yyvaluep);
  833. # endif
  834. YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
  835. YY_USE (yykind);
  836. YY_IGNORE_MAYBE_UNINITIALIZED_END
  837. }
  838. /*---------------------------.
  839. | Print this symbol on YYO. |
  840. `---------------------------*/
  841. static void
  842. yy_symbol_print (FILE *yyo,
  843. yysymbol_kind_t yykind, YYSTYPE const * const yyvaluep)
  844. {
  845. YYFPRINTF (yyo, "%s %s (",
  846. yykind < YYNTOKENS ? "token" : "nterm", yysymbol_name (yykind));
  847. yy_symbol_value_print (yyo, yykind, yyvaluep);
  848. YYFPRINTF (yyo, ")");
  849. }
  850. /*------------------------------------------------------------------.
  851. | yy_stack_print -- Print the state stack from its BOTTOM up to its |
  852. | TOP (included). |
  853. `------------------------------------------------------------------*/
  854. static void
  855. yy_stack_print (yy_state_t *yybottom, yy_state_t *yytop)
  856. {
  857. YYFPRINTF (stderr, "Stack now");
  858. for (; yybottom <= yytop; yybottom++)
  859. {
  860. int yybot = *yybottom;
  861. YYFPRINTF (stderr, " %d", yybot);
  862. }
  863. YYFPRINTF (stderr, "\n");
  864. }
  865. # define YY_STACK_PRINT(Bottom, Top) \
  866. do { \
  867. if (yydebug) \
  868. yy_stack_print ((Bottom), (Top)); \
  869. } while (0)
  870. /*------------------------------------------------.
  871. | Report that the YYRULE is going to be reduced. |
  872. `------------------------------------------------*/
  873. static void
  874. yy_reduce_print (yy_state_t *yyssp, YYSTYPE *yyvsp,
  875. int yyrule)
  876. {
  877. int yylno = yyrline[yyrule];
  878. int yynrhs = yyr2[yyrule];
  879. int yyi;
  880. YYFPRINTF (stderr, "Reducing stack by rule %d (line %d):\n",
  881. yyrule - 1, yylno);
  882. /* The symbols being reduced. */
  883. for (yyi = 0; yyi < yynrhs; yyi++)
  884. {
  885. YYFPRINTF (stderr, " $%d = ", yyi + 1);
  886. yy_symbol_print (stderr,
  887. YY_ACCESSING_SYMBOL (+yyssp[yyi + 1 - yynrhs]),
  888. &yyvsp[(yyi + 1) - (yynrhs)]);
  889. YYFPRINTF (stderr, "\n");
  890. }
  891. }
  892. # define YY_REDUCE_PRINT(Rule) \
  893. do { \
  894. if (yydebug) \
  895. yy_reduce_print (yyssp, yyvsp, Rule); \
  896. } while (0)
  897. /* Nonzero means print parse trace. It is left uninitialized so that
  898. multiple parsers can coexist. */
  899. int yydebug;
  900. #else /* !YYDEBUG */
  901. # define YYDPRINTF(Args) ((void) 0)
  902. # define YY_SYMBOL_PRINT(Title, Kind, Value, Location)
  903. # define YY_STACK_PRINT(Bottom, Top)
  904. # define YY_REDUCE_PRINT(Rule)
  905. #endif /* !YYDEBUG */
  906. /* YYINITDEPTH -- initial size of the parser's stacks. */
  907. #ifndef YYINITDEPTH
  908. # define YYINITDEPTH 200
  909. #endif
  910. /* YYMAXDEPTH -- maximum size the stacks can grow to (effective only
  911. if the built-in stack extension method is used).
  912. Do not make this value too large; the results are undefined if
  913. YYSTACK_ALLOC_MAXIMUM < YYSTACK_BYTES (YYMAXDEPTH)
  914. evaluated with infinite-precision integer arithmetic. */
  915. #ifndef YYMAXDEPTH
  916. # define YYMAXDEPTH 10000
  917. #endif
  918. /*-----------------------------------------------.
  919. | Release the memory associated to this symbol. |
  920. `-----------------------------------------------*/
  921. static void
  922. yydestruct (const char *yymsg,
  923. yysymbol_kind_t yykind, YYSTYPE *yyvaluep)
  924. {
  925. YY_USE (yyvaluep);
  926. if (!yymsg)
  927. yymsg = "Deleting";
  928. YY_SYMBOL_PRINT (yymsg, yykind, yyvaluep, yylocationp);
  929. YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
  930. switch (yykind)
  931. {
  932. case YYSYMBOL_choice_entry: /* choice_entry */
  933. {
  934. fprintf(stderr, "%s:%d: missing end statement for this entry\n",
  935. ((*yyvaluep).menu)->file->name, ((*yyvaluep).menu)->lineno);
  936. if (current_menu == ((*yyvaluep).menu))
  937. menu_end_menu();
  938. }
  939. break;
  940. case YYSYMBOL_if_entry: /* if_entry */
  941. {
  942. fprintf(stderr, "%s:%d: missing end statement for this entry\n",
  943. ((*yyvaluep).menu)->file->name, ((*yyvaluep).menu)->lineno);
  944. if (current_menu == ((*yyvaluep).menu))
  945. menu_end_menu();
  946. }
  947. break;
  948. case YYSYMBOL_menu_entry: /* menu_entry */
  949. {
  950. fprintf(stderr, "%s:%d: missing end statement for this entry\n",
  951. ((*yyvaluep).menu)->file->name, ((*yyvaluep).menu)->lineno);
  952. if (current_menu == ((*yyvaluep).menu))
  953. menu_end_menu();
  954. }
  955. break;
  956. default:
  957. break;
  958. }
  959. YY_IGNORE_MAYBE_UNINITIALIZED_END
  960. }
  961. /* Lookahead token kind. */
  962. int yychar;
  963. /* The semantic value of the lookahead symbol. */
  964. YYSTYPE yylval;
  965. /* Number of syntax errors so far. */
  966. int yynerrs;
  967. /*----------.
  968. | yyparse. |
  969. `----------*/
  970. int
  971. yyparse (void)
  972. {
  973. yy_state_fast_t yystate = 0;
  974. /* Number of tokens to shift before error messages enabled. */
  975. int yyerrstatus = 0;
  976. /* Refer to the stacks through separate pointers, to allow yyoverflow
  977. to reallocate them elsewhere. */
  978. /* Their size. */
  979. YYPTRDIFF_T yystacksize = YYINITDEPTH;
  980. /* The state stack: array, bottom, top. */
  981. yy_state_t yyssa[YYINITDEPTH];
  982. yy_state_t *yyss = yyssa;
  983. yy_state_t *yyssp = yyss;
  984. /* The semantic value stack: array, bottom, top. */
  985. YYSTYPE yyvsa[YYINITDEPTH];
  986. YYSTYPE *yyvs = yyvsa;
  987. YYSTYPE *yyvsp = yyvs;
  988. int yyn;
  989. /* The return value of yyparse. */
  990. int yyresult;
  991. /* Lookahead symbol kind. */
  992. yysymbol_kind_t yytoken = YYSYMBOL_YYEMPTY;
  993. /* The variables used to return semantic value and location from the
  994. action routines. */
  995. YYSTYPE yyval;
  996. #define YYPOPSTACK(N) (yyvsp -= (N), yyssp -= (N))
  997. /* The number of symbols on the RHS of the reduced rule.
  998. Keep to zero when no symbol should be popped. */
  999. int yylen = 0;
  1000. YYDPRINTF ((stderr, "Starting parse\n"));
  1001. yychar = YYEMPTY; /* Cause a token to be read. */
  1002. goto yysetstate;
  1003. /*------------------------------------------------------------.
  1004. | yynewstate -- push a new state, which is found in yystate. |
  1005. `------------------------------------------------------------*/
  1006. yynewstate:
  1007. /* In all cases, when you get here, the value and location stacks
  1008. have just been pushed. So pushing a state here evens the stacks. */
  1009. yyssp++;
  1010. /*--------------------------------------------------------------------.
  1011. | yysetstate -- set current state (the top of the stack) to yystate. |
  1012. `--------------------------------------------------------------------*/
  1013. yysetstate:
  1014. YYDPRINTF ((stderr, "Entering state %d\n", yystate));
  1015. YY_ASSERT (0 <= yystate && yystate < YYNSTATES);
  1016. YY_IGNORE_USELESS_CAST_BEGIN
  1017. *yyssp = YY_CAST (yy_state_t, yystate);
  1018. YY_IGNORE_USELESS_CAST_END
  1019. YY_STACK_PRINT (yyss, yyssp);
  1020. if (yyss + yystacksize - 1 <= yyssp)
  1021. #if !defined yyoverflow && !defined YYSTACK_RELOCATE
  1022. goto yyexhaustedlab;
  1023. #else
  1024. {
  1025. /* Get the current used size of the three stacks, in elements. */
  1026. YYPTRDIFF_T yysize = yyssp - yyss + 1;
  1027. # if defined yyoverflow
  1028. {
  1029. /* Give user a chance to reallocate the stack. Use copies of
  1030. these so that the &'s don't force the real ones into
  1031. memory. */
  1032. yy_state_t *yyss1 = yyss;
  1033. YYSTYPE *yyvs1 = yyvs;
  1034. /* Each stack pointer address is followed by the size of the
  1035. data in use in that stack, in bytes. This used to be a
  1036. conditional around just the two extra args, but that might
  1037. be undefined if yyoverflow is a macro. */
  1038. yyoverflow (YY_("memory exhausted"),
  1039. &yyss1, yysize * YYSIZEOF (*yyssp),
  1040. &yyvs1, yysize * YYSIZEOF (*yyvsp),
  1041. &yystacksize);
  1042. yyss = yyss1;
  1043. yyvs = yyvs1;
  1044. }
  1045. # else /* defined YYSTACK_RELOCATE */
  1046. /* Extend the stack our own way. */
  1047. if (YYMAXDEPTH <= yystacksize)
  1048. goto yyexhaustedlab;
  1049. yystacksize *= 2;
  1050. if (YYMAXDEPTH < yystacksize)
  1051. yystacksize = YYMAXDEPTH;
  1052. {
  1053. yy_state_t *yyss1 = yyss;
  1054. union yyalloc *yyptr =
  1055. YY_CAST (union yyalloc *,
  1056. YYSTACK_ALLOC (YY_CAST (YYSIZE_T, YYSTACK_BYTES (yystacksize))));
  1057. if (! yyptr)
  1058. goto yyexhaustedlab;
  1059. YYSTACK_RELOCATE (yyss_alloc, yyss);
  1060. YYSTACK_RELOCATE (yyvs_alloc, yyvs);
  1061. # undef YYSTACK_RELOCATE
  1062. if (yyss1 != yyssa)
  1063. YYSTACK_FREE (yyss1);
  1064. }
  1065. # endif
  1066. yyssp = yyss + yysize - 1;
  1067. yyvsp = yyvs + yysize - 1;
  1068. YY_IGNORE_USELESS_CAST_BEGIN
  1069. YYDPRINTF ((stderr, "Stack size increased to %ld\n",
  1070. YY_CAST (long, yystacksize)));
  1071. YY_IGNORE_USELESS_CAST_END
  1072. if (yyss + yystacksize - 1 <= yyssp)
  1073. YYABORT;
  1074. }
  1075. #endif /* !defined yyoverflow && !defined YYSTACK_RELOCATE */
  1076. if (yystate == YYFINAL)
  1077. YYACCEPT;
  1078. goto yybackup;
  1079. /*-----------.
  1080. | yybackup. |
  1081. `-----------*/
  1082. yybackup:
  1083. /* Do appropriate processing given the current state. Read a
  1084. lookahead token if we need one and don't already have one. */
  1085. /* First try to decide what to do without reference to lookahead token. */
  1086. yyn = yypact[yystate];
  1087. if (yypact_value_is_default (yyn))
  1088. goto yydefault;
  1089. /* Not known => get a lookahead token if don't already have one. */
  1090. /* YYCHAR is either empty, or end-of-input, or a valid lookahead. */
  1091. if (yychar == YYEMPTY)
  1092. {
  1093. YYDPRINTF ((stderr, "Reading a token\n"));
  1094. yychar = yylex ();
  1095. }
  1096. if (yychar <= YYEOF)
  1097. {
  1098. yychar = YYEOF;
  1099. yytoken = YYSYMBOL_YYEOF;
  1100. YYDPRINTF ((stderr, "Now at end of input.\n"));
  1101. }
  1102. else if (yychar == YYerror)
  1103. {
  1104. /* The scanner already issued an error message, process directly
  1105. to error recovery. But do not keep the error token as
  1106. lookahead, it is too special and may lead us to an endless
  1107. loop in error recovery. */
  1108. yychar = YYUNDEF;
  1109. yytoken = YYSYMBOL_YYerror;
  1110. goto yyerrlab1;
  1111. }
  1112. else
  1113. {
  1114. yytoken = YYTRANSLATE (yychar);
  1115. YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc);
  1116. }
  1117. /* If the proper action on seeing token YYTOKEN is to reduce or to
  1118. detect an error, take that action. */
  1119. yyn += yytoken;
  1120. if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken)
  1121. goto yydefault;
  1122. yyn = yytable[yyn];
  1123. if (yyn <= 0)
  1124. {
  1125. if (yytable_value_is_error (yyn))
  1126. goto yyerrlab;
  1127. yyn = -yyn;
  1128. goto yyreduce;
  1129. }
  1130. /* Count tokens shifted since error; after three, turn off error
  1131. status. */
  1132. if (yyerrstatus)
  1133. yyerrstatus--;
  1134. /* Shift the lookahead token. */
  1135. YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc);
  1136. yystate = yyn;
  1137. YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
  1138. *++yyvsp = yylval;
  1139. YY_IGNORE_MAYBE_UNINITIALIZED_END
  1140. /* Discard the shifted token. */
  1141. yychar = YYEMPTY;
  1142. goto yynewstate;
  1143. /*-----------------------------------------------------------.
  1144. | yydefault -- do the default action for the current state. |
  1145. `-----------------------------------------------------------*/
  1146. yydefault:
  1147. yyn = yydefact[yystate];
  1148. if (yyn == 0)
  1149. goto yyerrlab;
  1150. goto yyreduce;
  1151. /*-----------------------------.
  1152. | yyreduce -- do a reduction. |
  1153. `-----------------------------*/
  1154. yyreduce:
  1155. /* yyn is the number of a rule to reduce with. */
  1156. yylen = yyr2[yyn];
  1157. /* If YYLEN is nonzero, implement the default value of the action:
  1158. '$$ = $1'.
  1159. Otherwise, the following line sets YYVAL to garbage.
  1160. This behavior is undocumented and Bison
  1161. users should not rely upon it. Assigning to YYVAL
  1162. unconditionally makes the parser a bit smaller, and it avoids a
  1163. GCC warning that YYVAL may be used uninitialized. */
  1164. yyval = yyvsp[1-yylen];
  1165. YY_REDUCE_PRINT (yyn);
  1166. switch (yyn)
  1167. {
  1168. case 4: /* mainmenu_stmt: T_MAINMENU T_WORD_QUOTE T_EOL */
  1169. {
  1170. menu_add_prompt(P_MENU, (yyvsp[-1].string), NULL);
  1171. }
  1172. break;
  1173. case 14: /* stmt_list: stmt_list T_WORD error T_EOL */
  1174. { zconf_error("unknown statement \"%s\"", (yyvsp[-2].string)); }
  1175. break;
  1176. case 15: /* stmt_list: stmt_list error T_EOL */
  1177. { zconf_error("invalid statement"); }
  1178. break;
  1179. case 20: /* stmt_list_in_choice: stmt_list_in_choice error T_EOL */
  1180. { zconf_error("invalid statement"); }
  1181. break;
  1182. case 21: /* config_entry_start: T_CONFIG nonconst_symbol T_EOL */
  1183. {
  1184. (yyvsp[-1].symbol)->flags |= SYMBOL_OPTIONAL;
  1185. menu_add_entry((yyvsp[-1].symbol));
  1186. printd(DEBUG_PARSE, "%s:%d:config %s\n", zconf_curname(), zconf_lineno(), (yyvsp[-1].symbol)->name);
  1187. }
  1188. break;
  1189. case 22: /* config_stmt: config_entry_start config_option_list */
  1190. {
  1191. printd(DEBUG_PARSE, "%s:%d:endconfig\n", zconf_curname(), zconf_lineno());
  1192. }
  1193. break;
  1194. case 23: /* menuconfig_entry_start: T_MENUCONFIG nonconst_symbol T_EOL */
  1195. {
  1196. (yyvsp[-1].symbol)->flags |= SYMBOL_OPTIONAL;
  1197. menu_add_entry((yyvsp[-1].symbol));
  1198. printd(DEBUG_PARSE, "%s:%d:menuconfig %s\n", zconf_curname(), zconf_lineno(), (yyvsp[-1].symbol)->name);
  1199. }
  1200. break;
  1201. case 24: /* menuconfig_stmt: menuconfig_entry_start config_option_list */
  1202. {
  1203. if (current_entry->prompt)
  1204. current_entry->prompt->type = P_MENU;
  1205. else
  1206. zconfprint("warning: menuconfig statement without prompt");
  1207. printd(DEBUG_PARSE, "%s:%d:endconfig\n", zconf_curname(), zconf_lineno());
  1208. }
  1209. break;
  1210. case 29: /* config_option: type prompt_stmt_opt T_EOL */
  1211. {
  1212. menu_set_type((yyvsp[-2].type));
  1213. printd(DEBUG_PARSE, "%s:%d:type(%u)\n",
  1214. zconf_curname(), zconf_lineno(),
  1215. (yyvsp[-2].type));
  1216. }
  1217. break;
  1218. case 30: /* config_option: T_PROMPT T_WORD_QUOTE if_expr T_EOL */
  1219. {
  1220. menu_add_prompt(P_PROMPT, (yyvsp[-2].string), (yyvsp[-1].expr));
  1221. printd(DEBUG_PARSE, "%s:%d:prompt\n", zconf_curname(), zconf_lineno());
  1222. }
  1223. break;
  1224. case 31: /* config_option: default expr if_expr T_EOL */
  1225. {
  1226. menu_add_expr(P_DEFAULT, (yyvsp[-2].expr), (yyvsp[-1].expr));
  1227. if ((yyvsp[-3].type) != S_UNKNOWN)
  1228. menu_set_type((yyvsp[-3].type));
  1229. printd(DEBUG_PARSE, "%s:%d:default(%u)\n",
  1230. zconf_curname(), zconf_lineno(),
  1231. (yyvsp[-3].type));
  1232. }
  1233. break;
  1234. case 32: /* config_option: T_SELECT nonconst_symbol if_expr T_EOL */
  1235. {
  1236. menu_add_symbol(P_SELECT, (yyvsp[-2].symbol), (yyvsp[-1].expr));
  1237. printd(DEBUG_PARSE, "%s:%d:select\n", zconf_curname(), zconf_lineno());
  1238. }
  1239. break;
  1240. case 33: /* config_option: T_IMPLY nonconst_symbol if_expr T_EOL */
  1241. {
  1242. menu_add_symbol(P_IMPLY, (yyvsp[-2].symbol), (yyvsp[-1].expr));
  1243. printd(DEBUG_PARSE, "%s:%d:imply\n", zconf_curname(), zconf_lineno());
  1244. }
  1245. break;
  1246. case 34: /* config_option: T_RANGE symbol symbol if_expr T_EOL */
  1247. {
  1248. menu_add_expr(P_RANGE, expr_alloc_comp(E_RANGE,(yyvsp[-3].symbol), (yyvsp[-2].symbol)), (yyvsp[-1].expr));
  1249. printd(DEBUG_PARSE, "%s:%d:range\n", zconf_curname(), zconf_lineno());
  1250. }
  1251. break;
  1252. case 35: /* config_option: T_MODULES T_EOL */
  1253. {
  1254. if (modules_sym)
  1255. zconf_error("symbol '%s' redefines option 'modules' already defined by symbol '%s'",
  1256. current_entry->sym->name, modules_sym->name);
  1257. modules_sym = current_entry->sym;
  1258. }
  1259. break;
  1260. case 36: /* choice: T_CHOICE word_opt T_EOL */
  1261. {
  1262. struct symbol *sym = sym_lookup((yyvsp[-1].string), SYMBOL_CHOICE);
  1263. sym->flags |= SYMBOL_NO_WRITE;
  1264. menu_add_entry(sym);
  1265. menu_add_expr(P_CHOICE, NULL, NULL);
  1266. free((yyvsp[-1].string));
  1267. printd(DEBUG_PARSE, "%s:%d:choice\n", zconf_curname(), zconf_lineno());
  1268. }
  1269. break;
  1270. case 37: /* choice_entry: choice choice_option_list */
  1271. {
  1272. (yyval.menu) = menu_add_menu();
  1273. }
  1274. break;
  1275. case 38: /* choice_end: end */
  1276. {
  1277. if (zconf_endtoken((yyvsp[0].string), "choice")) {
  1278. menu_end_menu();
  1279. printd(DEBUG_PARSE, "%s:%d:endchoice\n", zconf_curname(), zconf_lineno());
  1280. }
  1281. }
  1282. break;
  1283. case 44: /* choice_option: T_PROMPT T_WORD_QUOTE if_expr T_EOL */
  1284. {
  1285. menu_add_prompt(P_PROMPT, (yyvsp[-2].string), (yyvsp[-1].expr));
  1286. printd(DEBUG_PARSE, "%s:%d:prompt\n", zconf_curname(), zconf_lineno());
  1287. }
  1288. break;
  1289. case 45: /* choice_option: logic_type prompt_stmt_opt T_EOL */
  1290. {
  1291. menu_set_type((yyvsp[-2].type));
  1292. printd(DEBUG_PARSE, "%s:%d:type(%u)\n",
  1293. zconf_curname(), zconf_lineno(), (yyvsp[-2].type));
  1294. }
  1295. break;
  1296. case 46: /* choice_option: T_OPTIONAL T_EOL */
  1297. {
  1298. current_entry->sym->flags |= SYMBOL_OPTIONAL;
  1299. printd(DEBUG_PARSE, "%s:%d:optional\n", zconf_curname(), zconf_lineno());
  1300. }
  1301. break;
  1302. case 47: /* choice_option: T_RESET if_expr T_EOL */
  1303. {
  1304. menu_add_prop(P_RESET, NULL, (yyvsp[-1].expr));
  1305. }
  1306. break;
  1307. case 48: /* choice_option: T_DEFAULT nonconst_symbol if_expr T_EOL */
  1308. {
  1309. menu_add_symbol(P_DEFAULT, (yyvsp[-2].symbol), (yyvsp[-1].expr));
  1310. printd(DEBUG_PARSE, "%s:%d:default\n",
  1311. zconf_curname(), zconf_lineno());
  1312. }
  1313. break;
  1314. case 50: /* type: T_INT */
  1315. { (yyval.type) = S_INT; }
  1316. break;
  1317. case 51: /* type: T_HEX */
  1318. { (yyval.type) = S_HEX; }
  1319. break;
  1320. case 52: /* type: T_STRING */
  1321. { (yyval.type) = S_STRING; }
  1322. break;
  1323. case 53: /* logic_type: T_BOOL */
  1324. { (yyval.type) = S_BOOLEAN; }
  1325. break;
  1326. case 54: /* logic_type: T_TRISTATE */
  1327. { (yyval.type) = S_TRISTATE; }
  1328. break;
  1329. case 55: /* default: T_DEFAULT */
  1330. { (yyval.type) = S_UNKNOWN; }
  1331. break;
  1332. case 56: /* default: T_DEF_BOOL */
  1333. { (yyval.type) = S_BOOLEAN; }
  1334. break;
  1335. case 57: /* default: T_DEF_TRISTATE */
  1336. { (yyval.type) = S_TRISTATE; }
  1337. break;
  1338. case 58: /* if_entry: T_IF expr T_EOL */
  1339. {
  1340. printd(DEBUG_PARSE, "%s:%d:if\n", zconf_curname(), zconf_lineno());
  1341. menu_add_entry(NULL);
  1342. menu_add_dep((yyvsp[-1].expr));
  1343. (yyval.menu) = menu_add_menu();
  1344. }
  1345. break;
  1346. case 59: /* if_end: end */
  1347. {
  1348. if (zconf_endtoken((yyvsp[0].string), "if")) {
  1349. menu_end_menu();
  1350. printd(DEBUG_PARSE, "%s:%d:endif\n", zconf_curname(), zconf_lineno());
  1351. }
  1352. }
  1353. break;
  1354. case 62: /* menu: T_MENU T_WORD_QUOTE T_EOL */
  1355. {
  1356. menu_add_entry(NULL);
  1357. menu_add_prompt(P_MENU, (yyvsp[-1].string), NULL);
  1358. printd(DEBUG_PARSE, "%s:%d:menu\n", zconf_curname(), zconf_lineno());
  1359. }
  1360. break;
  1361. case 63: /* menu_entry: menu menu_option_list */
  1362. {
  1363. (yyval.menu) = menu_add_menu();
  1364. }
  1365. break;
  1366. case 64: /* menu_end: end */
  1367. {
  1368. if (zconf_endtoken((yyvsp[0].string), "menu")) {
  1369. menu_end_menu();
  1370. printd(DEBUG_PARSE, "%s:%d:endmenu\n", zconf_curname(), zconf_lineno());
  1371. }
  1372. }
  1373. break;
  1374. case 69: /* source_stmt: T_SOURCE T_WORD_QUOTE T_EOL */
  1375. {
  1376. printd(DEBUG_PARSE, "%s:%d:source %s\n", zconf_curname(), zconf_lineno(), (yyvsp[-1].string));
  1377. zconf_nextfile((yyvsp[-1].string));
  1378. free((yyvsp[-1].string));
  1379. }
  1380. break;
  1381. case 70: /* comment: T_COMMENT T_WORD_QUOTE T_EOL */
  1382. {
  1383. menu_add_entry(NULL);
  1384. menu_add_prompt(P_COMMENT, (yyvsp[-1].string), NULL);
  1385. printd(DEBUG_PARSE, "%s:%d:comment\n", zconf_curname(), zconf_lineno());
  1386. }
  1387. break;
  1388. case 74: /* help_start: T_HELP T_EOL */
  1389. {
  1390. printd(DEBUG_PARSE, "%s:%d:help\n", zconf_curname(), zconf_lineno());
  1391. zconf_starthelp();
  1392. }
  1393. break;
  1394. case 75: /* help: help_start T_HELPTEXT */
  1395. {
  1396. /* Is the help text empty or all whitespace? */
  1397. if ((yyvsp[0].string)[strspn((yyvsp[0].string), " \f\n\r\t\v")] == '\0')
  1398. zconfprint("warning: '%s' defined with blank help text",
  1399. current_entry->sym->name ?: "<choice>");
  1400. current_entry->help = (yyvsp[0].string);
  1401. }
  1402. break;
  1403. case 76: /* depends: T_DEPENDS T_ON expr T_EOL */
  1404. {
  1405. menu_add_dep((yyvsp[-1].expr));
  1406. printd(DEBUG_PARSE, "%s:%d:depends on\n", zconf_curname(), zconf_lineno());
  1407. }
  1408. break;
  1409. case 77: /* visible: T_VISIBLE if_expr T_EOL */
  1410. {
  1411. menu_add_visibility((yyvsp[-1].expr));
  1412. }
  1413. break;
  1414. case 79: /* prompt_stmt_opt: T_WORD_QUOTE if_expr */
  1415. {
  1416. menu_add_prompt(P_PROMPT, (yyvsp[-1].string), (yyvsp[0].expr));
  1417. }
  1418. break;
  1419. case 80: /* end: T_ENDMENU T_EOL */
  1420. { (yyval.string) = "menu"; }
  1421. break;
  1422. case 81: /* end: T_ENDCHOICE T_EOL */
  1423. { (yyval.string) = "choice"; }
  1424. break;
  1425. case 82: /* end: T_ENDIF T_EOL */
  1426. { (yyval.string) = "if"; }
  1427. break;
  1428. case 83: /* if_expr: %empty */
  1429. { (yyval.expr) = NULL; }
  1430. break;
  1431. case 84: /* if_expr: T_IF expr */
  1432. { (yyval.expr) = (yyvsp[0].expr); }
  1433. break;
  1434. case 85: /* expr: symbol */
  1435. { (yyval.expr) = expr_alloc_symbol((yyvsp[0].symbol)); }
  1436. break;
  1437. case 86: /* expr: symbol T_LESS symbol */
  1438. { (yyval.expr) = expr_alloc_comp(E_LTH, (yyvsp[-2].symbol), (yyvsp[0].symbol)); }
  1439. break;
  1440. case 87: /* expr: symbol T_LESS_EQUAL symbol */
  1441. { (yyval.expr) = expr_alloc_comp(E_LEQ, (yyvsp[-2].symbol), (yyvsp[0].symbol)); }
  1442. break;
  1443. case 88: /* expr: symbol T_GREATER symbol */
  1444. { (yyval.expr) = expr_alloc_comp(E_GTH, (yyvsp[-2].symbol), (yyvsp[0].symbol)); }
  1445. break;
  1446. case 89: /* expr: symbol T_GREATER_EQUAL symbol */
  1447. { (yyval.expr) = expr_alloc_comp(E_GEQ, (yyvsp[-2].symbol), (yyvsp[0].symbol)); }
  1448. break;
  1449. case 90: /* expr: symbol T_EQUAL symbol */
  1450. { (yyval.expr) = expr_alloc_comp(E_EQUAL, (yyvsp[-2].symbol), (yyvsp[0].symbol)); }
  1451. break;
  1452. case 91: /* expr: symbol T_UNEQUAL symbol */
  1453. { (yyval.expr) = expr_alloc_comp(E_UNEQUAL, (yyvsp[-2].symbol), (yyvsp[0].symbol)); }
  1454. break;
  1455. case 92: /* expr: T_OPEN_PAREN expr T_CLOSE_PAREN */
  1456. { (yyval.expr) = (yyvsp[-1].expr); }
  1457. break;
  1458. case 93: /* expr: T_NOT expr */
  1459. { (yyval.expr) = expr_alloc_one(E_NOT, (yyvsp[0].expr)); }
  1460. break;
  1461. case 94: /* expr: expr T_OR expr */
  1462. { (yyval.expr) = expr_alloc_two(E_OR, (yyvsp[-2].expr), (yyvsp[0].expr)); }
  1463. break;
  1464. case 95: /* expr: expr T_AND expr */
  1465. { (yyval.expr) = expr_alloc_two(E_AND, (yyvsp[-2].expr), (yyvsp[0].expr)); }
  1466. break;
  1467. case 96: /* nonconst_symbol: T_WORD */
  1468. { (yyval.symbol) = sym_lookup((yyvsp[0].string), 0); free((yyvsp[0].string)); }
  1469. break;
  1470. case 98: /* symbol: T_WORD_QUOTE */
  1471. { (yyval.symbol) = sym_lookup((yyvsp[0].string), SYMBOL_CONST); free((yyvsp[0].string)); }
  1472. break;
  1473. case 99: /* word_opt: %empty */
  1474. { (yyval.string) = NULL; }
  1475. break;
  1476. case 101: /* assignment_stmt: T_WORD assign_op assign_val T_EOL */
  1477. { variable_add((yyvsp[-3].string), (yyvsp[-1].string), (yyvsp[-2].flavor)); free((yyvsp[-3].string)); free((yyvsp[-1].string)); }
  1478. break;
  1479. case 102: /* assign_op: T_EQUAL */
  1480. { (yyval.flavor) = VAR_RECURSIVE; }
  1481. break;
  1482. case 103: /* assign_op: T_COLON_EQUAL */
  1483. { (yyval.flavor) = VAR_SIMPLE; }
  1484. break;
  1485. case 104: /* assign_op: T_PLUS_EQUAL */
  1486. { (yyval.flavor) = VAR_APPEND; }
  1487. break;
  1488. case 105: /* assign_val: %empty */
  1489. { (yyval.string) = xstrdup(""); }
  1490. break;
  1491. default: break;
  1492. }
  1493. /* User semantic actions sometimes alter yychar, and that requires
  1494. that yytoken be updated with the new translation. We take the
  1495. approach of translating immediately before every use of yytoken.
  1496. One alternative is translating here after every semantic action,
  1497. but that translation would be missed if the semantic action invokes
  1498. YYABORT, YYACCEPT, or YYERROR immediately after altering yychar or
  1499. if it invokes YYBACKUP. In the case of YYABORT or YYACCEPT, an
  1500. incorrect destructor might then be invoked immediately. In the
  1501. case of YYERROR or YYBACKUP, subsequent parser actions might lead
  1502. to an incorrect destructor call or verbose syntax error message
  1503. before the lookahead is translated. */
  1504. YY_SYMBOL_PRINT ("-> $$ =", YY_CAST (yysymbol_kind_t, yyr1[yyn]), &yyval, &yyloc);
  1505. YYPOPSTACK (yylen);
  1506. yylen = 0;
  1507. *++yyvsp = yyval;
  1508. /* Now 'shift' the result of the reduction. Determine what state
  1509. that goes to, based on the state we popped back to and the rule
  1510. number reduced by. */
  1511. {
  1512. const int yylhs = yyr1[yyn] - YYNTOKENS;
  1513. const int yyi = yypgoto[yylhs] + *yyssp;
  1514. yystate = (0 <= yyi && yyi <= YYLAST && yycheck[yyi] == *yyssp
  1515. ? yytable[yyi]
  1516. : yydefgoto[yylhs]);
  1517. }
  1518. goto yynewstate;
  1519. /*--------------------------------------.
  1520. | yyerrlab -- here on detecting error. |
  1521. `--------------------------------------*/
  1522. yyerrlab:
  1523. /* Make sure we have latest lookahead translation. See comments at
  1524. user semantic actions for why this is necessary. */
  1525. yytoken = yychar == YYEMPTY ? YYSYMBOL_YYEMPTY : YYTRANSLATE (yychar);
  1526. /* If not already recovering from an error, report this error. */
  1527. if (!yyerrstatus)
  1528. {
  1529. ++yynerrs;
  1530. yyerror (YY_("syntax error"));
  1531. }
  1532. if (yyerrstatus == 3)
  1533. {
  1534. /* If just tried and failed to reuse lookahead token after an
  1535. error, discard it. */
  1536. if (yychar <= YYEOF)
  1537. {
  1538. /* Return failure if at end of input. */
  1539. if (yychar == YYEOF)
  1540. YYABORT;
  1541. }
  1542. else
  1543. {
  1544. yydestruct ("Error: discarding",
  1545. yytoken, &yylval);
  1546. yychar = YYEMPTY;
  1547. }
  1548. }
  1549. /* Else will try to reuse lookahead token after shifting the error
  1550. token. */
  1551. goto yyerrlab1;
  1552. /*---------------------------------------------------.
  1553. | yyerrorlab -- error raised explicitly by YYERROR. |
  1554. `---------------------------------------------------*/
  1555. yyerrorlab:
  1556. /* Pacify compilers when the user code never invokes YYERROR and the
  1557. label yyerrorlab therefore never appears in user code. */
  1558. if (0)
  1559. YYERROR;
  1560. /* Do not reclaim the symbols of the rule whose action triggered
  1561. this YYERROR. */
  1562. YYPOPSTACK (yylen);
  1563. yylen = 0;
  1564. YY_STACK_PRINT (yyss, yyssp);
  1565. yystate = *yyssp;
  1566. goto yyerrlab1;
  1567. /*-------------------------------------------------------------.
  1568. | yyerrlab1 -- common code for both syntax error and YYERROR. |
  1569. `-------------------------------------------------------------*/
  1570. yyerrlab1:
  1571. yyerrstatus = 3; /* Each real token shifted decrements this. */
  1572. /* Pop stack until we find a state that shifts the error token. */
  1573. for (;;)
  1574. {
  1575. yyn = yypact[yystate];
  1576. if (!yypact_value_is_default (yyn))
  1577. {
  1578. yyn += YYSYMBOL_YYerror;
  1579. if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYSYMBOL_YYerror)
  1580. {
  1581. yyn = yytable[yyn];
  1582. if (0 < yyn)
  1583. break;
  1584. }
  1585. }
  1586. /* Pop the current state because it cannot handle the error token. */
  1587. if (yyssp == yyss)
  1588. YYABORT;
  1589. yydestruct ("Error: popping",
  1590. YY_ACCESSING_SYMBOL (yystate), yyvsp);
  1591. YYPOPSTACK (1);
  1592. yystate = *yyssp;
  1593. YY_STACK_PRINT (yyss, yyssp);
  1594. }
  1595. YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
  1596. *++yyvsp = yylval;
  1597. YY_IGNORE_MAYBE_UNINITIALIZED_END
  1598. /* Shift the error token. */
  1599. YY_SYMBOL_PRINT ("Shifting", YY_ACCESSING_SYMBOL (yyn), yyvsp, yylsp);
  1600. yystate = yyn;
  1601. goto yynewstate;
  1602. /*-------------------------------------.
  1603. | yyacceptlab -- YYACCEPT comes here. |
  1604. `-------------------------------------*/
  1605. yyacceptlab:
  1606. yyresult = 0;
  1607. goto yyreturn;
  1608. /*-----------------------------------.
  1609. | yyabortlab -- YYABORT comes here. |
  1610. `-----------------------------------*/
  1611. yyabortlab:
  1612. yyresult = 1;
  1613. goto yyreturn;
  1614. #if !defined yyoverflow
  1615. /*-------------------------------------------------.
  1616. | yyexhaustedlab -- memory exhaustion comes here. |
  1617. `-------------------------------------------------*/
  1618. yyexhaustedlab:
  1619. yyerror (YY_("memory exhausted"));
  1620. yyresult = 2;
  1621. goto yyreturn;
  1622. #endif
  1623. /*-------------------------------------------------------.
  1624. | yyreturn -- parsing is finished, clean up and return. |
  1625. `-------------------------------------------------------*/
  1626. yyreturn:
  1627. if (yychar != YYEMPTY)
  1628. {
  1629. /* Make sure we have latest lookahead translation. See comments at
  1630. user semantic actions for why this is necessary. */
  1631. yytoken = YYTRANSLATE (yychar);
  1632. yydestruct ("Cleanup: discarding lookahead",
  1633. yytoken, &yylval);
  1634. }
  1635. /* Do not reclaim the symbols of the rule whose action triggered
  1636. this YYABORT or YYACCEPT. */
  1637. YYPOPSTACK (yylen);
  1638. YY_STACK_PRINT (yyss, yyssp);
  1639. while (yyssp != yyss)
  1640. {
  1641. yydestruct ("Cleanup: popping",
  1642. YY_ACCESSING_SYMBOL (+*yyssp), yyvsp);
  1643. YYPOPSTACK (1);
  1644. }
  1645. #ifndef yyoverflow
  1646. if (yyss != yyssa)
  1647. YYSTACK_FREE (yyss);
  1648. #endif
  1649. return yyresult;
  1650. }
  1651. void conf_parse(const char *name)
  1652. {
  1653. struct symbol *sym;
  1654. int i;
  1655. zconf_initscan(name);
  1656. _menu_init();
  1657. #if YYDEBUG
  1658. if (getenv("ZCONF_DEBUG"))
  1659. yydebug = 1;
  1660. #endif
  1661. yyparse();
  1662. /* Variables are expanded in the parse phase. We can free them here. */
  1663. variable_all_del();
  1664. if (yynerrs)
  1665. exit(1);
  1666. if (!modules_sym)
  1667. modules_sym = sym_find( "n" );
  1668. if (!menu_has_prompt(&rootmenu)) {
  1669. current_entry = &rootmenu;
  1670. menu_add_prompt(P_MENU, "Main menu", NULL);
  1671. }
  1672. menu_finalize(&rootmenu);
  1673. for_all_symbols(i, sym) {
  1674. if (sym_check_deps(sym))
  1675. yynerrs++;
  1676. }
  1677. if (yynerrs)
  1678. exit(1);
  1679. conf_set_changed(true);
  1680. }
  1681. static bool zconf_endtoken(const char *tokenname,
  1682. const char *expected_tokenname)
  1683. {
  1684. if (strcmp(tokenname, expected_tokenname)) {
  1685. zconf_error("unexpected '%s' within %s block",
  1686. tokenname, expected_tokenname);
  1687. yynerrs++;
  1688. return false;
  1689. }
  1690. if (current_menu->file != current_file) {
  1691. zconf_error("'%s' in different file than '%s'",
  1692. tokenname, expected_tokenname);
  1693. fprintf(stderr, "%s:%d: location of the '%s'\n",
  1694. current_menu->file->name, current_menu->lineno,
  1695. expected_tokenname);
  1696. yynerrs++;
  1697. return false;
  1698. }
  1699. return true;
  1700. }
  1701. static void zconfprint(const char *err, ...)
  1702. {
  1703. va_list ap;
  1704. fprintf(stderr, "%s:%d: ", zconf_curname(), zconf_lineno());
  1705. va_start(ap, err);
  1706. vfprintf(stderr, err, ap);
  1707. va_end(ap);
  1708. fprintf(stderr, "\n");
  1709. }
  1710. static void zconf_error(const char *err, ...)
  1711. {
  1712. va_list ap;
  1713. yynerrs++;
  1714. fprintf(stderr, "%s:%d: ", zconf_curname(), zconf_lineno());
  1715. va_start(ap, err);
  1716. vfprintf(stderr, err, ap);
  1717. va_end(ap);
  1718. fprintf(stderr, "\n");
  1719. }
  1720. static void yyerror(const char *err)
  1721. {
  1722. fprintf(stderr, "%s:%d: %s\n", zconf_curname(), zconf_lineno() + 1, err);
  1723. }
  1724. static void print_quoted_string(FILE *out, const char *str)
  1725. {
  1726. const char *p;
  1727. int len;
  1728. putc('"', out);
  1729. while ((p = strchr(str, '"'))) {
  1730. len = p - str;
  1731. if (len)
  1732. fprintf(out, "%.*s", len, str);
  1733. fputs("\\\"", out);
  1734. str = p + 1;
  1735. }
  1736. fputs(str, out);
  1737. putc('"', out);
  1738. }
  1739. static void print_symbol(FILE *out, struct menu *menu)
  1740. {
  1741. struct symbol *sym = menu->sym;
  1742. struct property *prop;
  1743. if (sym_is_choice(sym))
  1744. fprintf(out, "\nchoice\n");
  1745. else
  1746. fprintf(out, "\nconfig %s\n", sym->name);
  1747. switch (sym->type) {
  1748. case S_BOOLEAN:
  1749. fputs(" bool\n", out);
  1750. break;
  1751. case S_TRISTATE:
  1752. fputs(" tristate\n", out);
  1753. break;
  1754. case S_STRING:
  1755. fputs(" string\n", out);
  1756. break;
  1757. case S_INT:
  1758. fputs(" integer\n", out);
  1759. break;
  1760. case S_HEX:
  1761. fputs(" hex\n", out);
  1762. break;
  1763. default:
  1764. fputs(" ???\n", out);
  1765. break;
  1766. }
  1767. for (prop = sym->prop; prop; prop = prop->next) {
  1768. if (prop->menu != menu)
  1769. continue;
  1770. switch (prop->type) {
  1771. case P_PROMPT:
  1772. fputs(" prompt ", out);
  1773. print_quoted_string(out, prop->text);
  1774. if (!expr_is_yes(prop->visible.expr)) {
  1775. fputs(" if ", out);
  1776. expr_fprint(prop->visible.expr, out);
  1777. }
  1778. fputc('\n', out);
  1779. break;
  1780. case P_DEFAULT:
  1781. fputs( " default ", out);
  1782. expr_fprint(prop->expr, out);
  1783. if (!expr_is_yes(prop->visible.expr)) {
  1784. fputs(" if ", out);
  1785. expr_fprint(prop->visible.expr, out);
  1786. }
  1787. fputc('\n', out);
  1788. break;
  1789. case P_CHOICE:
  1790. fputs(" #choice value\n", out);
  1791. break;
  1792. case P_SELECT:
  1793. fputs( " select ", out);
  1794. expr_fprint(prop->expr, out);
  1795. fputc('\n', out);
  1796. break;
  1797. case P_IMPLY:
  1798. fputs( " imply ", out);
  1799. expr_fprint(prop->expr, out);
  1800. fputc('\n', out);
  1801. break;
  1802. case P_RANGE:
  1803. fputs( " range ", out);
  1804. expr_fprint(prop->expr, out);
  1805. fputc('\n', out);
  1806. break;
  1807. case P_MENU:
  1808. fputs( " menu ", out);
  1809. print_quoted_string(out, prop->text);
  1810. fputc('\n', out);
  1811. break;
  1812. case P_SYMBOL:
  1813. fputs( " symbol ", out);
  1814. fprintf(out, "%s\n", prop->menu->sym->name);
  1815. break;
  1816. default:
  1817. fprintf(out, " unknown prop %d!\n", prop->type);
  1818. break;
  1819. }
  1820. }
  1821. if (menu->help) {
  1822. int len = strlen(menu->help);
  1823. while (menu->help[--len] == '\n')
  1824. menu->help[len] = 0;
  1825. fprintf(out, " help\n%s\n", menu->help);
  1826. }
  1827. }
  1828. void zconfdump(FILE *out)
  1829. {
  1830. struct property *prop;
  1831. struct symbol *sym;
  1832. struct menu *menu;
  1833. menu = rootmenu.list;
  1834. while (menu) {
  1835. if ((sym = menu->sym))
  1836. print_symbol(out, menu);
  1837. else if ((prop = menu->prompt)) {
  1838. switch (prop->type) {
  1839. case P_COMMENT:
  1840. fputs("\ncomment ", out);
  1841. print_quoted_string(out, prop->text);
  1842. fputs("\n", out);
  1843. break;
  1844. case P_MENU:
  1845. fputs("\nmenu ", out);
  1846. print_quoted_string(out, prop->text);
  1847. fputs("\n", out);
  1848. break;
  1849. default:
  1850. ;
  1851. }
  1852. if (!expr_is_yes(prop->visible.expr)) {
  1853. fputs(" depends ", out);
  1854. expr_fprint(prop->visible.expr, out);
  1855. fputc('\n', out);
  1856. }
  1857. }
  1858. if (menu->list)
  1859. menu = menu->list;
  1860. else if (menu->next)
  1861. menu = menu->next;
  1862. else while ((menu = menu->parent)) {
  1863. if (menu->prompt && menu->prompt->type == P_MENU)
  1864. fputs("\nendmenu\n", out);
  1865. if (menu->next) {
  1866. menu = menu->next;
  1867. break;
  1868. }
  1869. }
  1870. }
  1871. }