NCDConfigParser_parse.c 62 KB

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