NCDConfigParser_parse.c 43 KB

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