NCDConfigParser_parse.c 44 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335
  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 <ncd/NCDConfig.h>
  12. struct parser_minor {
  13. char *str;
  14. size_t len;
  15. };
  16. struct parser_out {
  17. int out_of_memory;
  18. int syntax_error;
  19. struct NCDConfig_processes *ast;
  20. };
  21. #line 28 "NCDConfigParser_parse.c"
  22. /* Next is all token values, in a form suitable for use by makeheaders.
  23. ** This section will be null unless lemon is run with the -m switch.
  24. */
  25. /*
  26. ** These constants (all generated automatically by the parser generator)
  27. ** specify the various kinds of tokens (terminals) that the parser
  28. ** understands.
  29. **
  30. ** Each symbol here is a terminal symbol in the grammar.
  31. */
  32. /* Make sure the INTERFACE macro is defined.
  33. */
  34. #ifndef INTERFACE
  35. # define INTERFACE 1
  36. #endif
  37. /* The next thing included is series of defines which control
  38. ** various aspects of the generated parser.
  39. ** YYCODETYPE is the data type used for storing terminal
  40. ** and nonterminal numbers. "unsigned char" is
  41. ** used if there are fewer than 250 terminals
  42. ** and nonterminals. "int" is used otherwise.
  43. ** YYNOCODE is a number of type YYCODETYPE which corresponds
  44. ** to no legal terminal or nonterminal number. This
  45. ** number is used to fill in empty slots of the hash
  46. ** table.
  47. ** YYFALLBACK If defined, this indicates that one or more tokens
  48. ** have fall-back values which should be used if the
  49. ** original value of the token will not parse.
  50. ** YYACTIONTYPE is the data type used for storing terminal
  51. ** and nonterminal numbers. "unsigned char" is
  52. ** used if there are fewer than 250 rules and
  53. ** states combined. "int" is used otherwise.
  54. ** ParseTOKENTYPE is the data type used for minor tokens given
  55. ** directly to the parser from the tokenizer.
  56. ** YYMINORTYPE is the data type used for all minor tokens.
  57. ** This is typically a union of many types, one of
  58. ** which is ParseTOKENTYPE. The entry in the union
  59. ** for base tokens is called "yy0".
  60. ** YYSTACKDEPTH is the maximum depth of the parser's stack. If
  61. ** zero the stack is dynamically sized using realloc()
  62. ** ParseARG_SDECL A static variable declaration for the %extra_argument
  63. ** ParseARG_PDECL A parameter declaration for the %extra_argument
  64. ** ParseARG_STORE Code to store %extra_argument into yypParser
  65. ** ParseARG_FETCH Code to extract %extra_argument from yypParser
  66. ** YYNSTATE the combined number of states.
  67. ** YYNRULE the number of rules in the grammar
  68. ** YYERRORSYMBOL is the code number of the error symbol. If not
  69. ** defined, then do no error processing.
  70. */
  71. #define YYCODETYPE unsigned char
  72. #define YYNOCODE 30
  73. #define YYACTIONTYPE unsigned char
  74. #define ParseTOKENTYPE struct parser_minor
  75. typedef union {
  76. int yyinit;
  77. ParseTOKENTYPE yy0;
  78. char * yy5;
  79. struct NCDConfig_list * yy12;
  80. struct NCDConfig_statements * yy16;
  81. struct NCDConfig_strings * yy24;
  82. struct NCDConfig_processes * yy45;
  83. int yy46;
  84. } YYMINORTYPE;
  85. #ifndef YYSTACKDEPTH
  86. #define YYSTACKDEPTH 0
  87. #endif
  88. #define ParseARG_SDECL struct parser_out *parser_out;
  89. #define ParseARG_PDECL ,struct parser_out *parser_out
  90. #define ParseARG_FETCH struct parser_out *parser_out = yypParser->parser_out
  91. #define ParseARG_STORE yypParser->parser_out = parser_out
  92. #define YYNSTATE 50
  93. #define YYNRULE 27
  94. #define YY_NO_ACTION (YYNSTATE+YYNRULE+2)
  95. #define YY_ACCEPT_ACTION (YYNSTATE+YYNRULE+1)
  96. #define YY_ERROR_ACTION (YYNSTATE+YYNRULE)
  97. /* The yyzerominor constant is used to initialize instances of
  98. ** YYMINORTYPE objects to zero. */
  99. static const YYMINORTYPE yyzerominor = { 0 };
  100. /* Define the yytestcase() macro to be a no-op if is not already defined
  101. ** otherwise.
  102. **
  103. ** Applications can choose to define yytestcase() in the %include section
  104. ** to a macro that can assist in verifying code coverage. For production
  105. ** code the yytestcase() macro should be turned off. But it is useful
  106. ** for testing.
  107. */
  108. #ifndef yytestcase
  109. # define yytestcase(X)
  110. #endif
  111. /* Next are the tables used to determine what action to take based on the
  112. ** current state and lookahead token. These tables are used to implement
  113. ** functions that take a state number and lookahead value and return an
  114. ** action integer.
  115. **
  116. ** Suppose the action integer is N. Then the action is determined as
  117. ** follows
  118. **
  119. ** 0 <= N < YYNSTATE Shift N. That is, push the lookahead
  120. ** token onto the stack and goto state N.
  121. **
  122. ** YYNSTATE <= N < YYNSTATE+YYNRULE Reduce by rule N-YYNSTATE.
  123. **
  124. ** N == YYNSTATE+YYNRULE A syntax error has occurred.
  125. **
  126. ** N == YYNSTATE+YYNRULE+1 The parser accepts its input.
  127. **
  128. ** N == YYNSTATE+YYNRULE+2 No such action. Denotes unused
  129. ** slots in the yy_action[] table.
  130. **
  131. ** The action table is constructed as a single large table named yy_action[].
  132. ** Given state S and lookahead X, the action is computed as
  133. **
  134. ** yy_action[ yy_shift_ofst[S] + X ]
  135. **
  136. ** If the index value yy_shift_ofst[S]+X is out of range or if the value
  137. ** yy_lookahead[yy_shift_ofst[S]+X] is not equal to X or if yy_shift_ofst[S]
  138. ** is equal to YY_SHIFT_USE_DFLT, it means that the action is not in the table
  139. ** and that yy_default[S] should be used instead.
  140. **
  141. ** The formula above is for computing the action when the lookahead is
  142. ** a terminal symbol. If the lookahead is a non-terminal (as occurs after
  143. ** a reduce action) then the yy_reduce_ofst[] array is used in place of
  144. ** the yy_shift_ofst[] array and YY_REDUCE_USE_DFLT is used in place of
  145. ** YY_SHIFT_USE_DFLT.
  146. **
  147. ** The following are the tables generated in this section:
  148. **
  149. ** yy_action[] A single table containing all actions.
  150. ** yy_lookahead[] A table containing the lookahead for each entry in
  151. ** yy_action. Used to detect hash collisions.
  152. ** yy_shift_ofst[] For each state, the offset into yy_action for
  153. ** shifting terminals.
  154. ** yy_reduce_ofst[] For each state, the offset into yy_action for
  155. ** shifting non-terminals after a reduce.
  156. ** yy_default[] Default action for each state.
  157. */
  158. static const YYACTIONTYPE yy_action[] = {
  159. /* 0 */ 44, 21, 38, 45, 23, 46, 24, 44, 30, 38,
  160. /* 10 */ 45, 32, 46, 24, 23, 3, 40, 44, 37, 25,
  161. /* 20 */ 45, 18, 46, 24, 4, 22, 43, 44, 23, 3,
  162. /* 30 */ 45, 28, 46, 26, 33, 34, 20, 16, 4, 47,
  163. /* 40 */ 43, 36, 44, 29, 39, 45, 17, 46, 24, 44,
  164. /* 50 */ 23, 3, 45, 42, 46, 26, 18, 78, 44, 31,
  165. /* 60 */ 4, 45, 43, 46, 27, 35, 16, 1, 49, 16,
  166. /* 70 */ 14, 50, 9, 19, 12, 13, 8, 5, 41, 79,
  167. /* 80 */ 10, 79, 79, 2, 79, 79, 7, 6, 79, 48,
  168. /* 90 */ 11, 79, 15,
  169. };
  170. static const YYCODETYPE yy_lookahead[] = {
  171. /* 0 */ 19, 20, 21, 22, 1, 24, 25, 19, 20, 21,
  172. /* 10 */ 22, 17, 24, 25, 1, 2, 3, 19, 1, 21,
  173. /* 20 */ 22, 27, 24, 25, 11, 26, 13, 19, 1, 2,
  174. /* 30 */ 22, 23, 24, 25, 14, 15, 18, 19, 11, 12,
  175. /* 40 */ 13, 19, 19, 19, 21, 22, 17, 24, 25, 19,
  176. /* 50 */ 1, 2, 22, 23, 24, 25, 27, 28, 19, 26,
  177. /* 60 */ 11, 22, 13, 24, 25, 18, 19, 4, 18, 19,
  178. /* 70 */ 7, 0, 2, 1, 5, 8, 3, 9, 3, 29,
  179. /* 80 */ 6, 29, 29, 4, 29, 29, 10, 9, 29, 12,
  180. /* 90 */ 6, 29, 5,
  181. };
  182. #define YY_SHIFT_USE_DFLT (-1)
  183. #define YY_SHIFT_MAX 31
  184. static const signed char yy_shift_ofst[] = {
  185. /* 0 */ 20, 49, 49, 13, 27, 49, 49, 49, 20, 3,
  186. /* 10 */ 3, 3, 17, 3, 3, 17, 63, 71, 72, 70,
  187. /* 20 */ 73, 69, 74, 67, 68, 75, 76, 78, 77, 79,
  188. /* 30 */ 87, 84,
  189. };
  190. #define YY_REDUCE_USE_DFLT (-20)
  191. #define YY_REDUCE_MAX 15
  192. static const signed char yy_reduce_ofst[] = {
  193. /* 0 */ 29, -19, -12, -2, 8, 23, 30, 39, -6, 18,
  194. /* 10 */ 47, 50, -1, 22, 24, 33,
  195. };
  196. static const YYACTIONTYPE yy_default[] = {
  197. /* 0 */ 77, 59, 59, 77, 77, 77, 77, 77, 51, 77,
  198. /* 10 */ 53, 55, 73, 77, 77, 73, 77, 77, 77, 77,
  199. /* 20 */ 77, 77, 77, 57, 61, 77, 77, 65, 77, 77,
  200. /* 30 */ 77, 77, 52, 75, 76, 54, 58, 74, 60, 62,
  201. /* 40 */ 63, 64, 66, 69, 70, 71, 72, 67, 68, 56,
  202. };
  203. #define YY_SZ_ACTTAB (int)(sizeof(yy_action)/sizeof(yy_action[0]))
  204. /* The next table maps tokens into fallback tokens. If a construct
  205. ** like the following:
  206. **
  207. ** %fallback ID X Y Z.
  208. **
  209. ** appears in the grammar, then ID becomes a fallback token for X, Y,
  210. ** and Z. Whenever one of the tokens X, Y, or Z is input to the parser
  211. ** but it does not parse, the type of the token is changed to ID and
  212. ** the parse is retried before an error is thrown.
  213. */
  214. #ifdef YYFALLBACK
  215. static const YYCODETYPE yyFallback[] = {
  216. };
  217. #endif /* YYFALLBACK */
  218. /* The following structure represents a single element of the
  219. ** parser's stack. Information stored includes:
  220. **
  221. ** + The state number for the parser at this level of the stack.
  222. **
  223. ** + The value of the token stored at this level of the stack.
  224. ** (In other words, the "major" token.)
  225. **
  226. ** + The semantic value stored at this level of the stack. This is
  227. ** the information used by the action routines in the grammar.
  228. ** It is sometimes called the "minor" token.
  229. */
  230. struct yyStackEntry {
  231. YYACTIONTYPE stateno; /* The state-number */
  232. YYCODETYPE major; /* The major token value. This is the code
  233. ** number for the token at this stack level */
  234. YYMINORTYPE minor; /* The user-supplied minor token value. This
  235. ** is the value of the token */
  236. };
  237. typedef struct yyStackEntry yyStackEntry;
  238. /* The state of the parser is completely contained in an instance of
  239. ** the following structure */
  240. struct yyParser {
  241. int yyidx; /* Index of top element in stack */
  242. #ifdef YYTRACKMAXSTACKDEPTH
  243. int yyidxMax; /* Maximum value of yyidx */
  244. #endif
  245. int yyerrcnt; /* Shifts left before out of the error */
  246. ParseARG_SDECL /* A place to hold %extra_argument */
  247. #if YYSTACKDEPTH<=0
  248. int yystksz; /* Current side of the stack */
  249. yyStackEntry *yystack; /* The parser's stack */
  250. #else
  251. yyStackEntry yystack[YYSTACKDEPTH]; /* The parser's stack */
  252. #endif
  253. };
  254. typedef struct yyParser yyParser;
  255. #ifndef NDEBUG
  256. #include <stdio.h>
  257. static FILE *yyTraceFILE = 0;
  258. static char *yyTracePrompt = 0;
  259. #endif /* NDEBUG */
  260. #ifndef NDEBUG
  261. /*
  262. ** Turn parser tracing on by giving a stream to which to write the trace
  263. ** and a prompt to preface each trace message. Tracing is turned off
  264. ** by making either argument NULL
  265. **
  266. ** Inputs:
  267. ** <ul>
  268. ** <li> A FILE* to which trace output should be written.
  269. ** If NULL, then tracing is turned off.
  270. ** <li> A prefix string written at the beginning of every
  271. ** line of trace output. If NULL, then tracing is
  272. ** turned off.
  273. ** </ul>
  274. **
  275. ** Outputs:
  276. ** None.
  277. */
  278. void ParseTrace(FILE *TraceFILE, char *zTracePrompt){
  279. yyTraceFILE = TraceFILE;
  280. yyTracePrompt = zTracePrompt;
  281. if( yyTraceFILE==0 ) yyTracePrompt = 0;
  282. else if( yyTracePrompt==0 ) yyTraceFILE = 0;
  283. }
  284. #endif /* NDEBUG */
  285. #ifndef NDEBUG
  286. /* For tracing shifts, the names of all terminals and nonterminals
  287. ** are required. The following table supplies these names */
  288. static const char *const yyTokenName[] = {
  289. "$", "NAME", "CURLY_OPEN", "CURLY_CLOSE",
  290. "ROUND_OPEN", "ROUND_CLOSE", "SEMICOLON", "ARROW",
  291. "DOT", "COMMA", "COLON", "BRACKET_OPEN",
  292. "BRACKET_CLOSE", "STRING", "PROCESS", "TEMPLATE",
  293. "error", "processes", "statements", "statement_names",
  294. "statement_args_maybe", "list_contents", "list", "map_contents",
  295. "map", "value", "name_maybe", "process_or_template",
  296. "input",
  297. };
  298. #endif /* NDEBUG */
  299. #ifndef NDEBUG
  300. /* For tracing reduce actions, the names of all rules are required.
  301. */
  302. static const char *const yyRuleName[] = {
  303. /* 0 */ "input ::= processes",
  304. /* 1 */ "processes ::= process_or_template NAME CURLY_OPEN statements CURLY_CLOSE",
  305. /* 2 */ "processes ::= process_or_template NAME CURLY_OPEN statements CURLY_CLOSE processes",
  306. /* 3 */ "statements ::= statement_names ROUND_OPEN statement_args_maybe ROUND_CLOSE name_maybe SEMICOLON",
  307. /* 4 */ "statements ::= statement_names ROUND_OPEN statement_args_maybe ROUND_CLOSE name_maybe SEMICOLON statements",
  308. /* 5 */ "statements ::= statement_names ARROW statement_names ROUND_OPEN statement_args_maybe ROUND_CLOSE name_maybe SEMICOLON",
  309. /* 6 */ "statements ::= statement_names ARROW statement_names ROUND_OPEN statement_args_maybe ROUND_CLOSE name_maybe SEMICOLON statements",
  310. /* 7 */ "statement_names ::= NAME",
  311. /* 8 */ "statement_names ::= NAME DOT statement_names",
  312. /* 9 */ "statement_args_maybe ::=",
  313. /* 10 */ "statement_args_maybe ::= list_contents",
  314. /* 11 */ "list_contents ::= value",
  315. /* 12 */ "list_contents ::= value COMMA list_contents",
  316. /* 13 */ "list ::= CURLY_OPEN CURLY_CLOSE",
  317. /* 14 */ "list ::= CURLY_OPEN list_contents CURLY_CLOSE",
  318. /* 15 */ "map_contents ::= value COLON value",
  319. /* 16 */ "map_contents ::= value COLON value COMMA map_contents",
  320. /* 17 */ "map ::= BRACKET_OPEN BRACKET_CLOSE",
  321. /* 18 */ "map ::= BRACKET_OPEN map_contents BRACKET_CLOSE",
  322. /* 19 */ "value ::= STRING",
  323. /* 20 */ "value ::= statement_names",
  324. /* 21 */ "value ::= list",
  325. /* 22 */ "value ::= map",
  326. /* 23 */ "name_maybe ::=",
  327. /* 24 */ "name_maybe ::= NAME",
  328. /* 25 */ "process_or_template ::= PROCESS",
  329. /* 26 */ "process_or_template ::= TEMPLATE",
  330. };
  331. #endif /* NDEBUG */
  332. #if YYSTACKDEPTH<=0
  333. /*
  334. ** Try to increase the size of the parser stack.
  335. */
  336. static void yyGrowStack(yyParser *p){
  337. int newSize;
  338. yyStackEntry *pNew;
  339. newSize = p->yystksz*2 + 100;
  340. pNew = realloc(p->yystack, newSize*sizeof(pNew[0]));
  341. if( pNew ){
  342. p->yystack = pNew;
  343. p->yystksz = newSize;
  344. #ifndef NDEBUG
  345. if( yyTraceFILE ){
  346. fprintf(yyTraceFILE,"%sStack grows to %d entries!\n",
  347. yyTracePrompt, p->yystksz);
  348. }
  349. #endif
  350. }
  351. }
  352. #endif
  353. /*
  354. ** This function allocates a new parser.
  355. ** The only argument is a pointer to a function which works like
  356. ** malloc.
  357. **
  358. ** Inputs:
  359. ** A pointer to the function used to allocate memory.
  360. **
  361. ** Outputs:
  362. ** A pointer to a parser. This pointer is used in subsequent calls
  363. ** to Parse and ParseFree.
  364. */
  365. void *ParseAlloc(void *(*mallocProc)(size_t)){
  366. yyParser *pParser;
  367. pParser = (yyParser*)(*mallocProc)( (size_t)sizeof(yyParser) );
  368. if( pParser ){
  369. pParser->yyidx = -1;
  370. #ifdef YYTRACKMAXSTACKDEPTH
  371. pParser->yyidxMax = 0;
  372. #endif
  373. #if YYSTACKDEPTH<=0
  374. pParser->yystack = NULL;
  375. pParser->yystksz = 0;
  376. yyGrowStack(pParser);
  377. #endif
  378. }
  379. return pParser;
  380. }
  381. /* The following function deletes the value associated with a
  382. ** symbol. The symbol can be either a terminal or nonterminal.
  383. ** "yymajor" is the symbol code, and "yypminor" is a pointer to
  384. ** the value.
  385. */
  386. static void yy_destructor(
  387. yyParser *yypParser, /* The parser */
  388. YYCODETYPE yymajor, /* Type code for object to destroy */
  389. YYMINORTYPE *yypminor /* The object to be destroyed */
  390. ){
  391. ParseARG_FETCH;
  392. switch( yymajor ){
  393. /* Here is inserted the actions which take place when a
  394. ** terminal or non-terminal is destroyed. This can happen
  395. ** when the symbol is popped from the stack during a
  396. ** reduce or during error processing or when a parser is
  397. ** being destroyed before it is finished parsing.
  398. **
  399. ** Note: during a reduce, the only symbols destroyed are those
  400. ** which appear on the RHS of the rule, but which are not used
  401. ** inside the C code.
  402. */
  403. /* TERMINAL Destructor */
  404. case 1: /* NAME */
  405. case 2: /* CURLY_OPEN */
  406. case 3: /* CURLY_CLOSE */
  407. case 4: /* ROUND_OPEN */
  408. case 5: /* ROUND_CLOSE */
  409. case 6: /* SEMICOLON */
  410. case 7: /* ARROW */
  411. case 8: /* DOT */
  412. case 9: /* COMMA */
  413. case 10: /* COLON */
  414. case 11: /* BRACKET_OPEN */
  415. case 12: /* BRACKET_CLOSE */
  416. case 13: /* STRING */
  417. case 14: /* PROCESS */
  418. case 15: /* TEMPLATE */
  419. {
  420. #line 55 "NCDConfigParser_parse.y"
  421. free((yypminor->yy0).str);
  422. #line 445 "NCDConfigParser_parse.c"
  423. }
  424. break;
  425. case 17: /* processes */
  426. {
  427. #line 69 "NCDConfigParser_parse.y"
  428. NCDConfig_free_processes((yypminor->yy45));
  429. #line 452 "NCDConfigParser_parse.c"
  430. }
  431. break;
  432. case 18: /* statements */
  433. {
  434. #line 70 "NCDConfigParser_parse.y"
  435. NCDConfig_free_statements((yypminor->yy16));
  436. #line 459 "NCDConfigParser_parse.c"
  437. }
  438. break;
  439. case 19: /* statement_names */
  440. {
  441. #line 71 "NCDConfigParser_parse.y"
  442. NCDConfig_free_strings((yypminor->yy24));
  443. #line 466 "NCDConfigParser_parse.c"
  444. }
  445. break;
  446. case 20: /* statement_args_maybe */
  447. case 21: /* list_contents */
  448. case 22: /* list */
  449. case 23: /* map_contents */
  450. case 24: /* map */
  451. case 25: /* value */
  452. {
  453. #line 72 "NCDConfigParser_parse.y"
  454. NCDConfig_free_list((yypminor->yy12));
  455. #line 478 "NCDConfigParser_parse.c"
  456. }
  457. break;
  458. case 26: /* name_maybe */
  459. {
  460. #line 78 "NCDConfigParser_parse.y"
  461. free((yypminor->yy5));
  462. #line 485 "NCDConfigParser_parse.c"
  463. }
  464. break;
  465. default: break; /* If no destructor action specified: do nothing */
  466. }
  467. }
  468. /*
  469. ** Pop the parser's stack once.
  470. **
  471. ** If there is a destructor routine associated with the token which
  472. ** is popped from the stack, then call it.
  473. **
  474. ** Return the major token number for the symbol popped.
  475. */
  476. static int yy_pop_parser_stack(yyParser *pParser){
  477. YYCODETYPE yymajor;
  478. yyStackEntry *yytos = &pParser->yystack[pParser->yyidx];
  479. if( pParser->yyidx<0 ) return 0;
  480. #ifndef NDEBUG
  481. if( yyTraceFILE && pParser->yyidx>=0 ){
  482. fprintf(yyTraceFILE,"%sPopping %s\n",
  483. yyTracePrompt,
  484. yyTokenName[yytos->major]);
  485. }
  486. #endif
  487. yymajor = yytos->major;
  488. yy_destructor(pParser, yymajor, &yytos->minor);
  489. pParser->yyidx--;
  490. return yymajor;
  491. }
  492. /*
  493. ** Deallocate and destroy a parser. Destructors are all called for
  494. ** all stack elements before shutting the parser down.
  495. **
  496. ** Inputs:
  497. ** <ul>
  498. ** <li> A pointer to the parser. This should be a pointer
  499. ** obtained from ParseAlloc.
  500. ** <li> A pointer to a function used to reclaim memory obtained
  501. ** from malloc.
  502. ** </ul>
  503. */
  504. void ParseFree(
  505. void *p, /* The parser to be deleted */
  506. void (*freeProc)(void*) /* Function used to reclaim memory */
  507. ){
  508. yyParser *pParser = (yyParser*)p;
  509. if( pParser==0 ) return;
  510. while( pParser->yyidx>=0 ) yy_pop_parser_stack(pParser);
  511. #if YYSTACKDEPTH<=0
  512. free(pParser->yystack);
  513. #endif
  514. (*freeProc)((void*)pParser);
  515. }
  516. /*
  517. ** Return the peak depth of the stack for a parser.
  518. */
  519. #ifdef YYTRACKMAXSTACKDEPTH
  520. int ParseStackPeak(void *p){
  521. yyParser *pParser = (yyParser*)p;
  522. return pParser->yyidxMax;
  523. }
  524. #endif
  525. /*
  526. ** Find the appropriate action for a parser given the terminal
  527. ** look-ahead token iLookAhead.
  528. **
  529. ** If the look-ahead token is YYNOCODE, then check to see if the action is
  530. ** independent of the look-ahead. If it is, return the action, otherwise
  531. ** return YY_NO_ACTION.
  532. */
  533. static int yy_find_shift_action(
  534. yyParser *pParser, /* The parser */
  535. YYCODETYPE iLookAhead /* The look-ahead token */
  536. ){
  537. int i;
  538. int stateno = pParser->yystack[pParser->yyidx].stateno;
  539. if( stateno>YY_SHIFT_MAX || (i = yy_shift_ofst[stateno])==YY_SHIFT_USE_DFLT ){
  540. return yy_default[stateno];
  541. }
  542. assert( iLookAhead!=YYNOCODE );
  543. i += iLookAhead;
  544. if( i<0 || i>=YY_SZ_ACTTAB || yy_lookahead[i]!=iLookAhead ){
  545. if( iLookAhead>0 ){
  546. #ifdef YYFALLBACK
  547. YYCODETYPE iFallback; /* Fallback token */
  548. if( iLookAhead<sizeof(yyFallback)/sizeof(yyFallback[0])
  549. && (iFallback = yyFallback[iLookAhead])!=0 ){
  550. #ifndef NDEBUG
  551. if( yyTraceFILE ){
  552. fprintf(yyTraceFILE, "%sFALLBACK %s => %s\n",
  553. yyTracePrompt, yyTokenName[iLookAhead], yyTokenName[iFallback]);
  554. }
  555. #endif
  556. return yy_find_shift_action(pParser, iFallback);
  557. }
  558. #endif
  559. #ifdef YYWILDCARD
  560. {
  561. int j = i - iLookAhead + YYWILDCARD;
  562. if( j>=0 && j<YY_SZ_ACTTAB && yy_lookahead[j]==YYWILDCARD ){
  563. #ifndef NDEBUG
  564. if( yyTraceFILE ){
  565. fprintf(yyTraceFILE, "%sWILDCARD %s => %s\n",
  566. yyTracePrompt, yyTokenName[iLookAhead], yyTokenName[YYWILDCARD]);
  567. }
  568. #endif /* NDEBUG */
  569. return yy_action[j];
  570. }
  571. }
  572. #endif /* YYWILDCARD */
  573. }
  574. return yy_default[stateno];
  575. }else{
  576. return yy_action[i];
  577. }
  578. }
  579. /*
  580. ** Find the appropriate action for a parser given the non-terminal
  581. ** look-ahead token iLookAhead.
  582. **
  583. ** If the look-ahead token is YYNOCODE, then check to see if the action is
  584. ** independent of the look-ahead. If it is, return the action, otherwise
  585. ** return YY_NO_ACTION.
  586. */
  587. static int yy_find_reduce_action(
  588. int stateno, /* Current state number */
  589. YYCODETYPE iLookAhead /* The look-ahead token */
  590. ){
  591. int i;
  592. #ifdef YYERRORSYMBOL
  593. if( stateno>YY_REDUCE_MAX ){
  594. return yy_default[stateno];
  595. }
  596. #else
  597. assert( stateno<=YY_REDUCE_MAX );
  598. #endif
  599. i = yy_reduce_ofst[stateno];
  600. assert( i!=YY_REDUCE_USE_DFLT );
  601. assert( iLookAhead!=YYNOCODE );
  602. i += iLookAhead;
  603. #ifdef YYERRORSYMBOL
  604. if( i<0 || i>=YY_SZ_ACTTAB || yy_lookahead[i]!=iLookAhead ){
  605. return yy_default[stateno];
  606. }
  607. #else
  608. assert( i>=0 && i<YY_SZ_ACTTAB );
  609. assert( yy_lookahead[i]==iLookAhead );
  610. #endif
  611. return yy_action[i];
  612. }
  613. /*
  614. ** The following routine is called if the stack overflows.
  615. */
  616. static void yyStackOverflow(yyParser *yypParser, YYMINORTYPE *yypMinor){
  617. ParseARG_FETCH;
  618. yypParser->yyidx--;
  619. #ifndef NDEBUG
  620. if( yyTraceFILE ){
  621. fprintf(yyTraceFILE,"%sStack Overflow!\n",yyTracePrompt);
  622. }
  623. #endif
  624. while( yypParser->yyidx>=0 ) yy_pop_parser_stack(yypParser);
  625. /* Here code is inserted which will execute if the parser
  626. ** stack every overflows */
  627. #line 87 "NCDConfigParser_parse.y"
  628. if (yypMinor) {
  629. free(yypMinor->yy0.str);
  630. }
  631. #line 663 "NCDConfigParser_parse.c"
  632. ParseARG_STORE; /* Suppress warning about unused %extra_argument var */
  633. }
  634. /*
  635. ** Perform a shift action.
  636. */
  637. static void yy_shift(
  638. yyParser *yypParser, /* The parser to be shifted */
  639. int yyNewState, /* The new state to shift in */
  640. int yyMajor, /* The major token to shift in */
  641. YYMINORTYPE *yypMinor /* Pointer to the minor token to shift in */
  642. ){
  643. yyStackEntry *yytos;
  644. yypParser->yyidx++;
  645. #ifdef YYTRACKMAXSTACKDEPTH
  646. if( yypParser->yyidx>yypParser->yyidxMax ){
  647. yypParser->yyidxMax = yypParser->yyidx;
  648. }
  649. #endif
  650. #if YYSTACKDEPTH>0
  651. if( yypParser->yyidx>=YYSTACKDEPTH ){
  652. yyStackOverflow(yypParser, yypMinor);
  653. return;
  654. }
  655. #else
  656. if( yypParser->yyidx>=yypParser->yystksz ){
  657. yyGrowStack(yypParser);
  658. if( yypParser->yyidx>=yypParser->yystksz ){
  659. yyStackOverflow(yypParser, yypMinor);
  660. return;
  661. }
  662. }
  663. #endif
  664. yytos = &yypParser->yystack[yypParser->yyidx];
  665. yytos->stateno = (YYACTIONTYPE)yyNewState;
  666. yytos->major = (YYCODETYPE)yyMajor;
  667. yytos->minor = *yypMinor;
  668. #ifndef NDEBUG
  669. if( yyTraceFILE && yypParser->yyidx>0 ){
  670. int i;
  671. fprintf(yyTraceFILE,"%sShift %d\n",yyTracePrompt,yyNewState);
  672. fprintf(yyTraceFILE,"%sStack:",yyTracePrompt);
  673. for(i=1; i<=yypParser->yyidx; i++)
  674. fprintf(yyTraceFILE," %s",yyTokenName[yypParser->yystack[i].major]);
  675. fprintf(yyTraceFILE,"\n");
  676. }
  677. #endif
  678. }
  679. /* The following table contains information about every rule that
  680. ** is used during the reduce.
  681. */
  682. static const struct {
  683. YYCODETYPE lhs; /* Symbol on the left-hand side of the rule */
  684. unsigned char nrhs; /* Number of right-hand side symbols in the rule */
  685. } yyRuleInfo[] = {
  686. { 28, 1 },
  687. { 17, 5 },
  688. { 17, 6 },
  689. { 18, 6 },
  690. { 18, 7 },
  691. { 18, 8 },
  692. { 18, 9 },
  693. { 19, 1 },
  694. { 19, 3 },
  695. { 20, 0 },
  696. { 20, 1 },
  697. { 21, 1 },
  698. { 21, 3 },
  699. { 22, 2 },
  700. { 22, 3 },
  701. { 23, 3 },
  702. { 23, 5 },
  703. { 24, 2 },
  704. { 24, 3 },
  705. { 25, 1 },
  706. { 25, 1 },
  707. { 25, 1 },
  708. { 25, 1 },
  709. { 26, 0 },
  710. { 26, 1 },
  711. { 27, 1 },
  712. { 27, 1 },
  713. };
  714. static void yy_accept(yyParser*); /* Forward Declaration */
  715. /*
  716. ** Perform a reduce action and the shift that must immediately
  717. ** follow the reduce.
  718. */
  719. static void yy_reduce(
  720. yyParser *yypParser, /* The parser */
  721. int yyruleno /* Number of the rule by which to reduce */
  722. ){
  723. int yygoto; /* The next state */
  724. int yyact; /* The next action */
  725. YYMINORTYPE yygotominor; /* The LHS of the rule reduced */
  726. yyStackEntry *yymsp; /* The top of the parser's stack */
  727. int yysize; /* Amount to pop the stack */
  728. ParseARG_FETCH;
  729. yymsp = &yypParser->yystack[yypParser->yyidx];
  730. #ifndef NDEBUG
  731. if( yyTraceFILE && yyruleno>=0
  732. && yyruleno<(int)(sizeof(yyRuleName)/sizeof(yyRuleName[0])) ){
  733. fprintf(yyTraceFILE, "%sReduce [%s].\n", yyTracePrompt,
  734. yyRuleName[yyruleno]);
  735. }
  736. #endif /* NDEBUG */
  737. /* Silence complaints from purify about yygotominor being uninitialized
  738. ** in some cases when it is copied into the stack after the following
  739. ** switch. yygotominor is uninitialized when a rule reduces that does
  740. ** not set the value of its left-hand side nonterminal. Leaving the
  741. ** value of the nonterminal uninitialized is utterly harmless as long
  742. ** as the value is never used. So really the only thing this code
  743. ** accomplishes is to quieten purify.
  744. **
  745. ** 2007-01-16: The wireshark project (www.wireshark.org) reports that
  746. ** without this code, their parser segfaults. I'm not sure what there
  747. ** parser is doing to make this happen. This is the second bug report
  748. ** from wireshark this week. Clearly they are stressing Lemon in ways
  749. ** that it has not been previously stressed... (SQLite ticket #2172)
  750. */
  751. /*memset(&yygotominor, 0, sizeof(yygotominor));*/
  752. yygotominor = yyzerominor;
  753. switch( yyruleno ){
  754. /* Beginning here are the reduction cases. A typical example
  755. ** follows:
  756. ** case 0:
  757. ** #line <lineno> <grammarfile>
  758. ** { ... } // User supplied code
  759. ** #line <lineno> <thisfile>
  760. ** break;
  761. */
  762. case 0: /* input ::= processes */
  763. #line 93 "NCDConfigParser_parse.y"
  764. {
  765. parser_out->ast = yymsp[0].minor.yy45;
  766. if (!yymsp[0].minor.yy45) {
  767. parser_out->out_of_memory = 1;
  768. }
  769. }
  770. #line 810 "NCDConfigParser_parse.c"
  771. break;
  772. case 1: /* processes ::= process_or_template NAME CURLY_OPEN statements CURLY_CLOSE */
  773. #line 101 "NCDConfigParser_parse.y"
  774. {
  775. yygotominor.yy45 = NCDConfig_make_processes(yymsp[-4].minor.yy46, yymsp[-3].minor.yy0.str, yymsp[-1].minor.yy16, 0, NULL);
  776. if (!yygotominor.yy45) {
  777. parser_out->out_of_memory = 1;
  778. }
  779. yy_destructor(yypParser,2,&yymsp[-2].minor);
  780. yy_destructor(yypParser,3,&yymsp[0].minor);
  781. }
  782. #line 822 "NCDConfigParser_parse.c"
  783. break;
  784. case 2: /* processes ::= process_or_template NAME CURLY_OPEN statements CURLY_CLOSE processes */
  785. #line 108 "NCDConfigParser_parse.y"
  786. {
  787. yygotominor.yy45 = NCDConfig_make_processes(yymsp[-5].minor.yy46, yymsp[-4].minor.yy0.str, yymsp[-2].minor.yy16, 1, yymsp[0].minor.yy45);
  788. if (!yygotominor.yy45) {
  789. parser_out->out_of_memory = 1;
  790. }
  791. yy_destructor(yypParser,2,&yymsp[-3].minor);
  792. yy_destructor(yypParser,3,&yymsp[-1].minor);
  793. }
  794. #line 834 "NCDConfigParser_parse.c"
  795. break;
  796. case 3: /* statements ::= statement_names ROUND_OPEN statement_args_maybe ROUND_CLOSE name_maybe SEMICOLON */
  797. #line 115 "NCDConfigParser_parse.y"
  798. {
  799. yygotominor.yy16 = NCDConfig_make_statements(NULL, yymsp[-5].minor.yy24, yymsp[-3].minor.yy12, yymsp[-1].minor.yy5, NULL);
  800. if (!yygotominor.yy16) {
  801. parser_out->out_of_memory = 1;
  802. }
  803. yy_destructor(yypParser,4,&yymsp[-4].minor);
  804. yy_destructor(yypParser,5,&yymsp[-2].minor);
  805. yy_destructor(yypParser,6,&yymsp[0].minor);
  806. }
  807. #line 847 "NCDConfigParser_parse.c"
  808. break;
  809. case 4: /* statements ::= statement_names ROUND_OPEN statement_args_maybe ROUND_CLOSE name_maybe SEMICOLON statements */
  810. #line 122 "NCDConfigParser_parse.y"
  811. {
  812. yygotominor.yy16 = NCDConfig_make_statements(NULL, yymsp[-6].minor.yy24, yymsp[-4].minor.yy12, yymsp[-2].minor.yy5, yymsp[0].minor.yy16);
  813. if (!yygotominor.yy16) {
  814. parser_out->out_of_memory = 1;
  815. }
  816. yy_destructor(yypParser,4,&yymsp[-5].minor);
  817. yy_destructor(yypParser,5,&yymsp[-3].minor);
  818. yy_destructor(yypParser,6,&yymsp[-1].minor);
  819. }
  820. #line 860 "NCDConfigParser_parse.c"
  821. break;
  822. case 5: /* statements ::= statement_names ARROW statement_names ROUND_OPEN statement_args_maybe ROUND_CLOSE name_maybe SEMICOLON */
  823. #line 129 "NCDConfigParser_parse.y"
  824. {
  825. yygotominor.yy16 = NCDConfig_make_statements(yymsp[-7].minor.yy24, yymsp[-5].minor.yy24, yymsp[-3].minor.yy12, yymsp[-1].minor.yy5, NULL);
  826. if (!yygotominor.yy16) {
  827. parser_out->out_of_memory = 1;
  828. }
  829. yy_destructor(yypParser,7,&yymsp[-6].minor);
  830. yy_destructor(yypParser,4,&yymsp[-4].minor);
  831. yy_destructor(yypParser,5,&yymsp[-2].minor);
  832. yy_destructor(yypParser,6,&yymsp[0].minor);
  833. }
  834. #line 874 "NCDConfigParser_parse.c"
  835. break;
  836. case 6: /* statements ::= statement_names ARROW statement_names ROUND_OPEN statement_args_maybe ROUND_CLOSE name_maybe SEMICOLON statements */
  837. #line 136 "NCDConfigParser_parse.y"
  838. {
  839. yygotominor.yy16 = NCDConfig_make_statements(yymsp[-8].minor.yy24, yymsp[-6].minor.yy24, yymsp[-4].minor.yy12, yymsp[-2].minor.yy5, yymsp[0].minor.yy16);
  840. if (!yygotominor.yy16) {
  841. parser_out->out_of_memory = 1;
  842. }
  843. yy_destructor(yypParser,7,&yymsp[-7].minor);
  844. yy_destructor(yypParser,4,&yymsp[-5].minor);
  845. yy_destructor(yypParser,5,&yymsp[-3].minor);
  846. yy_destructor(yypParser,6,&yymsp[-1].minor);
  847. }
  848. #line 888 "NCDConfigParser_parse.c"
  849. break;
  850. case 7: /* statement_names ::= NAME */
  851. #line 143 "NCDConfigParser_parse.y"
  852. {
  853. yygotominor.yy24 = NCDConfig_make_strings(yymsp[0].minor.yy0.str, 0, NULL);
  854. if (!yygotominor.yy24) {
  855. parser_out->out_of_memory = 1;
  856. }
  857. }
  858. #line 898 "NCDConfigParser_parse.c"
  859. break;
  860. case 8: /* statement_names ::= NAME DOT statement_names */
  861. #line 150 "NCDConfigParser_parse.y"
  862. {
  863. yygotominor.yy24 = NCDConfig_make_strings(yymsp[-2].minor.yy0.str, 1, yymsp[0].minor.yy24);
  864. if (!yygotominor.yy24) {
  865. parser_out->out_of_memory = 1;
  866. }
  867. yy_destructor(yypParser,8,&yymsp[-1].minor);
  868. }
  869. #line 909 "NCDConfigParser_parse.c"
  870. break;
  871. case 9: /* statement_args_maybe ::= */
  872. #line 157 "NCDConfigParser_parse.y"
  873. {
  874. yygotominor.yy12 = NULL;
  875. }
  876. #line 916 "NCDConfigParser_parse.c"
  877. break;
  878. case 10: /* statement_args_maybe ::= list_contents */
  879. case 11: /* list_contents ::= value */ yytestcase(yyruleno==11);
  880. #line 161 "NCDConfigParser_parse.y"
  881. {
  882. yygotominor.yy12 = yymsp[0].minor.yy12;
  883. }
  884. #line 924 "NCDConfigParser_parse.c"
  885. break;
  886. case 12: /* list_contents ::= value COMMA list_contents */
  887. #line 169 "NCDConfigParser_parse.y"
  888. {
  889. if (!yymsp[-2].minor.yy12) {
  890. NCDConfig_free_list(yymsp[0].minor.yy12);
  891. } else {
  892. ASSERT(!yymsp[-2].minor.yy12->next)
  893. yymsp[-2].minor.yy12->next = yymsp[0].minor.yy12;
  894. }
  895. yygotominor.yy12 = yymsp[-2].minor.yy12;
  896. yy_destructor(yypParser,9,&yymsp[-1].minor);
  897. }
  898. #line 938 "NCDConfigParser_parse.c"
  899. break;
  900. case 13: /* list ::= CURLY_OPEN CURLY_CLOSE */
  901. #line 179 "NCDConfigParser_parse.y"
  902. {
  903. yygotominor.yy12 = NULL;
  904. yy_destructor(yypParser,2,&yymsp[-1].minor);
  905. yy_destructor(yypParser,3,&yymsp[0].minor);
  906. }
  907. #line 947 "NCDConfigParser_parse.c"
  908. break;
  909. case 14: /* list ::= CURLY_OPEN list_contents CURLY_CLOSE */
  910. #line 183 "NCDConfigParser_parse.y"
  911. {
  912. yygotominor.yy12 = yymsp[-1].minor.yy12;
  913. yy_destructor(yypParser,2,&yymsp[-2].minor);
  914. yy_destructor(yypParser,3,&yymsp[0].minor);
  915. }
  916. #line 956 "NCDConfigParser_parse.c"
  917. break;
  918. case 15: /* map_contents ::= value COLON value */
  919. #line 187 "NCDConfigParser_parse.y"
  920. {
  921. if (!yymsp[-2].minor.yy12 || !yymsp[0].minor.yy12) {
  922. NCDConfig_free_list(yymsp[-2].minor.yy12);
  923. NCDConfig_free_list(yymsp[0].minor.yy12);
  924. yygotominor.yy12 = NULL;
  925. } else {
  926. ASSERT(!yymsp[-2].minor.yy12->next)
  927. ASSERT(!yymsp[0].minor.yy12->next)
  928. yymsp[-2].minor.yy12->next = yymsp[0].minor.yy12;
  929. yygotominor.yy12 = yymsp[-2].minor.yy12;
  930. }
  931. yy_destructor(yypParser,10,&yymsp[-1].minor);
  932. }
  933. #line 973 "NCDConfigParser_parse.c"
  934. break;
  935. case 16: /* map_contents ::= value COLON value COMMA map_contents */
  936. #line 200 "NCDConfigParser_parse.y"
  937. {
  938. if (!yymsp[-4].minor.yy12 || !yymsp[-2].minor.yy12) {
  939. NCDConfig_free_list(yymsp[-4].minor.yy12);
  940. NCDConfig_free_list(yymsp[-2].minor.yy12);
  941. NCDConfig_free_list(yymsp[0].minor.yy12);
  942. yygotominor.yy12 = NULL;
  943. } else {
  944. ASSERT(!yymsp[-4].minor.yy12->next)
  945. ASSERT(!yymsp[-2].minor.yy12->next)
  946. yymsp[-4].minor.yy12->next = yymsp[-2].minor.yy12;
  947. yymsp[-2].minor.yy12->next = yymsp[0].minor.yy12;
  948. yygotominor.yy12 = yymsp[-4].minor.yy12;
  949. }
  950. yy_destructor(yypParser,10,&yymsp[-3].minor);
  951. yy_destructor(yypParser,9,&yymsp[-1].minor);
  952. }
  953. #line 993 "NCDConfigParser_parse.c"
  954. break;
  955. case 17: /* map ::= BRACKET_OPEN BRACKET_CLOSE */
  956. #line 215 "NCDConfigParser_parse.y"
  957. {
  958. yygotominor.yy12 = NULL;
  959. yy_destructor(yypParser,11,&yymsp[-1].minor);
  960. yy_destructor(yypParser,12,&yymsp[0].minor);
  961. }
  962. #line 1002 "NCDConfigParser_parse.c"
  963. break;
  964. case 18: /* map ::= BRACKET_OPEN map_contents BRACKET_CLOSE */
  965. #line 219 "NCDConfigParser_parse.y"
  966. {
  967. yygotominor.yy12 = yymsp[-1].minor.yy12;
  968. yy_destructor(yypParser,11,&yymsp[-2].minor);
  969. yy_destructor(yypParser,12,&yymsp[0].minor);
  970. }
  971. #line 1011 "NCDConfigParser_parse.c"
  972. break;
  973. case 19: /* value ::= STRING */
  974. #line 223 "NCDConfigParser_parse.y"
  975. {
  976. yygotominor.yy12 = NCDConfig_make_list_string(yymsp[0].minor.yy0.str, yymsp[0].minor.yy0.len, NULL);
  977. if (!yygotominor.yy12) {
  978. parser_out->out_of_memory = 1;
  979. }
  980. }
  981. #line 1021 "NCDConfigParser_parse.c"
  982. break;
  983. case 20: /* value ::= statement_names */
  984. #line 230 "NCDConfigParser_parse.y"
  985. {
  986. yygotominor.yy12 = NCDConfig_make_list_var(yymsp[0].minor.yy24, NULL);
  987. if (!yygotominor.yy12) {
  988. parser_out->out_of_memory = 1;
  989. }
  990. }
  991. #line 1031 "NCDConfigParser_parse.c"
  992. break;
  993. case 21: /* value ::= list */
  994. #line 237 "NCDConfigParser_parse.y"
  995. {
  996. yygotominor.yy12 = NCDConfig_make_list_list(yymsp[0].minor.yy12, NULL);
  997. if (!yygotominor.yy12) {
  998. parser_out->out_of_memory = 1;
  999. }
  1000. }
  1001. #line 1041 "NCDConfigParser_parse.c"
  1002. break;
  1003. case 22: /* value ::= map */
  1004. #line 244 "NCDConfigParser_parse.y"
  1005. {
  1006. yygotominor.yy12 = NCDConfig_make_list_maplist(yymsp[0].minor.yy12, NULL);
  1007. if (!yygotominor.yy12) {
  1008. parser_out->out_of_memory = 1;
  1009. }
  1010. }
  1011. #line 1051 "NCDConfigParser_parse.c"
  1012. break;
  1013. case 23: /* name_maybe ::= */
  1014. #line 251 "NCDConfigParser_parse.y"
  1015. {
  1016. yygotominor.yy5 = NULL;
  1017. }
  1018. #line 1058 "NCDConfigParser_parse.c"
  1019. break;
  1020. case 24: /* name_maybe ::= NAME */
  1021. #line 255 "NCDConfigParser_parse.y"
  1022. {
  1023. yygotominor.yy5 = yymsp[0].minor.yy0.str;
  1024. }
  1025. #line 1065 "NCDConfigParser_parse.c"
  1026. break;
  1027. case 25: /* process_or_template ::= PROCESS */
  1028. #line 259 "NCDConfigParser_parse.y"
  1029. {
  1030. yygotominor.yy46 = 0;
  1031. yy_destructor(yypParser,14,&yymsp[0].minor);
  1032. }
  1033. #line 1073 "NCDConfigParser_parse.c"
  1034. break;
  1035. case 26: /* process_or_template ::= TEMPLATE */
  1036. #line 263 "NCDConfigParser_parse.y"
  1037. {
  1038. yygotominor.yy46 = 1;
  1039. yy_destructor(yypParser,15,&yymsp[0].minor);
  1040. }
  1041. #line 1081 "NCDConfigParser_parse.c"
  1042. break;
  1043. default:
  1044. break;
  1045. };
  1046. yygoto = yyRuleInfo[yyruleno].lhs;
  1047. yysize = yyRuleInfo[yyruleno].nrhs;
  1048. yypParser->yyidx -= yysize;
  1049. yyact = yy_find_reduce_action(yymsp[-yysize].stateno,(YYCODETYPE)yygoto);
  1050. if( yyact < YYNSTATE ){
  1051. #ifdef NDEBUG
  1052. /* If we are not debugging and the reduce action popped at least
  1053. ** one element off the stack, then we can push the new element back
  1054. ** onto the stack here, and skip the stack overflow test in yy_shift().
  1055. ** That gives a significant speed improvement. */
  1056. if( yysize ){
  1057. yypParser->yyidx++;
  1058. yymsp -= yysize-1;
  1059. yymsp->stateno = (YYACTIONTYPE)yyact;
  1060. yymsp->major = (YYCODETYPE)yygoto;
  1061. yymsp->minor = yygotominor;
  1062. }else
  1063. #endif
  1064. {
  1065. yy_shift(yypParser,yyact,yygoto,&yygotominor);
  1066. }
  1067. }else{
  1068. assert( yyact == YYNSTATE + YYNRULE + 1 );
  1069. yy_accept(yypParser);
  1070. }
  1071. }
  1072. /*
  1073. ** The following code executes when the parse fails
  1074. */
  1075. #ifndef YYNOERRORRECOVERY
  1076. static void yy_parse_failed(
  1077. yyParser *yypParser /* The parser */
  1078. ){
  1079. ParseARG_FETCH;
  1080. #ifndef NDEBUG
  1081. if( yyTraceFILE ){
  1082. fprintf(yyTraceFILE,"%sFail!\n",yyTracePrompt);
  1083. }
  1084. #endif
  1085. while( yypParser->yyidx>=0 ) yy_pop_parser_stack(yypParser);
  1086. /* Here code is inserted which will be executed whenever the
  1087. ** parser fails */
  1088. ParseARG_STORE; /* Suppress warning about unused %extra_argument variable */
  1089. }
  1090. #endif /* YYNOERRORRECOVERY */
  1091. /*
  1092. ** The following code executes when a syntax error first occurs.
  1093. */
  1094. static void yy_syntax_error(
  1095. yyParser *yypParser, /* The parser */
  1096. int yymajor, /* The major type of the error token */
  1097. YYMINORTYPE yyminor /* The minor type of the error token */
  1098. ){
  1099. ParseARG_FETCH;
  1100. #define TOKEN (yyminor.yy0)
  1101. #line 82 "NCDConfigParser_parse.y"
  1102. parser_out->syntax_error = 1;
  1103. #line 1146 "NCDConfigParser_parse.c"
  1104. ParseARG_STORE; /* Suppress warning about unused %extra_argument variable */
  1105. }
  1106. /*
  1107. ** The following is executed when the parser accepts
  1108. */
  1109. static void yy_accept(
  1110. yyParser *yypParser /* The parser */
  1111. ){
  1112. ParseARG_FETCH;
  1113. #ifndef NDEBUG
  1114. if( yyTraceFILE ){
  1115. fprintf(yyTraceFILE,"%sAccept!\n",yyTracePrompt);
  1116. }
  1117. #endif
  1118. while( yypParser->yyidx>=0 ) yy_pop_parser_stack(yypParser);
  1119. /* Here code is inserted which will be executed whenever the
  1120. ** parser accepts */
  1121. ParseARG_STORE; /* Suppress warning about unused %extra_argument variable */
  1122. }
  1123. /* The main parser program.
  1124. ** The first argument is a pointer to a structure obtained from
  1125. ** "ParseAlloc" which describes the current state of the parser.
  1126. ** The second argument is the major token number. The third is
  1127. ** the minor token. The fourth optional argument is whatever the
  1128. ** user wants (and specified in the grammar) and is available for
  1129. ** use by the action routines.
  1130. **
  1131. ** Inputs:
  1132. ** <ul>
  1133. ** <li> A pointer to the parser (an opaque structure.)
  1134. ** <li> The major token number.
  1135. ** <li> The minor token number.
  1136. ** <li> An option argument of a grammar-specified type.
  1137. ** </ul>
  1138. **
  1139. ** Outputs:
  1140. ** None.
  1141. */
  1142. void Parse(
  1143. void *yyp, /* The parser */
  1144. int yymajor, /* The major token code number */
  1145. ParseTOKENTYPE yyminor /* The value for the token */
  1146. ParseARG_PDECL /* Optional %extra_argument parameter */
  1147. ){
  1148. YYMINORTYPE yyminorunion;
  1149. int yyact; /* The parser action. */
  1150. int yyendofinput; /* True if we are at the end of input */
  1151. #ifdef YYERRORSYMBOL
  1152. int yyerrorhit = 0; /* True if yymajor has invoked an error */
  1153. #endif
  1154. yyParser *yypParser; /* The parser */
  1155. /* (re)initialize the parser, if necessary */
  1156. yypParser = (yyParser*)yyp;
  1157. if( yypParser->yyidx<0 ){
  1158. #if YYSTACKDEPTH<=0
  1159. if( yypParser->yystksz <=0 ){
  1160. /*memset(&yyminorunion, 0, sizeof(yyminorunion));*/
  1161. yyminorunion = yyzerominor;
  1162. yyStackOverflow(yypParser, &yyminorunion);
  1163. return;
  1164. }
  1165. #endif
  1166. yypParser->yyidx = 0;
  1167. yypParser->yyerrcnt = -1;
  1168. yypParser->yystack[0].stateno = 0;
  1169. yypParser->yystack[0].major = 0;
  1170. }
  1171. yyminorunion.yy0 = yyminor;
  1172. yyendofinput = (yymajor==0);
  1173. ParseARG_STORE;
  1174. #ifndef NDEBUG
  1175. if( yyTraceFILE ){
  1176. fprintf(yyTraceFILE,"%sInput %s\n",yyTracePrompt,yyTokenName[yymajor]);
  1177. }
  1178. #endif
  1179. do{
  1180. yyact = yy_find_shift_action(yypParser,(YYCODETYPE)yymajor);
  1181. if( yyact<YYNSTATE ){
  1182. assert( !yyendofinput ); /* Impossible to shift the $ token */
  1183. yy_shift(yypParser,yyact,yymajor,&yyminorunion);
  1184. yypParser->yyerrcnt--;
  1185. yymajor = YYNOCODE;
  1186. }else if( yyact < YYNSTATE + YYNRULE ){
  1187. yy_reduce(yypParser,yyact-YYNSTATE);
  1188. }else{
  1189. assert( yyact == YY_ERROR_ACTION );
  1190. #ifdef YYERRORSYMBOL
  1191. int yymx;
  1192. #endif
  1193. #ifndef NDEBUG
  1194. if( yyTraceFILE ){
  1195. fprintf(yyTraceFILE,"%sSyntax Error!\n",yyTracePrompt);
  1196. }
  1197. #endif
  1198. #ifdef YYERRORSYMBOL
  1199. /* A syntax error has occurred.
  1200. ** The response to an error depends upon whether or not the
  1201. ** grammar defines an error token "ERROR".
  1202. **
  1203. ** This is what we do if the grammar does define ERROR:
  1204. **
  1205. ** * Call the %syntax_error function.
  1206. **
  1207. ** * Begin popping the stack until we enter a state where
  1208. ** it is legal to shift the error symbol, then shift
  1209. ** the error symbol.
  1210. **
  1211. ** * Set the error count to three.
  1212. **
  1213. ** * Begin accepting and shifting new tokens. No new error
  1214. ** processing will occur until three tokens have been
  1215. ** shifted successfully.
  1216. **
  1217. */
  1218. if( yypParser->yyerrcnt<0 ){
  1219. yy_syntax_error(yypParser,yymajor,yyminorunion);
  1220. }
  1221. yymx = yypParser->yystack[yypParser->yyidx].major;
  1222. if( yymx==YYERRORSYMBOL || yyerrorhit ){
  1223. #ifndef NDEBUG
  1224. if( yyTraceFILE ){
  1225. fprintf(yyTraceFILE,"%sDiscard input token %s\n",
  1226. yyTracePrompt,yyTokenName[yymajor]);
  1227. }
  1228. #endif
  1229. yy_destructor(yypParser, (YYCODETYPE)yymajor,&yyminorunion);
  1230. yymajor = YYNOCODE;
  1231. }else{
  1232. while(
  1233. yypParser->yyidx >= 0 &&
  1234. yymx != YYERRORSYMBOL &&
  1235. (yyact = yy_find_reduce_action(
  1236. yypParser->yystack[yypParser->yyidx].stateno,
  1237. YYERRORSYMBOL)) >= YYNSTATE
  1238. ){
  1239. yy_pop_parser_stack(yypParser);
  1240. }
  1241. if( yypParser->yyidx < 0 || yymajor==0 ){
  1242. yy_destructor(yypParser,(YYCODETYPE)yymajor,&yyminorunion);
  1243. yy_parse_failed(yypParser);
  1244. yymajor = YYNOCODE;
  1245. }else if( yymx!=YYERRORSYMBOL ){
  1246. YYMINORTYPE u2;
  1247. u2.YYERRSYMDT = 0;
  1248. yy_shift(yypParser,yyact,YYERRORSYMBOL,&u2);
  1249. }
  1250. }
  1251. yypParser->yyerrcnt = 3;
  1252. yyerrorhit = 1;
  1253. #elif defined(YYNOERRORRECOVERY)
  1254. /* If the YYNOERRORRECOVERY macro is defined, then do not attempt to
  1255. ** do any kind of error recovery. Instead, simply invoke the syntax
  1256. ** error routine and continue going as if nothing had happened.
  1257. **
  1258. ** Applications can set this macro (for example inside %include) if
  1259. ** they intend to abandon the parse upon the first syntax error seen.
  1260. */
  1261. yy_syntax_error(yypParser,yymajor,yyminorunion);
  1262. yy_destructor(yypParser,(YYCODETYPE)yymajor,&yyminorunion);
  1263. yymajor = YYNOCODE;
  1264. #else /* YYERRORSYMBOL is not defined */
  1265. /* This is what we do if the grammar does not define ERROR:
  1266. **
  1267. ** * Report an error message, and throw away the input token.
  1268. **
  1269. ** * If the input token is $, then fail the parse.
  1270. **
  1271. ** As before, subsequent error messages are suppressed until
  1272. ** three input tokens have been successfully shifted.
  1273. */
  1274. if( yypParser->yyerrcnt<=0 ){
  1275. yy_syntax_error(yypParser,yymajor,yyminorunion);
  1276. }
  1277. yypParser->yyerrcnt = 3;
  1278. yy_destructor(yypParser,(YYCODETYPE)yymajor,&yyminorunion);
  1279. if( yyendofinput ){
  1280. yy_parse_failed(yypParser);
  1281. }
  1282. yymajor = YYNOCODE;
  1283. #endif
  1284. }
  1285. }while( yymajor!=YYNOCODE && yypParser->yyidx>=0 );
  1286. return;
  1287. }