parser.tab.c 72 KB

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