NCDConfigParser_parse.c 58 KB

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