yconf.c 71 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510
  1. /* A Bison parser, made by GNU Bison 3.0.4. */
  2. /* Bison implementation for Yacc-like parsers in C
  3. Copyright (C) 1984, 1989-1990, 2000-2015 Free Software Foundation, Inc.
  4. This program is free software: you can redistribute it and/or modify
  5. it under the terms of the GNU General Public License as published by
  6. the Free Software Foundation, either version 3 of the License, or
  7. (at your option) any later version.
  8. This program is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. GNU General Public License for more details.
  12. You should have received a copy of the GNU General Public License
  13. along with this program. If not, see <http://www.gnu.org/licenses/>. */
  14. /* As a special exception, you may create a larger work that contains
  15. part or all of the Bison parser skeleton and distribute that work
  16. under terms of your choice, so long as that work isn't itself a
  17. parser generator using the skeleton or a modified version thereof
  18. as a parser skeleton. Alternatively, if you modify or redistribute
  19. the parser skeleton itself, you may (at your option) remove this
  20. special exception, which will cause the skeleton and the resulting
  21. Bison output files to be licensed under the GNU General Public
  22. License without this special exception.
  23. This special exception was added by the Free Software Foundation in
  24. version 2.2 of Bison. */
  25. /* C LALR(1) parser skeleton written by Richard Stallman, by
  26. simplifying the original so-called "semantic" parser. */
  27. /* All symbols defined below should begin with yy or YY, to avoid
  28. infringing on user name space. This should be done even for local
  29. variables, as they might otherwise be expanded by user macros.
  30. There are some unavoidable exceptions within include files to
  31. define necessary library symbols; they are noted "INFRINGES ON
  32. USER NAME SPACE" below. */
  33. /* Identify Bison output. */
  34. #define YYBISON 1
  35. /* Bison version. */
  36. #define YYBISON_VERSION "3.0.4"
  37. /* Skeleton name. */
  38. #define YYSKELETON_NAME "yacc.c"
  39. /* Pure parsers. */
  40. #define YYPURE 0
  41. /* Push parsers. */
  42. #define YYPUSH 0
  43. /* Pull parsers. */
  44. #define YYPULL 1
  45. /* Substitute the variable and function names. */
  46. #define yyparse zconfparse
  47. #define yylex zconflex
  48. #define yyerror zconferror
  49. #define yydebug zconfdebug
  50. #define yynerrs zconfnerrs
  51. #define yylval zconflval
  52. #define yychar zconfchar
  53. /* Copy the first part of user declarations. */
  54. /*
  55. * Copyright (C) 2002 Roman Zippel <zippel@linux-m68k.org>
  56. * Released under the terms of the GNU GPL v2.0.
  57. */
  58. #include <ctype.h>
  59. #include <stdarg.h>
  60. #include <stdio.h>
  61. #include <stdlib.h>
  62. #include <string.h>
  63. #include <stdbool.h>
  64. #include "lkc.h"
  65. #define printd(mask, fmt...) if (cdebug & (mask)) printf(fmt)
  66. #define PRINTD 0x0001
  67. #define DEBUG_PARSE 0x0002
  68. int cdebug = PRINTD;
  69. extern int zconflex(void);
  70. static void zconfprint(const char *err, ...);
  71. static void zconf_error(const char *err, ...);
  72. static void zconferror(const char *err);
  73. static bool zconf_endtoken(const struct kconf_id *id, int starttoken, int endtoken);
  74. struct symbol *symbol_hash[SYMBOL_HASHSIZE];
  75. static struct menu *current_menu, *current_entry;
  76. # ifndef YY_NULLPTR
  77. # if defined __cplusplus && 201103L <= __cplusplus
  78. # define YY_NULLPTR nullptr
  79. # else
  80. # define YY_NULLPTR 0
  81. # endif
  82. # endif
  83. /* Enabling verbose error messages. */
  84. #ifdef YYERROR_VERBOSE
  85. # undef YYERROR_VERBOSE
  86. # define YYERROR_VERBOSE 1
  87. #else
  88. # define YYERROR_VERBOSE 0
  89. #endif
  90. /* Debug traces. */
  91. #ifndef YYDEBUG
  92. # define YYDEBUG 1
  93. #endif
  94. #if YYDEBUG
  95. extern int zconfdebug;
  96. #endif
  97. /* Token type. */
  98. #ifndef YYTOKENTYPE
  99. # define YYTOKENTYPE
  100. enum yytokentype
  101. {
  102. T_MAINMENU = 258,
  103. T_MENU = 259,
  104. T_ENDMENU = 260,
  105. T_SOURCE = 261,
  106. T_CHOICE = 262,
  107. T_ENDCHOICE = 263,
  108. T_COMMENT = 264,
  109. T_CONFIG = 265,
  110. T_MENUCONFIG = 266,
  111. T_HELP = 267,
  112. T_HELPTEXT = 268,
  113. T_IF = 269,
  114. T_ENDIF = 270,
  115. T_DEPENDS = 271,
  116. T_OPTIONAL = 272,
  117. T_PROMPT = 273,
  118. T_TYPE = 274,
  119. T_DEFAULT = 275,
  120. T_SELECT = 276,
  121. T_IMPLY = 277,
  122. T_RANGE = 278,
  123. T_VISIBLE = 279,
  124. T_OPTION = 280,
  125. T_ON = 281,
  126. T_WORD = 282,
  127. T_WORD_QUOTE = 283,
  128. T_UNEQUAL = 284,
  129. T_LESS = 285,
  130. T_LESS_EQUAL = 286,
  131. T_GREATER = 287,
  132. T_GREATER_EQUAL = 288,
  133. T_CLOSE_PAREN = 289,
  134. T_OPEN_PAREN = 290,
  135. T_EOL = 291,
  136. T_OR = 292,
  137. T_AND = 293,
  138. T_EQUAL = 294,
  139. T_NOT = 295
  140. };
  141. #endif
  142. /* Tokens. */
  143. #define T_MAINMENU 258
  144. #define T_MENU 259
  145. #define T_ENDMENU 260
  146. #define T_SOURCE 261
  147. #define T_CHOICE 262
  148. #define T_ENDCHOICE 263
  149. #define T_COMMENT 264
  150. #define T_CONFIG 265
  151. #define T_MENUCONFIG 266
  152. #define T_HELP 267
  153. #define T_HELPTEXT 268
  154. #define T_IF 269
  155. #define T_ENDIF 270
  156. #define T_DEPENDS 271
  157. #define T_OPTIONAL 272
  158. #define T_PROMPT 273
  159. #define T_TYPE 274
  160. #define T_DEFAULT 275
  161. #define T_SELECT 276
  162. #define T_IMPLY 277
  163. #define T_RANGE 278
  164. #define T_VISIBLE 279
  165. #define T_OPTION 280
  166. #define T_ON 281
  167. #define T_WORD 282
  168. #define T_WORD_QUOTE 283
  169. #define T_UNEQUAL 284
  170. #define T_LESS 285
  171. #define T_LESS_EQUAL 286
  172. #define T_GREATER 287
  173. #define T_GREATER_EQUAL 288
  174. #define T_CLOSE_PAREN 289
  175. #define T_OPEN_PAREN 290
  176. #define T_EOL 291
  177. #define T_OR 292
  178. #define T_AND 293
  179. #define T_EQUAL 294
  180. #define T_NOT 295
  181. /* Value type. */
  182. #if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
  183. union YYSTYPE
  184. {
  185. char *string;
  186. struct file *file;
  187. struct symbol *symbol;
  188. struct expr *expr;
  189. struct menu *menu;
  190. const struct kconf_id *id;
  191. };
  192. typedef union YYSTYPE YYSTYPE;
  193. # define YYSTYPE_IS_TRIVIAL 1
  194. # define YYSTYPE_IS_DECLARED 1
  195. #endif
  196. extern YYSTYPE zconflval;
  197. int zconfparse (void);
  198. /* Copy the second part of user declarations. */
  199. /* Include zconf.hash.c here so it can see the token constants. */
  200. #include "hconf.c"
  201. #ifdef short
  202. # undef short
  203. #endif
  204. #ifdef YYTYPE_UINT8
  205. typedef YYTYPE_UINT8 yytype_uint8;
  206. #else
  207. typedef unsigned char yytype_uint8;
  208. #endif
  209. #ifdef YYTYPE_INT8
  210. typedef YYTYPE_INT8 yytype_int8;
  211. #else
  212. typedef signed char yytype_int8;
  213. #endif
  214. #ifdef YYTYPE_UINT16
  215. typedef YYTYPE_UINT16 yytype_uint16;
  216. #else
  217. typedef unsigned short int yytype_uint16;
  218. #endif
  219. #ifdef YYTYPE_INT16
  220. typedef YYTYPE_INT16 yytype_int16;
  221. #else
  222. typedef short int yytype_int16;
  223. #endif
  224. #ifndef YYSIZE_T
  225. # ifdef __SIZE_TYPE__
  226. # define YYSIZE_T __SIZE_TYPE__
  227. # elif defined size_t
  228. # define YYSIZE_T size_t
  229. # elif ! defined YYSIZE_T
  230. # include <stddef.h> /* INFRINGES ON USER NAME SPACE */
  231. # define YYSIZE_T size_t
  232. # else
  233. # define YYSIZE_T unsigned int
  234. # endif
  235. #endif
  236. #define YYSIZE_MAXIMUM ((YYSIZE_T) -1)
  237. #ifndef YY_
  238. # if defined YYENABLE_NLS && YYENABLE_NLS
  239. # if ENABLE_NLS
  240. # include <libintl.h> /* INFRINGES ON USER NAME SPACE */
  241. # define YY_(Msgid) dgettext ("bison-runtime", Msgid)
  242. # endif
  243. # endif
  244. # ifndef YY_
  245. # define YY_(Msgid) Msgid
  246. # endif
  247. #endif
  248. #ifndef YY_ATTRIBUTE
  249. # if (defined __GNUC__ \
  250. && (2 < __GNUC__ || (__GNUC__ == 2 && 96 <= __GNUC_MINOR__))) \
  251. || defined __SUNPRO_C && 0x5110 <= __SUNPRO_C
  252. # define YY_ATTRIBUTE(Spec) __attribute__(Spec)
  253. # else
  254. # define YY_ATTRIBUTE(Spec) /* empty */
  255. # endif
  256. #endif
  257. #ifndef YY_ATTRIBUTE_PURE
  258. # define YY_ATTRIBUTE_PURE YY_ATTRIBUTE ((__pure__))
  259. #endif
  260. #ifndef YY_ATTRIBUTE_UNUSED
  261. # define YY_ATTRIBUTE_UNUSED YY_ATTRIBUTE ((__unused__))
  262. #endif
  263. #if !defined _Noreturn \
  264. && (!defined __STDC_VERSION__ || __STDC_VERSION__ < 201112)
  265. # if defined _MSC_VER && 1200 <= _MSC_VER
  266. # define _Noreturn __declspec (noreturn)
  267. # else
  268. # define _Noreturn YY_ATTRIBUTE ((__noreturn__))
  269. # endif
  270. #endif
  271. /* Suppress unused-variable warnings by "using" E. */
  272. #if ! defined lint || defined __GNUC__
  273. # define YYUSE(E) ((void) (E))
  274. #else
  275. # define YYUSE(E) /* empty */
  276. #endif
  277. #if defined __GNUC__ && 407 <= __GNUC__ * 100 + __GNUC_MINOR__
  278. /* Suppress an incorrect diagnostic about yylval being uninitialized. */
  279. # define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN \
  280. _Pragma ("GCC diagnostic push") \
  281. _Pragma ("GCC diagnostic ignored \"-Wuninitialized\"")\
  282. _Pragma ("GCC diagnostic ignored \"-Wmaybe-uninitialized\"")
  283. # define YY_IGNORE_MAYBE_UNINITIALIZED_END \
  284. _Pragma ("GCC diagnostic pop")
  285. #else
  286. # define YY_INITIAL_VALUE(Value) Value
  287. #endif
  288. #ifndef YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
  289. # define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
  290. # define YY_IGNORE_MAYBE_UNINITIALIZED_END
  291. #endif
  292. #ifndef YY_INITIAL_VALUE
  293. # define YY_INITIAL_VALUE(Value) /* Nothing. */
  294. #endif
  295. #if ! defined yyoverflow || YYERROR_VERBOSE
  296. /* The parser invokes alloca or malloc; define the necessary symbols. */
  297. # ifdef YYSTACK_USE_ALLOCA
  298. # if YYSTACK_USE_ALLOCA
  299. # ifdef __GNUC__
  300. # define YYSTACK_ALLOC __builtin_alloca
  301. # elif defined __BUILTIN_VA_ARG_INCR
  302. # include <alloca.h> /* INFRINGES ON USER NAME SPACE */
  303. # elif defined _AIX
  304. # define YYSTACK_ALLOC __alloca
  305. # elif defined _MSC_VER
  306. # include <malloc.h> /* INFRINGES ON USER NAME SPACE */
  307. # define alloca _alloca
  308. # else
  309. # define YYSTACK_ALLOC alloca
  310. # if ! defined _ALLOCA_H && ! defined EXIT_SUCCESS
  311. # include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
  312. /* Use EXIT_SUCCESS as a witness for stdlib.h. */
  313. # ifndef EXIT_SUCCESS
  314. # define EXIT_SUCCESS 0
  315. # endif
  316. # endif
  317. # endif
  318. # endif
  319. # endif
  320. # ifdef YYSTACK_ALLOC
  321. /* Pacify GCC's 'empty if-body' warning. */
  322. # define YYSTACK_FREE(Ptr) do { /* empty */; } while (0)
  323. # ifndef YYSTACK_ALLOC_MAXIMUM
  324. /* The OS might guarantee only one guard page at the bottom of the stack,
  325. and a page size can be as small as 4096 bytes. So we cannot safely
  326. invoke alloca (N) if N exceeds 4096. Use a slightly smaller number
  327. to allow for a few compiler-allocated temporary stack slots. */
  328. # define YYSTACK_ALLOC_MAXIMUM 4032 /* reasonable circa 2006 */
  329. # endif
  330. # else
  331. # define YYSTACK_ALLOC YYMALLOC
  332. # define YYSTACK_FREE YYFREE
  333. # ifndef YYSTACK_ALLOC_MAXIMUM
  334. # define YYSTACK_ALLOC_MAXIMUM YYSIZE_MAXIMUM
  335. # endif
  336. # if (defined __cplusplus && ! defined EXIT_SUCCESS \
  337. && ! ((defined YYMALLOC || defined malloc) \
  338. && (defined YYFREE || defined free)))
  339. # include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
  340. # ifndef EXIT_SUCCESS
  341. # define EXIT_SUCCESS 0
  342. # endif
  343. # endif
  344. # ifndef YYMALLOC
  345. # define YYMALLOC malloc
  346. # if ! defined malloc && ! defined EXIT_SUCCESS
  347. void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */
  348. # endif
  349. # endif
  350. # ifndef YYFREE
  351. # define YYFREE free
  352. # if ! defined free && ! defined EXIT_SUCCESS
  353. void free (void *); /* INFRINGES ON USER NAME SPACE */
  354. # endif
  355. # endif
  356. # endif
  357. #endif /* ! defined yyoverflow || YYERROR_VERBOSE */
  358. #if (! defined yyoverflow \
  359. && (! defined __cplusplus \
  360. || (defined YYSTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL)))
  361. /* A type that is properly aligned for any stack member. */
  362. union yyalloc
  363. {
  364. yytype_int16 yyss_alloc;
  365. YYSTYPE yyvs_alloc;
  366. };
  367. /* The size of the maximum gap between one aligned stack and the next. */
  368. # define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1)
  369. /* The size of an array large to enough to hold all stacks, each with
  370. N elements. */
  371. # define YYSTACK_BYTES(N) \
  372. ((N) * (sizeof (yytype_int16) + sizeof (YYSTYPE)) \
  373. + YYSTACK_GAP_MAXIMUM)
  374. # define YYCOPY_NEEDED 1
  375. /* Relocate STACK from its old location to the new one. The
  376. local variables YYSIZE and YYSTACKSIZE give the old and new number of
  377. elements in the stack, and YYPTR gives the new location of the
  378. stack. Advance YYPTR to a properly aligned location for the next
  379. stack. */
  380. # define YYSTACK_RELOCATE(Stack_alloc, Stack) \
  381. do \
  382. { \
  383. YYSIZE_T yynewbytes; \
  384. YYCOPY (&yyptr->Stack_alloc, Stack, yysize); \
  385. Stack = &yyptr->Stack_alloc; \
  386. yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \
  387. yyptr += yynewbytes / sizeof (*yyptr); \
  388. } \
  389. while (0)
  390. #endif
  391. #if defined YYCOPY_NEEDED && YYCOPY_NEEDED
  392. /* Copy COUNT objects from SRC to DST. The source and destination do
  393. not overlap. */
  394. # ifndef YYCOPY
  395. # if defined __GNUC__ && 1 < __GNUC__
  396. # define YYCOPY(Dst, Src, Count) \
  397. __builtin_memcpy (Dst, Src, (Count) * sizeof (*(Src)))
  398. # else
  399. # define YYCOPY(Dst, Src, Count) \
  400. do \
  401. { \
  402. YYSIZE_T yyi; \
  403. for (yyi = 0; yyi < (Count); yyi++) \
  404. (Dst)[yyi] = (Src)[yyi]; \
  405. } \
  406. while (0)
  407. # endif
  408. # endif
  409. #endif /* !YYCOPY_NEEDED */
  410. /* YYFINAL -- State number of the termination state. */
  411. #define YYFINAL 11
  412. /* YYLAST -- Last index in YYTABLE. */
  413. #define YYLAST 301
  414. /* YYNTOKENS -- Number of terminals. */
  415. #define YYNTOKENS 41
  416. /* YYNNTS -- Number of nonterminals. */
  417. #define YYNNTS 50
  418. /* YYNRULES -- Number of rules. */
  419. #define YYNRULES 124
  420. /* YYNSTATES -- Number of states. */
  421. #define YYNSTATES 204
  422. /* YYTRANSLATE[YYX] -- Symbol number corresponding to YYX as returned
  423. by yylex, with out-of-bounds checking. */
  424. #define YYUNDEFTOK 2
  425. #define YYMAXUTOK 295
  426. #define YYTRANSLATE(YYX) \
  427. ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK)
  428. /* YYTRANSLATE[TOKEN-NUM] -- Symbol number corresponding to TOKEN-NUM
  429. as returned by yylex, without out-of-bounds checking. */
  430. static const yytype_uint8 yytranslate[] =
  431. {
  432. 0, 2, 2, 2, 2, 2, 2, 2, 2, 2,
  433. 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
  434. 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
  435. 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
  436. 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
  437. 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
  438. 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
  439. 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
  440. 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
  441. 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
  442. 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
  443. 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
  444. 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
  445. 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
  446. 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
  447. 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
  448. 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
  449. 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
  450. 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
  451. 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
  452. 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
  453. 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
  454. 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
  455. 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
  456. 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
  457. 2, 2, 2, 2, 2, 2, 1, 2, 3, 4,
  458. 5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
  459. 15, 16, 17, 18, 19, 20, 21, 22, 23, 24,
  460. 25, 26, 27, 28, 29, 30, 31, 32, 33, 34,
  461. 35, 36, 37, 38, 39, 40
  462. };
  463. #if YYDEBUG
  464. /* YYRLINE[YYN] -- Source line where rule number YYN was defined. */
  465. static const yytype_uint16 yyrline[] =
  466. {
  467. 0, 109, 109, 109, 111, 111, 113, 115, 116, 117,
  468. 118, 119, 120, 124, 128, 128, 128, 128, 128, 128,
  469. 128, 128, 128, 132, 133, 134, 135, 136, 137, 141,
  470. 142, 148, 156, 162, 170, 180, 182, 183, 184, 185,
  471. 186, 187, 190, 198, 204, 214, 220, 226, 232, 235,
  472. 237, 248, 249, 254, 263, 268, 276, 279, 281, 282,
  473. 283, 284, 285, 288, 294, 305, 311, 321, 323, 328,
  474. 336, 344, 347, 349, 350, 351, 356, 363, 370, 375,
  475. 383, 386, 388, 389, 390, 393, 401, 408, 415, 421,
  476. 428, 430, 431, 432, 435, 443, 445, 446, 449, 456,
  477. 458, 463, 464, 467, 468, 469, 473, 474, 477, 478,
  478. 481, 482, 483, 484, 485, 486, 487, 488, 489, 490,
  479. 491, 494, 495, 498, 499
  480. };
  481. #endif
  482. #if YYDEBUG || YYERROR_VERBOSE || 0
  483. /* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
  484. First, the terminals, then, starting at YYNTOKENS, nonterminals. */
  485. static const char *const yytname[] =
  486. {
  487. "$end", "error", "$undefined", "T_MAINMENU", "T_MENU", "T_ENDMENU",
  488. "T_SOURCE", "T_CHOICE", "T_ENDCHOICE", "T_COMMENT", "T_CONFIG",
  489. "T_MENUCONFIG", "T_HELP", "T_HELPTEXT", "T_IF", "T_ENDIF", "T_DEPENDS",
  490. "T_OPTIONAL", "T_PROMPT", "T_TYPE", "T_DEFAULT", "T_SELECT", "T_IMPLY",
  491. "T_RANGE", "T_VISIBLE", "T_OPTION", "T_ON", "T_WORD", "T_WORD_QUOTE",
  492. "T_UNEQUAL", "T_LESS", "T_LESS_EQUAL", "T_GREATER", "T_GREATER_EQUAL",
  493. "T_CLOSE_PAREN", "T_OPEN_PAREN", "T_EOL", "T_OR", "T_AND", "T_EQUAL",
  494. "T_NOT", "$accept", "input", "start", "stmt_list", "option_name",
  495. "common_stmt", "option_error", "config_entry_start", "config_stmt",
  496. "menuconfig_entry_start", "menuconfig_stmt", "config_option_list",
  497. "config_option", "symbol_option", "symbol_option_list",
  498. "symbol_option_arg", "choice", "choice_entry", "choice_end",
  499. "choice_stmt", "choice_option_list", "choice_option", "choice_block",
  500. "if_entry", "if_end", "if_stmt", "if_block", "mainmenu_stmt", "menu",
  501. "menu_entry", "menu_end", "menu_stmt", "menu_block", "source_stmt",
  502. "comment", "comment_stmt", "help_start", "help", "depends_list",
  503. "depends", "visibility_list", "visible", "prompt_stmt_opt", "prompt",
  504. "end", "nl", "if_expr", "expr", "symbol", "word_opt", YY_NULLPTR
  505. };
  506. #endif
  507. # ifdef YYPRINT
  508. /* YYTOKNUM[NUM] -- (External) token number corresponding to the
  509. (internal) symbol number NUM (which must be that of a token). */
  510. static const yytype_uint16 yytoknum[] =
  511. {
  512. 0, 256, 257, 258, 259, 260, 261, 262, 263, 264,
  513. 265, 266, 267, 268, 269, 270, 271, 272, 273, 274,
  514. 275, 276, 277, 278, 279, 280, 281, 282, 283, 284,
  515. 285, 286, 287, 288, 289, 290, 291, 292, 293, 294,
  516. 295
  517. };
  518. # endif
  519. #define YYPACT_NINF -92
  520. #define yypact_value_is_default(Yystate) \
  521. (!!((Yystate) == (-92)))
  522. #define YYTABLE_NINF -88
  523. #define yytable_value_is_error(Yytable_value) \
  524. 0
  525. /* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
  526. STATE-NUM. */
  527. static const yytype_int16 yypact[] =
  528. {
  529. 17, 41, -92, 15, -92, 150, -92, 19, -92, -92,
  530. -13, -92, 28, 41, 38, 41, 50, 47, 41, 79,
  531. 82, 44, 76, -92, -92, -92, -92, -92, -92, -92,
  532. -92, -92, 118, -92, 129, -92, -92, -92, -92, -92,
  533. -92, -92, -92, -92, -92, -92, -92, -92, -92, -92,
  534. -92, -92, 184, -92, -92, 107, -92, 111, -92, 113,
  535. -92, 116, -92, 139, 140, 151, -92, -92, 44, 44,
  536. 142, 256, -92, 160, 173, 27, 117, 80, 51, 255,
  537. -15, 255, 217, -92, -92, -92, -92, -92, -92, -8,
  538. -92, 44, 44, 107, 87, 87, 87, 87, 87, 87,
  539. -92, -92, 174, 176, 187, 41, 41, 44, 188, 189,
  540. 87, -92, 213, -92, -92, -92, -92, 206, -92, -92,
  541. 193, 41, 41, 203, -92, -92, -92, -92, -92, -92,
  542. -92, -92, -92, -92, -92, -92, -92, 229, -92, 241,
  543. -92, -92, -92, -92, -92, -92, -92, -92, -92, -92,
  544. 216, -92, -92, -92, -92, -92, -92, -92, -92, -92,
  545. 44, 229, 222, 229, 64, 229, 229, 87, 31, 231,
  546. -92, -92, 229, 236, 229, 44, -92, 145, 242, -92,
  547. -92, 243, 244, 245, 229, 251, -92, -92, 247, -92,
  548. 257, 125, -92, -92, -92, -92, -92, 260, 41, -92,
  549. -92, -92, -92, -92
  550. };
  551. /* YYDEFACT[STATE-NUM] -- Default reduction number in state STATE-NUM.
  552. Performed when YYTABLE does not specify something else to do. Zero
  553. means the default is an error. */
  554. static const yytype_uint8 yydefact[] =
  555. {
  556. 6, 0, 106, 0, 3, 0, 6, 6, 101, 102,
  557. 0, 1, 0, 0, 0, 0, 123, 0, 0, 0,
  558. 0, 0, 0, 14, 19, 15, 16, 21, 17, 18,
  559. 20, 22, 0, 23, 0, 7, 35, 26, 35, 27,
  560. 57, 67, 8, 72, 24, 95, 81, 9, 28, 90,
  561. 25, 10, 0, 107, 2, 76, 13, 0, 103, 0,
  562. 124, 0, 104, 0, 0, 0, 121, 122, 0, 0,
  563. 0, 110, 105, 0, 0, 0, 0, 0, 0, 0,
  564. 90, 0, 0, 77, 85, 53, 86, 31, 33, 0,
  565. 118, 0, 0, 69, 0, 0, 0, 0, 0, 0,
  566. 11, 12, 0, 0, 0, 0, 99, 0, 0, 0,
  567. 0, 49, 0, 41, 40, 36, 37, 0, 39, 38,
  568. 0, 0, 99, 0, 61, 62, 58, 60, 59, 68,
  569. 56, 55, 73, 75, 71, 74, 70, 108, 97, 0,
  570. 96, 82, 84, 80, 83, 79, 92, 93, 91, 117,
  571. 119, 120, 116, 111, 112, 113, 114, 115, 30, 88,
  572. 0, 108, 0, 108, 108, 108, 108, 0, 0, 0,
  573. 89, 65, 108, 0, 108, 0, 98, 0, 0, 42,
  574. 100, 0, 0, 0, 108, 51, 48, 29, 0, 64,
  575. 0, 109, 94, 43, 44, 45, 46, 0, 0, 50,
  576. 63, 66, 47, 52
  577. };
  578. /* YYPGOTO[NTERM-NUM]. */
  579. static const yytype_int16 yypgoto[] =
  580. {
  581. -92, -92, 285, 291, -92, 32, -66, -92, -92, -92,
  582. -92, 261, -92, -92, -92, -92, -92, -92, -92, 1,
  583. -92, -92, -92, -92, -92, -92, -92, -92, -92, -92,
  584. -92, 24, -92, -92, -92, -92, -92, 221, 220, -64,
  585. -92, -92, 179, -1, 67, 0, 110, -67, -91, -92
  586. };
  587. /* YYDEFGOTO[NTERM-NUM]. */
  588. static const yytype_int16 yydefgoto[] =
  589. {
  590. -1, 3, 4, 5, 34, 35, 114, 36, 37, 38,
  591. 39, 75, 115, 116, 168, 199, 40, 41, 130, 42,
  592. 77, 126, 78, 43, 134, 44, 79, 6, 45, 46,
  593. 143, 47, 81, 48, 49, 50, 117, 118, 82, 119,
  594. 80, 140, 162, 163, 51, 7, 176, 70, 71, 61
  595. };
  596. /* YYTABLE[YYPACT[STATE-NUM]] -- What to do in state STATE-NUM. If
  597. positive, shift that token. If negative, reduce the rule whose
  598. number is the opposite. If YYTABLE_NINF, syntax error. */
  599. static const yytype_int16 yytable[] =
  600. {
  601. 10, 89, 90, 152, 153, 154, 155, 156, 157, 137,
  602. 55, 125, 57, 128, 59, 11, 147, 63, 148, 167,
  603. 1, 138, 1, 2, 150, 151, 149, -32, 102, 91,
  604. 92, -32, -32, -32, -32, -32, -32, -32, -32, 103,
  605. 164, -32, -32, 104, -32, 105, 106, 107, 108, 109,
  606. 110, -32, 111, 2, 112, 53, 14, 15, 185, 17,
  607. 18, 19, 20, 113, 56, 21, 22, 186, 8, 9,
  608. 93, 66, 67, 147, 58, 148, 184, 60, 175, 68,
  609. 133, 102, 142, 62, 69, -54, -54, 33, -54, -54,
  610. -54, -54, 103, 177, -54, -54, 104, 120, 121, 122,
  611. 123, 91, 92, 135, 161, 144, 64, 112, 191, 65,
  612. 129, 132, 72, 141, 66, 67, 124, -34, 102, 73,
  613. 172, -34, -34, -34, -34, -34, -34, -34, -34, 103,
  614. 74, -34, -34, 104, -34, 105, 106, 107, 108, 109,
  615. 110, -34, 111, 53, 112, 131, 136, 83, 145, 84,
  616. -5, 12, 85, 113, 13, 14, 15, 16, 17, 18,
  617. 19, 20, 91, 92, 21, 22, 23, 24, 25, 26,
  618. 27, 28, 29, 30, 31, 86, 87, 32, 2, 91,
  619. 92, 192, 91, 92, -4, 12, 33, 88, 13, 14,
  620. 15, 16, 17, 18, 19, 20, 100, 203, 21, 22,
  621. 23, 24, 25, 26, 27, 28, 29, 30, 31, 101,
  622. 158, 32, 159, 160, 169, 165, 166, -87, 102, 170,
  623. 33, -87, -87, -87, -87, -87, -87, -87, -87, 171,
  624. 174, -87, -87, 104, -87, -87, -87, -87, -87, -87,
  625. -87, -87, 102, 175, 112, -78, -78, -78, -78, -78,
  626. -78, -78, -78, 146, 92, -78, -78, 104, 179, 13,
  627. 14, 15, 16, 17, 18, 19, 20, 187, 112, 21,
  628. 22, 178, 189, 180, 181, 182, 183, 146, 193, 194,
  629. 195, 196, 188, 200, 190, 94, 95, 96, 97, 98,
  630. 198, 33, 54, 201, 197, 99, 202, 52, 127, 76,
  631. 139, 173
  632. };
  633. static const yytype_uint8 yycheck[] =
  634. {
  635. 1, 68, 69, 94, 95, 96, 97, 98, 99, 24,
  636. 10, 77, 13, 77, 15, 0, 82, 18, 82, 110,
  637. 3, 36, 3, 36, 91, 92, 34, 0, 1, 37,
  638. 38, 4, 5, 6, 7, 8, 9, 10, 11, 12,
  639. 107, 14, 15, 16, 17, 18, 19, 20, 21, 22,
  640. 23, 24, 25, 36, 27, 36, 5, 6, 27, 8,
  641. 9, 10, 11, 36, 36, 14, 15, 36, 27, 28,
  642. 70, 27, 28, 139, 36, 139, 167, 27, 14, 35,
  643. 79, 1, 81, 36, 40, 5, 6, 36, 8, 9,
  644. 10, 11, 12, 160, 14, 15, 16, 17, 18, 19,
  645. 20, 37, 38, 79, 105, 81, 27, 27, 175, 27,
  646. 78, 79, 36, 81, 27, 28, 36, 0, 1, 1,
  647. 121, 4, 5, 6, 7, 8, 9, 10, 11, 12,
  648. 1, 14, 15, 16, 17, 18, 19, 20, 21, 22,
  649. 23, 24, 25, 36, 27, 78, 79, 36, 81, 36,
  650. 0, 1, 36, 36, 4, 5, 6, 7, 8, 9,
  651. 10, 11, 37, 38, 14, 15, 16, 17, 18, 19,
  652. 20, 21, 22, 23, 24, 36, 36, 27, 36, 37,
  653. 38, 36, 37, 38, 0, 1, 36, 36, 4, 5,
  654. 6, 7, 8, 9, 10, 11, 36, 198, 14, 15,
  655. 16, 17, 18, 19, 20, 21, 22, 23, 24, 36,
  656. 36, 27, 36, 26, 1, 27, 27, 0, 1, 13,
  657. 36, 4, 5, 6, 7, 8, 9, 10, 11, 36,
  658. 27, 14, 15, 16, 17, 18, 19, 20, 21, 22,
  659. 23, 24, 1, 14, 27, 4, 5, 6, 7, 8,
  660. 9, 10, 11, 36, 38, 14, 15, 16, 36, 4,
  661. 5, 6, 7, 8, 9, 10, 11, 36, 27, 14,
  662. 15, 161, 36, 163, 164, 165, 166, 36, 36, 36,
  663. 36, 36, 172, 36, 174, 29, 30, 31, 32, 33,
  664. 39, 36, 7, 36, 184, 39, 36, 6, 77, 38,
  665. 80, 122
  666. };
  667. /* YYSTOS[STATE-NUM] -- The (internal number of the) accessing
  668. symbol of state STATE-NUM. */
  669. static const yytype_uint8 yystos[] =
  670. {
  671. 0, 3, 36, 42, 43, 44, 68, 86, 27, 28,
  672. 84, 0, 1, 4, 5, 6, 7, 8, 9, 10,
  673. 11, 14, 15, 16, 17, 18, 19, 20, 21, 22,
  674. 23, 24, 27, 36, 45, 46, 48, 49, 50, 51,
  675. 57, 58, 60, 64, 66, 69, 70, 72, 74, 75,
  676. 76, 85, 44, 36, 43, 86, 36, 84, 36, 84,
  677. 27, 90, 36, 84, 27, 27, 27, 28, 35, 40,
  678. 88, 89, 36, 1, 1, 52, 52, 61, 63, 67,
  679. 81, 73, 79, 36, 36, 36, 36, 36, 36, 88,
  680. 88, 37, 38, 86, 29, 30, 31, 32, 33, 39,
  681. 36, 36, 1, 12, 16, 18, 19, 20, 21, 22,
  682. 23, 25, 27, 36, 47, 53, 54, 77, 78, 80,
  683. 17, 18, 19, 20, 36, 47, 62, 78, 80, 46,
  684. 59, 85, 46, 60, 65, 72, 85, 24, 36, 79,
  685. 82, 46, 60, 71, 72, 85, 36, 47, 80, 34,
  686. 88, 88, 89, 89, 89, 89, 89, 89, 36, 36,
  687. 26, 84, 83, 84, 88, 27, 27, 89, 55, 1,
  688. 13, 36, 84, 83, 27, 14, 87, 88, 87, 36,
  689. 87, 87, 87, 87, 89, 27, 36, 36, 87, 36,
  690. 87, 88, 36, 36, 36, 36, 36, 87, 39, 56,
  691. 36, 36, 36, 84
  692. };
  693. /* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */
  694. static const yytype_uint8 yyr1[] =
  695. {
  696. 0, 41, 42, 42, 43, 43, 44, 44, 44, 44,
  697. 44, 44, 44, 44, 45, 45, 45, 45, 45, 45,
  698. 45, 45, 45, 46, 46, 46, 46, 46, 46, 47,
  699. 47, 48, 49, 50, 51, 52, 52, 52, 52, 52,
  700. 52, 52, 53, 53, 53, 53, 53, 53, 54, 55,
  701. 55, 56, 56, 57, 58, 59, 60, 61, 61, 61,
  702. 61, 61, 61, 62, 62, 62, 62, 63, 63, 64,
  703. 65, 66, 67, 67, 67, 67, 68, 69, 70, 71,
  704. 72, 73, 73, 73, 73, 74, 75, 76, 77, 78,
  705. 79, 79, 79, 79, 80, 81, 81, 81, 82, 83,
  706. 83, 84, 84, 85, 85, 85, 86, 86, 87, 87,
  707. 88, 88, 88, 88, 88, 88, 88, 88, 88, 88,
  708. 88, 89, 89, 90, 90
  709. };
  710. /* YYR2[YYN] -- Number of symbols on the right hand side of rule YYN. */
  711. static const yytype_uint8 yyr2[] =
  712. {
  713. 0, 2, 2, 1, 2, 1, 0, 2, 2, 2,
  714. 2, 4, 4, 3, 1, 1, 1, 1, 1, 1,
  715. 1, 1, 1, 1, 1, 1, 1, 1, 1, 3,
  716. 2, 3, 2, 3, 2, 0, 2, 2, 2, 2,
  717. 2, 2, 3, 4, 4, 4, 4, 5, 3, 0,
  718. 3, 0, 2, 3, 2, 1, 3, 0, 2, 2,
  719. 2, 2, 2, 4, 3, 2, 4, 0, 2, 3,
  720. 1, 3, 0, 2, 2, 2, 3, 3, 3, 1,
  721. 3, 0, 2, 2, 2, 3, 3, 2, 2, 2,
  722. 0, 2, 2, 2, 4, 0, 2, 2, 2, 0,
  723. 2, 1, 1, 2, 2, 2, 1, 2, 0, 2,
  724. 1, 3, 3, 3, 3, 3, 3, 3, 2, 3,
  725. 3, 1, 1, 0, 1
  726. };
  727. #define yyerrok (yyerrstatus = 0)
  728. #define yyclearin (yychar = YYEMPTY)
  729. #define YYEMPTY (-2)
  730. #define YYEOF 0
  731. #define YYACCEPT goto yyacceptlab
  732. #define YYABORT goto yyabortlab
  733. #define YYERROR goto yyerrorlab
  734. #define YYRECOVERING() (!!yyerrstatus)
  735. #define YYBACKUP(Token, Value) \
  736. do \
  737. if (yychar == YYEMPTY) \
  738. { \
  739. yychar = (Token); \
  740. yylval = (Value); \
  741. YYPOPSTACK (yylen); \
  742. yystate = *yyssp; \
  743. goto yybackup; \
  744. } \
  745. else \
  746. { \
  747. yyerror (YY_("syntax error: cannot back up")); \
  748. YYERROR; \
  749. } \
  750. while (0)
  751. /* Error token number */
  752. #define YYTERROR 1
  753. #define YYERRCODE 256
  754. /* Enable debugging if requested. */
  755. #if YYDEBUG
  756. # ifndef YYFPRINTF
  757. # include <stdio.h> /* INFRINGES ON USER NAME SPACE */
  758. # define YYFPRINTF fprintf
  759. # endif
  760. # define YYDPRINTF(Args) \
  761. do { \
  762. if (yydebug) \
  763. YYFPRINTF Args; \
  764. } while (0)
  765. /* This macro is provided for backward compatibility. */
  766. #ifndef YY_LOCATION_PRINT
  767. # define YY_LOCATION_PRINT(File, Loc) ((void) 0)
  768. #endif
  769. # define YY_SYMBOL_PRINT(Title, Type, Value, Location) \
  770. do { \
  771. if (yydebug) \
  772. { \
  773. YYFPRINTF (stderr, "%s ", Title); \
  774. yy_symbol_print (stderr, \
  775. Type, Value); \
  776. YYFPRINTF (stderr, "\n"); \
  777. } \
  778. } while (0)
  779. /*----------------------------------------.
  780. | Print this symbol's value on YYOUTPUT. |
  781. `----------------------------------------*/
  782. static void
  783. yy_symbol_value_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep)
  784. {
  785. FILE *yyo = yyoutput;
  786. YYUSE (yyo);
  787. if (!yyvaluep)
  788. return;
  789. # ifdef YYPRINT
  790. if (yytype < YYNTOKENS)
  791. YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep);
  792. # endif
  793. YYUSE (yytype);
  794. }
  795. /*--------------------------------.
  796. | Print this symbol on YYOUTPUT. |
  797. `--------------------------------*/
  798. static void
  799. yy_symbol_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep)
  800. {
  801. YYFPRINTF (yyoutput, "%s %s (",
  802. yytype < YYNTOKENS ? "token" : "nterm", yytname[yytype]);
  803. yy_symbol_value_print (yyoutput, yytype, yyvaluep);
  804. YYFPRINTF (yyoutput, ")");
  805. }
  806. /*------------------------------------------------------------------.
  807. | yy_stack_print -- Print the state stack from its BOTTOM up to its |
  808. | TOP (included). |
  809. `------------------------------------------------------------------*/
  810. static void
  811. yy_stack_print (yytype_int16 *yybottom, yytype_int16 *yytop)
  812. {
  813. YYFPRINTF (stderr, "Stack now");
  814. for (; yybottom <= yytop; yybottom++)
  815. {
  816. int yybot = *yybottom;
  817. YYFPRINTF (stderr, " %d", yybot);
  818. }
  819. YYFPRINTF (stderr, "\n");
  820. }
  821. # define YY_STACK_PRINT(Bottom, Top) \
  822. do { \
  823. if (yydebug) \
  824. yy_stack_print ((Bottom), (Top)); \
  825. } while (0)
  826. /*------------------------------------------------.
  827. | Report that the YYRULE is going to be reduced. |
  828. `------------------------------------------------*/
  829. static void
  830. yy_reduce_print (yytype_int16 *yyssp, YYSTYPE *yyvsp, int yyrule)
  831. {
  832. unsigned long int yylno = yyrline[yyrule];
  833. int yynrhs = yyr2[yyrule];
  834. int yyi;
  835. YYFPRINTF (stderr, "Reducing stack by rule %d (line %lu):\n",
  836. yyrule - 1, yylno);
  837. /* The symbols being reduced. */
  838. for (yyi = 0; yyi < yynrhs; yyi++)
  839. {
  840. YYFPRINTF (stderr, " $%d = ", yyi + 1);
  841. yy_symbol_print (stderr,
  842. yystos[yyssp[yyi + 1 - yynrhs]],
  843. &(yyvsp[(yyi + 1) - (yynrhs)])
  844. );
  845. YYFPRINTF (stderr, "\n");
  846. }
  847. }
  848. # define YY_REDUCE_PRINT(Rule) \
  849. do { \
  850. if (yydebug) \
  851. yy_reduce_print (yyssp, yyvsp, Rule); \
  852. } while (0)
  853. /* Nonzero means print parse trace. It is left uninitialized so that
  854. multiple parsers can coexist. */
  855. int yydebug;
  856. #else /* !YYDEBUG */
  857. # define YYDPRINTF(Args)
  858. # define YY_SYMBOL_PRINT(Title, Type, Value, Location)
  859. # define YY_STACK_PRINT(Bottom, Top)
  860. # define YY_REDUCE_PRINT(Rule)
  861. #endif /* !YYDEBUG */
  862. /* YYINITDEPTH -- initial size of the parser's stacks. */
  863. #ifndef YYINITDEPTH
  864. # define YYINITDEPTH 200
  865. #endif
  866. /* YYMAXDEPTH -- maximum size the stacks can grow to (effective only
  867. if the built-in stack extension method is used).
  868. Do not make this value too large; the results are undefined if
  869. YYSTACK_ALLOC_MAXIMUM < YYSTACK_BYTES (YYMAXDEPTH)
  870. evaluated with infinite-precision integer arithmetic. */
  871. #ifndef YYMAXDEPTH
  872. # define YYMAXDEPTH 10000
  873. #endif
  874. #if YYERROR_VERBOSE
  875. # ifndef yystrlen
  876. # if defined __GLIBC__ && defined _STRING_H
  877. # define yystrlen strlen
  878. # else
  879. /* Return the length of YYSTR. */
  880. static YYSIZE_T
  881. yystrlen (const char *yystr)
  882. {
  883. YYSIZE_T yylen;
  884. for (yylen = 0; yystr[yylen]; yylen++)
  885. continue;
  886. return yylen;
  887. }
  888. # endif
  889. # endif
  890. # ifndef yystpcpy
  891. # if defined __GLIBC__ && defined _STRING_H && defined _GNU_SOURCE
  892. # define yystpcpy stpcpy
  893. # else
  894. /* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in
  895. YYDEST. */
  896. static char *
  897. yystpcpy (char *yydest, const char *yysrc)
  898. {
  899. char *yyd = yydest;
  900. const char *yys = yysrc;
  901. while ((*yyd++ = *yys++) != '\0')
  902. continue;
  903. return yyd - 1;
  904. }
  905. # endif
  906. # endif
  907. # ifndef yytnamerr
  908. /* Copy to YYRES the contents of YYSTR after stripping away unnecessary
  909. quotes and backslashes, so that it's suitable for yyerror. The
  910. heuristic is that double-quoting is unnecessary unless the string
  911. contains an apostrophe, a comma, or backslash (other than
  912. backslash-backslash). YYSTR is taken from yytname. If YYRES is
  913. null, do not copy; instead, return the length of what the result
  914. would have been. */
  915. static YYSIZE_T
  916. yytnamerr (char *yyres, const char *yystr)
  917. {
  918. if (*yystr == '"')
  919. {
  920. YYSIZE_T yyn = 0;
  921. char const *yyp = yystr;
  922. for (;;)
  923. switch (*++yyp)
  924. {
  925. case '\'':
  926. case ',':
  927. goto do_not_strip_quotes;
  928. case '\\':
  929. if (*++yyp != '\\')
  930. goto do_not_strip_quotes;
  931. /* Fall through. */
  932. default:
  933. if (yyres)
  934. yyres[yyn] = *yyp;
  935. yyn++;
  936. break;
  937. case '"':
  938. if (yyres)
  939. yyres[yyn] = '\0';
  940. return yyn;
  941. }
  942. do_not_strip_quotes: ;
  943. }
  944. if (! yyres)
  945. return yystrlen (yystr);
  946. return yystpcpy (yyres, yystr) - yyres;
  947. }
  948. # endif
  949. /* Copy into *YYMSG, which is of size *YYMSG_ALLOC, an error message
  950. about the unexpected token YYTOKEN for the state stack whose top is
  951. YYSSP.
  952. Return 0 if *YYMSG was successfully written. Return 1 if *YYMSG is
  953. not large enough to hold the message. In that case, also set
  954. *YYMSG_ALLOC to the required number of bytes. Return 2 if the
  955. required number of bytes is too large to store. */
  956. static int
  957. yysyntax_error (YYSIZE_T *yymsg_alloc, char **yymsg,
  958. yytype_int16 *yyssp, int yytoken)
  959. {
  960. YYSIZE_T yysize0 = yytnamerr (YY_NULLPTR, yytname[yytoken]);
  961. YYSIZE_T yysize = yysize0;
  962. enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 };
  963. /* Internationalized format string. */
  964. const char *yyformat = YY_NULLPTR;
  965. /* Arguments of yyformat. */
  966. char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM];
  967. /* Number of reported tokens (one for the "unexpected", one per
  968. "expected"). */
  969. int yycount = 0;
  970. /* There are many possibilities here to consider:
  971. - If this state is a consistent state with a default action, then
  972. the only way this function was invoked is if the default action
  973. is an error action. In that case, don't check for expected
  974. tokens because there are none.
  975. - The only way there can be no lookahead present (in yychar) is if
  976. this state is a consistent state with a default action. Thus,
  977. detecting the absence of a lookahead is sufficient to determine
  978. that there is no unexpected or expected token to report. In that
  979. case, just report a simple "syntax error".
  980. - Don't assume there isn't a lookahead just because this state is a
  981. consistent state with a default action. There might have been a
  982. previous inconsistent state, consistent state with a non-default
  983. action, or user semantic action that manipulated yychar.
  984. - Of course, the expected token list depends on states to have
  985. correct lookahead information, and it depends on the parser not
  986. to perform extra reductions after fetching a lookahead from the
  987. scanner and before detecting a syntax error. Thus, state merging
  988. (from LALR or IELR) and default reductions corrupt the expected
  989. token list. However, the list is correct for canonical LR with
  990. one exception: it will still contain any token that will not be
  991. accepted due to an error action in a later state.
  992. */
  993. if (yytoken != YYEMPTY)
  994. {
  995. int yyn = yypact[*yyssp];
  996. yyarg[yycount++] = yytname[yytoken];
  997. if (!yypact_value_is_default (yyn))
  998. {
  999. /* Start YYX at -YYN if negative to avoid negative indexes in
  1000. YYCHECK. In other words, skip the first -YYN actions for
  1001. this state because they are default actions. */
  1002. int yyxbegin = yyn < 0 ? -yyn : 0;
  1003. /* Stay within bounds of both yycheck and yytname. */
  1004. int yychecklim = YYLAST - yyn + 1;
  1005. int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS;
  1006. int yyx;
  1007. for (yyx = yyxbegin; yyx < yyxend; ++yyx)
  1008. if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR
  1009. && !yytable_value_is_error (yytable[yyx + yyn]))
  1010. {
  1011. if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM)
  1012. {
  1013. yycount = 1;
  1014. yysize = yysize0;
  1015. break;
  1016. }
  1017. yyarg[yycount++] = yytname[yyx];
  1018. {
  1019. YYSIZE_T yysize1 = yysize + yytnamerr (YY_NULLPTR, yytname[yyx]);
  1020. if (! (yysize <= yysize1
  1021. && yysize1 <= YYSTACK_ALLOC_MAXIMUM))
  1022. return 2;
  1023. yysize = yysize1;
  1024. }
  1025. }
  1026. }
  1027. }
  1028. switch (yycount)
  1029. {
  1030. # define YYCASE_(N, S) \
  1031. case N: \
  1032. yyformat = S; \
  1033. break
  1034. YYCASE_(0, YY_("syntax error"));
  1035. YYCASE_(1, YY_("syntax error, unexpected %s"));
  1036. YYCASE_(2, YY_("syntax error, unexpected %s, expecting %s"));
  1037. YYCASE_(3, YY_("syntax error, unexpected %s, expecting %s or %s"));
  1038. YYCASE_(4, YY_("syntax error, unexpected %s, expecting %s or %s or %s"));
  1039. YYCASE_(5, YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s"));
  1040. # undef YYCASE_
  1041. }
  1042. {
  1043. YYSIZE_T yysize1 = yysize + yystrlen (yyformat);
  1044. if (! (yysize <= yysize1 && yysize1 <= YYSTACK_ALLOC_MAXIMUM))
  1045. return 2;
  1046. yysize = yysize1;
  1047. }
  1048. if (*yymsg_alloc < yysize)
  1049. {
  1050. *yymsg_alloc = 2 * yysize;
  1051. if (! (yysize <= *yymsg_alloc
  1052. && *yymsg_alloc <= YYSTACK_ALLOC_MAXIMUM))
  1053. *yymsg_alloc = YYSTACK_ALLOC_MAXIMUM;
  1054. return 1;
  1055. }
  1056. /* Avoid sprintf, as that infringes on the user's name space.
  1057. Don't have undefined behavior even if the translation
  1058. produced a string with the wrong number of "%s"s. */
  1059. {
  1060. char *yyp = *yymsg;
  1061. int yyi = 0;
  1062. while ((*yyp = *yyformat) != '\0')
  1063. if (*yyp == '%' && yyformat[1] == 's' && yyi < yycount)
  1064. {
  1065. yyp += yytnamerr (yyp, yyarg[yyi++]);
  1066. yyformat += 2;
  1067. }
  1068. else
  1069. {
  1070. yyp++;
  1071. yyformat++;
  1072. }
  1073. }
  1074. return 0;
  1075. }
  1076. #endif /* YYERROR_VERBOSE */
  1077. /*-----------------------------------------------.
  1078. | Release the memory associated to this symbol. |
  1079. `-----------------------------------------------*/
  1080. static void
  1081. yydestruct (const char *yymsg, int yytype, YYSTYPE *yyvaluep)
  1082. {
  1083. YYUSE (yyvaluep);
  1084. if (!yymsg)
  1085. yymsg = "Deleting";
  1086. YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp);
  1087. YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
  1088. switch (yytype)
  1089. {
  1090. case 58: /* choice_entry */
  1091. {
  1092. fprintf(stderr, "%s:%d: missing end statement for this entry\n",
  1093. ((*yyvaluep).menu)->file->name, ((*yyvaluep).menu)->lineno);
  1094. if (current_menu == ((*yyvaluep).menu))
  1095. menu_end_menu();
  1096. }
  1097. break;
  1098. case 64: /* if_entry */
  1099. {
  1100. fprintf(stderr, "%s:%d: missing end statement for this entry\n",
  1101. ((*yyvaluep).menu)->file->name, ((*yyvaluep).menu)->lineno);
  1102. if (current_menu == ((*yyvaluep).menu))
  1103. menu_end_menu();
  1104. }
  1105. break;
  1106. case 70: /* menu_entry */
  1107. {
  1108. fprintf(stderr, "%s:%d: missing end statement for this entry\n",
  1109. ((*yyvaluep).menu)->file->name, ((*yyvaluep).menu)->lineno);
  1110. if (current_menu == ((*yyvaluep).menu))
  1111. menu_end_menu();
  1112. }
  1113. break;
  1114. default:
  1115. break;
  1116. }
  1117. YY_IGNORE_MAYBE_UNINITIALIZED_END
  1118. }
  1119. /* The lookahead symbol. */
  1120. int yychar;
  1121. /* The semantic value of the lookahead symbol. */
  1122. YYSTYPE yylval;
  1123. /* Number of syntax errors so far. */
  1124. int yynerrs;
  1125. /*----------.
  1126. | yyparse. |
  1127. `----------*/
  1128. int
  1129. yyparse (void)
  1130. {
  1131. int yystate;
  1132. /* Number of tokens to shift before error messages enabled. */
  1133. int yyerrstatus;
  1134. /* The stacks and their tools:
  1135. 'yyss': related to states.
  1136. 'yyvs': related to semantic values.
  1137. Refer to the stacks through separate pointers, to allow yyoverflow
  1138. to reallocate them elsewhere. */
  1139. /* The state stack. */
  1140. yytype_int16 yyssa[YYINITDEPTH];
  1141. yytype_int16 *yyss;
  1142. yytype_int16 *yyssp;
  1143. /* The semantic value stack. */
  1144. YYSTYPE yyvsa[YYINITDEPTH];
  1145. YYSTYPE *yyvs;
  1146. YYSTYPE *yyvsp;
  1147. YYSIZE_T yystacksize;
  1148. int yyn;
  1149. int yyresult;
  1150. /* Lookahead token as an internal (translated) token number. */
  1151. int yytoken = 0;
  1152. /* The variables used to return semantic value and location from the
  1153. action routines. */
  1154. YYSTYPE yyval;
  1155. #if YYERROR_VERBOSE
  1156. /* Buffer for error messages, and its allocated size. */
  1157. char yymsgbuf[128];
  1158. char *yymsg = yymsgbuf;
  1159. YYSIZE_T yymsg_alloc = sizeof yymsgbuf;
  1160. #endif
  1161. #define YYPOPSTACK(N) (yyvsp -= (N), yyssp -= (N))
  1162. /* The number of symbols on the RHS of the reduced rule.
  1163. Keep to zero when no symbol should be popped. */
  1164. int yylen = 0;
  1165. yyssp = yyss = yyssa;
  1166. yyvsp = yyvs = yyvsa;
  1167. yystacksize = YYINITDEPTH;
  1168. YYDPRINTF ((stderr, "Starting parse\n"));
  1169. yystate = 0;
  1170. yyerrstatus = 0;
  1171. yynerrs = 0;
  1172. yychar = YYEMPTY; /* Cause a token to be read. */
  1173. goto yysetstate;
  1174. /*------------------------------------------------------------.
  1175. | yynewstate -- Push a new state, which is found in yystate. |
  1176. `------------------------------------------------------------*/
  1177. yynewstate:
  1178. /* In all cases, when you get here, the value and location stacks
  1179. have just been pushed. So pushing a state here evens the stacks. */
  1180. yyssp++;
  1181. yysetstate:
  1182. *yyssp = yystate;
  1183. if (yyss + yystacksize - 1 <= yyssp)
  1184. {
  1185. /* Get the current used size of the three stacks, in elements. */
  1186. YYSIZE_T yysize = yyssp - yyss + 1;
  1187. #ifdef yyoverflow
  1188. {
  1189. /* Give user a chance to reallocate the stack. Use copies of
  1190. these so that the &'s don't force the real ones into
  1191. memory. */
  1192. YYSTYPE *yyvs1 = yyvs;
  1193. yytype_int16 *yyss1 = yyss;
  1194. /* Each stack pointer address is followed by the size of the
  1195. data in use in that stack, in bytes. This used to be a
  1196. conditional around just the two extra args, but that might
  1197. be undefined if yyoverflow is a macro. */
  1198. yyoverflow (YY_("memory exhausted"),
  1199. &yyss1, yysize * sizeof (*yyssp),
  1200. &yyvs1, yysize * sizeof (*yyvsp),
  1201. &yystacksize);
  1202. yyss = yyss1;
  1203. yyvs = yyvs1;
  1204. }
  1205. #else /* no yyoverflow */
  1206. # ifndef YYSTACK_RELOCATE
  1207. goto yyexhaustedlab;
  1208. # else
  1209. /* Extend the stack our own way. */
  1210. if (YYMAXDEPTH <= yystacksize)
  1211. goto yyexhaustedlab;
  1212. yystacksize *= 2;
  1213. if (YYMAXDEPTH < yystacksize)
  1214. yystacksize = YYMAXDEPTH;
  1215. {
  1216. yytype_int16 *yyss1 = yyss;
  1217. union yyalloc *yyptr =
  1218. (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize));
  1219. if (! yyptr)
  1220. goto yyexhaustedlab;
  1221. YYSTACK_RELOCATE (yyss_alloc, yyss);
  1222. YYSTACK_RELOCATE (yyvs_alloc, yyvs);
  1223. # undef YYSTACK_RELOCATE
  1224. if (yyss1 != yyssa)
  1225. YYSTACK_FREE (yyss1);
  1226. }
  1227. # endif
  1228. #endif /* no yyoverflow */
  1229. yyssp = yyss + yysize - 1;
  1230. yyvsp = yyvs + yysize - 1;
  1231. YYDPRINTF ((stderr, "Stack size increased to %lu\n",
  1232. (unsigned long int) yystacksize));
  1233. if (yyss + yystacksize - 1 <= yyssp)
  1234. YYABORT;
  1235. }
  1236. YYDPRINTF ((stderr, "Entering state %d\n", yystate));
  1237. if (yystate == YYFINAL)
  1238. YYACCEPT;
  1239. goto yybackup;
  1240. /*-----------.
  1241. | yybackup. |
  1242. `-----------*/
  1243. yybackup:
  1244. /* Do appropriate processing given the current state. Read a
  1245. lookahead token if we need one and don't already have one. */
  1246. /* First try to decide what to do without reference to lookahead token. */
  1247. yyn = yypact[yystate];
  1248. if (yypact_value_is_default (yyn))
  1249. goto yydefault;
  1250. /* Not known => get a lookahead token if don't already have one. */
  1251. /* YYCHAR is either YYEMPTY or YYEOF or a valid lookahead symbol. */
  1252. if (yychar == YYEMPTY)
  1253. {
  1254. YYDPRINTF ((stderr, "Reading a token: "));
  1255. yychar = yylex ();
  1256. }
  1257. if (yychar <= YYEOF)
  1258. {
  1259. yychar = yytoken = YYEOF;
  1260. YYDPRINTF ((stderr, "Now at end of input.\n"));
  1261. }
  1262. else
  1263. {
  1264. yytoken = YYTRANSLATE (yychar);
  1265. YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc);
  1266. }
  1267. /* If the proper action on seeing token YYTOKEN is to reduce or to
  1268. detect an error, take that action. */
  1269. yyn += yytoken;
  1270. if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken)
  1271. goto yydefault;
  1272. yyn = yytable[yyn];
  1273. if (yyn <= 0)
  1274. {
  1275. if (yytable_value_is_error (yyn))
  1276. goto yyerrlab;
  1277. yyn = -yyn;
  1278. goto yyreduce;
  1279. }
  1280. /* Count tokens shifted since error; after three, turn off error
  1281. status. */
  1282. if (yyerrstatus)
  1283. yyerrstatus--;
  1284. /* Shift the lookahead token. */
  1285. YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc);
  1286. /* Discard the shifted token. */
  1287. yychar = YYEMPTY;
  1288. yystate = yyn;
  1289. YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
  1290. *++yyvsp = yylval;
  1291. YY_IGNORE_MAYBE_UNINITIALIZED_END
  1292. goto yynewstate;
  1293. /*-----------------------------------------------------------.
  1294. | yydefault -- do the default action for the current state. |
  1295. `-----------------------------------------------------------*/
  1296. yydefault:
  1297. yyn = yydefact[yystate];
  1298. if (yyn == 0)
  1299. goto yyerrlab;
  1300. goto yyreduce;
  1301. /*-----------------------------.
  1302. | yyreduce -- Do a reduction. |
  1303. `-----------------------------*/
  1304. yyreduce:
  1305. /* yyn is the number of a rule to reduce with. */
  1306. yylen = yyr2[yyn];
  1307. /* If YYLEN is nonzero, implement the default value of the action:
  1308. '$$ = $1'.
  1309. Otherwise, the following line sets YYVAL to garbage.
  1310. This behavior is undocumented and Bison
  1311. users should not rely upon it. Assigning to YYVAL
  1312. unconditionally makes the parser a bit smaller, and it avoids a
  1313. GCC warning that YYVAL may be used uninitialized. */
  1314. yyval = yyvsp[1-yylen];
  1315. YY_REDUCE_PRINT (yyn);
  1316. switch (yyn)
  1317. {
  1318. case 10:
  1319. { zconf_error("unexpected end statement"); }
  1320. break;
  1321. case 11:
  1322. { zconf_error("unknown statement \"%s\"", (yyvsp[-2].string)); }
  1323. break;
  1324. case 12:
  1325. {
  1326. zconf_error("unexpected option \"%s\"", kconf_id_strings + (yyvsp[-2].id)->name);
  1327. }
  1328. break;
  1329. case 13:
  1330. { zconf_error("invalid statement"); }
  1331. break;
  1332. case 29:
  1333. { zconf_error("unknown option \"%s\"", (yyvsp[-2].string)); }
  1334. break;
  1335. case 30:
  1336. { zconf_error("invalid option"); }
  1337. break;
  1338. case 31:
  1339. {
  1340. struct symbol *sym = sym_lookup((yyvsp[-1].string), 0);
  1341. sym->flags |= SYMBOL_OPTIONAL;
  1342. menu_add_entry(sym);
  1343. printd(DEBUG_PARSE, "%s:%d:config %s\n", zconf_curname(), zconf_lineno(), (yyvsp[-1].string));
  1344. }
  1345. break;
  1346. case 32:
  1347. {
  1348. menu_end_entry();
  1349. printd(DEBUG_PARSE, "%s:%d:endconfig\n", zconf_curname(), zconf_lineno());
  1350. }
  1351. break;
  1352. case 33:
  1353. {
  1354. struct symbol *sym = sym_lookup((yyvsp[-1].string), 0);
  1355. sym->flags |= SYMBOL_OPTIONAL;
  1356. menu_add_entry(sym);
  1357. printd(DEBUG_PARSE, "%s:%d:menuconfig %s\n", zconf_curname(), zconf_lineno(), (yyvsp[-1].string));
  1358. }
  1359. break;
  1360. case 34:
  1361. {
  1362. if (current_entry->prompt)
  1363. current_entry->prompt->type = P_MENU;
  1364. else
  1365. zconfprint("warning: menuconfig statement without prompt");
  1366. menu_end_entry();
  1367. printd(DEBUG_PARSE, "%s:%d:endconfig\n", zconf_curname(), zconf_lineno());
  1368. }
  1369. break;
  1370. case 42:
  1371. {
  1372. menu_set_type((yyvsp[-2].id)->stype);
  1373. printd(DEBUG_PARSE, "%s:%d:type(%u)\n",
  1374. zconf_curname(), zconf_lineno(),
  1375. (yyvsp[-2].id)->stype);
  1376. }
  1377. break;
  1378. case 43:
  1379. {
  1380. menu_add_prompt(P_PROMPT, (yyvsp[-2].string), (yyvsp[-1].expr));
  1381. printd(DEBUG_PARSE, "%s:%d:prompt\n", zconf_curname(), zconf_lineno());
  1382. }
  1383. break;
  1384. case 44:
  1385. {
  1386. menu_add_expr(P_DEFAULT, (yyvsp[-2].expr), (yyvsp[-1].expr));
  1387. if ((yyvsp[-3].id)->stype != S_UNKNOWN)
  1388. menu_set_type((yyvsp[-3].id)->stype);
  1389. printd(DEBUG_PARSE, "%s:%d:default(%u)\n",
  1390. zconf_curname(), zconf_lineno(),
  1391. (yyvsp[-3].id)->stype);
  1392. }
  1393. break;
  1394. case 45:
  1395. {
  1396. menu_add_symbol(P_SELECT, sym_lookup((yyvsp[-2].string), 0), (yyvsp[-1].expr));
  1397. printd(DEBUG_PARSE, "%s:%d:select\n", zconf_curname(), zconf_lineno());
  1398. }
  1399. break;
  1400. case 46:
  1401. {
  1402. menu_add_symbol(P_IMPLY, sym_lookup((yyvsp[-2].string), 0), (yyvsp[-1].expr));
  1403. printd(DEBUG_PARSE, "%s:%d:imply\n", zconf_curname(), zconf_lineno());
  1404. }
  1405. break;
  1406. case 47:
  1407. {
  1408. menu_add_expr(P_RANGE, expr_alloc_comp(E_RANGE,(yyvsp[-3].symbol), (yyvsp[-2].symbol)), (yyvsp[-1].expr));
  1409. printd(DEBUG_PARSE, "%s:%d:range\n", zconf_curname(), zconf_lineno());
  1410. }
  1411. break;
  1412. case 50:
  1413. {
  1414. const struct kconf_id *id = kconf_id_lookup((yyvsp[-1].string), strlen((yyvsp[-1].string)));
  1415. if (id && id->flags & TF_OPTION)
  1416. menu_add_option(id->token, (yyvsp[0].string));
  1417. else
  1418. zconfprint("warning: ignoring unknown option %s", (yyvsp[-1].string));
  1419. free((yyvsp[-1].string));
  1420. }
  1421. break;
  1422. case 51:
  1423. { (yyval.string) = NULL; }
  1424. break;
  1425. case 52:
  1426. { (yyval.string) = (yyvsp[0].string); }
  1427. break;
  1428. case 53:
  1429. {
  1430. struct symbol *sym = sym_lookup((yyvsp[-1].string), SYMBOL_CHOICE);
  1431. sym->flags |= SYMBOL_AUTO;
  1432. menu_add_entry(sym);
  1433. menu_add_expr(P_CHOICE, NULL, NULL);
  1434. printd(DEBUG_PARSE, "%s:%d:choice\n", zconf_curname(), zconf_lineno());
  1435. }
  1436. break;
  1437. case 54:
  1438. {
  1439. (yyval.menu) = menu_add_menu();
  1440. }
  1441. break;
  1442. case 55:
  1443. {
  1444. if (zconf_endtoken((yyvsp[0].id), T_CHOICE, T_ENDCHOICE)) {
  1445. menu_end_menu();
  1446. printd(DEBUG_PARSE, "%s:%d:endchoice\n", zconf_curname(), zconf_lineno());
  1447. }
  1448. }
  1449. break;
  1450. case 63:
  1451. {
  1452. menu_add_prompt(P_PROMPT, (yyvsp[-2].string), (yyvsp[-1].expr));
  1453. printd(DEBUG_PARSE, "%s:%d:prompt\n", zconf_curname(), zconf_lineno());
  1454. }
  1455. break;
  1456. case 64:
  1457. {
  1458. if ((yyvsp[-2].id)->stype == S_BOOLEAN || (yyvsp[-2].id)->stype == S_TRISTATE) {
  1459. menu_set_type((yyvsp[-2].id)->stype);
  1460. printd(DEBUG_PARSE, "%s:%d:type(%u)\n",
  1461. zconf_curname(), zconf_lineno(),
  1462. (yyvsp[-2].id)->stype);
  1463. } else
  1464. YYERROR;
  1465. }
  1466. break;
  1467. case 65:
  1468. {
  1469. current_entry->sym->flags |= SYMBOL_OPTIONAL;
  1470. printd(DEBUG_PARSE, "%s:%d:optional\n", zconf_curname(), zconf_lineno());
  1471. }
  1472. break;
  1473. case 66:
  1474. {
  1475. if ((yyvsp[-3].id)->stype == S_UNKNOWN) {
  1476. menu_add_symbol(P_DEFAULT, sym_lookup((yyvsp[-2].string), 0), (yyvsp[-1].expr));
  1477. printd(DEBUG_PARSE, "%s:%d:default\n",
  1478. zconf_curname(), zconf_lineno());
  1479. } else
  1480. YYERROR;
  1481. }
  1482. break;
  1483. case 69:
  1484. {
  1485. printd(DEBUG_PARSE, "%s:%d:if\n", zconf_curname(), zconf_lineno());
  1486. menu_add_entry(NULL);
  1487. menu_add_dep((yyvsp[-1].expr));
  1488. (yyval.menu) = menu_add_menu();
  1489. }
  1490. break;
  1491. case 70:
  1492. {
  1493. if (zconf_endtoken((yyvsp[0].id), T_IF, T_ENDIF)) {
  1494. menu_end_menu();
  1495. printd(DEBUG_PARSE, "%s:%d:endif\n", zconf_curname(), zconf_lineno());
  1496. }
  1497. }
  1498. break;
  1499. case 76:
  1500. {
  1501. menu_add_prompt(P_MENU, (yyvsp[-1].string), NULL);
  1502. }
  1503. break;
  1504. case 77:
  1505. {
  1506. menu_add_entry(NULL);
  1507. menu_add_prompt(P_MENU, (yyvsp[-1].string), NULL);
  1508. printd(DEBUG_PARSE, "%s:%d:menu\n", zconf_curname(), zconf_lineno());
  1509. }
  1510. break;
  1511. case 78:
  1512. {
  1513. (yyval.menu) = menu_add_menu();
  1514. }
  1515. break;
  1516. case 79:
  1517. {
  1518. if (zconf_endtoken((yyvsp[0].id), T_MENU, T_ENDMENU)) {
  1519. menu_end_menu();
  1520. printd(DEBUG_PARSE, "%s:%d:endmenu\n", zconf_curname(), zconf_lineno());
  1521. }
  1522. }
  1523. break;
  1524. case 85:
  1525. {
  1526. printd(DEBUG_PARSE, "%s:%d:source %s\n", zconf_curname(), zconf_lineno(), (yyvsp[-1].string));
  1527. zconf_nextfile((yyvsp[-1].string));
  1528. }
  1529. break;
  1530. case 86:
  1531. {
  1532. menu_add_entry(NULL);
  1533. menu_add_prompt(P_COMMENT, (yyvsp[-1].string), NULL);
  1534. printd(DEBUG_PARSE, "%s:%d:comment\n", zconf_curname(), zconf_lineno());
  1535. }
  1536. break;
  1537. case 87:
  1538. {
  1539. menu_end_entry();
  1540. }
  1541. break;
  1542. case 88:
  1543. {
  1544. printd(DEBUG_PARSE, "%s:%d:help\n", zconf_curname(), zconf_lineno());
  1545. zconf_starthelp();
  1546. }
  1547. break;
  1548. case 89:
  1549. {
  1550. current_entry->help = (yyvsp[0].string);
  1551. }
  1552. break;
  1553. case 94:
  1554. {
  1555. menu_add_dep((yyvsp[-1].expr));
  1556. printd(DEBUG_PARSE, "%s:%d:depends on\n", zconf_curname(), zconf_lineno());
  1557. }
  1558. break;
  1559. case 98:
  1560. {
  1561. menu_add_visibility((yyvsp[0].expr));
  1562. }
  1563. break;
  1564. case 100:
  1565. {
  1566. menu_add_prompt(P_PROMPT, (yyvsp[-1].string), (yyvsp[0].expr));
  1567. }
  1568. break;
  1569. case 103:
  1570. { (yyval.id) = (yyvsp[-1].id); }
  1571. break;
  1572. case 104:
  1573. { (yyval.id) = (yyvsp[-1].id); }
  1574. break;
  1575. case 105:
  1576. { (yyval.id) = (yyvsp[-1].id); }
  1577. break;
  1578. case 108:
  1579. { (yyval.expr) = NULL; }
  1580. break;
  1581. case 109:
  1582. { (yyval.expr) = (yyvsp[0].expr); }
  1583. break;
  1584. case 110:
  1585. { (yyval.expr) = expr_alloc_symbol((yyvsp[0].symbol)); }
  1586. break;
  1587. case 111:
  1588. { (yyval.expr) = expr_alloc_comp(E_LTH, (yyvsp[-2].symbol), (yyvsp[0].symbol)); }
  1589. break;
  1590. case 112:
  1591. { (yyval.expr) = expr_alloc_comp(E_LEQ, (yyvsp[-2].symbol), (yyvsp[0].symbol)); }
  1592. break;
  1593. case 113:
  1594. { (yyval.expr) = expr_alloc_comp(E_GTH, (yyvsp[-2].symbol), (yyvsp[0].symbol)); }
  1595. break;
  1596. case 114:
  1597. { (yyval.expr) = expr_alloc_comp(E_GEQ, (yyvsp[-2].symbol), (yyvsp[0].symbol)); }
  1598. break;
  1599. case 115:
  1600. { (yyval.expr) = expr_alloc_comp(E_EQUAL, (yyvsp[-2].symbol), (yyvsp[0].symbol)); }
  1601. break;
  1602. case 116:
  1603. { (yyval.expr) = expr_alloc_comp(E_UNEQUAL, (yyvsp[-2].symbol), (yyvsp[0].symbol)); }
  1604. break;
  1605. case 117:
  1606. { (yyval.expr) = (yyvsp[-1].expr); }
  1607. break;
  1608. case 118:
  1609. { (yyval.expr) = expr_alloc_one(E_NOT, (yyvsp[0].expr)); }
  1610. break;
  1611. case 119:
  1612. { (yyval.expr) = expr_alloc_two(E_OR, (yyvsp[-2].expr), (yyvsp[0].expr)); }
  1613. break;
  1614. case 120:
  1615. { (yyval.expr) = expr_alloc_two(E_AND, (yyvsp[-2].expr), (yyvsp[0].expr)); }
  1616. break;
  1617. case 121:
  1618. { (yyval.symbol) = sym_lookup((yyvsp[0].string), 0); free((yyvsp[0].string)); }
  1619. break;
  1620. case 122:
  1621. { (yyval.symbol) = sym_lookup((yyvsp[0].string), SYMBOL_CONST); free((yyvsp[0].string)); }
  1622. break;
  1623. case 123:
  1624. { (yyval.string) = NULL; }
  1625. break;
  1626. default: break;
  1627. }
  1628. /* User semantic actions sometimes alter yychar, and that requires
  1629. that yytoken be updated with the new translation. We take the
  1630. approach of translating immediately before every use of yytoken.
  1631. One alternative is translating here after every semantic action,
  1632. but that translation would be missed if the semantic action invokes
  1633. YYABORT, YYACCEPT, or YYERROR immediately after altering yychar or
  1634. if it invokes YYBACKUP. In the case of YYABORT or YYACCEPT, an
  1635. incorrect destructor might then be invoked immediately. In the
  1636. case of YYERROR or YYBACKUP, subsequent parser actions might lead
  1637. to an incorrect destructor call or verbose syntax error message
  1638. before the lookahead is translated. */
  1639. YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc);
  1640. YYPOPSTACK (yylen);
  1641. yylen = 0;
  1642. YY_STACK_PRINT (yyss, yyssp);
  1643. *++yyvsp = yyval;
  1644. /* Now 'shift' the result of the reduction. Determine what state
  1645. that goes to, based on the state we popped back to and the rule
  1646. number reduced by. */
  1647. yyn = yyr1[yyn];
  1648. yystate = yypgoto[yyn - YYNTOKENS] + *yyssp;
  1649. if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp)
  1650. yystate = yytable[yystate];
  1651. else
  1652. yystate = yydefgoto[yyn - YYNTOKENS];
  1653. goto yynewstate;
  1654. /*--------------------------------------.
  1655. | yyerrlab -- here on detecting error. |
  1656. `--------------------------------------*/
  1657. yyerrlab:
  1658. /* Make sure we have latest lookahead translation. See comments at
  1659. user semantic actions for why this is necessary. */
  1660. yytoken = yychar == YYEMPTY ? YYEMPTY : YYTRANSLATE (yychar);
  1661. /* If not already recovering from an error, report this error. */
  1662. if (!yyerrstatus)
  1663. {
  1664. ++yynerrs;
  1665. #if ! YYERROR_VERBOSE
  1666. yyerror (YY_("syntax error"));
  1667. #else
  1668. # define YYSYNTAX_ERROR yysyntax_error (&yymsg_alloc, &yymsg, \
  1669. yyssp, yytoken)
  1670. {
  1671. char const *yymsgp = YY_("syntax error");
  1672. int yysyntax_error_status;
  1673. yysyntax_error_status = YYSYNTAX_ERROR;
  1674. if (yysyntax_error_status == 0)
  1675. yymsgp = yymsg;
  1676. else if (yysyntax_error_status == 1)
  1677. {
  1678. if (yymsg != yymsgbuf)
  1679. YYSTACK_FREE (yymsg);
  1680. yymsg = (char *) YYSTACK_ALLOC (yymsg_alloc);
  1681. if (!yymsg)
  1682. {
  1683. yymsg = yymsgbuf;
  1684. yymsg_alloc = sizeof yymsgbuf;
  1685. yysyntax_error_status = 2;
  1686. }
  1687. else
  1688. {
  1689. yysyntax_error_status = YYSYNTAX_ERROR;
  1690. yymsgp = yymsg;
  1691. }
  1692. }
  1693. yyerror (yymsgp);
  1694. if (yysyntax_error_status == 2)
  1695. goto yyexhaustedlab;
  1696. }
  1697. # undef YYSYNTAX_ERROR
  1698. #endif
  1699. }
  1700. if (yyerrstatus == 3)
  1701. {
  1702. /* If just tried and failed to reuse lookahead token after an
  1703. error, discard it. */
  1704. if (yychar <= YYEOF)
  1705. {
  1706. /* Return failure if at end of input. */
  1707. if (yychar == YYEOF)
  1708. YYABORT;
  1709. }
  1710. else
  1711. {
  1712. yydestruct ("Error: discarding",
  1713. yytoken, &yylval);
  1714. yychar = YYEMPTY;
  1715. }
  1716. }
  1717. /* Else will try to reuse lookahead token after shifting the error
  1718. token. */
  1719. goto yyerrlab1;
  1720. /*---------------------------------------------------.
  1721. | yyerrorlab -- error raised explicitly by YYERROR. |
  1722. `---------------------------------------------------*/
  1723. yyerrorlab:
  1724. /* Pacify compilers like GCC when the user code never invokes
  1725. YYERROR and the label yyerrorlab therefore never appears in user
  1726. code. */
  1727. if (/*CONSTCOND*/ 0)
  1728. goto yyerrorlab;
  1729. /* Do not reclaim the symbols of the rule whose action triggered
  1730. this YYERROR. */
  1731. YYPOPSTACK (yylen);
  1732. yylen = 0;
  1733. YY_STACK_PRINT (yyss, yyssp);
  1734. yystate = *yyssp;
  1735. goto yyerrlab1;
  1736. /*-------------------------------------------------------------.
  1737. | yyerrlab1 -- common code for both syntax error and YYERROR. |
  1738. `-------------------------------------------------------------*/
  1739. yyerrlab1:
  1740. yyerrstatus = 3; /* Each real token shifted decrements this. */
  1741. for (;;)
  1742. {
  1743. yyn = yypact[yystate];
  1744. if (!yypact_value_is_default (yyn))
  1745. {
  1746. yyn += YYTERROR;
  1747. if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR)
  1748. {
  1749. yyn = yytable[yyn];
  1750. if (0 < yyn)
  1751. break;
  1752. }
  1753. }
  1754. /* Pop the current state because it cannot handle the error token. */
  1755. if (yyssp == yyss)
  1756. YYABORT;
  1757. yydestruct ("Error: popping",
  1758. yystos[yystate], yyvsp);
  1759. YYPOPSTACK (1);
  1760. yystate = *yyssp;
  1761. YY_STACK_PRINT (yyss, yyssp);
  1762. }
  1763. YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
  1764. *++yyvsp = yylval;
  1765. YY_IGNORE_MAYBE_UNINITIALIZED_END
  1766. /* Shift the error token. */
  1767. YY_SYMBOL_PRINT ("Shifting", yystos[yyn], yyvsp, yylsp);
  1768. yystate = yyn;
  1769. goto yynewstate;
  1770. /*-------------------------------------.
  1771. | yyacceptlab -- YYACCEPT comes here. |
  1772. `-------------------------------------*/
  1773. yyacceptlab:
  1774. yyresult = 0;
  1775. goto yyreturn;
  1776. /*-----------------------------------.
  1777. | yyabortlab -- YYABORT comes here. |
  1778. `-----------------------------------*/
  1779. yyabortlab:
  1780. yyresult = 1;
  1781. goto yyreturn;
  1782. #if !defined yyoverflow || YYERROR_VERBOSE
  1783. /*-------------------------------------------------.
  1784. | yyexhaustedlab -- memory exhaustion comes here. |
  1785. `-------------------------------------------------*/
  1786. yyexhaustedlab:
  1787. yyerror (YY_("memory exhausted"));
  1788. yyresult = 2;
  1789. /* Fall through. */
  1790. #endif
  1791. yyreturn:
  1792. if (yychar != YYEMPTY)
  1793. {
  1794. /* Make sure we have latest lookahead translation. See comments at
  1795. user semantic actions for why this is necessary. */
  1796. yytoken = YYTRANSLATE (yychar);
  1797. yydestruct ("Cleanup: discarding lookahead",
  1798. yytoken, &yylval);
  1799. }
  1800. /* Do not reclaim the symbols of the rule whose action triggered
  1801. this YYABORT or YYACCEPT. */
  1802. YYPOPSTACK (yylen);
  1803. YY_STACK_PRINT (yyss, yyssp);
  1804. while (yyssp != yyss)
  1805. {
  1806. yydestruct ("Cleanup: popping",
  1807. yystos[*yyssp], yyvsp);
  1808. YYPOPSTACK (1);
  1809. }
  1810. #ifndef yyoverflow
  1811. if (yyss != yyssa)
  1812. YYSTACK_FREE (yyss);
  1813. #endif
  1814. #if YYERROR_VERBOSE
  1815. if (yymsg != yymsgbuf)
  1816. YYSTACK_FREE (yymsg);
  1817. #endif
  1818. return yyresult;
  1819. }
  1820. void conf_parse(const char *name)
  1821. {
  1822. struct symbol *sym;
  1823. int i;
  1824. zconf_initscan(name);
  1825. sym_init();
  1826. _menu_init();
  1827. rootmenu.prompt = menu_add_prompt(P_MENU, ROOTMENU, NULL);
  1828. if (getenv("ZCONF_DEBUG"))
  1829. zconfdebug = 1;
  1830. zconfparse();
  1831. if (zconfnerrs)
  1832. exit(1);
  1833. if (!modules_sym)
  1834. modules_sym = sym_find( "n" );
  1835. rootmenu.prompt->text = _(rootmenu.prompt->text);
  1836. rootmenu.prompt->text = sym_expand_string_value(rootmenu.prompt->text);
  1837. menu_finalize(&rootmenu);
  1838. for_all_symbols(i, sym) {
  1839. if (sym_check_deps(sym))
  1840. zconfnerrs++;
  1841. }
  1842. if (zconfnerrs)
  1843. exit(1);
  1844. sym_set_change_count(1);
  1845. }
  1846. static const char *zconf_tokenname(int token)
  1847. {
  1848. switch (token) {
  1849. case T_MENU: return "menu";
  1850. case T_ENDMENU: return "endmenu";
  1851. case T_CHOICE: return "choice";
  1852. case T_ENDCHOICE: return "endchoice";
  1853. case T_IF: return "if";
  1854. case T_ENDIF: return "endif";
  1855. case T_DEPENDS: return "depends";
  1856. case T_VISIBLE: return "visible";
  1857. }
  1858. return "<token>";
  1859. }
  1860. static bool zconf_endtoken(const struct kconf_id *id, int starttoken, int endtoken)
  1861. {
  1862. if (id->token != endtoken) {
  1863. zconf_error("unexpected '%s' within %s block",
  1864. kconf_id_strings + id->name, zconf_tokenname(starttoken));
  1865. zconfnerrs++;
  1866. return false;
  1867. }
  1868. if (current_menu->file != current_file) {
  1869. zconf_error("'%s' in different file than '%s'",
  1870. kconf_id_strings + id->name, zconf_tokenname(starttoken));
  1871. fprintf(stderr, "%s:%d: location of the '%s'\n",
  1872. current_menu->file->name, current_menu->lineno,
  1873. zconf_tokenname(starttoken));
  1874. zconfnerrs++;
  1875. return false;
  1876. }
  1877. return true;
  1878. }
  1879. static void zconfprint(const char *err, ...)
  1880. {
  1881. va_list ap;
  1882. fprintf(stderr, "%s:%d: ", zconf_curname(), zconf_lineno());
  1883. va_start(ap, err);
  1884. vfprintf(stderr, err, ap);
  1885. va_end(ap);
  1886. fprintf(stderr, "\n");
  1887. }
  1888. static void zconf_error(const char *err, ...)
  1889. {
  1890. va_list ap;
  1891. zconfnerrs++;
  1892. fprintf(stderr, "%s:%d: ", zconf_curname(), zconf_lineno());
  1893. va_start(ap, err);
  1894. vfprintf(stderr, err, ap);
  1895. va_end(ap);
  1896. fprintf(stderr, "\n");
  1897. }
  1898. static void zconferror(const char *err)
  1899. {
  1900. fprintf(stderr, "%s:%d: %s\n", zconf_curname(), zconf_lineno() + 1, err);
  1901. }
  1902. static void print_quoted_string(FILE *out, const char *str)
  1903. {
  1904. const char *p;
  1905. int len;
  1906. putc('"', out);
  1907. while ((p = strchr(str, '"'))) {
  1908. len = p - str;
  1909. if (len)
  1910. fprintf(out, "%.*s", len, str);
  1911. fputs("\\\"", out);
  1912. str = p + 1;
  1913. }
  1914. fputs(str, out);
  1915. putc('"', out);
  1916. }
  1917. static void print_symbol(FILE *out, struct menu *menu)
  1918. {
  1919. struct symbol *sym = menu->sym;
  1920. struct property *prop;
  1921. if (sym_is_choice(sym))
  1922. fprintf(out, "\nchoice\n");
  1923. else
  1924. fprintf(out, "\nconfig %s\n", sym->name);
  1925. switch (sym->type) {
  1926. case S_BOOLEAN:
  1927. fputs(" boolean\n", out);
  1928. break;
  1929. case S_TRISTATE:
  1930. fputs(" tristate\n", out);
  1931. break;
  1932. case S_STRING:
  1933. fputs(" string\n", out);
  1934. break;
  1935. case S_INT:
  1936. fputs(" integer\n", out);
  1937. break;
  1938. case S_HEX:
  1939. fputs(" hex\n", out);
  1940. break;
  1941. default:
  1942. fputs(" ???\n", out);
  1943. break;
  1944. }
  1945. for (prop = sym->prop; prop; prop = prop->next) {
  1946. if (prop->menu != menu)
  1947. continue;
  1948. switch (prop->type) {
  1949. case P_PROMPT:
  1950. fputs(" prompt ", out);
  1951. print_quoted_string(out, prop->text);
  1952. if (!expr_is_yes(prop->visible.expr)) {
  1953. fputs(" if ", out);
  1954. expr_fprint(prop->visible.expr, out);
  1955. }
  1956. fputc('\n', out);
  1957. break;
  1958. case P_DEFAULT:
  1959. fputs( " default ", out);
  1960. expr_fprint(prop->expr, out);
  1961. if (!expr_is_yes(prop->visible.expr)) {
  1962. fputs(" if ", out);
  1963. expr_fprint(prop->visible.expr, out);
  1964. }
  1965. fputc('\n', out);
  1966. break;
  1967. case P_CHOICE:
  1968. fputs(" #choice value\n", out);
  1969. break;
  1970. case P_SELECT:
  1971. fputs( " select ", out);
  1972. expr_fprint(prop->expr, out);
  1973. fputc('\n', out);
  1974. break;
  1975. case P_IMPLY:
  1976. fputs( " imply ", out);
  1977. expr_fprint(prop->expr, out);
  1978. fputc('\n', out);
  1979. break;
  1980. case P_RANGE:
  1981. fputs( " range ", out);
  1982. expr_fprint(prop->expr, out);
  1983. fputc('\n', out);
  1984. break;
  1985. case P_MENU:
  1986. fputs( " menu ", out);
  1987. print_quoted_string(out, prop->text);
  1988. fputc('\n', out);
  1989. break;
  1990. default:
  1991. fprintf(out, " unknown prop %d!\n", prop->type);
  1992. break;
  1993. }
  1994. }
  1995. if (menu->help) {
  1996. int len = strlen(menu->help);
  1997. while (menu->help[--len] == '\n')
  1998. menu->help[len] = 0;
  1999. fprintf(out, " help\n%s\n", menu->help);
  2000. }
  2001. }
  2002. void zconfdump(FILE *out)
  2003. {
  2004. struct property *prop;
  2005. struct symbol *sym;
  2006. struct menu *menu;
  2007. menu = rootmenu.list;
  2008. while (menu) {
  2009. if ((sym = menu->sym))
  2010. print_symbol(out, menu);
  2011. else if ((prop = menu->prompt)) {
  2012. switch (prop->type) {
  2013. case P_COMMENT:
  2014. fputs("\ncomment ", out);
  2015. print_quoted_string(out, prop->text);
  2016. fputs("\n", out);
  2017. break;
  2018. case P_MENU:
  2019. fputs("\nmenu ", out);
  2020. print_quoted_string(out, prop->text);
  2021. fputs("\n", out);
  2022. break;
  2023. default:
  2024. ;
  2025. }
  2026. if (!expr_is_yes(prop->visible.expr)) {
  2027. fputs(" depends ", out);
  2028. expr_fprint(prop->visible.expr, out);
  2029. fputc('\n', out);
  2030. }
  2031. }
  2032. if (menu->list)
  2033. menu = menu->list;
  2034. else if (menu->next)
  2035. menu = menu->next;
  2036. else while ((menu = menu->parent)) {
  2037. if (menu->prompt && menu->prompt->type == P_MENU)
  2038. fputs("\nendmenu\n", out);
  2039. if (menu->next) {
  2040. menu = menu->next;
  2041. break;
  2042. }
  2043. }
  2044. }
  2045. }
  2046. #include "lconf.c"
  2047. #include "util.c"
  2048. #include "confdata.c"
  2049. #include "expr.c"
  2050. #include "symbol.c"
  2051. #include "menu.c"