NCDConfigParser_parse.c 44 KB

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