NCDConfigParser_parse.c 58 KB

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