NCDConfigParser_parse.c 61 KB

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