NCDConfigParser_parse.c 57 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839
  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 */ 129, 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 ::= process_or_template NAME CURLY_OPEN statements CURLY_CLOSE",
  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, 5 },
  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 ::= process_or_template NAME CURLY_OPEN statements CURLY_CLOSE */
  859. #line 145 "NCDConfigParser_parse.y"
  860. {
  861. ASSERT(yymsp[-3].minor.yy0.str)
  862. if (!yymsp[-1].minor.yy29.have) {
  863. goto failA0;
  864. }
  865. NCDProcess proc;
  866. if (!NCDProcess_Init(&proc, yymsp[-4].minor.yy8, yymsp[-3].minor.yy0.str, yymsp[-1].minor.yy29.v)) {
  867. goto failA0;
  868. }
  869. yymsp[-1].minor.yy29.have = 0;
  870. NCDProgram prog;
  871. NCDProgram_Init(&prog);
  872. if (!NCDProgram_PrependProcess(&prog, proc)) {
  873. goto failA1;
  874. }
  875. yygotominor.yy74.have = 1;
  876. yygotominor.yy74.v = prog;
  877. goto doneA;
  878. failA1:
  879. NCDProgram_Free(&prog);
  880. NCDProcess_Free(&proc);
  881. failA0:
  882. yygotominor.yy74.have = 0;
  883. parser_out->out_of_memory = 1;
  884. doneA:
  885. free_token(yymsp[-3].minor.yy0);
  886. free_block(yymsp[-1].minor.yy29);
  887. yy_destructor(yypParser,2,&yymsp[-2].minor);
  888. yy_destructor(yypParser,3,&yymsp[0].minor);
  889. }
  890. #line 941 "NCDConfigParser_parse.c"
  891. break;
  892. case 2: /* processes ::= process_or_template NAME CURLY_OPEN statements CURLY_CLOSE processes */
  893. #line 179 "NCDConfigParser_parse.y"
  894. {
  895. ASSERT(yymsp[-4].minor.yy0.str)
  896. if (!yymsp[-2].minor.yy29.have || !yymsp[0].minor.yy74.have) {
  897. goto failB0;
  898. }
  899. NCDProcess proc;
  900. if (!NCDProcess_Init(&proc, yymsp[-5].minor.yy8, yymsp[-4].minor.yy0.str, yymsp[-2].minor.yy29.v)) {
  901. goto failB0;
  902. }
  903. yymsp[-2].minor.yy29.have = 0;
  904. if (!NCDProgram_PrependProcess(&yymsp[0].minor.yy74.v, proc)) {
  905. goto failB1;
  906. }
  907. yygotominor.yy74.have = 1;
  908. yygotominor.yy74.v = yymsp[0].minor.yy74.v;
  909. yymsp[0].minor.yy74.have = 0;
  910. goto doneB;
  911. failB1:
  912. NCDProcess_Free(&proc);
  913. failB0:
  914. yygotominor.yy74.have = 0;
  915. parser_out->out_of_memory = 1;
  916. doneB:
  917. free_token(yymsp[-4].minor.yy0);
  918. free_block(yymsp[-2].minor.yy29);
  919. free_program(yymsp[0].minor.yy74);
  920. yy_destructor(yypParser,2,&yymsp[-3].minor);
  921. yy_destructor(yypParser,3,&yymsp[-1].minor);
  922. }
  923. #line 978 "NCDConfigParser_parse.c"
  924. break;
  925. case 3: /* statement ::= dotted_name ROUND_OPEN statement_args_maybe ROUND_CLOSE name_maybe SEMICOLON */
  926. #line 211 "NCDConfigParser_parse.y"
  927. {
  928. if (!yymsp[-5].minor.yy9 || !yymsp[-3].minor.yy27.have) {
  929. goto failC0;
  930. }
  931. if (!NCDStatement_InitReg(&yygotominor.yy23.v, yymsp[-1].minor.yy9, NULL, yymsp[-5].minor.yy9, yymsp[-3].minor.yy27.v)) {
  932. goto failC0;
  933. }
  934. yymsp[-3].minor.yy27.have = 0;
  935. yygotominor.yy23.have = 1;
  936. goto doneC;
  937. failC0:
  938. yygotominor.yy23.have = 0;
  939. parser_out->out_of_memory = 1;
  940. doneC:
  941. free(yymsp[-5].minor.yy9);
  942. free_value(yymsp[-3].minor.yy27);
  943. free(yymsp[-1].minor.yy9);
  944. yy_destructor(yypParser,4,&yymsp[-4].minor);
  945. yy_destructor(yypParser,5,&yymsp[-2].minor);
  946. yy_destructor(yypParser,6,&yymsp[0].minor);
  947. }
  948. #line 1006 "NCDConfigParser_parse.c"
  949. break;
  950. case 4: /* statement ::= dotted_name ARROW dotted_name ROUND_OPEN statement_args_maybe ROUND_CLOSE name_maybe SEMICOLON */
  951. #line 233 "NCDConfigParser_parse.y"
  952. {
  953. if (!yymsp[-7].minor.yy9 || !yymsp[-5].minor.yy9 || !yymsp[-3].minor.yy27.have) {
  954. goto failD0;
  955. }
  956. if (!NCDStatement_InitReg(&yygotominor.yy23.v, yymsp[-1].minor.yy9, yymsp[-7].minor.yy9, yymsp[-5].minor.yy9, yymsp[-3].minor.yy27.v)) {
  957. goto failD0;
  958. }
  959. yymsp[-3].minor.yy27.have = 0;
  960. yygotominor.yy23.have = 1;
  961. goto doneD;
  962. failD0:
  963. yygotominor.yy23.have = 0;
  964. parser_out->out_of_memory = 1;
  965. doneD:
  966. free(yymsp[-7].minor.yy9);
  967. free(yymsp[-5].minor.yy9);
  968. free_value(yymsp[-3].minor.yy27);
  969. free(yymsp[-1].minor.yy9);
  970. yy_destructor(yypParser,7,&yymsp[-6].minor);
  971. yy_destructor(yypParser,4,&yymsp[-4].minor);
  972. yy_destructor(yypParser,5,&yymsp[-2].minor);
  973. yy_destructor(yypParser,6,&yymsp[0].minor);
  974. }
  975. #line 1036 "NCDConfigParser_parse.c"
  976. break;
  977. case 5: /* statement ::= IF ROUND_OPEN value ROUND_CLOSE CURLY_OPEN statements CURLY_CLOSE elif_maybe else_maybe name_maybe SEMICOLON */
  978. #line 256 "NCDConfigParser_parse.y"
  979. {
  980. if (!yymsp[-8].minor.yy27.have || !yymsp[-5].minor.yy29.have || !yymsp[-3].minor.yy4.have) {
  981. goto failE0;
  982. }
  983. NCDIf ifc;
  984. NCDIf_Init(&ifc, yymsp[-8].minor.yy27.v, yymsp[-5].minor.yy29.v);
  985. yymsp[-8].minor.yy27.have = 0;
  986. yymsp[-5].minor.yy29.have = 0;
  987. if (!NCDIfBlock_PrependIf(&yymsp[-3].minor.yy4.v, ifc)) {
  988. NCDIf_Free(&ifc);
  989. goto failE0;
  990. }
  991. if (!NCDStatement_InitIf(&yygotominor.yy23.v, yymsp[-1].minor.yy9, yymsp[-3].minor.yy4.v)) {
  992. goto failE0;
  993. }
  994. yymsp[-3].minor.yy4.have = 0;
  995. if (yymsp[-2].minor.yy29.have) {
  996. NCDStatement_IfAddElse(&yygotominor.yy23.v, yymsp[-2].minor.yy29.v);
  997. yymsp[-2].minor.yy29.have = 0;
  998. }
  999. yygotominor.yy23.have = 1;
  1000. goto doneE;
  1001. failE0:
  1002. yygotominor.yy23.have = 0;
  1003. parser_out->out_of_memory = 1;
  1004. doneE:
  1005. free_value(yymsp[-8].minor.yy27);
  1006. free_block(yymsp[-5].minor.yy29);
  1007. free_ifblock(yymsp[-3].minor.yy4);
  1008. free_block(yymsp[-2].minor.yy29);
  1009. free(yymsp[-1].minor.yy9);
  1010. yy_destructor(yypParser,8,&yymsp[-10].minor);
  1011. yy_destructor(yypParser,4,&yymsp[-9].minor);
  1012. yy_destructor(yypParser,5,&yymsp[-7].minor);
  1013. yy_destructor(yypParser,2,&yymsp[-6].minor);
  1014. yy_destructor(yypParser,3,&yymsp[-4].minor);
  1015. yy_destructor(yypParser,6,&yymsp[0].minor);
  1016. }
  1017. #line 1084 "NCDConfigParser_parse.c"
  1018. break;
  1019. case 6: /* statement ::= FOREACH ROUND_OPEN value AS NAME ROUND_CLOSE CURLY_OPEN statements CURLY_CLOSE name_maybe SEMICOLON */
  1020. #line 295 "NCDConfigParser_parse.y"
  1021. {
  1022. if (!yymsp[-8].minor.yy27.have || !yymsp[-6].minor.yy0.str || !yymsp[-3].minor.yy29.have) {
  1023. goto failEA0;
  1024. }
  1025. 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)) {
  1026. goto failEA0;
  1027. }
  1028. yymsp[-8].minor.yy27.have = 0;
  1029. yymsp[-3].minor.yy29.have = 0;
  1030. yygotominor.yy23.have = 1;
  1031. goto doneEA0;
  1032. failEA0:
  1033. yygotominor.yy23.have = 0;
  1034. parser_out->out_of_memory = 1;
  1035. doneEA0:
  1036. free_value(yymsp[-8].minor.yy27);
  1037. free_token(yymsp[-6].minor.yy0);
  1038. free_block(yymsp[-3].minor.yy29);
  1039. free(yymsp[-1].minor.yy9);
  1040. yy_destructor(yypParser,9,&yymsp[-10].minor);
  1041. yy_destructor(yypParser,4,&yymsp[-9].minor);
  1042. yy_destructor(yypParser,10,&yymsp[-7].minor);
  1043. yy_destructor(yypParser,5,&yymsp[-5].minor);
  1044. yy_destructor(yypParser,2,&yymsp[-4].minor);
  1045. yy_destructor(yypParser,3,&yymsp[-2].minor);
  1046. yy_destructor(yypParser,6,&yymsp[0].minor);
  1047. }
  1048. #line 1118 "NCDConfigParser_parse.c"
  1049. break;
  1050. case 7: /* statement ::= FOREACH ROUND_OPEN value AS NAME COLON NAME ROUND_CLOSE CURLY_OPEN statements CURLY_CLOSE name_maybe SEMICOLON */
  1051. #line 319 "NCDConfigParser_parse.y"
  1052. {
  1053. if (!yymsp[-10].minor.yy27.have || !yymsp[-8].minor.yy0.str || !yymsp[-6].minor.yy0.str || !yymsp[-3].minor.yy29.have) {
  1054. goto failEB0;
  1055. }
  1056. 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)) {
  1057. goto failEB0;
  1058. }
  1059. yymsp[-10].minor.yy27.have = 0;
  1060. yymsp[-3].minor.yy29.have = 0;
  1061. yygotominor.yy23.have = 1;
  1062. goto doneEB0;
  1063. failEB0:
  1064. yygotominor.yy23.have = 0;
  1065. parser_out->out_of_memory = 1;
  1066. doneEB0:
  1067. free_value(yymsp[-10].minor.yy27);
  1068. free_token(yymsp[-8].minor.yy0);
  1069. free_token(yymsp[-6].minor.yy0);
  1070. free_block(yymsp[-3].minor.yy29);
  1071. free(yymsp[-1].minor.yy9);
  1072. yy_destructor(yypParser,9,&yymsp[-12].minor);
  1073. yy_destructor(yypParser,4,&yymsp[-11].minor);
  1074. yy_destructor(yypParser,10,&yymsp[-9].minor);
  1075. yy_destructor(yypParser,11,&yymsp[-7].minor);
  1076. yy_destructor(yypParser,5,&yymsp[-5].minor);
  1077. yy_destructor(yypParser,2,&yymsp[-4].minor);
  1078. yy_destructor(yypParser,3,&yymsp[-2].minor);
  1079. yy_destructor(yypParser,6,&yymsp[0].minor);
  1080. }
  1081. #line 1154 "NCDConfigParser_parse.c"
  1082. break;
  1083. case 8: /* elif_maybe ::= */
  1084. #line 344 "NCDConfigParser_parse.y"
  1085. {
  1086. NCDIfBlock_Init(&yygotominor.yy4.v);
  1087. yygotominor.yy4.have = 1;
  1088. }
  1089. #line 1162 "NCDConfigParser_parse.c"
  1090. break;
  1091. case 9: /* elif_maybe ::= elif */
  1092. #line 349 "NCDConfigParser_parse.y"
  1093. {
  1094. yygotominor.yy4 = yymsp[0].minor.yy4;
  1095. }
  1096. #line 1169 "NCDConfigParser_parse.c"
  1097. break;
  1098. case 10: /* elif ::= ELIF ROUND_OPEN value ROUND_CLOSE CURLY_OPEN statements CURLY_CLOSE */
  1099. #line 353 "NCDConfigParser_parse.y"
  1100. {
  1101. if (!yymsp[-4].minor.yy27.have || !yymsp[-1].minor.yy29.have) {
  1102. goto failF0;
  1103. }
  1104. NCDIfBlock_Init(&yygotominor.yy4.v);
  1105. NCDIf ifc;
  1106. NCDIf_Init(&ifc, yymsp[-4].minor.yy27.v, yymsp[-1].minor.yy29.v);
  1107. yymsp[-4].minor.yy27.have = 0;
  1108. yymsp[-1].minor.yy29.have = 0;
  1109. if (!NCDIfBlock_PrependIf(&yygotominor.yy4.v, ifc)) {
  1110. goto failF1;
  1111. }
  1112. yygotominor.yy4.have = 1;
  1113. goto doneF0;
  1114. failF1:
  1115. NCDIf_Free(&ifc);
  1116. NCDIfBlock_Free(&yygotominor.yy4.v);
  1117. failF0:
  1118. yygotominor.yy4.have = 0;
  1119. parser_out->out_of_memory = 1;
  1120. doneF0:
  1121. free_value(yymsp[-4].minor.yy27);
  1122. free_block(yymsp[-1].minor.yy29);
  1123. yy_destructor(yypParser,12,&yymsp[-6].minor);
  1124. yy_destructor(yypParser,4,&yymsp[-5].minor);
  1125. yy_destructor(yypParser,5,&yymsp[-3].minor);
  1126. yy_destructor(yypParser,2,&yymsp[-2].minor);
  1127. yy_destructor(yypParser,3,&yymsp[0].minor);
  1128. }
  1129. #line 1207 "NCDConfigParser_parse.c"
  1130. break;
  1131. case 11: /* elif ::= ELIF ROUND_OPEN value ROUND_CLOSE CURLY_OPEN statements CURLY_CLOSE elif */
  1132. #line 383 "NCDConfigParser_parse.y"
  1133. {
  1134. if (!yymsp[-5].minor.yy27.have || !yymsp[-2].minor.yy29.have || !yymsp[0].minor.yy4.have) {
  1135. goto failG0;
  1136. }
  1137. NCDIf ifc;
  1138. NCDIf_Init(&ifc, yymsp[-5].minor.yy27.v, yymsp[-2].minor.yy29.v);
  1139. yymsp[-5].minor.yy27.have = 0;
  1140. yymsp[-2].minor.yy29.have = 0;
  1141. if (!NCDIfBlock_PrependIf(&yymsp[0].minor.yy4.v, ifc)) {
  1142. goto failG1;
  1143. }
  1144. yygotominor.yy4.have = 1;
  1145. yygotominor.yy4.v = yymsp[0].minor.yy4.v;
  1146. yymsp[0].minor.yy4.have = 0;
  1147. goto doneG0;
  1148. failG1:
  1149. NCDIf_Free(&ifc);
  1150. failG0:
  1151. yygotominor.yy4.have = 0;
  1152. parser_out->out_of_memory = 1;
  1153. doneG0:
  1154. free_value(yymsp[-5].minor.yy27);
  1155. free_block(yymsp[-2].minor.yy29);
  1156. free_ifblock(yymsp[0].minor.yy4);
  1157. yy_destructor(yypParser,12,&yymsp[-7].minor);
  1158. yy_destructor(yypParser,4,&yymsp[-6].minor);
  1159. yy_destructor(yypParser,5,&yymsp[-4].minor);
  1160. yy_destructor(yypParser,2,&yymsp[-3].minor);
  1161. yy_destructor(yypParser,3,&yymsp[-1].minor);
  1162. }
  1163. #line 1245 "NCDConfigParser_parse.c"
  1164. break;
  1165. case 12: /* else_maybe ::= */
  1166. #line 413 "NCDConfigParser_parse.y"
  1167. {
  1168. yygotominor.yy29.have = 0;
  1169. }
  1170. #line 1252 "NCDConfigParser_parse.c"
  1171. break;
  1172. case 13: /* else_maybe ::= ELSE CURLY_OPEN statements CURLY_CLOSE */
  1173. #line 417 "NCDConfigParser_parse.y"
  1174. {
  1175. yygotominor.yy29 = yymsp[-1].minor.yy29;
  1176. yy_destructor(yypParser,13,&yymsp[-3].minor);
  1177. yy_destructor(yypParser,2,&yymsp[-2].minor);
  1178. yy_destructor(yypParser,3,&yymsp[0].minor);
  1179. }
  1180. #line 1262 "NCDConfigParser_parse.c"
  1181. break;
  1182. case 14: /* statements ::= statement */
  1183. #line 421 "NCDConfigParser_parse.y"
  1184. {
  1185. if (!yymsp[0].minor.yy23.have) {
  1186. goto failH0;
  1187. }
  1188. NCDBlock_Init(&yygotominor.yy29.v);
  1189. if (!NCDBlock_PrependStatement(&yygotominor.yy29.v, yymsp[0].minor.yy23.v)) {
  1190. goto failH1;
  1191. }
  1192. yymsp[0].minor.yy23.have = 0;
  1193. yygotominor.yy29.have = 1;
  1194. goto doneH;
  1195. failH1:
  1196. NCDBlock_Free(&yygotominor.yy29.v);
  1197. failH0:
  1198. yygotominor.yy29.have = 0;
  1199. parser_out->out_of_memory = 1;
  1200. doneH:
  1201. free_statement(yymsp[0].minor.yy23);
  1202. }
  1203. #line 1289 "NCDConfigParser_parse.c"
  1204. break;
  1205. case 15: /* statements ::= statement statements */
  1206. #line 445 "NCDConfigParser_parse.y"
  1207. {
  1208. if (!yymsp[-1].minor.yy23.have || !yymsp[0].minor.yy29.have) {
  1209. goto failI0;
  1210. }
  1211. if (!NCDBlock_PrependStatement(&yymsp[0].minor.yy29.v, yymsp[-1].minor.yy23.v)) {
  1212. goto failI1;
  1213. }
  1214. yymsp[-1].minor.yy23.have = 0;
  1215. yygotominor.yy29.have = 1;
  1216. yygotominor.yy29.v = yymsp[0].minor.yy29.v;
  1217. yymsp[0].minor.yy29.have = 0;
  1218. goto doneI;
  1219. failI1:
  1220. NCDBlock_Free(&yygotominor.yy29.v);
  1221. failI0:
  1222. yygotominor.yy29.have = 0;
  1223. parser_out->out_of_memory = 1;
  1224. doneI:
  1225. free_statement(yymsp[-1].minor.yy23);
  1226. free_block(yymsp[0].minor.yy29);
  1227. }
  1228. #line 1317 "NCDConfigParser_parse.c"
  1229. break;
  1230. case 16: /* dotted_name ::= NAME */
  1231. case 33: /* name_maybe ::= NAME */ yytestcase(yyruleno==33);
  1232. #line 470 "NCDConfigParser_parse.y"
  1233. {
  1234. ASSERT(yymsp[0].minor.yy0.str)
  1235. yygotominor.yy9 = yymsp[0].minor.yy0.str;
  1236. }
  1237. #line 1327 "NCDConfigParser_parse.c"
  1238. break;
  1239. case 17: /* dotted_name ::= NAME DOT dotted_name */
  1240. #line 476 "NCDConfigParser_parse.y"
  1241. {
  1242. ASSERT(yymsp[-2].minor.yy0.str)
  1243. if (!yymsp[0].minor.yy9) {
  1244. goto failJ0;
  1245. }
  1246. if (!(yygotominor.yy9 = concat_strings(3, yymsp[-2].minor.yy0.str, ".", yymsp[0].minor.yy9))) {
  1247. goto failJ0;
  1248. }
  1249. goto doneJ;
  1250. failJ0:
  1251. yygotominor.yy9 = NULL;
  1252. parser_out->out_of_memory = 1;
  1253. doneJ:
  1254. free_token(yymsp[-2].minor.yy0);
  1255. free(yymsp[0].minor.yy9);
  1256. yy_destructor(yypParser,14,&yymsp[-1].minor);
  1257. }
  1258. #line 1351 "NCDConfigParser_parse.c"
  1259. break;
  1260. case 18: /* statement_args_maybe ::= */
  1261. #line 496 "NCDConfigParser_parse.y"
  1262. {
  1263. yygotominor.yy27.have = 1;
  1264. NCDValue_InitList(&yygotominor.yy27.v);
  1265. }
  1266. #line 1359 "NCDConfigParser_parse.c"
  1267. break;
  1268. case 19: /* statement_args_maybe ::= list_contents */
  1269. case 30: /* value ::= list */ yytestcase(yyruleno==30);
  1270. case 31: /* value ::= map */ yytestcase(yyruleno==31);
  1271. #line 501 "NCDConfigParser_parse.y"
  1272. {
  1273. yygotominor.yy27 = yymsp[0].minor.yy27;
  1274. }
  1275. #line 1368 "NCDConfigParser_parse.c"
  1276. break;
  1277. case 20: /* list_contents ::= value */
  1278. #line 505 "NCDConfigParser_parse.y"
  1279. {
  1280. if (!yymsp[0].minor.yy27.have) {
  1281. goto failL0;
  1282. }
  1283. NCDValue_InitList(&yygotominor.yy27.v);
  1284. if (!NCDValue_ListPrepend(&yygotominor.yy27.v, yymsp[0].minor.yy27.v)) {
  1285. goto failL1;
  1286. }
  1287. yymsp[0].minor.yy27.have = 0;
  1288. yygotominor.yy27.have = 1;
  1289. goto doneL;
  1290. failL1:
  1291. NCDValue_Free(&yygotominor.yy27.v);
  1292. failL0:
  1293. yygotominor.yy27.have = 0;
  1294. parser_out->out_of_memory = 1;
  1295. doneL:
  1296. free_value(yymsp[0].minor.yy27);
  1297. }
  1298. #line 1395 "NCDConfigParser_parse.c"
  1299. break;
  1300. case 21: /* list_contents ::= value COMMA list_contents */
  1301. #line 529 "NCDConfigParser_parse.y"
  1302. {
  1303. if (!yymsp[-2].minor.yy27.have || !yymsp[0].minor.yy27.have) {
  1304. goto failM0;
  1305. }
  1306. if (!NCDValue_ListPrepend(&yymsp[0].minor.yy27.v, yymsp[-2].minor.yy27.v)) {
  1307. goto failM0;
  1308. }
  1309. yymsp[-2].minor.yy27.have = 0;
  1310. yygotominor.yy27.have = 1;
  1311. yygotominor.yy27.v = yymsp[0].minor.yy27.v;
  1312. yymsp[0].minor.yy27.have = 0;
  1313. goto doneM;
  1314. failM0:
  1315. yygotominor.yy27.have = 0;
  1316. parser_out->out_of_memory = 1;
  1317. doneM:
  1318. free_value(yymsp[-2].minor.yy27);
  1319. free_value(yymsp[0].minor.yy27);
  1320. yy_destructor(yypParser,15,&yymsp[-1].minor);
  1321. }
  1322. #line 1422 "NCDConfigParser_parse.c"
  1323. break;
  1324. case 22: /* list ::= CURLY_OPEN CURLY_CLOSE */
  1325. #line 552 "NCDConfigParser_parse.y"
  1326. {
  1327. yygotominor.yy27.have = 1;
  1328. NCDValue_InitList(&yygotominor.yy27.v);
  1329. yy_destructor(yypParser,2,&yymsp[-1].minor);
  1330. yy_destructor(yypParser,3,&yymsp[0].minor);
  1331. }
  1332. #line 1432 "NCDConfigParser_parse.c"
  1333. break;
  1334. case 23: /* list ::= CURLY_OPEN list_contents CURLY_CLOSE */
  1335. #line 557 "NCDConfigParser_parse.y"
  1336. {
  1337. yygotominor.yy27 = yymsp[-1].minor.yy27;
  1338. yy_destructor(yypParser,2,&yymsp[-2].minor);
  1339. yy_destructor(yypParser,3,&yymsp[0].minor);
  1340. }
  1341. #line 1441 "NCDConfigParser_parse.c"
  1342. break;
  1343. case 24: /* map_contents ::= value COLON value */
  1344. #line 561 "NCDConfigParser_parse.y"
  1345. {
  1346. if (!yymsp[-2].minor.yy27.have || !yymsp[0].minor.yy27.have) {
  1347. goto failS0;
  1348. }
  1349. NCDValue_InitMap(&yygotominor.yy27.v);
  1350. if (!NCDValue_MapPrepend(&yygotominor.yy27.v, yymsp[-2].minor.yy27.v, yymsp[0].minor.yy27.v)) {
  1351. goto failS1;
  1352. }
  1353. yymsp[-2].minor.yy27.have = 0;
  1354. yymsp[0].minor.yy27.have = 0;
  1355. yygotominor.yy27.have = 1;
  1356. goto doneS;
  1357. failS1:
  1358. NCDValue_Free(&yygotominor.yy27.v);
  1359. failS0:
  1360. yygotominor.yy27.have = 0;
  1361. parser_out->out_of_memory = 1;
  1362. doneS:
  1363. free_value(yymsp[-2].minor.yy27);
  1364. free_value(yymsp[0].minor.yy27);
  1365. yy_destructor(yypParser,11,&yymsp[-1].minor);
  1366. }
  1367. #line 1471 "NCDConfigParser_parse.c"
  1368. break;
  1369. case 25: /* map_contents ::= value COLON value COMMA map_contents */
  1370. #line 587 "NCDConfigParser_parse.y"
  1371. {
  1372. if (!yymsp[-4].minor.yy27.have || !yymsp[-2].minor.yy27.have || !yymsp[0].minor.yy27.have) {
  1373. goto failT0;
  1374. }
  1375. if (!NCDValue_MapPrepend(&yymsp[0].minor.yy27.v, yymsp[-4].minor.yy27.v, yymsp[-2].minor.yy27.v)) {
  1376. goto failT0;
  1377. }
  1378. yymsp[-4].minor.yy27.have = 0;
  1379. yymsp[-2].minor.yy27.have = 0;
  1380. yygotominor.yy27.have = 1;
  1381. yygotominor.yy27.v = yymsp[0].minor.yy27.v;
  1382. yymsp[0].minor.yy27.have = 0;
  1383. goto doneT;
  1384. failT0:
  1385. yygotominor.yy27.have = 0;
  1386. parser_out->out_of_memory = 1;
  1387. doneT:
  1388. free_value(yymsp[-4].minor.yy27);
  1389. free_value(yymsp[-2].minor.yy27);
  1390. free_value(yymsp[0].minor.yy27);
  1391. yy_destructor(yypParser,11,&yymsp[-3].minor);
  1392. yy_destructor(yypParser,15,&yymsp[-1].minor);
  1393. }
  1394. #line 1501 "NCDConfigParser_parse.c"
  1395. break;
  1396. case 26: /* map ::= BRACKET_OPEN BRACKET_CLOSE */
  1397. #line 612 "NCDConfigParser_parse.y"
  1398. {
  1399. yygotominor.yy27.have = 1;
  1400. NCDValue_InitMap(&yygotominor.yy27.v);
  1401. yy_destructor(yypParser,16,&yymsp[-1].minor);
  1402. yy_destructor(yypParser,17,&yymsp[0].minor);
  1403. }
  1404. #line 1511 "NCDConfigParser_parse.c"
  1405. break;
  1406. case 27: /* map ::= BRACKET_OPEN map_contents BRACKET_CLOSE */
  1407. #line 617 "NCDConfigParser_parse.y"
  1408. {
  1409. yygotominor.yy27 = yymsp[-1].minor.yy27;
  1410. yy_destructor(yypParser,16,&yymsp[-2].minor);
  1411. yy_destructor(yypParser,17,&yymsp[0].minor);
  1412. }
  1413. #line 1520 "NCDConfigParser_parse.c"
  1414. break;
  1415. case 28: /* value ::= STRING */
  1416. #line 621 "NCDConfigParser_parse.y"
  1417. {
  1418. ASSERT(yymsp[0].minor.yy0.str)
  1419. if (!NCDValue_InitStringBin(&yygotominor.yy27.v, (uint8_t *)yymsp[0].minor.yy0.str, yymsp[0].minor.yy0.len)) {
  1420. goto failU0;
  1421. }
  1422. yygotominor.yy27.have = 1;
  1423. goto doneU;
  1424. failU0:
  1425. yygotominor.yy27.have = 0;
  1426. parser_out->out_of_memory = 1;
  1427. doneU:
  1428. free_token(yymsp[0].minor.yy0);
  1429. }
  1430. #line 1540 "NCDConfigParser_parse.c"
  1431. break;
  1432. case 29: /* value ::= dotted_name */
  1433. #line 638 "NCDConfigParser_parse.y"
  1434. {
  1435. if (!yymsp[0].minor.yy9) {
  1436. goto failV0;
  1437. }
  1438. if (!NCDValue_InitVar(&yygotominor.yy27.v, yymsp[0].minor.yy9)) {
  1439. goto failV0;
  1440. }
  1441. yygotominor.yy27.have = 1;
  1442. goto doneV;
  1443. failV0:
  1444. yygotominor.yy27.have = 0;
  1445. parser_out->out_of_memory = 1;
  1446. doneV:
  1447. free(yymsp[0].minor.yy9);
  1448. }
  1449. #line 1562 "NCDConfigParser_parse.c"
  1450. break;
  1451. case 32: /* name_maybe ::= */
  1452. #line 665 "NCDConfigParser_parse.y"
  1453. {
  1454. yygotominor.yy9 = NULL;
  1455. }
  1456. #line 1569 "NCDConfigParser_parse.c"
  1457. break;
  1458. case 34: /* process_or_template ::= PROCESS */
  1459. #line 675 "NCDConfigParser_parse.y"
  1460. {
  1461. yygotominor.yy8 = 0;
  1462. yy_destructor(yypParser,19,&yymsp[0].minor);
  1463. }
  1464. #line 1577 "NCDConfigParser_parse.c"
  1465. break;
  1466. case 35: /* process_or_template ::= TEMPLATE */
  1467. #line 679 "NCDConfigParser_parse.y"
  1468. {
  1469. yygotominor.yy8 = 1;
  1470. yy_destructor(yypParser,20,&yymsp[0].minor);
  1471. }
  1472. #line 1585 "NCDConfigParser_parse.c"
  1473. break;
  1474. default:
  1475. break;
  1476. };
  1477. yygoto = yyRuleInfo[yyruleno].lhs;
  1478. yysize = yyRuleInfo[yyruleno].nrhs;
  1479. yypParser->yyidx -= yysize;
  1480. yyact = yy_find_reduce_action(yymsp[-yysize].stateno,(YYCODETYPE)yygoto);
  1481. if( yyact < YYNSTATE ){
  1482. #ifdef NDEBUG
  1483. /* If we are not debugging and the reduce action popped at least
  1484. ** one element off the stack, then we can push the new element back
  1485. ** onto the stack here, and skip the stack overflow test in yy_shift().
  1486. ** That gives a significant speed improvement. */
  1487. if( yysize ){
  1488. yypParser->yyidx++;
  1489. yymsp -= yysize-1;
  1490. yymsp->stateno = (YYACTIONTYPE)yyact;
  1491. yymsp->major = (YYCODETYPE)yygoto;
  1492. yymsp->minor = yygotominor;
  1493. }else
  1494. #endif
  1495. {
  1496. yy_shift(yypParser,yyact,yygoto,&yygotominor);
  1497. }
  1498. }else{
  1499. assert( yyact == YYNSTATE + YYNRULE + 1 );
  1500. yy_accept(yypParser);
  1501. }
  1502. }
  1503. /*
  1504. ** The following code executes when the parse fails
  1505. */
  1506. #ifndef YYNOERRORRECOVERY
  1507. static void yy_parse_failed(
  1508. yyParser *yypParser /* The parser */
  1509. ){
  1510. ParseARG_FETCH;
  1511. #ifndef NDEBUG
  1512. if( yyTraceFILE ){
  1513. fprintf(yyTraceFILE,"%sFail!\n",yyTracePrompt);
  1514. }
  1515. #endif
  1516. while( yypParser->yyidx>=0 ) yy_pop_parser_stack(yypParser);
  1517. /* Here code is inserted which will be executed whenever the
  1518. ** parser fails */
  1519. ParseARG_STORE; /* Suppress warning about unused %extra_argument variable */
  1520. }
  1521. #endif /* YYNOERRORRECOVERY */
  1522. /*
  1523. ** The following code executes when a syntax error first occurs.
  1524. */
  1525. static void yy_syntax_error(
  1526. yyParser *yypParser, /* The parser */
  1527. int yymajor, /* The major type of the error token */
  1528. YYMINORTYPE yyminor /* The minor type of the error token */
  1529. ){
  1530. ParseARG_FETCH;
  1531. #define TOKEN (yyminor.yy0)
  1532. #line 125 "NCDConfigParser_parse.y"
  1533. parser_out->syntax_error = 1;
  1534. #line 1650 "NCDConfigParser_parse.c"
  1535. ParseARG_STORE; /* Suppress warning about unused %extra_argument variable */
  1536. }
  1537. /*
  1538. ** The following is executed when the parser accepts
  1539. */
  1540. static void yy_accept(
  1541. yyParser *yypParser /* The parser */
  1542. ){
  1543. ParseARG_FETCH;
  1544. #ifndef NDEBUG
  1545. if( yyTraceFILE ){
  1546. fprintf(yyTraceFILE,"%sAccept!\n",yyTracePrompt);
  1547. }
  1548. #endif
  1549. while( yypParser->yyidx>=0 ) yy_pop_parser_stack(yypParser);
  1550. /* Here code is inserted which will be executed whenever the
  1551. ** parser accepts */
  1552. ParseARG_STORE; /* Suppress warning about unused %extra_argument variable */
  1553. }
  1554. /* The main parser program.
  1555. ** The first argument is a pointer to a structure obtained from
  1556. ** "ParseAlloc" which describes the current state of the parser.
  1557. ** The second argument is the major token number. The third is
  1558. ** the minor token. The fourth optional argument is whatever the
  1559. ** user wants (and specified in the grammar) and is available for
  1560. ** use by the action routines.
  1561. **
  1562. ** Inputs:
  1563. ** <ul>
  1564. ** <li> A pointer to the parser (an opaque structure.)
  1565. ** <li> The major token number.
  1566. ** <li> The minor token number.
  1567. ** <li> An option argument of a grammar-specified type.
  1568. ** </ul>
  1569. **
  1570. ** Outputs:
  1571. ** None.
  1572. */
  1573. void Parse(
  1574. void *yyp, /* The parser */
  1575. int yymajor, /* The major token code number */
  1576. ParseTOKENTYPE yyminor /* The value for the token */
  1577. ParseARG_PDECL /* Optional %extra_argument parameter */
  1578. ){
  1579. YYMINORTYPE yyminorunion;
  1580. int yyact; /* The parser action. */
  1581. int yyendofinput; /* True if we are at the end of input */
  1582. #ifdef YYERRORSYMBOL
  1583. int yyerrorhit = 0; /* True if yymajor has invoked an error */
  1584. #endif
  1585. yyParser *yypParser; /* The parser */
  1586. /* (re)initialize the parser, if necessary */
  1587. yypParser = (yyParser*)yyp;
  1588. if( yypParser->yyidx<0 ){
  1589. #if YYSTACKDEPTH<=0
  1590. if( yypParser->yystksz <=0 ){
  1591. /*memset(&yyminorunion, 0, sizeof(yyminorunion));*/
  1592. yyminorunion = yyzerominor;
  1593. yyStackOverflow(yypParser, &yyminorunion);
  1594. return;
  1595. }
  1596. #endif
  1597. yypParser->yyidx = 0;
  1598. yypParser->yyerrcnt = -1;
  1599. yypParser->yystack[0].stateno = 0;
  1600. yypParser->yystack[0].major = 0;
  1601. }
  1602. yyminorunion.yy0 = yyminor;
  1603. yyendofinput = (yymajor==0);
  1604. ParseARG_STORE;
  1605. #ifndef NDEBUG
  1606. if( yyTraceFILE ){
  1607. fprintf(yyTraceFILE,"%sInput %s\n",yyTracePrompt,yyTokenName[yymajor]);
  1608. }
  1609. #endif
  1610. do{
  1611. yyact = yy_find_shift_action(yypParser,(YYCODETYPE)yymajor);
  1612. if( yyact<YYNSTATE ){
  1613. assert( !yyendofinput ); /* Impossible to shift the $ token */
  1614. yy_shift(yypParser,yyact,yymajor,&yyminorunion);
  1615. yypParser->yyerrcnt--;
  1616. yymajor = YYNOCODE;
  1617. }else if( yyact < YYNSTATE + YYNRULE ){
  1618. yy_reduce(yypParser,yyact-YYNSTATE);
  1619. }else{
  1620. assert( yyact == YY_ERROR_ACTION );
  1621. #ifdef YYERRORSYMBOL
  1622. int yymx;
  1623. #endif
  1624. #ifndef NDEBUG
  1625. if( yyTraceFILE ){
  1626. fprintf(yyTraceFILE,"%sSyntax Error!\n",yyTracePrompt);
  1627. }
  1628. #endif
  1629. #ifdef YYERRORSYMBOL
  1630. /* A syntax error has occurred.
  1631. ** The response to an error depends upon whether or not the
  1632. ** grammar defines an error token "ERROR".
  1633. **
  1634. ** This is what we do if the grammar does define ERROR:
  1635. **
  1636. ** * Call the %syntax_error function.
  1637. **
  1638. ** * Begin popping the stack until we enter a state where
  1639. ** it is legal to shift the error symbol, then shift
  1640. ** the error symbol.
  1641. **
  1642. ** * Set the error count to three.
  1643. **
  1644. ** * Begin accepting and shifting new tokens. No new error
  1645. ** processing will occur until three tokens have been
  1646. ** shifted successfully.
  1647. **
  1648. */
  1649. if( yypParser->yyerrcnt<0 ){
  1650. yy_syntax_error(yypParser,yymajor,yyminorunion);
  1651. }
  1652. yymx = yypParser->yystack[yypParser->yyidx].major;
  1653. if( yymx==YYERRORSYMBOL || yyerrorhit ){
  1654. #ifndef NDEBUG
  1655. if( yyTraceFILE ){
  1656. fprintf(yyTraceFILE,"%sDiscard input token %s\n",
  1657. yyTracePrompt,yyTokenName[yymajor]);
  1658. }
  1659. #endif
  1660. yy_destructor(yypParser, (YYCODETYPE)yymajor,&yyminorunion);
  1661. yymajor = YYNOCODE;
  1662. }else{
  1663. while(
  1664. yypParser->yyidx >= 0 &&
  1665. yymx != YYERRORSYMBOL &&
  1666. (yyact = yy_find_reduce_action(
  1667. yypParser->yystack[yypParser->yyidx].stateno,
  1668. YYERRORSYMBOL)) >= YYNSTATE
  1669. ){
  1670. yy_pop_parser_stack(yypParser);
  1671. }
  1672. if( yypParser->yyidx < 0 || yymajor==0 ){
  1673. yy_destructor(yypParser,(YYCODETYPE)yymajor,&yyminorunion);
  1674. yy_parse_failed(yypParser);
  1675. yymajor = YYNOCODE;
  1676. }else if( yymx!=YYERRORSYMBOL ){
  1677. YYMINORTYPE u2;
  1678. u2.YYERRSYMDT = 0;
  1679. yy_shift(yypParser,yyact,YYERRORSYMBOL,&u2);
  1680. }
  1681. }
  1682. yypParser->yyerrcnt = 3;
  1683. yyerrorhit = 1;
  1684. #elif defined(YYNOERRORRECOVERY)
  1685. /* If the YYNOERRORRECOVERY macro is defined, then do not attempt to
  1686. ** do any kind of error recovery. Instead, simply invoke the syntax
  1687. ** error routine and continue going as if nothing had happened.
  1688. **
  1689. ** Applications can set this macro (for example inside %include) if
  1690. ** they intend to abandon the parse upon the first syntax error seen.
  1691. */
  1692. yy_syntax_error(yypParser,yymajor,yyminorunion);
  1693. yy_destructor(yypParser,(YYCODETYPE)yymajor,&yyminorunion);
  1694. yymajor = YYNOCODE;
  1695. #else /* YYERRORSYMBOL is not defined */
  1696. /* This is what we do if the grammar does not define ERROR:
  1697. **
  1698. ** * Report an error message, and throw away the input token.
  1699. **
  1700. ** * If the input token is $, then fail the parse.
  1701. **
  1702. ** As before, subsequent error messages are suppressed until
  1703. ** three input tokens have been successfully shifted.
  1704. */
  1705. if( yypParser->yyerrcnt<=0 ){
  1706. yy_syntax_error(yypParser,yymajor,yyminorunion);
  1707. }
  1708. yypParser->yyerrcnt = 3;
  1709. yy_destructor(yypParser,(YYCODETYPE)yymajor,&yyminorunion);
  1710. if( yyendofinput ){
  1711. yy_parse_failed(yypParser);
  1712. }
  1713. yymajor = YYNOCODE;
  1714. #endif
  1715. }
  1716. }while( yymajor!=YYNOCODE && yypParser->yyidx>=0 );
  1717. return;
  1718. }