NCDConfigParser_parse.c 59 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890
  1. /* Driver template for the LEMON parser generator.
  2. ** The author disclaims copyright to this source code.
  3. */
  4. /* First off, code is included that follows the "include" declaration
  5. ** in the input grammar file. */
  6. #include <stdio.h>
  7. #line 30 "NCDConfigParser_parse.y"
  8. #include <string.h>
  9. #include <stddef.h>
  10. #include <misc/debug.h>
  11. #include <misc/concat_strings.h>
  12. #include <ncd/NCDAst.h>
  13. struct parser_out {
  14. int out_of_memory;
  15. int syntax_error;
  16. int have_ast;
  17. NCDProgram ast;
  18. };
  19. struct token {
  20. char *str;
  21. size_t len;
  22. };
  23. struct program {
  24. int have;
  25. NCDProgram v;
  26. };
  27. struct block {
  28. int have;
  29. NCDBlock v;
  30. };
  31. struct statement {
  32. int have;
  33. NCDStatement v;
  34. };
  35. struct ifblock {
  36. int have;
  37. NCDIfBlock v;
  38. };
  39. struct value {
  40. int have;
  41. NCDValue v;
  42. };
  43. static void free_token (struct token o) { free(o.str); }
  44. static void free_program (struct program o) { if (o.have) NCDProgram_Free(&o.v); }
  45. static void free_block (struct block o) { if (o.have) NCDBlock_Free(&o.v); }
  46. static void free_statement (struct statement o) { if (o.have) NCDStatement_Free(&o.v); }
  47. static void free_ifblock (struct ifblock o) { if (o.have) NCDIfBlock_Free(&o.v); }
  48. static void free_value (struct value o) { if (o.have) NCDValue_Free(&o.v); }
  49. #line 62 "NCDConfigParser_parse.c"
  50. /* Next is all token values, in a form suitable for use by makeheaders.
  51. ** This section will be null unless lemon is run with the -m switch.
  52. */
  53. /*
  54. ** These constants (all generated automatically by the parser generator)
  55. ** specify the various kinds of tokens (terminals) that the parser
  56. ** understands.
  57. **
  58. ** Each symbol here is a terminal symbol in the grammar.
  59. */
  60. /* Make sure the INTERFACE macro is defined.
  61. */
  62. #ifndef INTERFACE
  63. # define INTERFACE 1
  64. #endif
  65. /* The next thing included is series of defines which control
  66. ** various aspects of the generated parser.
  67. ** YYCODETYPE is the data type used for storing terminal
  68. ** and nonterminal numbers. "unsigned char" is
  69. ** used if there are fewer than 250 terminals
  70. ** and nonterminals. "int" is used otherwise.
  71. ** YYNOCODE is a number of type YYCODETYPE which corresponds
  72. ** to no legal terminal or nonterminal number. This
  73. ** number is used to fill in empty slots of the hash
  74. ** table.
  75. ** YYFALLBACK If defined, this indicates that one or more tokens
  76. ** have fall-back values which should be used if the
  77. ** original value of the token will not parse.
  78. ** YYACTIONTYPE is the data type used for storing terminal
  79. ** and nonterminal numbers. "unsigned char" is
  80. ** used if there are fewer than 250 rules and
  81. ** states combined. "int" is used otherwise.
  82. ** ParseTOKENTYPE is the data type used for minor tokens given
  83. ** directly to the parser from the tokenizer.
  84. ** YYMINORTYPE is the data type used for all minor tokens.
  85. ** This is typically a union of many types, one of
  86. ** which is ParseTOKENTYPE. The entry in the union
  87. ** for base tokens is called "yy0".
  88. ** YYSTACKDEPTH is the maximum depth of the parser's stack. If
  89. ** zero the stack is dynamically sized using realloc()
  90. ** ParseARG_SDECL A static variable declaration for the %extra_argument
  91. ** ParseARG_PDECL A parameter declaration for the %extra_argument
  92. ** ParseARG_STORE Code to store %extra_argument into yypParser
  93. ** ParseARG_FETCH Code to extract %extra_argument from yypParser
  94. ** YYNSTATE the combined number of states.
  95. ** YYNRULE the number of rules in the grammar
  96. ** YYERRORSYMBOL is the code number of the error symbol. If not
  97. ** defined, then do no error processing.
  98. */
  99. #define YYCODETYPE unsigned char
  100. #define YYNOCODE 41
  101. #define YYACTIONTYPE unsigned char
  102. #define ParseTOKENTYPE struct token
  103. typedef union {
  104. int yyinit;
  105. ParseTOKENTYPE yy0;
  106. int yy12;
  107. char * yy33;
  108. struct block yy37;
  109. struct value yy51;
  110. struct program yy54;
  111. struct ifblock yy76;
  112. struct statement yy79;
  113. } YYMINORTYPE;
  114. #ifndef YYSTACKDEPTH
  115. #define YYSTACKDEPTH 0
  116. #endif
  117. #define ParseARG_SDECL struct parser_out *parser_out ;
  118. #define ParseARG_PDECL , struct parser_out *parser_out
  119. #define ParseARG_FETCH struct parser_out *parser_out = yypParser->parser_out
  120. #define ParseARG_STORE yypParser->parser_out = parser_out
  121. #define YYNSTATE 99
  122. #define YYNRULE 38
  123. #define YY_NO_ACTION (YYNSTATE+YYNRULE+2)
  124. #define YY_ACCEPT_ACTION (YYNSTATE+YYNRULE+1)
  125. #define YY_ERROR_ACTION (YYNSTATE+YYNRULE)
  126. /* The yyzerominor constant is used to initialize instances of
  127. ** YYMINORTYPE objects to zero. */
  128. static const YYMINORTYPE yyzerominor = { 0 };
  129. /* Define the yytestcase() macro to be a no-op if is not already defined
  130. ** otherwise.
  131. **
  132. ** Applications can choose to define yytestcase() in the %include section
  133. ** to a macro that can assist in verifying code coverage. For production
  134. ** code the yytestcase() macro should be turned off. But it is useful
  135. ** for testing.
  136. */
  137. #ifndef yytestcase
  138. # define yytestcase(X)
  139. #endif
  140. /* Next are the tables used to determine what action to take based on the
  141. ** current state and lookahead token. These tables are used to implement
  142. ** functions that take a state number and lookahead value and return an
  143. ** action integer.
  144. **
  145. ** Suppose the action integer is N. Then the action is determined as
  146. ** follows
  147. **
  148. ** 0 <= N < YYNSTATE Shift N. That is, push the lookahead
  149. ** token onto the stack and goto state N.
  150. **
  151. ** YYNSTATE <= N < YYNSTATE+YYNRULE Reduce by rule N-YYNSTATE.
  152. **
  153. ** N == YYNSTATE+YYNRULE A syntax error has occurred.
  154. **
  155. ** N == YYNSTATE+YYNRULE+1 The parser accepts its input.
  156. **
  157. ** N == YYNSTATE+YYNRULE+2 No such action. Denotes unused
  158. ** slots in the yy_action[] table.
  159. **
  160. ** The action table is constructed as a single large table named yy_action[].
  161. ** Given state S and lookahead X, the action is computed as
  162. **
  163. ** yy_action[ yy_shift_ofst[S] + X ]
  164. **
  165. ** If the index value yy_shift_ofst[S]+X is out of range or if the value
  166. ** yy_lookahead[yy_shift_ofst[S]+X] is not equal to X or if yy_shift_ofst[S]
  167. ** is equal to YY_SHIFT_USE_DFLT, it means that the action is not in the table
  168. ** and that yy_default[S] should be used instead.
  169. **
  170. ** The formula above is for computing the action when the lookahead is
  171. ** a terminal symbol. If the lookahead is a non-terminal (as occurs after
  172. ** a reduce action) then the yy_reduce_ofst[] array is used in place of
  173. ** the yy_shift_ofst[] array and YY_REDUCE_USE_DFLT is used in place of
  174. ** YY_SHIFT_USE_DFLT.
  175. **
  176. ** The following are the tables generated in this section:
  177. **
  178. ** yy_action[] A single table containing all actions.
  179. ** yy_lookahead[] A table containing the lookahead for each entry in
  180. ** yy_action. Used to detect hash collisions.
  181. ** yy_shift_ofst[] For each state, the offset into yy_action for
  182. ** shifting terminals.
  183. ** yy_reduce_ofst[] For each state, the offset into yy_action for
  184. ** shifting non-terminals after a reduce.
  185. ** yy_default[] Default action for each state.
  186. */
  187. static const YYACTIONTYPE yy_action[] = {
  188. /* 0 */ 86, 39, 80, 87, 68, 88, 42, 86, 48, 80,
  189. /* 10 */ 87, 1, 88, 42, 24, 85, 78, 41, 3, 82,
  190. /* 20 */ 86, 40, 43, 87, 41, 88, 42, 41, 85, 79,
  191. /* 30 */ 41, 3, 4, 86, 50, 56, 87, 46, 88, 44,
  192. /* 40 */ 47, 85, 49, 41, 3, 4, 89, 34, 86, 35,
  193. /* 50 */ 81, 87, 72, 88, 42, 73, 54, 86, 4, 55,
  194. /* 60 */ 87, 84, 88, 44, 26, 97, 36, 75, 76, 36,
  195. /* 70 */ 86, 61, 66, 87, 86, 88, 45, 87, 86, 88,
  196. /* 80 */ 51, 87, 86, 88, 57, 87, 33, 88, 69, 15,
  197. /* 90 */ 59, 27, 98, 38, 31, 99, 62, 37, 18, 15,
  198. /* 100 */ 36, 138, 15, 53, 31, 15, 67, 31, 15, 60,
  199. /* 110 */ 31, 15, 94, 31, 15, 65, 31, 19, 71, 31,
  200. /* 120 */ 20, 11, 77, 23, 74, 22, 5, 83, 6, 90,
  201. /* 130 */ 2, 91, 7, 25, 8, 12, 52, 21, 36, 13,
  202. /* 140 */ 9, 92, 58, 32, 28, 14, 93, 63, 29, 64,
  203. /* 150 */ 16, 139, 96, 95, 10, 17, 70, 30,
  204. };
  205. static const YYCODETYPE yy_lookahead[] = {
  206. /* 0 */ 30, 31, 32, 33, 15, 35, 36, 30, 31, 32,
  207. /* 10 */ 33, 7, 35, 36, 10, 2, 4, 4, 5, 6,
  208. /* 20 */ 30, 37, 32, 33, 4, 35, 36, 4, 2, 30,
  209. /* 30 */ 4, 5, 19, 30, 11, 12, 33, 34, 35, 36,
  210. /* 40 */ 30, 2, 37, 4, 5, 19, 20, 1, 30, 3,
  211. /* 50 */ 32, 33, 24, 35, 36, 24, 37, 30, 19, 16,
  212. /* 60 */ 33, 34, 35, 36, 26, 27, 38, 21, 22, 38,
  213. /* 70 */ 30, 37, 37, 33, 30, 35, 36, 33, 30, 35,
  214. /* 80 */ 36, 33, 30, 35, 36, 33, 24, 35, 36, 25,
  215. /* 90 */ 8, 28, 27, 29, 30, 0, 14, 4, 2, 25,
  216. /* 100 */ 38, 39, 25, 29, 30, 25, 29, 30, 25, 29,
  217. /* 110 */ 30, 25, 29, 30, 25, 29, 30, 2, 29, 30,
  218. /* 120 */ 6, 5, 9, 17, 24, 8, 18, 6, 18, 20,
  219. /* 130 */ 7, 9, 14, 8, 7, 5, 8, 6, 38, 5,
  220. /* 140 */ 7, 9, 13, 4, 6, 5, 9, 4, 6, 8,
  221. /* 150 */ 5, 40, 6, 9, 7, 5, 8, 6,
  222. };
  223. #define YY_SHIFT_USE_DFLT (-12)
  224. #define YY_SHIFT_MAX 71
  225. static const short yy_shift_ofst[] = {
  226. /* 0 */ 46, 39, 39, 13, 26, 39, 39, 39, 39, 39,
  227. /* 10 */ 39, 23, 23, 23, 23, 23, 23, 23, 46, 46,
  228. /* 20 */ 46, -11, 12, 20, 20, 12, 43, 12, 12, 12,
  229. /* 30 */ -11, 4, 82, 95, 96, 115, 93, 116, 114, 117,
  230. /* 40 */ 113, 106, 108, 121, 118, 110, 109, 123, 125, 122,
  231. /* 50 */ 127, 128, 130, 131, 132, 134, 133, 129, 139, 140,
  232. /* 60 */ 138, 137, 143, 141, 145, 142, 144, 146, 147, 148,
  233. /* 70 */ 150, 151,
  234. };
  235. #define YY_REDUCE_USE_DFLT (-31)
  236. #define YY_REDUCE_MAX 30
  237. static const signed char yy_reduce_ofst[] = {
  238. /* 0 */ 62, -30, -23, -10, 3, 18, 27, 40, 44, 48,
  239. /* 10 */ 52, 64, 74, 77, 80, 83, 86, 89, 28, 31,
  240. /* 20 */ 100, 38, -16, -1, 10, 5, 63, 19, 34, 35,
  241. /* 30 */ 65,
  242. };
  243. static const YYACTIONTYPE yy_default[] = {
  244. /* 0 */ 100, 119, 119, 137, 137, 137, 137, 137, 137, 137,
  245. /* 10 */ 137, 137, 137, 137, 137, 115, 137, 137, 100, 100,
  246. /* 20 */ 100, 109, 133, 137, 137, 133, 113, 133, 133, 133,
  247. /* 30 */ 111, 137, 137, 137, 137, 137, 137, 137, 137, 137,
  248. /* 40 */ 137, 117, 121, 137, 137, 125, 137, 137, 137, 137,
  249. /* 50 */ 137, 137, 137, 137, 137, 137, 137, 137, 137, 137,
  250. /* 60 */ 137, 137, 137, 137, 137, 137, 137, 137, 137, 137,
  251. /* 70 */ 137, 137, 101, 102, 103, 135, 136, 104, 134, 118,
  252. /* 80 */ 120, 122, 123, 124, 126, 129, 130, 131, 132, 127,
  253. /* 90 */ 128, 105, 106, 107, 116, 108, 114, 110, 112,
  254. };
  255. #define YY_SZ_ACTTAB (int)(sizeof(yy_action)/sizeof(yy_action[0]))
  256. /* The next table maps tokens into fallback tokens. If a construct
  257. ** like the following:
  258. **
  259. ** %fallback ID X Y Z.
  260. **
  261. ** appears in the grammar, then ID becomes a fallback token for X, Y,
  262. ** and Z. Whenever one of the tokens X, Y, or Z is input to the parser
  263. ** but it does not parse, the type of the token is changed to ID and
  264. ** the parse is retried before an error is thrown.
  265. */
  266. #ifdef YYFALLBACK
  267. static const YYCODETYPE yyFallback[] = {
  268. };
  269. #endif /* YYFALLBACK */
  270. /* The following structure represents a single element of the
  271. ** parser's stack. Information stored includes:
  272. **
  273. ** + The state number for the parser at this level of the stack.
  274. **
  275. ** + The value of the token stored at this level of the stack.
  276. ** (In other words, the "major" token.)
  277. **
  278. ** + The semantic value stored at this level of the stack. This is
  279. ** the information used by the action routines in the grammar.
  280. ** It is sometimes called the "minor" token.
  281. */
  282. struct yyStackEntry {
  283. YYACTIONTYPE stateno; /* The state-number */
  284. YYCODETYPE major; /* The major token value. This is the code
  285. ** number for the token at this stack level */
  286. YYMINORTYPE minor; /* The user-supplied minor token value. This
  287. ** is the value of the token */
  288. };
  289. typedef struct yyStackEntry yyStackEntry;
  290. /* The state of the parser is completely contained in an instance of
  291. ** the following structure */
  292. struct yyParser {
  293. int yyidx; /* Index of top element in stack */
  294. #ifdef YYTRACKMAXSTACKDEPTH
  295. int yyidxMax; /* Maximum value of yyidx */
  296. #endif
  297. int yyerrcnt; /* Shifts left before out of the error */
  298. ParseARG_SDECL /* A place to hold %extra_argument */
  299. #if YYSTACKDEPTH<=0
  300. int yystksz; /* Current side of the stack */
  301. yyStackEntry *yystack; /* The parser's stack */
  302. #else
  303. yyStackEntry yystack[YYSTACKDEPTH]; /* The parser's stack */
  304. #endif
  305. };
  306. typedef struct yyParser yyParser;
  307. #ifndef NDEBUG
  308. #include <stdio.h>
  309. static FILE *yyTraceFILE = 0;
  310. static char *yyTracePrompt = 0;
  311. #endif /* NDEBUG */
  312. #ifndef NDEBUG
  313. /*
  314. ** Turn parser tracing on by giving a stream to which to write the trace
  315. ** and a prompt to preface each trace message. Tracing is turned off
  316. ** by making either argument NULL
  317. **
  318. ** Inputs:
  319. ** <ul>
  320. ** <li> A FILE* to which trace output should be written.
  321. ** If NULL, then tracing is turned off.
  322. ** <li> A prefix string written at the beginning of every
  323. ** line of trace output. If NULL, then tracing is
  324. ** turned off.
  325. ** </ul>
  326. **
  327. ** Outputs:
  328. ** None.
  329. */
  330. void ParseTrace(FILE *TraceFILE, char *zTracePrompt){
  331. yyTraceFILE = TraceFILE;
  332. yyTracePrompt = zTracePrompt;
  333. if( yyTraceFILE==0 ) yyTracePrompt = 0;
  334. else if( yyTracePrompt==0 ) yyTraceFILE = 0;
  335. }
  336. #endif /* NDEBUG */
  337. #ifndef NDEBUG
  338. /* For tracing shifts, the names of all terminals and nonterminals
  339. ** are required. The following table supplies these names */
  340. static const char *const yyTokenName[] = {
  341. "$", "INCLUDE", "STRING", "INCLUDE_GUARD",
  342. "NAME", "CURLY_OPEN", "CURLY_CLOSE", "ROUND_OPEN",
  343. "ROUND_CLOSE", "SEMICOLON", "ARROW", "IF",
  344. "FOREACH", "AS", "COLON", "ELIF",
  345. "ELSE", "DOT", "COMMA", "BRACKET_OPEN",
  346. "BRACKET_CLOSE", "PROCESS", "TEMPLATE", "error",
  347. "processes", "statement", "elif_maybe", "elif",
  348. "else_maybe", "statements", "dotted_name", "statement_args_maybe",
  349. "list_contents", "list", "map_contents", "map",
  350. "value", "name_maybe", "process_or_template", "input",
  351. };
  352. #endif /* NDEBUG */
  353. #ifndef NDEBUG
  354. /* For tracing reduce actions, the names of all rules are required.
  355. */
  356. static const char *const yyRuleName[] = {
  357. /* 0 */ "input ::= processes",
  358. /* 1 */ "processes ::=",
  359. /* 2 */ "processes ::= INCLUDE STRING processes",
  360. /* 3 */ "processes ::= INCLUDE_GUARD STRING processes",
  361. /* 4 */ "processes ::= process_or_template NAME CURLY_OPEN statements CURLY_CLOSE processes",
  362. /* 5 */ "statement ::= dotted_name ROUND_OPEN statement_args_maybe ROUND_CLOSE name_maybe SEMICOLON",
  363. /* 6 */ "statement ::= dotted_name ARROW dotted_name ROUND_OPEN statement_args_maybe ROUND_CLOSE name_maybe SEMICOLON",
  364. /* 7 */ "statement ::= IF ROUND_OPEN value ROUND_CLOSE CURLY_OPEN statements CURLY_CLOSE elif_maybe else_maybe name_maybe SEMICOLON",
  365. /* 8 */ "statement ::= FOREACH ROUND_OPEN value AS NAME ROUND_CLOSE CURLY_OPEN statements CURLY_CLOSE name_maybe SEMICOLON",
  366. /* 9 */ "statement ::= FOREACH ROUND_OPEN value AS NAME COLON NAME ROUND_CLOSE CURLY_OPEN statements CURLY_CLOSE name_maybe SEMICOLON",
  367. /* 10 */ "elif_maybe ::=",
  368. /* 11 */ "elif_maybe ::= elif",
  369. /* 12 */ "elif ::= ELIF ROUND_OPEN value ROUND_CLOSE CURLY_OPEN statements CURLY_CLOSE",
  370. /* 13 */ "elif ::= ELIF ROUND_OPEN value ROUND_CLOSE CURLY_OPEN statements CURLY_CLOSE elif",
  371. /* 14 */ "else_maybe ::=",
  372. /* 15 */ "else_maybe ::= ELSE CURLY_OPEN statements CURLY_CLOSE",
  373. /* 16 */ "statements ::= statement",
  374. /* 17 */ "statements ::= statement statements",
  375. /* 18 */ "dotted_name ::= NAME",
  376. /* 19 */ "dotted_name ::= NAME DOT dotted_name",
  377. /* 20 */ "statement_args_maybe ::=",
  378. /* 21 */ "statement_args_maybe ::= list_contents",
  379. /* 22 */ "list_contents ::= value",
  380. /* 23 */ "list_contents ::= value COMMA list_contents",
  381. /* 24 */ "list ::= CURLY_OPEN CURLY_CLOSE",
  382. /* 25 */ "list ::= CURLY_OPEN list_contents CURLY_CLOSE",
  383. /* 26 */ "map_contents ::= value COLON value",
  384. /* 27 */ "map_contents ::= value COLON value COMMA map_contents",
  385. /* 28 */ "map ::= BRACKET_OPEN BRACKET_CLOSE",
  386. /* 29 */ "map ::= BRACKET_OPEN map_contents BRACKET_CLOSE",
  387. /* 30 */ "value ::= STRING",
  388. /* 31 */ "value ::= dotted_name",
  389. /* 32 */ "value ::= list",
  390. /* 33 */ "value ::= map",
  391. /* 34 */ "name_maybe ::=",
  392. /* 35 */ "name_maybe ::= NAME",
  393. /* 36 */ "process_or_template ::= PROCESS",
  394. /* 37 */ "process_or_template ::= TEMPLATE",
  395. };
  396. #endif /* NDEBUG */
  397. #if YYSTACKDEPTH<=0
  398. /*
  399. ** Try to increase the size of the parser stack.
  400. */
  401. static void yyGrowStack(yyParser *p){
  402. int newSize;
  403. yyStackEntry *pNew;
  404. newSize = p->yystksz*2 + 100;
  405. pNew = realloc(p->yystack, newSize*sizeof(pNew[0]));
  406. if( pNew ){
  407. p->yystack = pNew;
  408. p->yystksz = newSize;
  409. #ifndef NDEBUG
  410. if( yyTraceFILE ){
  411. fprintf(yyTraceFILE,"%sStack grows to %d entries!\n",
  412. yyTracePrompt, p->yystksz);
  413. }
  414. #endif
  415. }
  416. }
  417. #endif
  418. /*
  419. ** This function allocates a new parser.
  420. ** The only argument is a pointer to a function which works like
  421. ** malloc.
  422. **
  423. ** Inputs:
  424. ** A pointer to the function used to allocate memory.
  425. **
  426. ** Outputs:
  427. ** A pointer to a parser. This pointer is used in subsequent calls
  428. ** to Parse and ParseFree.
  429. */
  430. void *ParseAlloc(void *(*mallocProc)(size_t)){
  431. yyParser *pParser;
  432. pParser = (yyParser*)(*mallocProc)( (size_t)sizeof(yyParser) );
  433. if( pParser ){
  434. pParser->yyidx = -1;
  435. #ifdef YYTRACKMAXSTACKDEPTH
  436. pParser->yyidxMax = 0;
  437. #endif
  438. #if YYSTACKDEPTH<=0
  439. pParser->yystack = NULL;
  440. pParser->yystksz = 0;
  441. yyGrowStack(pParser);
  442. #endif
  443. }
  444. return pParser;
  445. }
  446. /* The following function deletes the value associated with a
  447. ** symbol. The symbol can be either a terminal or nonterminal.
  448. ** "yymajor" is the symbol code, and "yypminor" is a pointer to
  449. ** the value.
  450. */
  451. static void yy_destructor(
  452. yyParser *yypParser, /* The parser */
  453. YYCODETYPE yymajor, /* Type code for object to destroy */
  454. YYMINORTYPE *yypminor /* The object to be destroyed */
  455. ){
  456. ParseARG_FETCH;
  457. switch( yymajor ){
  458. /* Here is inserted the actions which take place when a
  459. ** terminal or non-terminal is destroyed. This can happen
  460. ** when the symbol is popped from the stack during a
  461. ** reduce or during error processing or when a parser is
  462. ** being destroyed before it is finished parsing.
  463. **
  464. ** Note: during a reduce, the only symbols destroyed are those
  465. ** which appear on the RHS of the rule, but which are not used
  466. ** inside the C code.
  467. */
  468. /* TERMINAL Destructor */
  469. case 1: /* INCLUDE */
  470. case 2: /* STRING */
  471. case 3: /* INCLUDE_GUARD */
  472. case 4: /* NAME */
  473. case 5: /* CURLY_OPEN */
  474. case 6: /* CURLY_CLOSE */
  475. case 7: /* ROUND_OPEN */
  476. case 8: /* ROUND_CLOSE */
  477. case 9: /* SEMICOLON */
  478. case 10: /* ARROW */
  479. case 11: /* IF */
  480. case 12: /* FOREACH */
  481. case 13: /* AS */
  482. case 14: /* COLON */
  483. case 15: /* ELIF */
  484. case 16: /* ELSE */
  485. case 17: /* DOT */
  486. case 18: /* COMMA */
  487. case 19: /* BRACKET_OPEN */
  488. case 20: /* BRACKET_CLOSE */
  489. case 21: /* PROCESS */
  490. case 22: /* TEMPLATE */
  491. {
  492. #line 89 "NCDConfigParser_parse.y"
  493. free_token((yypminor->yy0));
  494. #line 523 "NCDConfigParser_parse.c"
  495. }
  496. break;
  497. case 24: /* processes */
  498. {
  499. #line 108 "NCDConfigParser_parse.y"
  500. (void)parser_out; free_program((yypminor->yy54));
  501. #line 530 "NCDConfigParser_parse.c"
  502. }
  503. break;
  504. case 25: /* statement */
  505. {
  506. #line 109 "NCDConfigParser_parse.y"
  507. free_statement((yypminor->yy79));
  508. #line 537 "NCDConfigParser_parse.c"
  509. }
  510. break;
  511. case 26: /* elif_maybe */
  512. case 27: /* elif */
  513. {
  514. #line 110 "NCDConfigParser_parse.y"
  515. free_ifblock((yypminor->yy76));
  516. #line 545 "NCDConfigParser_parse.c"
  517. }
  518. break;
  519. case 28: /* else_maybe */
  520. case 29: /* statements */
  521. {
  522. #line 112 "NCDConfigParser_parse.y"
  523. free_block((yypminor->yy37));
  524. #line 553 "NCDConfigParser_parse.c"
  525. }
  526. break;
  527. case 30: /* dotted_name */
  528. case 37: /* name_maybe */
  529. {
  530. #line 114 "NCDConfigParser_parse.y"
  531. free((yypminor->yy33));
  532. #line 561 "NCDConfigParser_parse.c"
  533. }
  534. break;
  535. case 31: /* statement_args_maybe */
  536. case 32: /* list_contents */
  537. case 33: /* list */
  538. case 34: /* map_contents */
  539. case 35: /* map */
  540. case 36: /* value */
  541. {
  542. #line 115 "NCDConfigParser_parse.y"
  543. free_value((yypminor->yy51));
  544. #line 573 "NCDConfigParser_parse.c"
  545. }
  546. break;
  547. default: break; /* If no destructor action specified: do nothing */
  548. }
  549. }
  550. /*
  551. ** Pop the parser's stack once.
  552. **
  553. ** If there is a destructor routine associated with the token which
  554. ** is popped from the stack, then call it.
  555. **
  556. ** Return the major token number for the symbol popped.
  557. */
  558. static int yy_pop_parser_stack(yyParser *pParser){
  559. YYCODETYPE yymajor;
  560. yyStackEntry *yytos = &pParser->yystack[pParser->yyidx];
  561. if( pParser->yyidx<0 ) return 0;
  562. #ifndef NDEBUG
  563. if( yyTraceFILE && pParser->yyidx>=0 ){
  564. fprintf(yyTraceFILE,"%sPopping %s\n",
  565. yyTracePrompt,
  566. yyTokenName[yytos->major]);
  567. }
  568. #endif
  569. yymajor = yytos->major;
  570. yy_destructor(pParser, yymajor, &yytos->minor);
  571. pParser->yyidx--;
  572. return yymajor;
  573. }
  574. /*
  575. ** Deallocate and destroy a parser. Destructors are all called for
  576. ** all stack elements before shutting the parser down.
  577. **
  578. ** Inputs:
  579. ** <ul>
  580. ** <li> A pointer to the parser. This should be a pointer
  581. ** obtained from ParseAlloc.
  582. ** <li> A pointer to a function used to reclaim memory obtained
  583. ** from malloc.
  584. ** </ul>
  585. */
  586. void ParseFree(
  587. void *p, /* The parser to be deleted */
  588. void (*freeProc)(void*) /* Function used to reclaim memory */
  589. ){
  590. yyParser *pParser = (yyParser*)p;
  591. if( pParser==0 ) return;
  592. while( pParser->yyidx>=0 ) yy_pop_parser_stack(pParser);
  593. #if YYSTACKDEPTH<=0
  594. free(pParser->yystack);
  595. #endif
  596. (*freeProc)((void*)pParser);
  597. }
  598. /*
  599. ** Return the peak depth of the stack for a parser.
  600. */
  601. #ifdef YYTRACKMAXSTACKDEPTH
  602. int ParseStackPeak(void *p){
  603. yyParser *pParser = (yyParser*)p;
  604. return pParser->yyidxMax;
  605. }
  606. #endif
  607. /*
  608. ** Find the appropriate action for a parser given the terminal
  609. ** look-ahead token iLookAhead.
  610. **
  611. ** If the look-ahead token is YYNOCODE, then check to see if the action is
  612. ** independent of the look-ahead. If it is, return the action, otherwise
  613. ** return YY_NO_ACTION.
  614. */
  615. static int yy_find_shift_action(
  616. yyParser *pParser, /* The parser */
  617. YYCODETYPE iLookAhead /* The look-ahead token */
  618. ){
  619. int i;
  620. int stateno = pParser->yystack[pParser->yyidx].stateno;
  621. if( stateno>YY_SHIFT_MAX || (i = yy_shift_ofst[stateno])==YY_SHIFT_USE_DFLT ){
  622. return yy_default[stateno];
  623. }
  624. assert( iLookAhead!=YYNOCODE );
  625. i += iLookAhead;
  626. if( i<0 || i>=YY_SZ_ACTTAB || yy_lookahead[i]!=iLookAhead ){
  627. if( iLookAhead>0 ){
  628. #ifdef YYFALLBACK
  629. YYCODETYPE iFallback; /* Fallback token */
  630. if( iLookAhead<sizeof(yyFallback)/sizeof(yyFallback[0])
  631. && (iFallback = yyFallback[iLookAhead])!=0 ){
  632. #ifndef NDEBUG
  633. if( yyTraceFILE ){
  634. fprintf(yyTraceFILE, "%sFALLBACK %s => %s\n",
  635. yyTracePrompt, yyTokenName[iLookAhead], yyTokenName[iFallback]);
  636. }
  637. #endif
  638. return yy_find_shift_action(pParser, iFallback);
  639. }
  640. #endif
  641. #ifdef YYWILDCARD
  642. {
  643. int j = i - iLookAhead + YYWILDCARD;
  644. if( j>=0 && j<YY_SZ_ACTTAB && yy_lookahead[j]==YYWILDCARD ){
  645. #ifndef NDEBUG
  646. if( yyTraceFILE ){
  647. fprintf(yyTraceFILE, "%sWILDCARD %s => %s\n",
  648. yyTracePrompt, yyTokenName[iLookAhead], yyTokenName[YYWILDCARD]);
  649. }
  650. #endif /* NDEBUG */
  651. return yy_action[j];
  652. }
  653. }
  654. #endif /* YYWILDCARD */
  655. }
  656. return yy_default[stateno];
  657. }else{
  658. return yy_action[i];
  659. }
  660. }
  661. /*
  662. ** Find the appropriate action for a parser given the non-terminal
  663. ** look-ahead token iLookAhead.
  664. **
  665. ** If the look-ahead token is YYNOCODE, then check to see if the action is
  666. ** independent of the look-ahead. If it is, return the action, otherwise
  667. ** return YY_NO_ACTION.
  668. */
  669. static int yy_find_reduce_action(
  670. int stateno, /* Current state number */
  671. YYCODETYPE iLookAhead /* The look-ahead token */
  672. ){
  673. int i;
  674. #ifdef YYERRORSYMBOL
  675. if( stateno>YY_REDUCE_MAX ){
  676. return yy_default[stateno];
  677. }
  678. #else
  679. assert( stateno<=YY_REDUCE_MAX );
  680. #endif
  681. i = yy_reduce_ofst[stateno];
  682. assert( i!=YY_REDUCE_USE_DFLT );
  683. assert( iLookAhead!=YYNOCODE );
  684. i += iLookAhead;
  685. #ifdef YYERRORSYMBOL
  686. if( i<0 || i>=YY_SZ_ACTTAB || yy_lookahead[i]!=iLookAhead ){
  687. return yy_default[stateno];
  688. }
  689. #else
  690. assert( i>=0 && i<YY_SZ_ACTTAB );
  691. assert( yy_lookahead[i]==iLookAhead );
  692. #endif
  693. return yy_action[i];
  694. }
  695. /*
  696. ** The following routine is called if the stack overflows.
  697. */
  698. static void yyStackOverflow(yyParser *yypParser, YYMINORTYPE *yypMinor){
  699. ParseARG_FETCH;
  700. yypParser->yyidx--;
  701. #ifndef NDEBUG
  702. if( yyTraceFILE ){
  703. fprintf(yyTraceFILE,"%sStack Overflow!\n",yyTracePrompt);
  704. }
  705. #endif
  706. while( yypParser->yyidx>=0 ) yy_pop_parser_stack(yypParser);
  707. /* Here code is inserted which will execute if the parser
  708. ** stack every overflows */
  709. #line 130 "NCDConfigParser_parse.y"
  710. if (yypMinor) {
  711. free_token(yypMinor->yy0);
  712. }
  713. #line 751 "NCDConfigParser_parse.c"
  714. ParseARG_STORE; /* Suppress warning about unused %extra_argument var */
  715. }
  716. /*
  717. ** Perform a shift action.
  718. */
  719. static void yy_shift(
  720. yyParser *yypParser, /* The parser to be shifted */
  721. int yyNewState, /* The new state to shift in */
  722. int yyMajor, /* The major token to shift in */
  723. YYMINORTYPE *yypMinor /* Pointer to the minor token to shift in */
  724. ){
  725. yyStackEntry *yytos;
  726. yypParser->yyidx++;
  727. #ifdef YYTRACKMAXSTACKDEPTH
  728. if( yypParser->yyidx>yypParser->yyidxMax ){
  729. yypParser->yyidxMax = yypParser->yyidx;
  730. }
  731. #endif
  732. #if YYSTACKDEPTH>0
  733. if( yypParser->yyidx>=YYSTACKDEPTH ){
  734. yyStackOverflow(yypParser, yypMinor);
  735. return;
  736. }
  737. #else
  738. if( yypParser->yyidx>=yypParser->yystksz ){
  739. yyGrowStack(yypParser);
  740. if( yypParser->yyidx>=yypParser->yystksz ){
  741. yyStackOverflow(yypParser, yypMinor);
  742. return;
  743. }
  744. }
  745. #endif
  746. yytos = &yypParser->yystack[yypParser->yyidx];
  747. yytos->stateno = (YYACTIONTYPE)yyNewState;
  748. yytos->major = (YYCODETYPE)yyMajor;
  749. yytos->minor = *yypMinor;
  750. #ifndef NDEBUG
  751. if( yyTraceFILE && yypParser->yyidx>0 ){
  752. int i;
  753. fprintf(yyTraceFILE,"%sShift %d\n",yyTracePrompt,yyNewState);
  754. fprintf(yyTraceFILE,"%sStack:",yyTracePrompt);
  755. for(i=1; i<=yypParser->yyidx; i++)
  756. fprintf(yyTraceFILE," %s",yyTokenName[yypParser->yystack[i].major]);
  757. fprintf(yyTraceFILE,"\n");
  758. }
  759. #endif
  760. }
  761. /* The following table contains information about every rule that
  762. ** is used during the reduce.
  763. */
  764. static const struct {
  765. YYCODETYPE lhs; /* Symbol on the left-hand side of the rule */
  766. unsigned char nrhs; /* Number of right-hand side symbols in the rule */
  767. } yyRuleInfo[] = {
  768. { 39, 1 },
  769. { 24, 0 },
  770. { 24, 3 },
  771. { 24, 3 },
  772. { 24, 6 },
  773. { 25, 6 },
  774. { 25, 8 },
  775. { 25, 11 },
  776. { 25, 11 },
  777. { 25, 13 },
  778. { 26, 0 },
  779. { 26, 1 },
  780. { 27, 7 },
  781. { 27, 8 },
  782. { 28, 0 },
  783. { 28, 4 },
  784. { 29, 1 },
  785. { 29, 2 },
  786. { 30, 1 },
  787. { 30, 3 },
  788. { 31, 0 },
  789. { 31, 1 },
  790. { 32, 1 },
  791. { 32, 3 },
  792. { 33, 2 },
  793. { 33, 3 },
  794. { 34, 3 },
  795. { 34, 5 },
  796. { 35, 2 },
  797. { 35, 3 },
  798. { 36, 1 },
  799. { 36, 1 },
  800. { 36, 1 },
  801. { 36, 1 },
  802. { 37, 0 },
  803. { 37, 1 },
  804. { 38, 1 },
  805. { 38, 1 },
  806. };
  807. static void yy_accept(yyParser*); /* Forward Declaration */
  808. /*
  809. ** Perform a reduce action and the shift that must immediately
  810. ** follow the reduce.
  811. */
  812. static void yy_reduce(
  813. yyParser *yypParser, /* The parser */
  814. int yyruleno /* Number of the rule by which to reduce */
  815. ){
  816. int yygoto; /* The next state */
  817. int yyact; /* The next action */
  818. YYMINORTYPE yygotominor; /* The LHS of the rule reduced */
  819. yyStackEntry *yymsp; /* The top of the parser's stack */
  820. int yysize; /* Amount to pop the stack */
  821. ParseARG_FETCH;
  822. yymsp = &yypParser->yystack[yypParser->yyidx];
  823. #ifndef NDEBUG
  824. if( yyTraceFILE && yyruleno>=0
  825. && yyruleno<(int)(sizeof(yyRuleName)/sizeof(yyRuleName[0])) ){
  826. fprintf(yyTraceFILE, "%sReduce [%s].\n", yyTracePrompt,
  827. yyRuleName[yyruleno]);
  828. }
  829. #endif /* NDEBUG */
  830. /* Silence complaints from purify about yygotominor being uninitialized
  831. ** in some cases when it is copied into the stack after the following
  832. ** switch. yygotominor is uninitialized when a rule reduces that does
  833. ** not set the value of its left-hand side nonterminal. Leaving the
  834. ** value of the nonterminal uninitialized is utterly harmless as long
  835. ** as the value is never used. So really the only thing this code
  836. ** accomplishes is to quieten purify.
  837. **
  838. ** 2007-01-16: The wireshark project (www.wireshark.org) reports that
  839. ** without this code, their parser segfaults. I'm not sure what there
  840. ** parser is doing to make this happen. This is the second bug report
  841. ** from wireshark this week. Clearly they are stressing Lemon in ways
  842. ** that it has not been previously stressed... (SQLite ticket #2172)
  843. */
  844. /*memset(&yygotominor, 0, sizeof(yygotominor));*/
  845. yygotominor = yyzerominor;
  846. switch( yyruleno ){
  847. /* Beginning here are the reduction cases. A typical example
  848. ** follows:
  849. ** case 0:
  850. ** #line <lineno> <grammarfile>
  851. ** { ... } // User supplied code
  852. ** #line <lineno> <thisfile>
  853. ** break;
  854. */
  855. case 0: /* input ::= processes */
  856. #line 136 "NCDConfigParser_parse.y"
  857. {
  858. ASSERT(!parser_out->have_ast)
  859. if (yymsp[0].minor.yy54.have) {
  860. parser_out->have_ast = 1;
  861. parser_out->ast = yymsp[0].minor.yy54.v;
  862. }
  863. }
  864. #line 910 "NCDConfigParser_parse.c"
  865. break;
  866. case 1: /* processes ::= */
  867. #line 145 "NCDConfigParser_parse.y"
  868. {
  869. NCDProgram prog;
  870. NCDProgram_Init(&prog);
  871. yygotominor.yy54.have = 1;
  872. yygotominor.yy54.v = prog;
  873. }
  874. #line 921 "NCDConfigParser_parse.c"
  875. break;
  876. case 2: /* processes ::= INCLUDE STRING processes */
  877. #line 153 "NCDConfigParser_parse.y"
  878. {
  879. ASSERT(yymsp[-1].minor.yy0.str)
  880. if (!yymsp[0].minor.yy54.have) {
  881. goto failA0;
  882. }
  883. NCDProgramElem elem;
  884. if (!NCDProgramElem_InitInclude(&elem, yymsp[-1].minor.yy0.str, yymsp[-1].minor.yy0.len)) {
  885. goto failA0;
  886. }
  887. if (!NCDProgram_PrependElem(&yymsp[0].minor.yy54.v, elem)) {
  888. goto failA1;
  889. }
  890. yygotominor.yy54.have = 1;
  891. yygotominor.yy54.v = yymsp[0].minor.yy54.v;
  892. yymsp[0].minor.yy54.have = 0;
  893. goto doneA;
  894. failA1:
  895. NCDProgramElem_Free(&elem);
  896. failA0:
  897. yygotominor.yy54.have = 0;
  898. parser_out->out_of_memory = 1;
  899. doneA:
  900. free_token(yymsp[-1].minor.yy0);
  901. free_program(yymsp[0].minor.yy54);
  902. yy_destructor(yypParser,1,&yymsp[-2].minor);
  903. }
  904. #line 955 "NCDConfigParser_parse.c"
  905. break;
  906. case 3: /* processes ::= INCLUDE_GUARD STRING processes */
  907. #line 183 "NCDConfigParser_parse.y"
  908. {
  909. ASSERT(yymsp[-1].minor.yy0.str)
  910. if (!yymsp[0].minor.yy54.have) {
  911. goto failZ0;
  912. }
  913. NCDProgramElem elem;
  914. if (!NCDProgramElem_InitIncludeGuard(&elem, yymsp[-1].minor.yy0.str, yymsp[-1].minor.yy0.len)) {
  915. goto failZ0;
  916. }
  917. if (!NCDProgram_PrependElem(&yymsp[0].minor.yy54.v, elem)) {
  918. goto failZ1;
  919. }
  920. yygotominor.yy54.have = 1;
  921. yygotominor.yy54.v = yymsp[0].minor.yy54.v;
  922. yymsp[0].minor.yy54.have = 0;
  923. goto doneZ;
  924. failZ1:
  925. NCDProgramElem_Free(&elem);
  926. failZ0:
  927. yygotominor.yy54.have = 0;
  928. parser_out->out_of_memory = 1;
  929. doneZ:
  930. free_token(yymsp[-1].minor.yy0);
  931. free_program(yymsp[0].minor.yy54);
  932. yy_destructor(yypParser,3,&yymsp[-2].minor);
  933. }
  934. #line 989 "NCDConfigParser_parse.c"
  935. break;
  936. case 4: /* processes ::= process_or_template NAME CURLY_OPEN statements CURLY_CLOSE processes */
  937. #line 213 "NCDConfigParser_parse.y"
  938. {
  939. ASSERT(yymsp[-4].minor.yy0.str)
  940. if (!yymsp[-2].minor.yy37.have || !yymsp[0].minor.yy54.have) {
  941. goto failB0;
  942. }
  943. NCDProcess proc;
  944. if (!NCDProcess_Init(&proc, yymsp[-5].minor.yy12, yymsp[-4].minor.yy0.str, yymsp[-2].minor.yy37.v)) {
  945. goto failB0;
  946. }
  947. yymsp[-2].minor.yy37.have = 0;
  948. NCDProgramElem elem;
  949. NCDProgramElem_InitProcess(&elem, proc);
  950. if (!NCDProgram_PrependElem(&yymsp[0].minor.yy54.v, elem)) {
  951. goto failB1;
  952. }
  953. yygotominor.yy54.have = 1;
  954. yygotominor.yy54.v = yymsp[0].minor.yy54.v;
  955. yymsp[0].minor.yy54.have = 0;
  956. goto doneB;
  957. failB1:
  958. NCDProgramElem_Free(&elem);
  959. failB0:
  960. yygotominor.yy54.have = 0;
  961. parser_out->out_of_memory = 1;
  962. doneB:
  963. free_token(yymsp[-4].minor.yy0);
  964. free_block(yymsp[-2].minor.yy37);
  965. free_program(yymsp[0].minor.yy54);
  966. yy_destructor(yypParser,5,&yymsp[-3].minor);
  967. yy_destructor(yypParser,6,&yymsp[-1].minor);
  968. }
  969. #line 1029 "NCDConfigParser_parse.c"
  970. break;
  971. case 5: /* statement ::= dotted_name ROUND_OPEN statement_args_maybe ROUND_CLOSE name_maybe SEMICOLON */
  972. #line 248 "NCDConfigParser_parse.y"
  973. {
  974. if (!yymsp[-5].minor.yy33 || !yymsp[-3].minor.yy51.have) {
  975. goto failC0;
  976. }
  977. if (!NCDStatement_InitReg(&yygotominor.yy79.v, yymsp[-1].minor.yy33, NULL, yymsp[-5].minor.yy33, yymsp[-3].minor.yy51.v)) {
  978. goto failC0;
  979. }
  980. yymsp[-3].minor.yy51.have = 0;
  981. yygotominor.yy79.have = 1;
  982. goto doneC;
  983. failC0:
  984. yygotominor.yy79.have = 0;
  985. parser_out->out_of_memory = 1;
  986. doneC:
  987. free(yymsp[-5].minor.yy33);
  988. free_value(yymsp[-3].minor.yy51);
  989. free(yymsp[-1].minor.yy33);
  990. yy_destructor(yypParser,7,&yymsp[-4].minor);
  991. yy_destructor(yypParser,8,&yymsp[-2].minor);
  992. yy_destructor(yypParser,9,&yymsp[0].minor);
  993. }
  994. #line 1057 "NCDConfigParser_parse.c"
  995. break;
  996. case 6: /* statement ::= dotted_name ARROW dotted_name ROUND_OPEN statement_args_maybe ROUND_CLOSE name_maybe SEMICOLON */
  997. #line 270 "NCDConfigParser_parse.y"
  998. {
  999. if (!yymsp[-7].minor.yy33 || !yymsp[-5].minor.yy33 || !yymsp[-3].minor.yy51.have) {
  1000. goto failD0;
  1001. }
  1002. if (!NCDStatement_InitReg(&yygotominor.yy79.v, yymsp[-1].minor.yy33, yymsp[-7].minor.yy33, yymsp[-5].minor.yy33, yymsp[-3].minor.yy51.v)) {
  1003. goto failD0;
  1004. }
  1005. yymsp[-3].minor.yy51.have = 0;
  1006. yygotominor.yy79.have = 1;
  1007. goto doneD;
  1008. failD0:
  1009. yygotominor.yy79.have = 0;
  1010. parser_out->out_of_memory = 1;
  1011. doneD:
  1012. free(yymsp[-7].minor.yy33);
  1013. free(yymsp[-5].minor.yy33);
  1014. free_value(yymsp[-3].minor.yy51);
  1015. free(yymsp[-1].minor.yy33);
  1016. yy_destructor(yypParser,10,&yymsp[-6].minor);
  1017. yy_destructor(yypParser,7,&yymsp[-4].minor);
  1018. yy_destructor(yypParser,8,&yymsp[-2].minor);
  1019. yy_destructor(yypParser,9,&yymsp[0].minor);
  1020. }
  1021. #line 1087 "NCDConfigParser_parse.c"
  1022. break;
  1023. case 7: /* statement ::= IF ROUND_OPEN value ROUND_CLOSE CURLY_OPEN statements CURLY_CLOSE elif_maybe else_maybe name_maybe SEMICOLON */
  1024. #line 293 "NCDConfigParser_parse.y"
  1025. {
  1026. if (!yymsp[-8].minor.yy51.have || !yymsp[-5].minor.yy37.have || !yymsp[-3].minor.yy76.have) {
  1027. goto failE0;
  1028. }
  1029. NCDIf ifc;
  1030. NCDIf_Init(&ifc, yymsp[-8].minor.yy51.v, yymsp[-5].minor.yy37.v);
  1031. yymsp[-8].minor.yy51.have = 0;
  1032. yymsp[-5].minor.yy37.have = 0;
  1033. if (!NCDIfBlock_PrependIf(&yymsp[-3].minor.yy76.v, ifc)) {
  1034. NCDIf_Free(&ifc);
  1035. goto failE0;
  1036. }
  1037. if (!NCDStatement_InitIf(&yygotominor.yy79.v, yymsp[-1].minor.yy33, yymsp[-3].minor.yy76.v)) {
  1038. goto failE0;
  1039. }
  1040. yymsp[-3].minor.yy76.have = 0;
  1041. if (yymsp[-2].minor.yy37.have) {
  1042. NCDStatement_IfAddElse(&yygotominor.yy79.v, yymsp[-2].minor.yy37.v);
  1043. yymsp[-2].minor.yy37.have = 0;
  1044. }
  1045. yygotominor.yy79.have = 1;
  1046. goto doneE;
  1047. failE0:
  1048. yygotominor.yy79.have = 0;
  1049. parser_out->out_of_memory = 1;
  1050. doneE:
  1051. free_value(yymsp[-8].minor.yy51);
  1052. free_block(yymsp[-5].minor.yy37);
  1053. free_ifblock(yymsp[-3].minor.yy76);
  1054. free_block(yymsp[-2].minor.yy37);
  1055. free(yymsp[-1].minor.yy33);
  1056. yy_destructor(yypParser,11,&yymsp[-10].minor);
  1057. yy_destructor(yypParser,7,&yymsp[-9].minor);
  1058. yy_destructor(yypParser,8,&yymsp[-7].minor);
  1059. yy_destructor(yypParser,5,&yymsp[-6].minor);
  1060. yy_destructor(yypParser,6,&yymsp[-4].minor);
  1061. yy_destructor(yypParser,9,&yymsp[0].minor);
  1062. }
  1063. #line 1135 "NCDConfigParser_parse.c"
  1064. break;
  1065. case 8: /* statement ::= FOREACH ROUND_OPEN value AS NAME ROUND_CLOSE CURLY_OPEN statements CURLY_CLOSE name_maybe SEMICOLON */
  1066. #line 332 "NCDConfigParser_parse.y"
  1067. {
  1068. if (!yymsp[-8].minor.yy51.have || !yymsp[-6].minor.yy0.str || !yymsp[-3].minor.yy37.have) {
  1069. goto failEA0;
  1070. }
  1071. if (!NCDStatement_InitForeach(&yygotominor.yy79.v, yymsp[-1].minor.yy33, yymsp[-8].minor.yy51.v, yymsp[-6].minor.yy0.str, NULL, yymsp[-3].minor.yy37.v)) {
  1072. goto failEA0;
  1073. }
  1074. yymsp[-8].minor.yy51.have = 0;
  1075. yymsp[-3].minor.yy37.have = 0;
  1076. yygotominor.yy79.have = 1;
  1077. goto doneEA0;
  1078. failEA0:
  1079. yygotominor.yy79.have = 0;
  1080. parser_out->out_of_memory = 1;
  1081. doneEA0:
  1082. free_value(yymsp[-8].minor.yy51);
  1083. free_token(yymsp[-6].minor.yy0);
  1084. free_block(yymsp[-3].minor.yy37);
  1085. free(yymsp[-1].minor.yy33);
  1086. yy_destructor(yypParser,12,&yymsp[-10].minor);
  1087. yy_destructor(yypParser,7,&yymsp[-9].minor);
  1088. yy_destructor(yypParser,13,&yymsp[-7].minor);
  1089. yy_destructor(yypParser,8,&yymsp[-5].minor);
  1090. yy_destructor(yypParser,5,&yymsp[-4].minor);
  1091. yy_destructor(yypParser,6,&yymsp[-2].minor);
  1092. yy_destructor(yypParser,9,&yymsp[0].minor);
  1093. }
  1094. #line 1169 "NCDConfigParser_parse.c"
  1095. break;
  1096. case 9: /* statement ::= FOREACH ROUND_OPEN value AS NAME COLON NAME ROUND_CLOSE CURLY_OPEN statements CURLY_CLOSE name_maybe SEMICOLON */
  1097. #line 356 "NCDConfigParser_parse.y"
  1098. {
  1099. if (!yymsp[-10].minor.yy51.have || !yymsp[-8].minor.yy0.str || !yymsp[-6].minor.yy0.str || !yymsp[-3].minor.yy37.have) {
  1100. goto failEB0;
  1101. }
  1102. if (!NCDStatement_InitForeach(&yygotominor.yy79.v, yymsp[-1].minor.yy33, yymsp[-10].minor.yy51.v, yymsp[-8].minor.yy0.str, yymsp[-6].minor.yy0.str, yymsp[-3].minor.yy37.v)) {
  1103. goto failEB0;
  1104. }
  1105. yymsp[-10].minor.yy51.have = 0;
  1106. yymsp[-3].minor.yy37.have = 0;
  1107. yygotominor.yy79.have = 1;
  1108. goto doneEB0;
  1109. failEB0:
  1110. yygotominor.yy79.have = 0;
  1111. parser_out->out_of_memory = 1;
  1112. doneEB0:
  1113. free_value(yymsp[-10].minor.yy51);
  1114. free_token(yymsp[-8].minor.yy0);
  1115. free_token(yymsp[-6].minor.yy0);
  1116. free_block(yymsp[-3].minor.yy37);
  1117. free(yymsp[-1].minor.yy33);
  1118. yy_destructor(yypParser,12,&yymsp[-12].minor);
  1119. yy_destructor(yypParser,7,&yymsp[-11].minor);
  1120. yy_destructor(yypParser,13,&yymsp[-9].minor);
  1121. yy_destructor(yypParser,14,&yymsp[-7].minor);
  1122. yy_destructor(yypParser,8,&yymsp[-5].minor);
  1123. yy_destructor(yypParser,5,&yymsp[-4].minor);
  1124. yy_destructor(yypParser,6,&yymsp[-2].minor);
  1125. yy_destructor(yypParser,9,&yymsp[0].minor);
  1126. }
  1127. #line 1205 "NCDConfigParser_parse.c"
  1128. break;
  1129. case 10: /* elif_maybe ::= */
  1130. #line 381 "NCDConfigParser_parse.y"
  1131. {
  1132. NCDIfBlock_Init(&yygotominor.yy76.v);
  1133. yygotominor.yy76.have = 1;
  1134. }
  1135. #line 1213 "NCDConfigParser_parse.c"
  1136. break;
  1137. case 11: /* elif_maybe ::= elif */
  1138. #line 386 "NCDConfigParser_parse.y"
  1139. {
  1140. yygotominor.yy76 = yymsp[0].minor.yy76;
  1141. }
  1142. #line 1220 "NCDConfigParser_parse.c"
  1143. break;
  1144. case 12: /* elif ::= ELIF ROUND_OPEN value ROUND_CLOSE CURLY_OPEN statements CURLY_CLOSE */
  1145. #line 390 "NCDConfigParser_parse.y"
  1146. {
  1147. if (!yymsp[-4].minor.yy51.have || !yymsp[-1].minor.yy37.have) {
  1148. goto failF0;
  1149. }
  1150. NCDIfBlock_Init(&yygotominor.yy76.v);
  1151. NCDIf ifc;
  1152. NCDIf_Init(&ifc, yymsp[-4].minor.yy51.v, yymsp[-1].minor.yy37.v);
  1153. yymsp[-4].minor.yy51.have = 0;
  1154. yymsp[-1].minor.yy37.have = 0;
  1155. if (!NCDIfBlock_PrependIf(&yygotominor.yy76.v, ifc)) {
  1156. goto failF1;
  1157. }
  1158. yygotominor.yy76.have = 1;
  1159. goto doneF0;
  1160. failF1:
  1161. NCDIf_Free(&ifc);
  1162. NCDIfBlock_Free(&yygotominor.yy76.v);
  1163. failF0:
  1164. yygotominor.yy76.have = 0;
  1165. parser_out->out_of_memory = 1;
  1166. doneF0:
  1167. free_value(yymsp[-4].minor.yy51);
  1168. free_block(yymsp[-1].minor.yy37);
  1169. yy_destructor(yypParser,15,&yymsp[-6].minor);
  1170. yy_destructor(yypParser,7,&yymsp[-5].minor);
  1171. yy_destructor(yypParser,8,&yymsp[-3].minor);
  1172. yy_destructor(yypParser,5,&yymsp[-2].minor);
  1173. yy_destructor(yypParser,6,&yymsp[0].minor);
  1174. }
  1175. #line 1258 "NCDConfigParser_parse.c"
  1176. break;
  1177. case 13: /* elif ::= ELIF ROUND_OPEN value ROUND_CLOSE CURLY_OPEN statements CURLY_CLOSE elif */
  1178. #line 420 "NCDConfigParser_parse.y"
  1179. {
  1180. if (!yymsp[-5].minor.yy51.have || !yymsp[-2].minor.yy37.have || !yymsp[0].minor.yy76.have) {
  1181. goto failG0;
  1182. }
  1183. NCDIf ifc;
  1184. NCDIf_Init(&ifc, yymsp[-5].minor.yy51.v, yymsp[-2].minor.yy37.v);
  1185. yymsp[-5].minor.yy51.have = 0;
  1186. yymsp[-2].minor.yy37.have = 0;
  1187. if (!NCDIfBlock_PrependIf(&yymsp[0].minor.yy76.v, ifc)) {
  1188. goto failG1;
  1189. }
  1190. yygotominor.yy76.have = 1;
  1191. yygotominor.yy76.v = yymsp[0].minor.yy76.v;
  1192. yymsp[0].minor.yy76.have = 0;
  1193. goto doneG0;
  1194. failG1:
  1195. NCDIf_Free(&ifc);
  1196. failG0:
  1197. yygotominor.yy76.have = 0;
  1198. parser_out->out_of_memory = 1;
  1199. doneG0:
  1200. free_value(yymsp[-5].minor.yy51);
  1201. free_block(yymsp[-2].minor.yy37);
  1202. free_ifblock(yymsp[0].minor.yy76);
  1203. yy_destructor(yypParser,15,&yymsp[-7].minor);
  1204. yy_destructor(yypParser,7,&yymsp[-6].minor);
  1205. yy_destructor(yypParser,8,&yymsp[-4].minor);
  1206. yy_destructor(yypParser,5,&yymsp[-3].minor);
  1207. yy_destructor(yypParser,6,&yymsp[-1].minor);
  1208. }
  1209. #line 1296 "NCDConfigParser_parse.c"
  1210. break;
  1211. case 14: /* else_maybe ::= */
  1212. #line 450 "NCDConfigParser_parse.y"
  1213. {
  1214. yygotominor.yy37.have = 0;
  1215. }
  1216. #line 1303 "NCDConfigParser_parse.c"
  1217. break;
  1218. case 15: /* else_maybe ::= ELSE CURLY_OPEN statements CURLY_CLOSE */
  1219. #line 454 "NCDConfigParser_parse.y"
  1220. {
  1221. yygotominor.yy37 = yymsp[-1].minor.yy37;
  1222. yy_destructor(yypParser,16,&yymsp[-3].minor);
  1223. yy_destructor(yypParser,5,&yymsp[-2].minor);
  1224. yy_destructor(yypParser,6,&yymsp[0].minor);
  1225. }
  1226. #line 1313 "NCDConfigParser_parse.c"
  1227. break;
  1228. case 16: /* statements ::= statement */
  1229. #line 458 "NCDConfigParser_parse.y"
  1230. {
  1231. if (!yymsp[0].minor.yy79.have) {
  1232. goto failH0;
  1233. }
  1234. NCDBlock_Init(&yygotominor.yy37.v);
  1235. if (!NCDBlock_PrependStatement(&yygotominor.yy37.v, yymsp[0].minor.yy79.v)) {
  1236. goto failH1;
  1237. }
  1238. yymsp[0].minor.yy79.have = 0;
  1239. yygotominor.yy37.have = 1;
  1240. goto doneH;
  1241. failH1:
  1242. NCDBlock_Free(&yygotominor.yy37.v);
  1243. failH0:
  1244. yygotominor.yy37.have = 0;
  1245. parser_out->out_of_memory = 1;
  1246. doneH:
  1247. free_statement(yymsp[0].minor.yy79);
  1248. }
  1249. #line 1340 "NCDConfigParser_parse.c"
  1250. break;
  1251. case 17: /* statements ::= statement statements */
  1252. #line 482 "NCDConfigParser_parse.y"
  1253. {
  1254. if (!yymsp[-1].minor.yy79.have || !yymsp[0].minor.yy37.have) {
  1255. goto failI0;
  1256. }
  1257. if (!NCDBlock_PrependStatement(&yymsp[0].minor.yy37.v, yymsp[-1].minor.yy79.v)) {
  1258. goto failI1;
  1259. }
  1260. yymsp[-1].minor.yy79.have = 0;
  1261. yygotominor.yy37.have = 1;
  1262. yygotominor.yy37.v = yymsp[0].minor.yy37.v;
  1263. yymsp[0].minor.yy37.have = 0;
  1264. goto doneI;
  1265. failI1:
  1266. NCDBlock_Free(&yygotominor.yy37.v);
  1267. failI0:
  1268. yygotominor.yy37.have = 0;
  1269. parser_out->out_of_memory = 1;
  1270. doneI:
  1271. free_statement(yymsp[-1].minor.yy79);
  1272. free_block(yymsp[0].minor.yy37);
  1273. }
  1274. #line 1368 "NCDConfigParser_parse.c"
  1275. break;
  1276. case 18: /* dotted_name ::= NAME */
  1277. case 35: /* name_maybe ::= NAME */ yytestcase(yyruleno==35);
  1278. #line 507 "NCDConfigParser_parse.y"
  1279. {
  1280. ASSERT(yymsp[0].minor.yy0.str)
  1281. yygotominor.yy33 = yymsp[0].minor.yy0.str;
  1282. }
  1283. #line 1378 "NCDConfigParser_parse.c"
  1284. break;
  1285. case 19: /* dotted_name ::= NAME DOT dotted_name */
  1286. #line 513 "NCDConfigParser_parse.y"
  1287. {
  1288. ASSERT(yymsp[-2].minor.yy0.str)
  1289. if (!yymsp[0].minor.yy33) {
  1290. goto failJ0;
  1291. }
  1292. if (!(yygotominor.yy33 = concat_strings(3, yymsp[-2].minor.yy0.str, ".", yymsp[0].minor.yy33))) {
  1293. goto failJ0;
  1294. }
  1295. goto doneJ;
  1296. failJ0:
  1297. yygotominor.yy33 = NULL;
  1298. parser_out->out_of_memory = 1;
  1299. doneJ:
  1300. free_token(yymsp[-2].minor.yy0);
  1301. free(yymsp[0].minor.yy33);
  1302. yy_destructor(yypParser,17,&yymsp[-1].minor);
  1303. }
  1304. #line 1402 "NCDConfigParser_parse.c"
  1305. break;
  1306. case 20: /* statement_args_maybe ::= */
  1307. #line 533 "NCDConfigParser_parse.y"
  1308. {
  1309. yygotominor.yy51.have = 1;
  1310. NCDValue_InitList(&yygotominor.yy51.v);
  1311. }
  1312. #line 1410 "NCDConfigParser_parse.c"
  1313. break;
  1314. case 21: /* statement_args_maybe ::= list_contents */
  1315. case 32: /* value ::= list */ yytestcase(yyruleno==32);
  1316. case 33: /* value ::= map */ yytestcase(yyruleno==33);
  1317. #line 538 "NCDConfigParser_parse.y"
  1318. {
  1319. yygotominor.yy51 = yymsp[0].minor.yy51;
  1320. }
  1321. #line 1419 "NCDConfigParser_parse.c"
  1322. break;
  1323. case 22: /* list_contents ::= value */
  1324. #line 542 "NCDConfigParser_parse.y"
  1325. {
  1326. if (!yymsp[0].minor.yy51.have) {
  1327. goto failL0;
  1328. }
  1329. NCDValue_InitList(&yygotominor.yy51.v);
  1330. if (!NCDValue_ListPrepend(&yygotominor.yy51.v, yymsp[0].minor.yy51.v)) {
  1331. goto failL1;
  1332. }
  1333. yymsp[0].minor.yy51.have = 0;
  1334. yygotominor.yy51.have = 1;
  1335. goto doneL;
  1336. failL1:
  1337. NCDValue_Free(&yygotominor.yy51.v);
  1338. failL0:
  1339. yygotominor.yy51.have = 0;
  1340. parser_out->out_of_memory = 1;
  1341. doneL:
  1342. free_value(yymsp[0].minor.yy51);
  1343. }
  1344. #line 1446 "NCDConfigParser_parse.c"
  1345. break;
  1346. case 23: /* list_contents ::= value COMMA list_contents */
  1347. #line 566 "NCDConfigParser_parse.y"
  1348. {
  1349. if (!yymsp[-2].minor.yy51.have || !yymsp[0].minor.yy51.have) {
  1350. goto failM0;
  1351. }
  1352. if (!NCDValue_ListPrepend(&yymsp[0].minor.yy51.v, yymsp[-2].minor.yy51.v)) {
  1353. goto failM0;
  1354. }
  1355. yymsp[-2].minor.yy51.have = 0;
  1356. yygotominor.yy51.have = 1;
  1357. yygotominor.yy51.v = yymsp[0].minor.yy51.v;
  1358. yymsp[0].minor.yy51.have = 0;
  1359. goto doneM;
  1360. failM0:
  1361. yygotominor.yy51.have = 0;
  1362. parser_out->out_of_memory = 1;
  1363. doneM:
  1364. free_value(yymsp[-2].minor.yy51);
  1365. free_value(yymsp[0].minor.yy51);
  1366. yy_destructor(yypParser,18,&yymsp[-1].minor);
  1367. }
  1368. #line 1473 "NCDConfigParser_parse.c"
  1369. break;
  1370. case 24: /* list ::= CURLY_OPEN CURLY_CLOSE */
  1371. #line 589 "NCDConfigParser_parse.y"
  1372. {
  1373. yygotominor.yy51.have = 1;
  1374. NCDValue_InitList(&yygotominor.yy51.v);
  1375. yy_destructor(yypParser,5,&yymsp[-1].minor);
  1376. yy_destructor(yypParser,6,&yymsp[0].minor);
  1377. }
  1378. #line 1483 "NCDConfigParser_parse.c"
  1379. break;
  1380. case 25: /* list ::= CURLY_OPEN list_contents CURLY_CLOSE */
  1381. #line 594 "NCDConfigParser_parse.y"
  1382. {
  1383. yygotominor.yy51 = yymsp[-1].minor.yy51;
  1384. yy_destructor(yypParser,5,&yymsp[-2].minor);
  1385. yy_destructor(yypParser,6,&yymsp[0].minor);
  1386. }
  1387. #line 1492 "NCDConfigParser_parse.c"
  1388. break;
  1389. case 26: /* map_contents ::= value COLON value */
  1390. #line 598 "NCDConfigParser_parse.y"
  1391. {
  1392. if (!yymsp[-2].minor.yy51.have || !yymsp[0].minor.yy51.have) {
  1393. goto failS0;
  1394. }
  1395. NCDValue_InitMap(&yygotominor.yy51.v);
  1396. if (!NCDValue_MapPrepend(&yygotominor.yy51.v, yymsp[-2].minor.yy51.v, yymsp[0].minor.yy51.v)) {
  1397. goto failS1;
  1398. }
  1399. yymsp[-2].minor.yy51.have = 0;
  1400. yymsp[0].minor.yy51.have = 0;
  1401. yygotominor.yy51.have = 1;
  1402. goto doneS;
  1403. failS1:
  1404. NCDValue_Free(&yygotominor.yy51.v);
  1405. failS0:
  1406. yygotominor.yy51.have = 0;
  1407. parser_out->out_of_memory = 1;
  1408. doneS:
  1409. free_value(yymsp[-2].minor.yy51);
  1410. free_value(yymsp[0].minor.yy51);
  1411. yy_destructor(yypParser,14,&yymsp[-1].minor);
  1412. }
  1413. #line 1522 "NCDConfigParser_parse.c"
  1414. break;
  1415. case 27: /* map_contents ::= value COLON value COMMA map_contents */
  1416. #line 624 "NCDConfigParser_parse.y"
  1417. {
  1418. if (!yymsp[-4].minor.yy51.have || !yymsp[-2].minor.yy51.have || !yymsp[0].minor.yy51.have) {
  1419. goto failT0;
  1420. }
  1421. if (!NCDValue_MapPrepend(&yymsp[0].minor.yy51.v, yymsp[-4].minor.yy51.v, yymsp[-2].minor.yy51.v)) {
  1422. goto failT0;
  1423. }
  1424. yymsp[-4].minor.yy51.have = 0;
  1425. yymsp[-2].minor.yy51.have = 0;
  1426. yygotominor.yy51.have = 1;
  1427. yygotominor.yy51.v = yymsp[0].minor.yy51.v;
  1428. yymsp[0].minor.yy51.have = 0;
  1429. goto doneT;
  1430. failT0:
  1431. yygotominor.yy51.have = 0;
  1432. parser_out->out_of_memory = 1;
  1433. doneT:
  1434. free_value(yymsp[-4].minor.yy51);
  1435. free_value(yymsp[-2].minor.yy51);
  1436. free_value(yymsp[0].minor.yy51);
  1437. yy_destructor(yypParser,14,&yymsp[-3].minor);
  1438. yy_destructor(yypParser,18,&yymsp[-1].minor);
  1439. }
  1440. #line 1552 "NCDConfigParser_parse.c"
  1441. break;
  1442. case 28: /* map ::= BRACKET_OPEN BRACKET_CLOSE */
  1443. #line 649 "NCDConfigParser_parse.y"
  1444. {
  1445. yygotominor.yy51.have = 1;
  1446. NCDValue_InitMap(&yygotominor.yy51.v);
  1447. yy_destructor(yypParser,19,&yymsp[-1].minor);
  1448. yy_destructor(yypParser,20,&yymsp[0].minor);
  1449. }
  1450. #line 1562 "NCDConfigParser_parse.c"
  1451. break;
  1452. case 29: /* map ::= BRACKET_OPEN map_contents BRACKET_CLOSE */
  1453. #line 654 "NCDConfigParser_parse.y"
  1454. {
  1455. yygotominor.yy51 = yymsp[-1].minor.yy51;
  1456. yy_destructor(yypParser,19,&yymsp[-2].minor);
  1457. yy_destructor(yypParser,20,&yymsp[0].minor);
  1458. }
  1459. #line 1571 "NCDConfigParser_parse.c"
  1460. break;
  1461. case 30: /* value ::= STRING */
  1462. #line 658 "NCDConfigParser_parse.y"
  1463. {
  1464. ASSERT(yymsp[0].minor.yy0.str)
  1465. if (!NCDValue_InitStringBin(&yygotominor.yy51.v, (uint8_t *)yymsp[0].minor.yy0.str, yymsp[0].minor.yy0.len)) {
  1466. goto failU0;
  1467. }
  1468. yygotominor.yy51.have = 1;
  1469. goto doneU;
  1470. failU0:
  1471. yygotominor.yy51.have = 0;
  1472. parser_out->out_of_memory = 1;
  1473. doneU:
  1474. free_token(yymsp[0].minor.yy0);
  1475. }
  1476. #line 1591 "NCDConfigParser_parse.c"
  1477. break;
  1478. case 31: /* value ::= dotted_name */
  1479. #line 675 "NCDConfigParser_parse.y"
  1480. {
  1481. if (!yymsp[0].minor.yy33) {
  1482. goto failV0;
  1483. }
  1484. if (!NCDValue_InitVar(&yygotominor.yy51.v, yymsp[0].minor.yy33)) {
  1485. goto failV0;
  1486. }
  1487. yygotominor.yy51.have = 1;
  1488. goto doneV;
  1489. failV0:
  1490. yygotominor.yy51.have = 0;
  1491. parser_out->out_of_memory = 1;
  1492. doneV:
  1493. free(yymsp[0].minor.yy33);
  1494. }
  1495. #line 1613 "NCDConfigParser_parse.c"
  1496. break;
  1497. case 34: /* name_maybe ::= */
  1498. #line 702 "NCDConfigParser_parse.y"
  1499. {
  1500. yygotominor.yy33 = NULL;
  1501. }
  1502. #line 1620 "NCDConfigParser_parse.c"
  1503. break;
  1504. case 36: /* process_or_template ::= PROCESS */
  1505. #line 712 "NCDConfigParser_parse.y"
  1506. {
  1507. yygotominor.yy12 = 0;
  1508. yy_destructor(yypParser,21,&yymsp[0].minor);
  1509. }
  1510. #line 1628 "NCDConfigParser_parse.c"
  1511. break;
  1512. case 37: /* process_or_template ::= TEMPLATE */
  1513. #line 716 "NCDConfigParser_parse.y"
  1514. {
  1515. yygotominor.yy12 = 1;
  1516. yy_destructor(yypParser,22,&yymsp[0].minor);
  1517. }
  1518. #line 1636 "NCDConfigParser_parse.c"
  1519. break;
  1520. default:
  1521. break;
  1522. };
  1523. yygoto = yyRuleInfo[yyruleno].lhs;
  1524. yysize = yyRuleInfo[yyruleno].nrhs;
  1525. yypParser->yyidx -= yysize;
  1526. yyact = yy_find_reduce_action(yymsp[-yysize].stateno,(YYCODETYPE)yygoto);
  1527. if( yyact < YYNSTATE ){
  1528. #ifdef NDEBUG
  1529. /* If we are not debugging and the reduce action popped at least
  1530. ** one element off the stack, then we can push the new element back
  1531. ** onto the stack here, and skip the stack overflow test in yy_shift().
  1532. ** That gives a significant speed improvement. */
  1533. if( yysize ){
  1534. yypParser->yyidx++;
  1535. yymsp -= yysize-1;
  1536. yymsp->stateno = (YYACTIONTYPE)yyact;
  1537. yymsp->major = (YYCODETYPE)yygoto;
  1538. yymsp->minor = yygotominor;
  1539. }else
  1540. #endif
  1541. {
  1542. yy_shift(yypParser,yyact,yygoto,&yygotominor);
  1543. }
  1544. }else{
  1545. assert( yyact == YYNSTATE + YYNRULE + 1 );
  1546. yy_accept(yypParser);
  1547. }
  1548. }
  1549. /*
  1550. ** The following code executes when the parse fails
  1551. */
  1552. #ifndef YYNOERRORRECOVERY
  1553. static void yy_parse_failed(
  1554. yyParser *yypParser /* The parser */
  1555. ){
  1556. ParseARG_FETCH;
  1557. #ifndef NDEBUG
  1558. if( yyTraceFILE ){
  1559. fprintf(yyTraceFILE,"%sFail!\n",yyTracePrompt);
  1560. }
  1561. #endif
  1562. while( yypParser->yyidx>=0 ) yy_pop_parser_stack(yypParser);
  1563. /* Here code is inserted which will be executed whenever the
  1564. ** parser fails */
  1565. ParseARG_STORE; /* Suppress warning about unused %extra_argument variable */
  1566. }
  1567. #endif /* YYNOERRORRECOVERY */
  1568. /*
  1569. ** The following code executes when a syntax error first occurs.
  1570. */
  1571. static void yy_syntax_error(
  1572. yyParser *yypParser, /* The parser */
  1573. int yymajor, /* The major type of the error token */
  1574. YYMINORTYPE yyminor /* The minor type of the error token */
  1575. ){
  1576. ParseARG_FETCH;
  1577. #define TOKEN (yyminor.yy0)
  1578. #line 125 "NCDConfigParser_parse.y"
  1579. parser_out->syntax_error = 1;
  1580. #line 1701 "NCDConfigParser_parse.c"
  1581. ParseARG_STORE; /* Suppress warning about unused %extra_argument variable */
  1582. }
  1583. /*
  1584. ** The following is executed when the parser accepts
  1585. */
  1586. static void yy_accept(
  1587. yyParser *yypParser /* The parser */
  1588. ){
  1589. ParseARG_FETCH;
  1590. #ifndef NDEBUG
  1591. if( yyTraceFILE ){
  1592. fprintf(yyTraceFILE,"%sAccept!\n",yyTracePrompt);
  1593. }
  1594. #endif
  1595. while( yypParser->yyidx>=0 ) yy_pop_parser_stack(yypParser);
  1596. /* Here code is inserted which will be executed whenever the
  1597. ** parser accepts */
  1598. ParseARG_STORE; /* Suppress warning about unused %extra_argument variable */
  1599. }
  1600. /* The main parser program.
  1601. ** The first argument is a pointer to a structure obtained from
  1602. ** "ParseAlloc" which describes the current state of the parser.
  1603. ** The second argument is the major token number. The third is
  1604. ** the minor token. The fourth optional argument is whatever the
  1605. ** user wants (and specified in the grammar) and is available for
  1606. ** use by the action routines.
  1607. **
  1608. ** Inputs:
  1609. ** <ul>
  1610. ** <li> A pointer to the parser (an opaque structure.)
  1611. ** <li> The major token number.
  1612. ** <li> The minor token number.
  1613. ** <li> An option argument of a grammar-specified type.
  1614. ** </ul>
  1615. **
  1616. ** Outputs:
  1617. ** None.
  1618. */
  1619. void Parse(
  1620. void *yyp, /* The parser */
  1621. int yymajor, /* The major token code number */
  1622. ParseTOKENTYPE yyminor /* The value for the token */
  1623. ParseARG_PDECL /* Optional %extra_argument parameter */
  1624. ){
  1625. YYMINORTYPE yyminorunion;
  1626. int yyact; /* The parser action. */
  1627. int yyendofinput; /* True if we are at the end of input */
  1628. #ifdef YYERRORSYMBOL
  1629. int yyerrorhit = 0; /* True if yymajor has invoked an error */
  1630. #endif
  1631. yyParser *yypParser; /* The parser */
  1632. /* (re)initialize the parser, if necessary */
  1633. yypParser = (yyParser*)yyp;
  1634. if( yypParser->yyidx<0 ){
  1635. #if YYSTACKDEPTH<=0
  1636. if( yypParser->yystksz <=0 ){
  1637. /*memset(&yyminorunion, 0, sizeof(yyminorunion));*/
  1638. yyminorunion = yyzerominor;
  1639. yyStackOverflow(yypParser, &yyminorunion);
  1640. return;
  1641. }
  1642. #endif
  1643. yypParser->yyidx = 0;
  1644. yypParser->yyerrcnt = -1;
  1645. yypParser->yystack[0].stateno = 0;
  1646. yypParser->yystack[0].major = 0;
  1647. }
  1648. yyminorunion.yy0 = yyminor;
  1649. yyendofinput = (yymajor==0);
  1650. ParseARG_STORE;
  1651. #ifndef NDEBUG
  1652. if( yyTraceFILE ){
  1653. fprintf(yyTraceFILE,"%sInput %s\n",yyTracePrompt,yyTokenName[yymajor]);
  1654. }
  1655. #endif
  1656. do{
  1657. yyact = yy_find_shift_action(yypParser,(YYCODETYPE)yymajor);
  1658. if( yyact<YYNSTATE ){
  1659. assert( !yyendofinput ); /* Impossible to shift the $ token */
  1660. yy_shift(yypParser,yyact,yymajor,&yyminorunion);
  1661. yypParser->yyerrcnt--;
  1662. yymajor = YYNOCODE;
  1663. }else if( yyact < YYNSTATE + YYNRULE ){
  1664. yy_reduce(yypParser,yyact-YYNSTATE);
  1665. }else{
  1666. assert( yyact == YY_ERROR_ACTION );
  1667. #ifdef YYERRORSYMBOL
  1668. int yymx;
  1669. #endif
  1670. #ifndef NDEBUG
  1671. if( yyTraceFILE ){
  1672. fprintf(yyTraceFILE,"%sSyntax Error!\n",yyTracePrompt);
  1673. }
  1674. #endif
  1675. #ifdef YYERRORSYMBOL
  1676. /* A syntax error has occurred.
  1677. ** The response to an error depends upon whether or not the
  1678. ** grammar defines an error token "ERROR".
  1679. **
  1680. ** This is what we do if the grammar does define ERROR:
  1681. **
  1682. ** * Call the %syntax_error function.
  1683. **
  1684. ** * Begin popping the stack until we enter a state where
  1685. ** it is legal to shift the error symbol, then shift
  1686. ** the error symbol.
  1687. **
  1688. ** * Set the error count to three.
  1689. **
  1690. ** * Begin accepting and shifting new tokens. No new error
  1691. ** processing will occur until three tokens have been
  1692. ** shifted successfully.
  1693. **
  1694. */
  1695. if( yypParser->yyerrcnt<0 ){
  1696. yy_syntax_error(yypParser,yymajor,yyminorunion);
  1697. }
  1698. yymx = yypParser->yystack[yypParser->yyidx].major;
  1699. if( yymx==YYERRORSYMBOL || yyerrorhit ){
  1700. #ifndef NDEBUG
  1701. if( yyTraceFILE ){
  1702. fprintf(yyTraceFILE,"%sDiscard input token %s\n",
  1703. yyTracePrompt,yyTokenName[yymajor]);
  1704. }
  1705. #endif
  1706. yy_destructor(yypParser, (YYCODETYPE)yymajor,&yyminorunion);
  1707. yymajor = YYNOCODE;
  1708. }else{
  1709. while(
  1710. yypParser->yyidx >= 0 &&
  1711. yymx != YYERRORSYMBOL &&
  1712. (yyact = yy_find_reduce_action(
  1713. yypParser->yystack[yypParser->yyidx].stateno,
  1714. YYERRORSYMBOL)) >= YYNSTATE
  1715. ){
  1716. yy_pop_parser_stack(yypParser);
  1717. }
  1718. if( yypParser->yyidx < 0 || yymajor==0 ){
  1719. yy_destructor(yypParser,(YYCODETYPE)yymajor,&yyminorunion);
  1720. yy_parse_failed(yypParser);
  1721. yymajor = YYNOCODE;
  1722. }else if( yymx!=YYERRORSYMBOL ){
  1723. YYMINORTYPE u2;
  1724. u2.YYERRSYMDT = 0;
  1725. yy_shift(yypParser,yyact,YYERRORSYMBOL,&u2);
  1726. }
  1727. }
  1728. yypParser->yyerrcnt = 3;
  1729. yyerrorhit = 1;
  1730. #elif defined(YYNOERRORRECOVERY)
  1731. /* If the YYNOERRORRECOVERY macro is defined, then do not attempt to
  1732. ** do any kind of error recovery. Instead, simply invoke the syntax
  1733. ** error routine and continue going as if nothing had happened.
  1734. **
  1735. ** Applications can set this macro (for example inside %include) if
  1736. ** they intend to abandon the parse upon the first syntax error seen.
  1737. */
  1738. yy_syntax_error(yypParser,yymajor,yyminorunion);
  1739. yy_destructor(yypParser,(YYCODETYPE)yymajor,&yyminorunion);
  1740. yymajor = YYNOCODE;
  1741. #else /* YYERRORSYMBOL is not defined */
  1742. /* This is what we do if the grammar does not define ERROR:
  1743. **
  1744. ** * Report an error message, and throw away the input token.
  1745. **
  1746. ** * If the input token is $, then fail the parse.
  1747. **
  1748. ** As before, subsequent error messages are suppressed until
  1749. ** three input tokens have been successfully shifted.
  1750. */
  1751. if( yypParser->yyerrcnt<=0 ){
  1752. yy_syntax_error(yypParser,yymajor,yyminorunion);
  1753. }
  1754. yypParser->yyerrcnt = 3;
  1755. yy_destructor(yypParser,(YYCODETYPE)yymajor,&yyminorunion);
  1756. if( yyendofinput ){
  1757. yy_parse_failed(yypParser);
  1758. }
  1759. yymajor = YYNOCODE;
  1760. #endif
  1761. }
  1762. }while( yymajor!=YYNOCODE && yypParser->yyidx>=0 );
  1763. return;
  1764. }