NCDConfigParser_parse.c 61 KB

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