BadVPN – Blame information for rev 1

Subversion Repositories:
Rev:
Rev Author Line No. Line
1 office 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  
9  
10 #include <string.h>
11 #include <stddef.h>
12  
13 #include <misc/debug.h>
14 #include <misc/concat_strings.h>
15 #include <ncd/NCDAst.h>
16  
17 struct parser_out {
18 int out_of_memory;
19 int syntax_error;
20 int have_ast;
21 NCDProgram ast;
22 };
23  
24 struct token {
25 char *str;
26 size_t len;
27 };
28  
29 struct program {
30 int have;
31 NCDProgram v;
32 };
33  
34 struct block {
35 int have;
36 NCDBlock v;
37 };
38  
39 struct statement {
40 int have;
41 NCDStatement v;
42 };
43  
44 struct ifblock {
45 int have;
46 NCDIfBlock v;
47 };
48  
49 struct value {
50 int have;
51 NCDValue v;
52 };
53  
54 static void free_token (struct token o) { free(o.str); }
55 static void free_program (struct program o) { if (o.have) NCDProgram_Free(&o.v); }
56 static void free_block (struct block o) { if (o.have) NCDBlock_Free(&o.v); }
57 static void free_statement (struct statement o) { if (o.have) NCDStatement_Free(&o.v); }
58 static void free_ifblock (struct ifblock o) { if (o.have) NCDIfBlock_Free(&o.v); }
59 static void free_value (struct value o) { if (o.have) NCDValue_Free(&o.v); }
60  
61 #line 62 "NCDConfigParser_parse.c"
62 /* Next is all token values, in a form suitable for use by makeheaders.
63 ** This section will be null unless lemon is run with the -m switch.
64 */
65 /*
66 ** These constants (all generated automatically by the parser generator)
67 ** specify the various kinds of tokens (terminals) that the parser
68 ** understands.
69 **
70 ** Each symbol here is a terminal symbol in the grammar.
71 */
72 /* Make sure the INTERFACE macro is defined.
73 */
74 #ifndef INTERFACE
75 # define INTERFACE 1
76 #endif
77 /* The next thing included is series of defines which control
78 ** various aspects of the generated parser.
79 ** YYCODETYPE is the data type used for storing terminal
80 ** and nonterminal numbers. "unsigned char" is
81 ** used if there are fewer than 250 terminals
82 ** and nonterminals. "int" is used otherwise.
83 ** YYNOCODE is a number of type YYCODETYPE which corresponds
84 ** to no legal terminal or nonterminal number. This
85 ** number is used to fill in empty slots of the hash
86 ** table.
87 ** YYFALLBACK If defined, this indicates that one or more tokens
88 ** have fall-back values which should be used if the
89 ** original value of the token will not parse.
90 ** YYACTIONTYPE is the data type used for storing terminal
91 ** and nonterminal numbers. "unsigned char" is
92 ** used if there are fewer than 250 rules and
93 ** states combined. "int" is used otherwise.
94 ** ParseTOKENTYPE is the data type used for minor tokens given
95 ** directly to the parser from the tokenizer.
96 ** YYMINORTYPE is the data type used for all minor tokens.
97 ** This is typically a union of many types, one of
98 ** which is ParseTOKENTYPE. The entry in the union
99 ** for base tokens is called "yy0".
100 ** YYSTACKDEPTH is the maximum depth of the parser's stack. If
101 ** zero the stack is dynamically sized using realloc()
102 ** ParseARG_SDECL A static variable declaration for the %extra_argument
103 ** ParseARG_PDECL A parameter declaration for the %extra_argument
104 ** ParseARG_STORE Code to store %extra_argument into yypParser
105 ** ParseARG_FETCH Code to extract %extra_argument from yypParser
106 ** YYNSTATE the combined number of states.
107 ** YYNRULE the number of rules in the grammar
108 ** YYERRORSYMBOL is the code number of the error symbol. If not
109 ** defined, then do no error processing.
110 */
111 #define YYCODETYPE unsigned char
112 #define YYNOCODE 49
113 #define YYACTIONTYPE unsigned char
114 #define ParseTOKENTYPE struct token
115 typedef union {
116 int yyinit;
117 ParseTOKENTYPE yy0;
118 struct program yy6;
119 struct value yy19;
120 int yy28;
121 struct ifblock yy44;
122 struct statement yy47;
123 char * yy49;
124 struct block yy69;
125 } YYMINORTYPE;
126 #ifndef YYSTACKDEPTH
127 #define YYSTACKDEPTH 0
128 #endif
129 #define ParseARG_SDECL struct parser_out *parser_out ;
130 #define ParseARG_PDECL , struct parser_out *parser_out
131 #define ParseARG_FETCH struct parser_out *parser_out = yypParser->parser_out
132 #define ParseARG_STORE yypParser->parser_out = parser_out
133 #define YYNSTATE 130
134 #define YYNRULE 49
135 #define YY_NO_ACTION (YYNSTATE+YYNRULE+2)
136 #define YY_ACCEPT_ACTION (YYNSTATE+YYNRULE+1)
137 #define YY_ERROR_ACTION (YYNSTATE+YYNRULE)
138  
139 /* The yyzerominor constant is used to initialize instances of
140 ** YYMINORTYPE objects to zero. */
141 static const YYMINORTYPE yyzerominor = { 0 };
142  
143 /* Define the yytestcase() macro to be a no-op if is not already defined
144 ** otherwise.
145 **
146 ** Applications can choose to define yytestcase() in the %include section
147 ** to a macro that can assist in verifying code coverage. For production
148 ** code the yytestcase() macro should be turned off. But it is useful
149 ** for testing.
150 */
151 #ifndef yytestcase
152 # define yytestcase(X)
153 #endif
154  
155  
156 /* Next are the tables used to determine what action to take based on the
157 ** current state and lookahead token. These tables are used to implement
158 ** functions that take a state number and lookahead value and return an
159 ** action integer.
160 **
161 ** Suppose the action integer is N. Then the action is determined as
162 ** follows
163 **
164 ** 0 <= N < YYNSTATE Shift N. That is, push the lookahead
165 ** token onto the stack and goto state N.
166 **
167 ** YYNSTATE <= N < YYNSTATE+YYNRULE Reduce by rule N-YYNSTATE.
168 **
169 ** N == YYNSTATE+YYNRULE A syntax error has occurred.
170 **
171 ** N == YYNSTATE+YYNRULE+1 The parser accepts its input.
172 **
173 ** N == YYNSTATE+YYNRULE+2 No such action. Denotes unused
174 ** slots in the yy_action[] table.
175 **
176 ** The action table is constructed as a single large table named yy_action[].
177 ** Given state S and lookahead X, the action is computed as
178 **
179 ** yy_action[ yy_shift_ofst[S] + X ]
180 **
181 ** If the index value yy_shift_ofst[S]+X is out of range or if the value
182 ** yy_lookahead[yy_shift_ofst[S]+X] is not equal to X or if yy_shift_ofst[S]
183 ** is equal to YY_SHIFT_USE_DFLT, it means that the action is not in the table
184 ** and that yy_default[S] should be used instead.
185 **
186 ** The formula above is for computing the action when the lookahead is
187 ** a terminal symbol. If the lookahead is a non-terminal (as occurs after
188 ** a reduce action) then the yy_reduce_ofst[] array is used in place of
189 ** the yy_shift_ofst[] array and YY_REDUCE_USE_DFLT is used in place of
190 ** YY_SHIFT_USE_DFLT.
191 **
192 ** The following are the tables generated in this section:
193 **
194 ** yy_action[] A single table containing all actions.
195 ** yy_lookahead[] A table containing the lookahead for each entry in
196 ** yy_action. Used to detect hash collisions.
197 ** yy_shift_ofst[] For each state, the offset into yy_action for
198 ** shifting terminals.
199 ** yy_reduce_ofst[] For each state, the offset into yy_action for
200 ** shifting non-terminals after a reduce.
201 ** yy_default[] Default action for each state.
202 */
203 static const YYACTIONTYPE yy_action[] = {
204 /* 0 */ 107, 51, 59, 4, 104, 9, 107, 2, 59, 4,
205 /* 10 */ 94, 9, 107, 58, 59, 4, 54, 9, 95, 180,
206 /* 20 */ 5, 6, 29, 30, 100, 54, 5, 117, 29, 30,
207 /* 30 */ 34, 128, 5, 54, 29, 30, 111, 57, 102, 112,
208 /* 40 */ 59, 113, 115, 43, 111, 62, 102, 112, 96, 113,
209 /* 50 */ 115, 43, 2, 111, 65, 102, 112, 91, 113, 115,
210 /* 60 */ 43, 101, 111, 54, 60, 112, 7, 113, 115, 43,
211 /* 70 */ 111, 61, 2, 112, 63, 113, 115, 44, 111, 8,
212 /* 80 */ 103, 112, 108, 113, 115, 43, 111, 2, 116, 112,
213 /* 90 */ 106, 113, 115, 44, 111, 2, 68, 112, 2, 113,
214 /* 100 */ 115, 45, 1, 111, 73, 32, 112, 110, 113, 115,
215 /* 110 */ 46, 111, 64, 52, 112, 53, 113, 115, 47, 111,
216 /* 120 */ 109, 66, 112, 71, 113, 115, 48, 111, 70, 59,
217 /* 130 */ 112, 35, 113, 115, 50, 39, 67, 72, 97, 98,
218 /* 140 */ 76, 20, 77, 79, 80, 56, 42, 20, 82, 20,
219 /* 150 */ 129, 69, 42, 90, 42, 130, 20, 84, 20, 89,
220 /* 160 */ 75, 42, 78, 42, 20, 23, 24, 20, 81, 42,
221 /* 170 */ 20, 83, 42, 20, 124, 42, 20, 88, 42, 74,
222 /* 180 */ 93, 42, 2, 92, 55, 85, 13, 27, 25, 28,
223 /* 190 */ 105, 118, 99, 31, 114, 3, 119, 33, 10, 14,
224 /* 200 */ 49, 26, 120, 15, 11, 16, 86, 36, 121, 17,
225 /* 210 */ 181, 37, 122, 18, 87, 38, 123, 19, 181, 21,
226 /* 220 */ 181, 40, 125, 127, 41, 126, 181, 12, 22,
227 };
228 static const YYCODETYPE yy_lookahead[] = {
229 /* 0 */ 2, 29, 4, 5, 6, 7, 2, 7, 4, 5,
230 /* 10 */ 29, 7, 2, 43, 4, 5, 44, 7, 29, 47,
231 /* 20 */ 22, 21, 24, 25, 4, 44, 22, 23, 24, 25,
232 /* 30 */ 31, 32, 22, 44, 24, 25, 35, 36, 37, 38,
233 /* 40 */ 4, 40, 41, 42, 35, 36, 37, 38, 29, 40,
234 /* 50 */ 41, 42, 7, 35, 36, 37, 38, 15, 40, 41,
235 /* 60 */ 42, 35, 35, 44, 37, 38, 21, 40, 41, 42,
236 /* 70 */ 35, 4, 7, 38, 39, 40, 41, 42, 35, 14,
237 /* 80 */ 37, 38, 35, 40, 41, 42, 35, 7, 8, 38,
238 /* 90 */ 39, 40, 41, 42, 35, 7, 8, 38, 7, 40,
239 /* 100 */ 41, 42, 7, 35, 13, 10, 38, 45, 40, 41,
240 /* 110 */ 42, 35, 35, 1, 38, 3, 40, 41, 42, 35,
241 /* 120 */ 45, 43, 38, 16, 40, 41, 42, 35, 43, 4,
242 /* 130 */ 38, 33, 40, 41, 42, 46, 11, 12, 26, 27,
243 /* 140 */ 43, 30, 17, 43, 19, 34, 35, 30, 18, 30,
244 /* 150 */ 32, 34, 35, 34, 35, 0, 30, 43, 30, 43,
245 /* 160 */ 34, 35, 34, 35, 30, 2, 2, 30, 34, 35,
246 /* 170 */ 30, 34, 35, 30, 34, 35, 30, 34, 35, 8,
247 /* 180 */ 34, 35, 7, 8, 4, 14, 5, 8, 6, 20,
248 /* 190 */ 6, 23, 9, 20, 8, 7, 9, 8, 7, 5,
249 /* 200 */ 4, 6, 9, 5, 7, 5, 4, 6, 9, 5,
250 /* 210 */ 48, 6, 9, 5, 8, 6, 6, 5, 48, 5,
251 /* 220 */ 48, 6, 9, 6, 6, 9, 48, 7, 5,
252 };
253 #define YY_SHIFT_USE_DFLT (-3)
254 #define YY_SHIFT_MAX 93
255 static const short yy_shift_ofst[] = {
256 /* 0 */ 112, 10, 10, 10, -2, 4, 10, 10, 10, 10,
257 /* 10 */ 10, 10, 10, 125, 125, 125, 125, 125, 125, 125,
258 /* 20 */ 125, 125, 125, 112, 112, 112, 42, 20, 36, 36,
259 /* 30 */ 67, 67, 36, 20, 107, 20, 20, 20, 130, 20,
260 /* 40 */ 20, 42, 95, 0, 65, 45, 80, 88, 91, 171,
261 /* 50 */ 175, 155, 163, 164, 180, 181, 182, 179, 183, 169,
262 /* 60 */ 184, 173, 186, 168, 188, 189, 187, 191, 194, 195,
263 /* 70 */ 193, 198, 197, 196, 200, 201, 199, 204, 205, 203,
264 /* 80 */ 208, 209, 212, 210, 213, 202, 206, 214, 215, 216,
265 /* 90 */ 217, 220, 223, 218,
266 };
267 #define YY_REDUCE_USE_DFLT (-31)
268 #define YY_REDUCE_MAX 41
269 static const short yy_reduce_ofst[] = {
270 /* 0 */ -28, 1, 9, 18, 27, 35, 43, 51, 59, 68,
271 /* 10 */ 76, 84, 92, 111, 117, 119, 126, 128, 134, 137,
272 /* 20 */ 140, 143, 146, -19, -11, 19, -1, -30, 26, 47,
273 /* 30 */ 62, 75, 77, 78, 98, 85, 97, 100, 89, 114,
274 /* 40 */ 116, 118,
275 };
276 static const YYACTIONTYPE yy_default[] = {
277 /* 0 */ 131, 156, 156, 156, 179, 179, 179, 179, 179, 179,
278 /* 10 */ 179, 179, 179, 179, 179, 179, 179, 179, 179, 179,
279 /* 20 */ 150, 179, 179, 131, 131, 131, 140, 175, 179, 179,
280 /* 30 */ 179, 179, 179, 175, 144, 175, 175, 175, 147, 175,
281 /* 40 */ 175, 142, 179, 158, 179, 162, 179, 179, 179, 179,
282 /* 50 */ 179, 179, 179, 179, 179, 179, 179, 179, 179, 152,
283 /* 60 */ 179, 154, 179, 179, 179, 179, 179, 179, 179, 179,
284 /* 70 */ 179, 179, 179, 179, 179, 179, 179, 179, 179, 179,
285 /* 80 */ 179, 179, 179, 179, 179, 179, 179, 179, 179, 179,
286 /* 90 */ 179, 179, 179, 179, 132, 133, 134, 177, 178, 135,
287 /* 100 */ 176, 153, 157, 159, 160, 161, 163, 167, 168, 155,
288 /* 110 */ 169, 170, 171, 172, 166, 174, 173, 164, 165, 136,
289 /* 120 */ 137, 138, 146, 148, 151, 149, 139, 145, 141, 143,
290 };
291 #define YY_SZ_ACTTAB (int)(sizeof(yy_action)/sizeof(yy_action[0]))
292  
293 /* The next table maps tokens into fallback tokens. If a construct
294 ** like the following:
295 **
296 ** %fallback ID X Y Z.
297 **
298 ** appears in the grammar, then ID becomes a fallback token for X, Y,
299 ** and Z. Whenever one of the tokens X, Y, or Z is input to the parser
300 ** but it does not parse, the type of the token is changed to ID and
301 ** the parse is retried before an error is thrown.
302 */
303 #ifdef YYFALLBACK
304 static const YYCODETYPE yyFallback[] = {
305 };
306 #endif /* YYFALLBACK */
307  
308 /* The following structure represents a single element of the
309 ** parser's stack. Information stored includes:
310 **
311 ** + The state number for the parser at this level of the stack.
312 **
313 ** + The value of the token stored at this level of the stack.
314 ** (In other words, the "major" token.)
315 **
316 ** + The semantic value stored at this level of the stack. This is
317 ** the information used by the action routines in the grammar.
318 ** It is sometimes called the "minor" token.
319 */
320 struct yyStackEntry {
321 YYACTIONTYPE stateno; /* The state-number */
322 YYCODETYPE major; /* The major token value. This is the code
323 ** number for the token at this stack level */
324 YYMINORTYPE minor; /* The user-supplied minor token value. This
325 ** is the value of the token */
326 };
327 typedef struct yyStackEntry yyStackEntry;
328  
329 /* The state of the parser is completely contained in an instance of
330 ** the following structure */
331 struct yyParser {
332 int yyidx; /* Index of top element in stack */
333 #ifdef YYTRACKMAXSTACKDEPTH
334 int yyidxMax; /* Maximum value of yyidx */
335 #endif
336 int yyerrcnt; /* Shifts left before out of the error */
337 ParseARG_SDECL /* A place to hold %extra_argument */
338 #if YYSTACKDEPTH<=0
339 int yystksz; /* Current side of the stack */
340 yyStackEntry *yystack; /* The parser's stack */
341 #else
342 yyStackEntry yystack[YYSTACKDEPTH]; /* The parser's stack */
343 #endif
344 };
345 typedef struct yyParser yyParser;
346  
347 #ifndef NDEBUG
348 #include <stdio.h>
349 static FILE *yyTraceFILE = 0;
350 static char *yyTracePrompt = 0;
351 #endif /* NDEBUG */
352  
353 #ifndef NDEBUG
354 /*
355 ** Turn parser tracing on by giving a stream to which to write the trace
356 ** and a prompt to preface each trace message. Tracing is turned off
357 ** by making either argument NULL
358 **
359 ** Inputs:
360 ** <ul>
361 ** <li> A FILE* to which trace output should be written.
362 ** If NULL, then tracing is turned off.
363 ** <li> A prefix string written at the beginning of every
364 ** line of trace output. If NULL, then tracing is
365 ** turned off.
366 ** </ul>
367 **
368 ** Outputs:
369 ** None.
370 */
371 void ParseTrace(FILE *TraceFILE, char *zTracePrompt){
372 yyTraceFILE = TraceFILE;
373 yyTracePrompt = zTracePrompt;
374 if( yyTraceFILE==0 ) yyTracePrompt = 0;
375 else if( yyTracePrompt==0 ) yyTraceFILE = 0;
376 }
377 #endif /* NDEBUG */
378  
379 #ifndef NDEBUG
380 /* For tracing shifts, the names of all terminals and nonterminals
381 ** are required. The following table supplies these names */
382 static const char *const yyTokenName[] = {
383 "$", "INCLUDE", "STRING", "INCLUDE_GUARD",
384 "NAME", "CURLY_OPEN", "CURLY_CLOSE", "ROUND_OPEN",
385 "ROUND_CLOSE", "SEMICOLON", "ARROW", "IF",
386 "FOREACH", "AS", "COLON", "ELIF",
387 "ELSE", "BLOCK", "TOKEN_INTERRUPT", "TOKEN_DO",
388 "DOT", "COMMA", "BRACKET_OPEN", "BRACKET_CLOSE",
389 "AT_SIGN", "CARET", "PROCESS", "TEMPLATE",
390 "error", "processes", "statement", "elif_maybe",
391 "elif", "else_maybe", "statements", "dotted_name",
392 "list_contents_maybe", "list_contents", "list", "map_contents",
393 "map", "invoc", "value", "name_maybe",
394 "process_or_template", "name_list", "interrupt_maybe", "input",
395 };
396 #endif /* NDEBUG */
397  
398 #ifndef NDEBUG
399 /* For tracing reduce actions, the names of all rules are required.
400 */
401 static const char *const yyRuleName[] = {
402 /* 0 */ "input ::= processes",
403 /* 1 */ "processes ::=",
404 /* 2 */ "processes ::= INCLUDE STRING processes",
405 /* 3 */ "processes ::= INCLUDE_GUARD STRING processes",
406 /* 4 */ "processes ::= process_or_template NAME CURLY_OPEN statements CURLY_CLOSE processes",
407 /* 5 */ "statement ::= dotted_name ROUND_OPEN list_contents_maybe ROUND_CLOSE name_maybe SEMICOLON",
408 /* 6 */ "statement ::= dotted_name ARROW dotted_name ROUND_OPEN list_contents_maybe ROUND_CLOSE name_maybe SEMICOLON",
409 /* 7 */ "statement ::= IF ROUND_OPEN value ROUND_CLOSE CURLY_OPEN statements CURLY_CLOSE elif_maybe else_maybe name_maybe SEMICOLON",
410 /* 8 */ "statement ::= FOREACH ROUND_OPEN value AS NAME ROUND_CLOSE CURLY_OPEN statements CURLY_CLOSE name_maybe SEMICOLON",
411 /* 9 */ "statement ::= FOREACH ROUND_OPEN value AS NAME COLON NAME ROUND_CLOSE CURLY_OPEN statements CURLY_CLOSE name_maybe SEMICOLON",
412 /* 10 */ "elif_maybe ::=",
413 /* 11 */ "elif_maybe ::= elif",
414 /* 12 */ "elif ::= ELIF ROUND_OPEN value ROUND_CLOSE CURLY_OPEN statements CURLY_CLOSE",
415 /* 13 */ "elif ::= ELIF ROUND_OPEN value ROUND_CLOSE CURLY_OPEN statements CURLY_CLOSE elif",
416 /* 14 */ "else_maybe ::=",
417 /* 15 */ "else_maybe ::= ELSE CURLY_OPEN statements CURLY_CLOSE",
418 /* 16 */ "statement ::= BLOCK CURLY_OPEN statements CURLY_CLOSE name_maybe SEMICOLON",
419 /* 17 */ "interrupt_maybe ::=",
420 /* 18 */ "interrupt_maybe ::= TOKEN_INTERRUPT CURLY_OPEN statements CURLY_CLOSE",
421 /* 19 */ "statement ::= TOKEN_DO CURLY_OPEN statements CURLY_CLOSE interrupt_maybe name_maybe SEMICOLON",
422 /* 20 */ "statements ::= statement",
423 /* 21 */ "statements ::= statement statements",
424 /* 22 */ "dotted_name ::= NAME",
425 /* 23 */ "dotted_name ::= NAME DOT dotted_name",
426 /* 24 */ "name_list ::= NAME",
427 /* 25 */ "name_list ::= NAME DOT name_list",
428 /* 26 */ "list_contents_maybe ::=",
429 /* 27 */ "list_contents_maybe ::= list_contents",
430 /* 28 */ "list_contents ::= value",
431 /* 29 */ "list_contents ::= value COMMA list_contents",
432 /* 30 */ "list ::= CURLY_OPEN CURLY_CLOSE",
433 /* 31 */ "list ::= CURLY_OPEN list_contents CURLY_CLOSE",
434 /* 32 */ "map_contents ::= value COLON value",
435 /* 33 */ "map_contents ::= value COLON value COMMA map_contents",
436 /* 34 */ "map ::= BRACKET_OPEN BRACKET_CLOSE",
437 /* 35 */ "map ::= BRACKET_OPEN map_contents BRACKET_CLOSE",
438 /* 36 */ "invoc ::= value ROUND_OPEN list_contents_maybe ROUND_CLOSE",
439 /* 37 */ "value ::= STRING",
440 /* 38 */ "value ::= AT_SIGN dotted_name",
441 /* 39 */ "value ::= CARET name_list",
442 /* 40 */ "value ::= dotted_name",
443 /* 41 */ "value ::= list",
444 /* 42 */ "value ::= map",
445 /* 43 */ "value ::= ROUND_OPEN value ROUND_CLOSE",
446 /* 44 */ "value ::= invoc",
447 /* 45 */ "name_maybe ::=",
448 /* 46 */ "name_maybe ::= NAME",
449 /* 47 */ "process_or_template ::= PROCESS",
450 /* 48 */ "process_or_template ::= TEMPLATE",
451 };
452 #endif /* NDEBUG */
453  
454  
455 #if YYSTACKDEPTH<=0
456 /*
457 ** Try to increase the size of the parser stack.
458 */
459 static void yyGrowStack(yyParser *p){
460 int newSize;
461 yyStackEntry *pNew;
462  
463 newSize = p->yystksz*2 + 100;
464 pNew = realloc(p->yystack, newSize*sizeof(pNew[0]));
465 if( pNew ){
466 p->yystack = pNew;
467 p->yystksz = newSize;
468 #ifndef NDEBUG
469 if( yyTraceFILE ){
470 fprintf(yyTraceFILE,"%sStack grows to %d entries!\n",
471 yyTracePrompt, p->yystksz);
472 }
473 #endif
474 }
475 }
476 #endif
477  
478 /*
479 ** This function allocates a new parser.
480 ** The only argument is a pointer to a function which works like
481 ** malloc.
482 **
483 ** Inputs:
484 ** A pointer to the function used to allocate memory.
485 **
486 ** Outputs:
487 ** A pointer to a parser. This pointer is used in subsequent calls
488 ** to Parse and ParseFree.
489 */
490 void *ParseAlloc(void *(*mallocProc)(size_t)){
491 yyParser *pParser;
492 pParser = (yyParser*)(*mallocProc)( (size_t)sizeof(yyParser) );
493 if( pParser ){
494 pParser->yyidx = -1;
495 #ifdef YYTRACKMAXSTACKDEPTH
496 pParser->yyidxMax = 0;
497 #endif
498 #if YYSTACKDEPTH<=0
499 pParser->yystack = NULL;
500 pParser->yystksz = 0;
501 yyGrowStack(pParser);
502 #endif
503 }
504 return pParser;
505 }
506  
507 /* The following function deletes the value associated with a
508 ** symbol. The symbol can be either a terminal or nonterminal.
509 ** "yymajor" is the symbol code, and "yypminor" is a pointer to
510 ** the value.
511 */
512 static void yy_destructor(
513 yyParser *yypParser, /* The parser */
514 YYCODETYPE yymajor, /* Type code for object to destroy */
515 YYMINORTYPE *yypminor /* The object to be destroyed */
516 ){
517 ParseARG_FETCH;
518 switch( yymajor ){
519 /* Here is inserted the actions which take place when a
520 ** terminal or non-terminal is destroyed. This can happen
521 ** when the symbol is popped from the stack during a
522 ** reduce or during error processing or when a parser is
523 ** being destroyed before it is finished parsing.
524 **
525 ** Note: during a reduce, the only symbols destroyed are those
526 ** which appear on the RHS of the rule, but which are not used
527 ** inside the C code.
528 */
529 /* TERMINAL Destructor */
530 case 1: /* INCLUDE */
531 case 2: /* STRING */
532 case 3: /* INCLUDE_GUARD */
533 case 4: /* NAME */
534 case 5: /* CURLY_OPEN */
535 case 6: /* CURLY_CLOSE */
536 case 7: /* ROUND_OPEN */
537 case 8: /* ROUND_CLOSE */
538 case 9: /* SEMICOLON */
539 case 10: /* ARROW */
540 case 11: /* IF */
541 case 12: /* FOREACH */
542 case 13: /* AS */
543 case 14: /* COLON */
544 case 15: /* ELIF */
545 case 16: /* ELSE */
546 case 17: /* BLOCK */
547 case 18: /* TOKEN_INTERRUPT */
548 case 19: /* TOKEN_DO */
549 case 20: /* DOT */
550 case 21: /* COMMA */
551 case 22: /* BRACKET_OPEN */
552 case 23: /* BRACKET_CLOSE */
553 case 24: /* AT_SIGN */
554 case 25: /* CARET */
555 case 26: /* PROCESS */
556 case 27: /* TEMPLATE */
557 {
558 #line 89 "NCDConfigParser_parse.y"
559 free_token((yypminor->yy0));
560 #line 561 "NCDConfigParser_parse.c"
561 }
562 break;
563 case 29: /* processes */
564 {
565 #line 111 "NCDConfigParser_parse.y"
566 (void)parser_out; free_program((yypminor->yy6));
567 #line 568 "NCDConfigParser_parse.c"
568 }
569 break;
570 case 30: /* statement */
571 {
572 #line 112 "NCDConfigParser_parse.y"
573 free_statement((yypminor->yy47));
574 #line 575 "NCDConfigParser_parse.c"
575 }
576 break;
577 case 31: /* elif_maybe */
578 case 32: /* elif */
579 {
580 #line 113 "NCDConfigParser_parse.y"
581 free_ifblock((yypminor->yy44));
582 #line 583 "NCDConfigParser_parse.c"
583 }
584 break;
585 case 33: /* else_maybe */
586 case 34: /* statements */
587 case 46: /* interrupt_maybe */
588 {
589 #line 115 "NCDConfigParser_parse.y"
590 free_block((yypminor->yy69));
591 #line 592 "NCDConfigParser_parse.c"
592 }
593 break;
594 case 35: /* dotted_name */
595 case 43: /* name_maybe */
596 {
597 #line 117 "NCDConfigParser_parse.y"
598 free((yypminor->yy49));
599 #line 600 "NCDConfigParser_parse.c"
600 }
601 break;
602 case 36: /* list_contents_maybe */
603 case 37: /* list_contents */
604 case 38: /* list */
605 case 39: /* map_contents */
606 case 40: /* map */
607 case 41: /* invoc */
608 case 42: /* value */
609 case 45: /* name_list */
610 {
611 #line 118 "NCDConfigParser_parse.y"
612 free_value((yypminor->yy19));
613 #line 614 "NCDConfigParser_parse.c"
614 }
615 break;
616 default: break; /* If no destructor action specified: do nothing */
617 }
618 }
619  
620 /*
621 ** Pop the parser's stack once.
622 **
623 ** If there is a destructor routine associated with the token which
624 ** is popped from the stack, then call it.
625 **
626 ** Return the major token number for the symbol popped.
627 */
628 static int yy_pop_parser_stack(yyParser *pParser){
629 YYCODETYPE yymajor;
630 yyStackEntry *yytos = &pParser->yystack[pParser->yyidx];
631  
632 if( pParser->yyidx<0 ) return 0;
633 #ifndef NDEBUG
634 if( yyTraceFILE && pParser->yyidx>=0 ){
635 fprintf(yyTraceFILE,"%sPopping %s\n",
636 yyTracePrompt,
637 yyTokenName[yytos->major]);
638 }
639 #endif
640 yymajor = yytos->major;
641 yy_destructor(pParser, yymajor, &yytos->minor);
642 pParser->yyidx--;
643 return yymajor;
644 }
645  
646 /*
647 ** Deallocate and destroy a parser. Destructors are all called for
648 ** all stack elements before shutting the parser down.
649 **
650 ** Inputs:
651 ** <ul>
652 ** <li> A pointer to the parser. This should be a pointer
653 ** obtained from ParseAlloc.
654 ** <li> A pointer to a function used to reclaim memory obtained
655 ** from malloc.
656 ** </ul>
657 */
658 void ParseFree(
659 void *p, /* The parser to be deleted */
660 void (*freeProc)(void*) /* Function used to reclaim memory */
661 ){
662 yyParser *pParser = (yyParser*)p;
663 if( pParser==0 ) return;
664 while( pParser->yyidx>=0 ) yy_pop_parser_stack(pParser);
665 #if YYSTACKDEPTH<=0
666 free(pParser->yystack);
667 #endif
668 (*freeProc)((void*)pParser);
669 }
670  
671 /*
672 ** Return the peak depth of the stack for a parser.
673 */
674 #ifdef YYTRACKMAXSTACKDEPTH
675 int ParseStackPeak(void *p){
676 yyParser *pParser = (yyParser*)p;
677 return pParser->yyidxMax;
678 }
679 #endif
680  
681 /*
682 ** Find the appropriate action for a parser given the terminal
683 ** look-ahead token iLookAhead.
684 **
685 ** If the look-ahead token is YYNOCODE, then check to see if the action is
686 ** independent of the look-ahead. If it is, return the action, otherwise
687 ** return YY_NO_ACTION.
688 */
689 static int yy_find_shift_action(
690 yyParser *pParser, /* The parser */
691 YYCODETYPE iLookAhead /* The look-ahead token */
692 ){
693 int i;
694 int stateno = pParser->yystack[pParser->yyidx].stateno;
695  
696 if( stateno>YY_SHIFT_MAX || (i = yy_shift_ofst[stateno])==YY_SHIFT_USE_DFLT ){
697 return yy_default[stateno];
698 }
699 assert( iLookAhead!=YYNOCODE );
700 i += iLookAhead;
701 if( i<0 || i>=YY_SZ_ACTTAB || yy_lookahead[i]!=iLookAhead ){
702 if( iLookAhead>0 ){
703 #ifdef YYFALLBACK
704 YYCODETYPE iFallback; /* Fallback token */
705 if( iLookAhead<sizeof(yyFallback)/sizeof(yyFallback[0])
706 && (iFallback = yyFallback[iLookAhead])!=0 ){
707 #ifndef NDEBUG
708 if( yyTraceFILE ){
709 fprintf(yyTraceFILE, "%sFALLBACK %s => %s\n",
710 yyTracePrompt, yyTokenName[iLookAhead], yyTokenName[iFallback]);
711 }
712 #endif
713 return yy_find_shift_action(pParser, iFallback);
714 }
715 #endif
716 #ifdef YYWILDCARD
717 {
718 int j = i - iLookAhead + YYWILDCARD;
719 if( j>=0 && j<YY_SZ_ACTTAB && yy_lookahead[j]==YYWILDCARD ){
720 #ifndef NDEBUG
721 if( yyTraceFILE ){
722 fprintf(yyTraceFILE, "%sWILDCARD %s => %s\n",
723 yyTracePrompt, yyTokenName[iLookAhead], yyTokenName[YYWILDCARD]);
724 }
725 #endif /* NDEBUG */
726 return yy_action[j];
727 }
728 }
729 #endif /* YYWILDCARD */
730 }
731 return yy_default[stateno];
732 }else{
733 return yy_action[i];
734 }
735 }
736  
737 /*
738 ** Find the appropriate action for a parser given the non-terminal
739 ** look-ahead token iLookAhead.
740 **
741 ** If the look-ahead token is YYNOCODE, then check to see if the action is
742 ** independent of the look-ahead. If it is, return the action, otherwise
743 ** return YY_NO_ACTION.
744 */
745 static int yy_find_reduce_action(
746 int stateno, /* Current state number */
747 YYCODETYPE iLookAhead /* The look-ahead token */
748 ){
749 int i;
750 #ifdef YYERRORSYMBOL
751 if( stateno>YY_REDUCE_MAX ){
752 return yy_default[stateno];
753 }
754 #else
755 assert( stateno<=YY_REDUCE_MAX );
756 #endif
757 i = yy_reduce_ofst[stateno];
758 assert( i!=YY_REDUCE_USE_DFLT );
759 assert( iLookAhead!=YYNOCODE );
760 i += iLookAhead;
761 #ifdef YYERRORSYMBOL
762 if( i<0 || i>=YY_SZ_ACTTAB || yy_lookahead[i]!=iLookAhead ){
763 return yy_default[stateno];
764 }
765 #else
766 assert( i>=0 && i<YY_SZ_ACTTAB );
767 assert( yy_lookahead[i]==iLookAhead );
768 #endif
769 return yy_action[i];
770 }
771  
772 /*
773 ** The following routine is called if the stack overflows.
774 */
775 static void yyStackOverflow(yyParser *yypParser, YYMINORTYPE *yypMinor){
776 ParseARG_FETCH;
777 yypParser->yyidx--;
778 #ifndef NDEBUG
779 if( yyTraceFILE ){
780 fprintf(yyTraceFILE,"%sStack Overflow!\n",yyTracePrompt);
781 }
782 #endif
783 while( yypParser->yyidx>=0 ) yy_pop_parser_stack(yypParser);
784 /* Here code is inserted which will execute if the parser
785 ** stack every overflows */
786 #line 136 "NCDConfigParser_parse.y"
787  
788 if (yypMinor) {
789 free_token(yypMinor->yy0);
790 }
791 #line 792 "NCDConfigParser_parse.c"
792 ParseARG_STORE; /* Suppress warning about unused %extra_argument var */
793 }
794  
795 /*
796 ** Perform a shift action.
797 */
798 static void yy_shift(
799 yyParser *yypParser, /* The parser to be shifted */
800 int yyNewState, /* The new state to shift in */
801 int yyMajor, /* The major token to shift in */
802 YYMINORTYPE *yypMinor /* Pointer to the minor token to shift in */
803 ){
804 yyStackEntry *yytos;
805 yypParser->yyidx++;
806 #ifdef YYTRACKMAXSTACKDEPTH
807 if( yypParser->yyidx>yypParser->yyidxMax ){
808 yypParser->yyidxMax = yypParser->yyidx;
809 }
810 #endif
811 #if YYSTACKDEPTH>0
812 if( yypParser->yyidx>=YYSTACKDEPTH ){
813 yyStackOverflow(yypParser, yypMinor);
814 return;
815 }
816 #else
817 if( yypParser->yyidx>=yypParser->yystksz ){
818 yyGrowStack(yypParser);
819 if( yypParser->yyidx>=yypParser->yystksz ){
820 yyStackOverflow(yypParser, yypMinor);
821 return;
822 }
823 }
824 #endif
825 yytos = &yypParser->yystack[yypParser->yyidx];
826 yytos->stateno = (YYACTIONTYPE)yyNewState;
827 yytos->major = (YYCODETYPE)yyMajor;
828 yytos->minor = *yypMinor;
829 #ifndef NDEBUG
830 if( yyTraceFILE && yypParser->yyidx>0 ){
831 int i;
832 fprintf(yyTraceFILE,"%sShift %d\n",yyTracePrompt,yyNewState);
833 fprintf(yyTraceFILE,"%sStack:",yyTracePrompt);
834 for(i=1; i<=yypParser->yyidx; i++)
835 fprintf(yyTraceFILE," %s",yyTokenName[yypParser->yystack[i].major]);
836 fprintf(yyTraceFILE,"\n");
837 }
838 #endif
839 }
840  
841 /* The following table contains information about every rule that
842 ** is used during the reduce.
843 */
844 static const struct {
845 YYCODETYPE lhs; /* Symbol on the left-hand side of the rule */
846 unsigned char nrhs; /* Number of right-hand side symbols in the rule */
847 } yyRuleInfo[] = {
848 { 47, 1 },
849 { 29, 0 },
850 { 29, 3 },
851 { 29, 3 },
852 { 29, 6 },
853 { 30, 6 },
854 { 30, 8 },
855 { 30, 11 },
856 { 30, 11 },
857 { 30, 13 },
858 { 31, 0 },
859 { 31, 1 },
860 { 32, 7 },
861 { 32, 8 },
862 { 33, 0 },
863 { 33, 4 },
864 { 30, 6 },
865 { 46, 0 },
866 { 46, 4 },
867 { 30, 7 },
868 { 34, 1 },
869 { 34, 2 },
870 { 35, 1 },
871 { 35, 3 },
872 { 45, 1 },
873 { 45, 3 },
874 { 36, 0 },
875 { 36, 1 },
876 { 37, 1 },
877 { 37, 3 },
878 { 38, 2 },
879 { 38, 3 },
880 { 39, 3 },
881 { 39, 5 },
882 { 40, 2 },
883 { 40, 3 },
884 { 41, 4 },
885 { 42, 1 },
886 { 42, 2 },
887 { 42, 2 },
888 { 42, 1 },
889 { 42, 1 },
890 { 42, 1 },
891 { 42, 3 },
892 { 42, 1 },
893 { 43, 0 },
894 { 43, 1 },
895 { 44, 1 },
896 { 44, 1 },
897 };
898  
899 static void yy_accept(yyParser*); /* Forward Declaration */
900  
901 /*
902 ** Perform a reduce action and the shift that must immediately
903 ** follow the reduce.
904 */
905 static void yy_reduce(
906 yyParser *yypParser, /* The parser */
907 int yyruleno /* Number of the rule by which to reduce */
908 ){
909 int yygoto; /* The next state */
910 int yyact; /* The next action */
911 YYMINORTYPE yygotominor; /* The LHS of the rule reduced */
912 yyStackEntry *yymsp; /* The top of the parser's stack */
913 int yysize; /* Amount to pop the stack */
914 ParseARG_FETCH;
915 yymsp = &yypParser->yystack[yypParser->yyidx];
916 #ifndef NDEBUG
917 if( yyTraceFILE && yyruleno>=0
918 && yyruleno<(int)(sizeof(yyRuleName)/sizeof(yyRuleName[0])) ){
919 fprintf(yyTraceFILE, "%sReduce [%s].\n", yyTracePrompt,
920 yyRuleName[yyruleno]);
921 }
922 #endif /* NDEBUG */
923  
924 /* Silence complaints from purify about yygotominor being uninitialized
925 ** in some cases when it is copied into the stack after the following
926 ** switch. yygotominor is uninitialized when a rule reduces that does
927 ** not set the value of its left-hand side nonterminal. Leaving the
928 ** value of the nonterminal uninitialized is utterly harmless as long
929 ** as the value is never used. So really the only thing this code
930 ** accomplishes is to quieten purify.
931 **
932 ** 2007-01-16: The wireshark project (www.wireshark.org) reports that
933 ** without this code, their parser segfaults. I'm not sure what there
934 ** parser is doing to make this happen. This is the second bug report
935 ** from wireshark this week. Clearly they are stressing Lemon in ways
936 ** that it has not been previously stressed... (SQLite ticket #2172)
937 */
938 /*memset(&yygotominor, 0, sizeof(yygotominor));*/
939 yygotominor = yyzerominor;
940  
941  
942 switch( yyruleno ){
943 /* Beginning here are the reduction cases. A typical example
944 ** follows:
945 ** case 0:
946 ** #line <lineno> <grammarfile>
947 ** { ... } // User supplied code
948 ** #line <lineno> <thisfile>
949 ** break;
950 */
951 case 0: /* input ::= processes */
952 #line 142 "NCDConfigParser_parse.y"
953 {
954 ASSERT(!parser_out->have_ast)
955  
956 if (yymsp[0].minor.yy6.have) {
957 parser_out->have_ast = 1;
958 parser_out->ast = yymsp[0].minor.yy6.v;
959 }
960 }
961 #line 962 "NCDConfigParser_parse.c"
962 break;
963 case 1: /* processes ::= */
964 #line 151 "NCDConfigParser_parse.y"
965 {
966 NCDProgram prog;
967 NCDProgram_Init(&prog);
968  
969 yygotominor.yy6.have = 1;
970 yygotominor.yy6.v = prog;
971 }
972 #line 973 "NCDConfigParser_parse.c"
973 break;
974 case 2: /* processes ::= INCLUDE STRING processes */
975 #line 159 "NCDConfigParser_parse.y"
976 {
977 ASSERT(yymsp[-1].minor.yy0.str)
978 if (!yymsp[0].minor.yy6.have) {
979 goto failA0;
980 }
981  
982 NCDProgramElem elem;
983 if (!NCDProgramElem_InitInclude(&elem, yymsp[-1].minor.yy0.str, yymsp[-1].minor.yy0.len)) {
984 goto failA0;
985 }
986  
987 if (!NCDProgram_PrependElem(&yymsp[0].minor.yy6.v, elem)) {
988 goto failA1;
989 }
990  
991 yygotominor.yy6.have = 1;
992 yygotominor.yy6.v = yymsp[0].minor.yy6.v;
993 yymsp[0].minor.yy6.have = 0;
994 goto doneA;
995  
996 failA1:
997 NCDProgramElem_Free(&elem);
998 failA0:
999 yygotominor.yy6.have = 0;
1000 parser_out->out_of_memory = 1;
1001 doneA:
1002 free_token(yymsp[-1].minor.yy0);
1003 free_program(yymsp[0].minor.yy6);
1004 yy_destructor(yypParser,1,&yymsp[-2].minor);
1005 }
1006 #line 1007 "NCDConfigParser_parse.c"
1007 break;
1008 case 3: /* processes ::= INCLUDE_GUARD STRING processes */
1009 #line 189 "NCDConfigParser_parse.y"
1010 {
1011 ASSERT(yymsp[-1].minor.yy0.str)
1012 if (!yymsp[0].minor.yy6.have) {
1013 goto failZ0;
1014 }
1015  
1016 NCDProgramElem elem;
1017 if (!NCDProgramElem_InitIncludeGuard(&elem, yymsp[-1].minor.yy0.str, yymsp[-1].minor.yy0.len)) {
1018 goto failZ0;
1019 }
1020  
1021 if (!NCDProgram_PrependElem(&yymsp[0].minor.yy6.v, elem)) {
1022 goto failZ1;
1023 }
1024  
1025 yygotominor.yy6.have = 1;
1026 yygotominor.yy6.v = yymsp[0].minor.yy6.v;
1027 yymsp[0].minor.yy6.have = 0;
1028 goto doneZ;
1029  
1030 failZ1:
1031 NCDProgramElem_Free(&elem);
1032 failZ0:
1033 yygotominor.yy6.have = 0;
1034 parser_out->out_of_memory = 1;
1035 doneZ:
1036 free_token(yymsp[-1].minor.yy0);
1037 free_program(yymsp[0].minor.yy6);
1038 yy_destructor(yypParser,3,&yymsp[-2].minor);
1039 }
1040 #line 1041 "NCDConfigParser_parse.c"
1041 break;
1042 case 4: /* processes ::= process_or_template NAME CURLY_OPEN statements CURLY_CLOSE processes */
1043 #line 219 "NCDConfigParser_parse.y"
1044 {
1045 ASSERT(yymsp[-4].minor.yy0.str)
1046 if (!yymsp[-2].minor.yy69.have || !yymsp[0].minor.yy6.have) {
1047 goto failB0;
1048 }
1049  
1050 NCDProcess proc;
1051 if (!NCDProcess_Init(&proc, yymsp[-5].minor.yy28, yymsp[-4].minor.yy0.str, yymsp[-2].minor.yy69.v)) {
1052 goto failB0;
1053 }
1054 yymsp[-2].minor.yy69.have = 0;
1055  
1056 NCDProgramElem elem;
1057 NCDProgramElem_InitProcess(&elem, proc);
1058  
1059 if (!NCDProgram_PrependElem(&yymsp[0].minor.yy6.v, elem)) {
1060 goto failB1;
1061 }
1062  
1063 yygotominor.yy6.have = 1;
1064 yygotominor.yy6.v = yymsp[0].minor.yy6.v;
1065 yymsp[0].minor.yy6.have = 0;
1066 goto doneB;
1067  
1068 failB1:
1069 NCDProgramElem_Free(&elem);
1070 failB0:
1071 yygotominor.yy6.have = 0;
1072 parser_out->out_of_memory = 1;
1073 doneB:
1074 free_token(yymsp[-4].minor.yy0);
1075 free_block(yymsp[-2].minor.yy69);
1076 free_program(yymsp[0].minor.yy6);
1077 yy_destructor(yypParser,5,&yymsp[-3].minor);
1078 yy_destructor(yypParser,6,&yymsp[-1].minor);
1079 }
1080 #line 1081 "NCDConfigParser_parse.c"
1081 break;
1082 case 5: /* statement ::= dotted_name ROUND_OPEN list_contents_maybe ROUND_CLOSE name_maybe SEMICOLON */
1083 #line 254 "NCDConfigParser_parse.y"
1084 {
1085 if (!yymsp[-5].minor.yy49 || !yymsp[-3].minor.yy19.have) {
1086 goto failC0;
1087 }
1088  
1089 if (!NCDStatement_InitReg(&yygotominor.yy47.v, yymsp[-1].minor.yy49, NULL, yymsp[-5].minor.yy49, yymsp[-3].minor.yy19.v)) {
1090 goto failC0;
1091 }
1092 yymsp[-3].minor.yy19.have = 0;
1093  
1094 yygotominor.yy47.have = 1;
1095 goto doneC;
1096  
1097 failC0:
1098 yygotominor.yy47.have = 0;
1099 parser_out->out_of_memory = 1;
1100 doneC:
1101 free(yymsp[-5].minor.yy49);
1102 free_value(yymsp[-3].minor.yy19);
1103 free(yymsp[-1].minor.yy49);
1104 yy_destructor(yypParser,7,&yymsp[-4].minor);
1105 yy_destructor(yypParser,8,&yymsp[-2].minor);
1106 yy_destructor(yypParser,9,&yymsp[0].minor);
1107 }
1108 #line 1109 "NCDConfigParser_parse.c"
1109 break;
1110 case 6: /* statement ::= dotted_name ARROW dotted_name ROUND_OPEN list_contents_maybe ROUND_CLOSE name_maybe SEMICOLON */
1111 #line 276 "NCDConfigParser_parse.y"
1112 {
1113 if (!yymsp[-7].minor.yy49 || !yymsp[-5].minor.yy49 || !yymsp[-3].minor.yy19.have) {
1114 goto failD0;
1115 }
1116  
1117 if (!NCDStatement_InitReg(&yygotominor.yy47.v, yymsp[-1].minor.yy49, yymsp[-7].minor.yy49, yymsp[-5].minor.yy49, yymsp[-3].minor.yy19.v)) {
1118 goto failD0;
1119 }
1120 yymsp[-3].minor.yy19.have = 0;
1121  
1122 yygotominor.yy47.have = 1;
1123 goto doneD;
1124  
1125 failD0:
1126 yygotominor.yy47.have = 0;
1127 parser_out->out_of_memory = 1;
1128 doneD:
1129 free(yymsp[-7].minor.yy49);
1130 free(yymsp[-5].minor.yy49);
1131 free_value(yymsp[-3].minor.yy19);
1132 free(yymsp[-1].minor.yy49);
1133 yy_destructor(yypParser,10,&yymsp[-6].minor);
1134 yy_destructor(yypParser,7,&yymsp[-4].minor);
1135 yy_destructor(yypParser,8,&yymsp[-2].minor);
1136 yy_destructor(yypParser,9,&yymsp[0].minor);
1137 }
1138 #line 1139 "NCDConfigParser_parse.c"
1139 break;
1140 case 7: /* statement ::= IF ROUND_OPEN value ROUND_CLOSE CURLY_OPEN statements CURLY_CLOSE elif_maybe else_maybe name_maybe SEMICOLON */
1141 #line 299 "NCDConfigParser_parse.y"
1142 {
1143 if (!yymsp[-8].minor.yy19.have || !yymsp[-5].minor.yy69.have || !yymsp[-3].minor.yy44.have) {
1144 goto failE0;
1145 }
1146  
1147 NCDIf ifc;
1148 NCDIf_Init(&ifc, yymsp[-8].minor.yy19.v, yymsp[-5].minor.yy69.v);
1149 yymsp[-8].minor.yy19.have = 0;
1150 yymsp[-5].minor.yy69.have = 0;
1151  
1152 if (!NCDIfBlock_PrependIf(&yymsp[-3].minor.yy44.v, ifc)) {
1153 NCDIf_Free(&ifc);
1154 goto failE0;
1155 }
1156  
1157 if (!NCDStatement_InitIf(&yygotominor.yy47.v, yymsp[-1].minor.yy49, yymsp[-3].minor.yy44.v, NCDIFTYPE_IF)) {
1158 goto failE0;
1159 }
1160 yymsp[-3].minor.yy44.have = 0;
1161  
1162 if (yymsp[-2].minor.yy69.have) {
1163 NCDStatement_IfAddElse(&yygotominor.yy47.v, yymsp[-2].minor.yy69.v);
1164 yymsp[-2].minor.yy69.have = 0;
1165 }
1166  
1167 yygotominor.yy47.have = 1;
1168 goto doneE;
1169  
1170 failE0:
1171 yygotominor.yy47.have = 0;
1172 parser_out->out_of_memory = 1;
1173 doneE:
1174 free_value(yymsp[-8].minor.yy19);
1175 free_block(yymsp[-5].minor.yy69);
1176 free_ifblock(yymsp[-3].minor.yy44);
1177 free_block(yymsp[-2].minor.yy69);
1178 free(yymsp[-1].minor.yy49);
1179 yy_destructor(yypParser,11,&yymsp[-10].minor);
1180 yy_destructor(yypParser,7,&yymsp[-9].minor);
1181 yy_destructor(yypParser,8,&yymsp[-7].minor);
1182 yy_destructor(yypParser,5,&yymsp[-6].minor);
1183 yy_destructor(yypParser,6,&yymsp[-4].minor);
1184 yy_destructor(yypParser,9,&yymsp[0].minor);
1185 }
1186 #line 1187 "NCDConfigParser_parse.c"
1187 break;
1188 case 8: /* statement ::= FOREACH ROUND_OPEN value AS NAME ROUND_CLOSE CURLY_OPEN statements CURLY_CLOSE name_maybe SEMICOLON */
1189 #line 338 "NCDConfigParser_parse.y"
1190 {
1191 if (!yymsp[-8].minor.yy19.have || !yymsp[-6].minor.yy0.str || !yymsp[-3].minor.yy69.have) {
1192 goto failEA0;
1193 }
1194  
1195 if (!NCDStatement_InitForeach(&yygotominor.yy47.v, yymsp[-1].minor.yy49, yymsp[-8].minor.yy19.v, yymsp[-6].minor.yy0.str, NULL, yymsp[-3].minor.yy69.v)) {
1196 goto failEA0;
1197 }
1198 yymsp[-8].minor.yy19.have = 0;
1199 yymsp[-3].minor.yy69.have = 0;
1200  
1201 yygotominor.yy47.have = 1;
1202 goto doneEA0;
1203  
1204 failEA0:
1205 yygotominor.yy47.have = 0;
1206 parser_out->out_of_memory = 1;
1207 doneEA0:
1208 free_value(yymsp[-8].minor.yy19);
1209 free_token(yymsp[-6].minor.yy0);
1210 free_block(yymsp[-3].minor.yy69);
1211 free(yymsp[-1].minor.yy49);
1212 yy_destructor(yypParser,12,&yymsp[-10].minor);
1213 yy_destructor(yypParser,7,&yymsp[-9].minor);
1214 yy_destructor(yypParser,13,&yymsp[-7].minor);
1215 yy_destructor(yypParser,8,&yymsp[-5].minor);
1216 yy_destructor(yypParser,5,&yymsp[-4].minor);
1217 yy_destructor(yypParser,6,&yymsp[-2].minor);
1218 yy_destructor(yypParser,9,&yymsp[0].minor);
1219 }
1220 #line 1221 "NCDConfigParser_parse.c"
1221 break;
1222 case 9: /* statement ::= FOREACH ROUND_OPEN value AS NAME COLON NAME ROUND_CLOSE CURLY_OPEN statements CURLY_CLOSE name_maybe SEMICOLON */
1223 #line 362 "NCDConfigParser_parse.y"
1224 {
1225 if (!yymsp[-10].minor.yy19.have || !yymsp[-8].minor.yy0.str || !yymsp[-6].minor.yy0.str || !yymsp[-3].minor.yy69.have) {
1226 goto failEB0;
1227 }
1228  
1229 if (!NCDStatement_InitForeach(&yygotominor.yy47.v, yymsp[-1].minor.yy49, yymsp[-10].minor.yy19.v, yymsp[-8].minor.yy0.str, yymsp[-6].minor.yy0.str, yymsp[-3].minor.yy69.v)) {
1230 goto failEB0;
1231 }
1232 yymsp[-10].minor.yy19.have = 0;
1233 yymsp[-3].minor.yy69.have = 0;
1234  
1235 yygotominor.yy47.have = 1;
1236 goto doneEB0;
1237  
1238 failEB0:
1239 yygotominor.yy47.have = 0;
1240 parser_out->out_of_memory = 1;
1241 doneEB0:
1242 free_value(yymsp[-10].minor.yy19);
1243 free_token(yymsp[-8].minor.yy0);
1244 free_token(yymsp[-6].minor.yy0);
1245 free_block(yymsp[-3].minor.yy69);
1246 free(yymsp[-1].minor.yy49);
1247 yy_destructor(yypParser,12,&yymsp[-12].minor);
1248 yy_destructor(yypParser,7,&yymsp[-11].minor);
1249 yy_destructor(yypParser,13,&yymsp[-9].minor);
1250 yy_destructor(yypParser,14,&yymsp[-7].minor);
1251 yy_destructor(yypParser,8,&yymsp[-5].minor);
1252 yy_destructor(yypParser,5,&yymsp[-4].minor);
1253 yy_destructor(yypParser,6,&yymsp[-2].minor);
1254 yy_destructor(yypParser,9,&yymsp[0].minor);
1255 }
1256 #line 1257 "NCDConfigParser_parse.c"
1257 break;
1258 case 10: /* elif_maybe ::= */
1259 #line 387 "NCDConfigParser_parse.y"
1260 {
1261 NCDIfBlock_Init(&yygotominor.yy44.v);
1262 yygotominor.yy44.have = 1;
1263 }
1264 #line 1265 "NCDConfigParser_parse.c"
1265 break;
1266 case 11: /* elif_maybe ::= elif */
1267 #line 392 "NCDConfigParser_parse.y"
1268 {
1269 yygotominor.yy44 = yymsp[0].minor.yy44;
1270 }
1271 #line 1272 "NCDConfigParser_parse.c"
1272 break;
1273 case 12: /* elif ::= ELIF ROUND_OPEN value ROUND_CLOSE CURLY_OPEN statements CURLY_CLOSE */
1274 #line 396 "NCDConfigParser_parse.y"
1275 {
1276 if (!yymsp[-4].minor.yy19.have || !yymsp[-1].minor.yy69.have) {
1277 goto failF0;
1278 }
1279  
1280 NCDIfBlock_Init(&yygotominor.yy44.v);
1281  
1282 NCDIf ifc;
1283 NCDIf_Init(&ifc, yymsp[-4].minor.yy19.v, yymsp[-1].minor.yy69.v);
1284 yymsp[-4].minor.yy19.have = 0;
1285 yymsp[-1].minor.yy69.have = 0;
1286  
1287 if (!NCDIfBlock_PrependIf(&yygotominor.yy44.v, ifc)) {
1288 goto failF1;
1289 }
1290  
1291 yygotominor.yy44.have = 1;
1292 goto doneF0;
1293  
1294 failF1:
1295 NCDIf_Free(&ifc);
1296 NCDIfBlock_Free(&yygotominor.yy44.v);
1297 failF0:
1298 yygotominor.yy44.have = 0;
1299 parser_out->out_of_memory = 1;
1300 doneF0:
1301 free_value(yymsp[-4].minor.yy19);
1302 free_block(yymsp[-1].minor.yy69);
1303 yy_destructor(yypParser,15,&yymsp[-6].minor);
1304 yy_destructor(yypParser,7,&yymsp[-5].minor);
1305 yy_destructor(yypParser,8,&yymsp[-3].minor);
1306 yy_destructor(yypParser,5,&yymsp[-2].minor);
1307 yy_destructor(yypParser,6,&yymsp[0].minor);
1308 }
1309 #line 1310 "NCDConfigParser_parse.c"
1310 break;
1311 case 13: /* elif ::= ELIF ROUND_OPEN value ROUND_CLOSE CURLY_OPEN statements CURLY_CLOSE elif */
1312 #line 426 "NCDConfigParser_parse.y"
1313 {
1314 if (!yymsp[-5].minor.yy19.have || !yymsp[-2].minor.yy69.have || !yymsp[0].minor.yy44.have) {
1315 goto failG0;
1316 }
1317  
1318 NCDIf ifc;
1319 NCDIf_Init(&ifc, yymsp[-5].minor.yy19.v, yymsp[-2].minor.yy69.v);
1320 yymsp[-5].minor.yy19.have = 0;
1321 yymsp[-2].minor.yy69.have = 0;
1322  
1323 if (!NCDIfBlock_PrependIf(&yymsp[0].minor.yy44.v, ifc)) {
1324 goto failG1;
1325 }
1326  
1327 yygotominor.yy44.have = 1;
1328 yygotominor.yy44.v = yymsp[0].minor.yy44.v;
1329 yymsp[0].minor.yy44.have = 0;
1330 goto doneG0;
1331  
1332 failG1:
1333 NCDIf_Free(&ifc);
1334 failG0:
1335 yygotominor.yy44.have = 0;
1336 parser_out->out_of_memory = 1;
1337 doneG0:
1338 free_value(yymsp[-5].minor.yy19);
1339 free_block(yymsp[-2].minor.yy69);
1340 free_ifblock(yymsp[0].minor.yy44);
1341 yy_destructor(yypParser,15,&yymsp[-7].minor);
1342 yy_destructor(yypParser,7,&yymsp[-6].minor);
1343 yy_destructor(yypParser,8,&yymsp[-4].minor);
1344 yy_destructor(yypParser,5,&yymsp[-3].minor);
1345 yy_destructor(yypParser,6,&yymsp[-1].minor);
1346 }
1347 #line 1348 "NCDConfigParser_parse.c"
1348 break;
1349 case 14: /* else_maybe ::= */
1350 case 17: /* interrupt_maybe ::= */ yytestcase(yyruleno==17);
1351 #line 456 "NCDConfigParser_parse.y"
1352 {
1353 yygotominor.yy69.have = 0;
1354 }
1355 #line 1356 "NCDConfigParser_parse.c"
1356 break;
1357 case 15: /* else_maybe ::= ELSE CURLY_OPEN statements CURLY_CLOSE */
1358 #line 460 "NCDConfigParser_parse.y"
1359 {
1360 yygotominor.yy69 = yymsp[-1].minor.yy69;
1361 yy_destructor(yypParser,16,&yymsp[-3].minor);
1362 yy_destructor(yypParser,5,&yymsp[-2].minor);
1363 yy_destructor(yypParser,6,&yymsp[0].minor);
1364 }
1365 #line 1366 "NCDConfigParser_parse.c"
1366 break;
1367 case 16: /* statement ::= BLOCK CURLY_OPEN statements CURLY_CLOSE name_maybe SEMICOLON */
1368 #line 464 "NCDConfigParser_parse.y"
1369 {
1370 if (!yymsp[-3].minor.yy69.have) {
1371 goto failGA0;
1372 }
1373  
1374 if (!NCDStatement_InitBlock(&yygotominor.yy47.v, yymsp[-1].minor.yy49, yymsp[-3].minor.yy69.v)) {
1375 goto failGA0;
1376 }
1377 yymsp[-3].minor.yy69.have = 0;
1378  
1379 yygotominor.yy47.have = 1;
1380 goto doneGA0;
1381  
1382 failGA0:
1383 yygotominor.yy47.have = 0;
1384 parser_out->out_of_memory = 1;
1385 doneGA0:
1386 free_block(yymsp[-3].minor.yy69);
1387 free(yymsp[-1].minor.yy49);
1388 yy_destructor(yypParser,17,&yymsp[-5].minor);
1389 yy_destructor(yypParser,5,&yymsp[-4].minor);
1390 yy_destructor(yypParser,6,&yymsp[-2].minor);
1391 yy_destructor(yypParser,9,&yymsp[0].minor);
1392 }
1393 #line 1394 "NCDConfigParser_parse.c"
1394 break;
1395 case 18: /* interrupt_maybe ::= TOKEN_INTERRUPT CURLY_OPEN statements CURLY_CLOSE */
1396 #line 489 "NCDConfigParser_parse.y"
1397 {
1398 yygotominor.yy69 = yymsp[-1].minor.yy69;
1399 yy_destructor(yypParser,18,&yymsp[-3].minor);
1400 yy_destructor(yypParser,5,&yymsp[-2].minor);
1401 yy_destructor(yypParser,6,&yymsp[0].minor);
1402 }
1403 #line 1404 "NCDConfigParser_parse.c"
1404 break;
1405 case 19: /* statement ::= TOKEN_DO CURLY_OPEN statements CURLY_CLOSE interrupt_maybe name_maybe SEMICOLON */
1406 #line 493 "NCDConfigParser_parse.y"
1407 {
1408 if (!yymsp[-4].minor.yy69.have) {
1409 goto failGB0;
1410 }
1411  
1412 NCDIfBlock if_block;
1413 NCDIfBlock_Init(&if_block);
1414  
1415 if (yymsp[-2].minor.yy69.have) {
1416 NCDIf int_if;
1417 NCDIf_InitBlock(&int_if, yymsp[-2].minor.yy69.v);
1418 yymsp[-2].minor.yy69.have = 0;
1419  
1420 if (!NCDIfBlock_PrependIf(&if_block, int_if)) {
1421 NCDIf_Free(&int_if);
1422 goto failGB1;
1423 }
1424 }
1425  
1426 NCDIf the_if;
1427 NCDIf_InitBlock(&the_if, yymsp[-4].minor.yy69.v);
1428 yymsp[-4].minor.yy69.have = 0;
1429  
1430 if (!NCDIfBlock_PrependIf(&if_block, the_if)) {
1431 NCDIf_Free(&the_if);
1432 goto failGB1;
1433 }
1434  
1435 if (!NCDStatement_InitIf(&yygotominor.yy47.v, yymsp[-1].minor.yy49, if_block, NCDIFTYPE_DO)) {
1436 goto failGB1;
1437 }
1438  
1439 yygotominor.yy47.have = 1;
1440 goto doneGB0;
1441  
1442 failGB1:
1443 NCDIfBlock_Free(&if_block);
1444 failGB0:
1445 yygotominor.yy47.have = 0;
1446 parser_out->out_of_memory = 1;
1447 doneGB0:
1448 free_block(yymsp[-4].minor.yy69);
1449 free_block(yymsp[-2].minor.yy69);
1450 free(yymsp[-1].minor.yy49);
1451 yy_destructor(yypParser,19,&yymsp[-6].minor);
1452 yy_destructor(yypParser,5,&yymsp[-5].minor);
1453 yy_destructor(yypParser,6,&yymsp[-3].minor);
1454 yy_destructor(yypParser,9,&yymsp[0].minor);
1455 }
1456 #line 1457 "NCDConfigParser_parse.c"
1457 break;
1458 case 20: /* statements ::= statement */
1459 #line 539 "NCDConfigParser_parse.y"
1460 {
1461 if (!yymsp[0].minor.yy47.have) {
1462 goto failH0;
1463 }
1464  
1465 NCDBlock_Init(&yygotominor.yy69.v);
1466  
1467 if (!NCDBlock_PrependStatement(&yygotominor.yy69.v, yymsp[0].minor.yy47.v)) {
1468 goto failH1;
1469 }
1470 yymsp[0].minor.yy47.have = 0;
1471  
1472 yygotominor.yy69.have = 1;
1473 goto doneH;
1474  
1475 failH1:
1476 NCDBlock_Free(&yygotominor.yy69.v);
1477 failH0:
1478 yygotominor.yy69.have = 0;
1479 parser_out->out_of_memory = 1;
1480 doneH:
1481 free_statement(yymsp[0].minor.yy47);
1482 }
1483 #line 1484 "NCDConfigParser_parse.c"
1484 break;
1485 case 21: /* statements ::= statement statements */
1486 #line 563 "NCDConfigParser_parse.y"
1487 {
1488 if (!yymsp[-1].minor.yy47.have || !yymsp[0].minor.yy69.have) {
1489 goto failI0;
1490 }
1491  
1492 if (!NCDBlock_PrependStatement(&yymsp[0].minor.yy69.v, yymsp[-1].minor.yy47.v)) {
1493 goto failI1;
1494 }
1495 yymsp[-1].minor.yy47.have = 0;
1496  
1497 yygotominor.yy69.have = 1;
1498 yygotominor.yy69.v = yymsp[0].minor.yy69.v;
1499 yymsp[0].minor.yy69.have = 0;
1500 goto doneI;
1501  
1502 failI1:
1503 NCDBlock_Free(&yygotominor.yy69.v);
1504 failI0:
1505 yygotominor.yy69.have = 0;
1506 parser_out->out_of_memory = 1;
1507 doneI:
1508 free_statement(yymsp[-1].minor.yy47);
1509 free_block(yymsp[0].minor.yy69);
1510 }
1511 #line 1512 "NCDConfigParser_parse.c"
1512 break;
1513 case 22: /* dotted_name ::= NAME */
1514 case 46: /* name_maybe ::= NAME */ yytestcase(yyruleno==46);
1515 #line 588 "NCDConfigParser_parse.y"
1516 {
1517 ASSERT(yymsp[0].minor.yy0.str)
1518  
1519 yygotominor.yy49 = yymsp[0].minor.yy0.str;
1520 }
1521 #line 1522 "NCDConfigParser_parse.c"
1522 break;
1523 case 23: /* dotted_name ::= NAME DOT dotted_name */
1524 #line 594 "NCDConfigParser_parse.y"
1525 {
1526 ASSERT(yymsp[-2].minor.yy0.str)
1527 if (!yymsp[0].minor.yy49) {
1528 goto failJ0;
1529 }
1530  
1531 if (!(yygotominor.yy49 = concat_strings(3, yymsp[-2].minor.yy0.str, ".", yymsp[0].minor.yy49))) {
1532 goto failJ0;
1533 }
1534  
1535 goto doneJ;
1536  
1537 failJ0:
1538 yygotominor.yy49 = NULL;
1539 parser_out->out_of_memory = 1;
1540 doneJ:
1541 free_token(yymsp[-2].minor.yy0);
1542 free(yymsp[0].minor.yy49);
1543 yy_destructor(yypParser,20,&yymsp[-1].minor);
1544 }
1545 #line 1546 "NCDConfigParser_parse.c"
1546 break;
1547 case 24: /* name_list ::= NAME */
1548 #line 614 "NCDConfigParser_parse.y"
1549 {
1550 if (!yymsp[0].minor.yy0.str) {
1551 goto failK0;
1552 }
1553  
1554 NCDValue_InitList(&yygotominor.yy19.v);
1555  
1556 NCDValue this_string;
1557 if (!NCDValue_InitString(&this_string, yymsp[0].minor.yy0.str)) {
1558 goto failK1;
1559 }
1560  
1561 if (!NCDValue_ListPrepend(&yygotominor.yy19.v, this_string)) {
1562 goto failK2;
1563 }
1564  
1565 yygotominor.yy19.have = 1;
1566 goto doneK;
1567  
1568 failK2:
1569 NCDValue_Free(&this_string);
1570 failK1:
1571 NCDValue_Free(&yygotominor.yy19.v);
1572 failK0:
1573 yygotominor.yy19.have = 0;
1574 parser_out->out_of_memory = 1;
1575 doneK:
1576 free_token(yymsp[0].minor.yy0);
1577 }
1578 #line 1579 "NCDConfigParser_parse.c"
1579 break;
1580 case 25: /* name_list ::= NAME DOT name_list */
1581 #line 644 "NCDConfigParser_parse.y"
1582 {
1583 if (!yymsp[-2].minor.yy0.str || !yymsp[0].minor.yy19.have) {
1584 goto failKA0;
1585 }
1586  
1587 NCDValue this_string;
1588 if (!NCDValue_InitString(&this_string, yymsp[-2].minor.yy0.str)) {
1589 goto failKA0;
1590 }
1591  
1592 if (!NCDValue_ListPrepend(&yymsp[0].minor.yy19.v, this_string)) {
1593 goto failKA1;
1594 }
1595  
1596 yygotominor.yy19.have = 1;
1597 yygotominor.yy19.v = yymsp[0].minor.yy19.v;
1598 yymsp[0].minor.yy19.have = 0;
1599 goto doneKA;
1600  
1601 failKA1:
1602 NCDValue_Free(&this_string);
1603 failKA0:
1604 yygotominor.yy19.have = 0;
1605 parser_out->out_of_memory = 1;
1606 doneKA:
1607 free_token(yymsp[-2].minor.yy0);
1608 free_value(yymsp[0].minor.yy19);
1609 yy_destructor(yypParser,20,&yymsp[-1].minor);
1610 }
1611 #line 1612 "NCDConfigParser_parse.c"
1612 break;
1613 case 26: /* list_contents_maybe ::= */
1614 #line 673 "NCDConfigParser_parse.y"
1615 {
1616 yygotominor.yy19.have = 1;
1617 NCDValue_InitList(&yygotominor.yy19.v);
1618 }
1619 #line 1620 "NCDConfigParser_parse.c"
1620 break;
1621 case 27: /* list_contents_maybe ::= list_contents */
1622 case 41: /* value ::= list */ yytestcase(yyruleno==41);
1623 case 42: /* value ::= map */ yytestcase(yyruleno==42);
1624 case 44: /* value ::= invoc */ yytestcase(yyruleno==44);
1625 #line 678 "NCDConfigParser_parse.y"
1626 {
1627 yygotominor.yy19 = yymsp[0].minor.yy19;
1628 }
1629 #line 1630 "NCDConfigParser_parse.c"
1630 break;
1631 case 28: /* list_contents ::= value */
1632 #line 682 "NCDConfigParser_parse.y"
1633 {
1634 if (!yymsp[0].minor.yy19.have) {
1635 goto failL0;
1636 }
1637  
1638 NCDValue_InitList(&yygotominor.yy19.v);
1639  
1640 if (!NCDValue_ListPrepend(&yygotominor.yy19.v, yymsp[0].minor.yy19.v)) {
1641 goto failL1;
1642 }
1643 yymsp[0].minor.yy19.have = 0;
1644  
1645 yygotominor.yy19.have = 1;
1646 goto doneL;
1647  
1648 failL1:
1649 NCDValue_Free(&yygotominor.yy19.v);
1650 failL0:
1651 yygotominor.yy19.have = 0;
1652 parser_out->out_of_memory = 1;
1653 doneL:
1654 free_value(yymsp[0].minor.yy19);
1655 }
1656 #line 1657 "NCDConfigParser_parse.c"
1657 break;
1658 case 29: /* list_contents ::= value COMMA list_contents */
1659 #line 706 "NCDConfigParser_parse.y"
1660 {
1661 if (!yymsp[-2].minor.yy19.have || !yymsp[0].minor.yy19.have) {
1662 goto failM0;
1663 }
1664  
1665 if (!NCDValue_ListPrepend(&yymsp[0].minor.yy19.v, yymsp[-2].minor.yy19.v)) {
1666 goto failM0;
1667 }
1668 yymsp[-2].minor.yy19.have = 0;
1669  
1670 yygotominor.yy19.have = 1;
1671 yygotominor.yy19.v = yymsp[0].minor.yy19.v;
1672 yymsp[0].minor.yy19.have = 0;
1673 goto doneM;
1674  
1675 failM0:
1676 yygotominor.yy19.have = 0;
1677 parser_out->out_of_memory = 1;
1678 doneM:
1679 free_value(yymsp[-2].minor.yy19);
1680 free_value(yymsp[0].minor.yy19);
1681 yy_destructor(yypParser,21,&yymsp[-1].minor);
1682 }
1683 #line 1684 "NCDConfigParser_parse.c"
1684 break;
1685 case 30: /* list ::= CURLY_OPEN CURLY_CLOSE */
1686 #line 729 "NCDConfigParser_parse.y"
1687 {
1688 yygotominor.yy19.have = 1;
1689 NCDValue_InitList(&yygotominor.yy19.v);
1690 yy_destructor(yypParser,5,&yymsp[-1].minor);
1691 yy_destructor(yypParser,6,&yymsp[0].minor);
1692 }
1693 #line 1694 "NCDConfigParser_parse.c"
1694 break;
1695 case 31: /* list ::= CURLY_OPEN list_contents CURLY_CLOSE */
1696 #line 734 "NCDConfigParser_parse.y"
1697 {
1698 yygotominor.yy19 = yymsp[-1].minor.yy19;
1699 yy_destructor(yypParser,5,&yymsp[-2].minor);
1700 yy_destructor(yypParser,6,&yymsp[0].minor);
1701 }
1702 #line 1703 "NCDConfigParser_parse.c"
1703 break;
1704 case 32: /* map_contents ::= value COLON value */
1705 #line 738 "NCDConfigParser_parse.y"
1706 {
1707 if (!yymsp[-2].minor.yy19.have || !yymsp[0].minor.yy19.have) {
1708 goto failS0;
1709 }
1710  
1711 NCDValue_InitMap(&yygotominor.yy19.v);
1712  
1713 if (!NCDValue_MapPrepend(&yygotominor.yy19.v, yymsp[-2].minor.yy19.v, yymsp[0].minor.yy19.v)) {
1714 goto failS1;
1715 }
1716 yymsp[-2].minor.yy19.have = 0;
1717 yymsp[0].minor.yy19.have = 0;
1718  
1719 yygotominor.yy19.have = 1;
1720 goto doneS;
1721  
1722 failS1:
1723 NCDValue_Free(&yygotominor.yy19.v);
1724 failS0:
1725 yygotominor.yy19.have = 0;
1726 parser_out->out_of_memory = 1;
1727 doneS:
1728 free_value(yymsp[-2].minor.yy19);
1729 free_value(yymsp[0].minor.yy19);
1730 yy_destructor(yypParser,14,&yymsp[-1].minor);
1731 }
1732 #line 1733 "NCDConfigParser_parse.c"
1733 break;
1734 case 33: /* map_contents ::= value COLON value COMMA map_contents */
1735 #line 764 "NCDConfigParser_parse.y"
1736 {
1737 if (!yymsp[-4].minor.yy19.have || !yymsp[-2].minor.yy19.have || !yymsp[0].minor.yy19.have) {
1738 goto failT0;
1739 }
1740  
1741 if (!NCDValue_MapPrepend(&yymsp[0].minor.yy19.v, yymsp[-4].minor.yy19.v, yymsp[-2].minor.yy19.v)) {
1742 goto failT0;
1743 }
1744 yymsp[-4].minor.yy19.have = 0;
1745 yymsp[-2].minor.yy19.have = 0;
1746  
1747 yygotominor.yy19.have = 1;
1748 yygotominor.yy19.v = yymsp[0].minor.yy19.v;
1749 yymsp[0].minor.yy19.have = 0;
1750 goto doneT;
1751  
1752 failT0:
1753 yygotominor.yy19.have = 0;
1754 parser_out->out_of_memory = 1;
1755 doneT:
1756 free_value(yymsp[-4].minor.yy19);
1757 free_value(yymsp[-2].minor.yy19);
1758 free_value(yymsp[0].minor.yy19);
1759 yy_destructor(yypParser,14,&yymsp[-3].minor);
1760 yy_destructor(yypParser,21,&yymsp[-1].minor);
1761 }
1762 #line 1763 "NCDConfigParser_parse.c"
1763 break;
1764 case 34: /* map ::= BRACKET_OPEN BRACKET_CLOSE */
1765 #line 789 "NCDConfigParser_parse.y"
1766 {
1767 yygotominor.yy19.have = 1;
1768 NCDValue_InitMap(&yygotominor.yy19.v);
1769 yy_destructor(yypParser,22,&yymsp[-1].minor);
1770 yy_destructor(yypParser,23,&yymsp[0].minor);
1771 }
1772 #line 1773 "NCDConfigParser_parse.c"
1773 break;
1774 case 35: /* map ::= BRACKET_OPEN map_contents BRACKET_CLOSE */
1775 #line 794 "NCDConfigParser_parse.y"
1776 {
1777 yygotominor.yy19 = yymsp[-1].minor.yy19;
1778 yy_destructor(yypParser,22,&yymsp[-2].minor);
1779 yy_destructor(yypParser,23,&yymsp[0].minor);
1780 }
1781 #line 1782 "NCDConfigParser_parse.c"
1782 break;
1783 case 36: /* invoc ::= value ROUND_OPEN list_contents_maybe ROUND_CLOSE */
1784 #line 798 "NCDConfigParser_parse.y"
1785 {
1786 if (!yymsp[-3].minor.yy19.have || !yymsp[-1].minor.yy19.have) {
1787 goto failQ0;
1788 }
1789  
1790 if (!NCDValue_InitInvoc(&yygotominor.yy19.v, yymsp[-3].minor.yy19.v, yymsp[-1].minor.yy19.v)) {
1791 goto failQ0;
1792 }
1793 yymsp[-3].minor.yy19.have = 0;
1794 yymsp[-1].minor.yy19.have = 0;
1795 yygotominor.yy19.have = 1;
1796 goto doneQ;
1797  
1798 failQ0:
1799 yygotominor.yy19.have = 0;
1800 parser_out->out_of_memory = 1;
1801 doneQ:
1802 free_value(yymsp[-3].minor.yy19);
1803 free_value(yymsp[-1].minor.yy19);
1804 yy_destructor(yypParser,7,&yymsp[-2].minor);
1805 yy_destructor(yypParser,8,&yymsp[0].minor);
1806 }
1807 #line 1808 "NCDConfigParser_parse.c"
1808 break;
1809 case 37: /* value ::= STRING */
1810 #line 819 "NCDConfigParser_parse.y"
1811 {
1812 ASSERT(yymsp[0].minor.yy0.str)
1813  
1814 if (!NCDValue_InitStringBin(&yygotominor.yy19.v, (uint8_t *)yymsp[0].minor.yy0.str, yymsp[0].minor.yy0.len)) {
1815 goto failU0;
1816 }
1817  
1818 yygotominor.yy19.have = 1;
1819 goto doneU;
1820  
1821 failU0:
1822 yygotominor.yy19.have = 0;
1823 parser_out->out_of_memory = 1;
1824 doneU:
1825 free_token(yymsp[0].minor.yy0);
1826 }
1827 #line 1828 "NCDConfigParser_parse.c"
1828 break;
1829 case 38: /* value ::= AT_SIGN dotted_name */
1830 #line 836 "NCDConfigParser_parse.y"
1831 {
1832 if (!yymsp[0].minor.yy49) {
1833 goto failUA0;
1834 }
1835  
1836 if (!NCDValue_InitString(&yygotominor.yy19.v, yymsp[0].minor.yy49)) {
1837 goto failUA0;
1838 }
1839  
1840 yygotominor.yy19.have = 1;
1841 goto doneUA0;
1842  
1843 failUA0:
1844 yygotominor.yy19.have = 0;
1845 parser_out->out_of_memory = 1;
1846 doneUA0:
1847 free(yymsp[0].minor.yy49);
1848 yy_destructor(yypParser,24,&yymsp[-1].minor);
1849 }
1850 #line 1851 "NCDConfigParser_parse.c"
1851 break;
1852 case 39: /* value ::= CARET name_list */
1853 #line 855 "NCDConfigParser_parse.y"
1854 {
1855 yygotominor.yy19 = yymsp[0].minor.yy19;
1856 yy_destructor(yypParser,25,&yymsp[-1].minor);
1857 }
1858 #line 1859 "NCDConfigParser_parse.c"
1859 break;
1860 case 40: /* value ::= dotted_name */
1861 #line 859 "NCDConfigParser_parse.y"
1862 {
1863 if (!yymsp[0].minor.yy49) {
1864 goto failV0;
1865 }
1866  
1867 if (!NCDValue_InitVar(&yygotominor.yy19.v, yymsp[0].minor.yy49)) {
1868 goto failV0;
1869 }
1870  
1871 yygotominor.yy19.have = 1;
1872 goto doneV;
1873  
1874 failV0:
1875 yygotominor.yy19.have = 0;
1876 parser_out->out_of_memory = 1;
1877 doneV:
1878 free(yymsp[0].minor.yy49);
1879 }
1880 #line 1881 "NCDConfigParser_parse.c"
1881 break;
1882 case 43: /* value ::= ROUND_OPEN value ROUND_CLOSE */
1883 #line 886 "NCDConfigParser_parse.y"
1884 {
1885 yygotominor.yy19 = yymsp[-1].minor.yy19;
1886 yy_destructor(yypParser,7,&yymsp[-2].minor);
1887 yy_destructor(yypParser,8,&yymsp[0].minor);
1888 }
1889 #line 1890 "NCDConfigParser_parse.c"
1890 break;
1891 case 45: /* name_maybe ::= */
1892 #line 894 "NCDConfigParser_parse.y"
1893 {
1894 yygotominor.yy49 = NULL;
1895 }
1896 #line 1897 "NCDConfigParser_parse.c"
1897 break;
1898 case 47: /* process_or_template ::= PROCESS */
1899 #line 904 "NCDConfigParser_parse.y"
1900 {
1901 yygotominor.yy28 = 0;
1902 yy_destructor(yypParser,26,&yymsp[0].minor);
1903 }
1904 #line 1905 "NCDConfigParser_parse.c"
1905 break;
1906 case 48: /* process_or_template ::= TEMPLATE */
1907 #line 908 "NCDConfigParser_parse.y"
1908 {
1909 yygotominor.yy28 = 1;
1910 yy_destructor(yypParser,27,&yymsp[0].minor);
1911 }
1912 #line 1913 "NCDConfigParser_parse.c"
1913 break;
1914 default:
1915 break;
1916 };
1917 yygoto = yyRuleInfo[yyruleno].lhs;
1918 yysize = yyRuleInfo[yyruleno].nrhs;
1919 yypParser->yyidx -= yysize;
1920 yyact = yy_find_reduce_action(yymsp[-yysize].stateno,(YYCODETYPE)yygoto);
1921 if( yyact < YYNSTATE ){
1922 #ifdef NDEBUG
1923 /* If we are not debugging and the reduce action popped at least
1924 ** one element off the stack, then we can push the new element back
1925 ** onto the stack here, and skip the stack overflow test in yy_shift().
1926 ** That gives a significant speed improvement. */
1927 if( yysize ){
1928 yypParser->yyidx++;
1929 yymsp -= yysize-1;
1930 yymsp->stateno = (YYACTIONTYPE)yyact;
1931 yymsp->major = (YYCODETYPE)yygoto;
1932 yymsp->minor = yygotominor;
1933 }else
1934 #endif
1935 {
1936 yy_shift(yypParser,yyact,yygoto,&yygotominor);
1937 }
1938 }else{
1939 assert( yyact == YYNSTATE + YYNRULE + 1 );
1940 yy_accept(yypParser);
1941 }
1942 }
1943  
1944 /*
1945 ** The following code executes when the parse fails
1946 */
1947 #ifndef YYNOERRORRECOVERY
1948 static void yy_parse_failed(
1949 yyParser *yypParser /* The parser */
1950 ){
1951 ParseARG_FETCH;
1952 #ifndef NDEBUG
1953 if( yyTraceFILE ){
1954 fprintf(yyTraceFILE,"%sFail!\n",yyTracePrompt);
1955 }
1956 #endif
1957 while( yypParser->yyidx>=0 ) yy_pop_parser_stack(yypParser);
1958 /* Here code is inserted which will be executed whenever the
1959 ** parser fails */
1960 ParseARG_STORE; /* Suppress warning about unused %extra_argument variable */
1961 }
1962 #endif /* YYNOERRORRECOVERY */
1963  
1964 /*
1965 ** The following code executes when a syntax error first occurs.
1966 */
1967 static void yy_syntax_error(
1968 yyParser *yypParser, /* The parser */
1969 int yymajor, /* The major type of the error token */
1970 YYMINORTYPE yyminor /* The minor type of the error token */
1971 ){
1972 ParseARG_FETCH;
1973 #define TOKEN (yyminor.yy0)
1974 #line 131 "NCDConfigParser_parse.y"
1975  
1976 parser_out->syntax_error = 1;
1977 #line 1978 "NCDConfigParser_parse.c"
1978 ParseARG_STORE; /* Suppress warning about unused %extra_argument variable */
1979 }
1980  
1981 /*
1982 ** The following is executed when the parser accepts
1983 */
1984 static void yy_accept(
1985 yyParser *yypParser /* The parser */
1986 ){
1987 ParseARG_FETCH;
1988 #ifndef NDEBUG
1989 if( yyTraceFILE ){
1990 fprintf(yyTraceFILE,"%sAccept!\n",yyTracePrompt);
1991 }
1992 #endif
1993 while( yypParser->yyidx>=0 ) yy_pop_parser_stack(yypParser);
1994 /* Here code is inserted which will be executed whenever the
1995 ** parser accepts */
1996 ParseARG_STORE; /* Suppress warning about unused %extra_argument variable */
1997 }
1998  
1999 /* The main parser program.
2000 ** The first argument is a pointer to a structure obtained from
2001 ** "ParseAlloc" which describes the current state of the parser.
2002 ** The second argument is the major token number. The third is
2003 ** the minor token. The fourth optional argument is whatever the
2004 ** user wants (and specified in the grammar) and is available for
2005 ** use by the action routines.
2006 **
2007 ** Inputs:
2008 ** <ul>
2009 ** <li> A pointer to the parser (an opaque structure.)
2010 ** <li> The major token number.
2011 ** <li> The minor token number.
2012 ** <li> An option argument of a grammar-specified type.
2013 ** </ul>
2014 **
2015 ** Outputs:
2016 ** None.
2017 */
2018 void Parse(
2019 void *yyp, /* The parser */
2020 int yymajor, /* The major token code number */
2021 ParseTOKENTYPE yyminor /* The value for the token */
2022 ParseARG_PDECL /* Optional %extra_argument parameter */
2023 ){
2024 YYMINORTYPE yyminorunion;
2025 int yyact; /* The parser action. */
2026 int yyendofinput; /* True if we are at the end of input */
2027 #ifdef YYERRORSYMBOL
2028 int yyerrorhit = 0; /* True if yymajor has invoked an error */
2029 #endif
2030 yyParser *yypParser; /* The parser */
2031  
2032 /* (re)initialize the parser, if necessary */
2033 yypParser = (yyParser*)yyp;
2034 if( yypParser->yyidx<0 ){
2035 #if YYSTACKDEPTH<=0
2036 if( yypParser->yystksz <=0 ){
2037 /*memset(&yyminorunion, 0, sizeof(yyminorunion));*/
2038 yyminorunion = yyzerominor;
2039 yyStackOverflow(yypParser, &yyminorunion);
2040 return;
2041 }
2042 #endif
2043 yypParser->yyidx = 0;
2044 yypParser->yyerrcnt = -1;
2045 yypParser->yystack[0].stateno = 0;
2046 yypParser->yystack[0].major = 0;
2047 }
2048 yyminorunion.yy0 = yyminor;
2049 yyendofinput = (yymajor==0);
2050 ParseARG_STORE;
2051  
2052 #ifndef NDEBUG
2053 if( yyTraceFILE ){
2054 fprintf(yyTraceFILE,"%sInput %s\n",yyTracePrompt,yyTokenName[yymajor]);
2055 }
2056 #endif
2057  
2058 do{
2059 yyact = yy_find_shift_action(yypParser,(YYCODETYPE)yymajor);
2060 if( yyact<YYNSTATE ){
2061 assert( !yyendofinput ); /* Impossible to shift the $ token */
2062 yy_shift(yypParser,yyact,yymajor,&yyminorunion);
2063 yypParser->yyerrcnt--;
2064 yymajor = YYNOCODE;
2065 }else if( yyact < YYNSTATE + YYNRULE ){
2066 yy_reduce(yypParser,yyact-YYNSTATE);
2067 }else{
2068 assert( yyact == YY_ERROR_ACTION );
2069 #ifdef YYERRORSYMBOL
2070 int yymx;
2071 #endif
2072 #ifndef NDEBUG
2073 if( yyTraceFILE ){
2074 fprintf(yyTraceFILE,"%sSyntax Error!\n",yyTracePrompt);
2075 }
2076 #endif
2077 #ifdef YYERRORSYMBOL
2078 /* A syntax error has occurred.
2079 ** The response to an error depends upon whether or not the
2080 ** grammar defines an error token "ERROR".
2081 **
2082 ** This is what we do if the grammar does define ERROR:
2083 **
2084 ** * Call the %syntax_error function.
2085 **
2086 ** * Begin popping the stack until we enter a state where
2087 ** it is legal to shift the error symbol, then shift
2088 ** the error symbol.
2089 **
2090 ** * Set the error count to three.
2091 **
2092 ** * Begin accepting and shifting new tokens. No new error
2093 ** processing will occur until three tokens have been
2094 ** shifted successfully.
2095 **
2096 */
2097 if( yypParser->yyerrcnt<0 ){
2098 yy_syntax_error(yypParser,yymajor,yyminorunion);
2099 }
2100 yymx = yypParser->yystack[yypParser->yyidx].major;
2101 if( yymx==YYERRORSYMBOL || yyerrorhit ){
2102 #ifndef NDEBUG
2103 if( yyTraceFILE ){
2104 fprintf(yyTraceFILE,"%sDiscard input token %s\n",
2105 yyTracePrompt,yyTokenName[yymajor]);
2106 }
2107 #endif
2108 yy_destructor(yypParser, (YYCODETYPE)yymajor,&yyminorunion);
2109 yymajor = YYNOCODE;
2110 }else{
2111 while(
2112 yypParser->yyidx >= 0 &&
2113 yymx != YYERRORSYMBOL &&
2114 (yyact = yy_find_reduce_action(
2115 yypParser->yystack[yypParser->yyidx].stateno,
2116 YYERRORSYMBOL)) >= YYNSTATE
2117 ){
2118 yy_pop_parser_stack(yypParser);
2119 }
2120 if( yypParser->yyidx < 0 || yymajor==0 ){
2121 yy_destructor(yypParser,(YYCODETYPE)yymajor,&yyminorunion);
2122 yy_parse_failed(yypParser);
2123 yymajor = YYNOCODE;
2124 }else if( yymx!=YYERRORSYMBOL ){
2125 YYMINORTYPE u2;
2126 u2.YYERRSYMDT = 0;
2127 yy_shift(yypParser,yyact,YYERRORSYMBOL,&u2);
2128 }
2129 }
2130 yypParser->yyerrcnt = 3;
2131 yyerrorhit = 1;
2132 #elif defined(YYNOERRORRECOVERY)
2133 /* If the YYNOERRORRECOVERY macro is defined, then do not attempt to
2134 ** do any kind of error recovery. Instead, simply invoke the syntax
2135 ** error routine and continue going as if nothing had happened.
2136 **
2137 ** Applications can set this macro (for example inside %include) if
2138 ** they intend to abandon the parse upon the first syntax error seen.
2139 */
2140 yy_syntax_error(yypParser,yymajor,yyminorunion);
2141 yy_destructor(yypParser,(YYCODETYPE)yymajor,&yyminorunion);
2142 yymajor = YYNOCODE;
2143  
2144 #else /* YYERRORSYMBOL is not defined */
2145 /* This is what we do if the grammar does not define ERROR:
2146 **
2147 ** * Report an error message, and throw away the input token.
2148 **
2149 ** * If the input token is $, then fail the parse.
2150 **
2151 ** As before, subsequent error messages are suppressed until
2152 ** three input tokens have been successfully shifted.
2153 */
2154 if( yypParser->yyerrcnt<=0 ){
2155 yy_syntax_error(yypParser,yymajor,yyminorunion);
2156 }
2157 yypParser->yyerrcnt = 3;
2158 yy_destructor(yypParser,(YYCODETYPE)yymajor,&yyminorunion);
2159 if( yyendofinput ){
2160 yy_parse_failed(yypParser);
2161 }
2162 yymajor = YYNOCODE;
2163 #endif
2164 }
2165 }while( yymajor!=YYNOCODE && yypParser->yyidx>=0 );
2166 return;
2167 }