NCDConfigParser_parse.c 57 KB

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