bitbake/lib/bb/parse/parse_c:
[vuplus_bitbake] / lib / bb / parse / parse_c / bitbakeparser.cc
1 /* Driver template for the LEMON parser generator.
2 ** The author disclaims copyright to this source code.
3 */
4 /* First off, code is include which follows the "include" declaration
5 ** in the input file. */
6 #include <stdio.h>
7 #line 43 "bitbakeparser.y"
8
9 #include "token.h"
10 #include "lexer.h"
11 #line 13 "bitbakeparser.c"
12 /* Next is all token values, in a form suitable for use by makeheaders.
13 ** This section will be null unless lemon is run with the -m switch.
14 */
15 /* 
16 ** These constants (all generated automatically by the parser generator)
17 ** specify the various kinds of tokens (terminals) that the parser
18 ** understands. 
19 **
20 ** Each symbol here is a terminal symbol in the grammar.
21 */
22 /* Make sure the INTERFACE macro is defined.
23 */
24 #ifndef INTERFACE
25 # define INTERFACE 1
26 #endif
27 /* The next thing included is series of defines which control
28 ** various aspects of the generated parser.
29 **    YYCODETYPE         is the data type used for storing terminal
30 **                       and nonterminal numbers.  "unsigned char" is
31 **                       used if there are fewer than 250 terminals
32 **                       and nonterminals.  "int" is used otherwise.
33 **    YYNOCODE           is a number of type YYCODETYPE which corresponds
34 **                       to no legal terminal or nonterminal number.  This
35 **                       number is used to fill in empty slots of the hash 
36 **                       table.
37 **    YYFALLBACK         If defined, this indicates that one or more tokens
38 **                       have fall-back values which should be used if the
39 **                       original value of the token will not parse.
40 **    YYACTIONTYPE       is the data type used for storing terminal
41 **                       and nonterminal numbers.  "unsigned char" is
42 **                       used if there are fewer than 250 rules and
43 **                       states combined.  "int" is used otherwise.
44 **    bbparseTOKENTYPE     is the data type used for minor tokens given 
45 **                       directly to the parser from the tokenizer.
46 **    YYMINORTYPE        is the data type used for all minor tokens.
47 **                       This is typically a union of many types, one of
48 **                       which is bbparseTOKENTYPE.  The entry in the union
49 **                       for base tokens is called "yy0".
50 **    YYSTACKDEPTH       is the maximum depth of the parser's stack.
51 **    bbparseARG_SDECL     A static variable declaration for the %extra_argument
52 **    bbparseARG_PDECL     A parameter declaration for the %extra_argument
53 **    bbparseARG_STORE     Code to store %extra_argument into yypParser
54 **    bbparseARG_FETCH     Code to extract %extra_argument from yypParser
55 **    YYNSTATE           the combined number of states.
56 **    YYNRULE            the number of rules in the grammar
57 **    YYERRORSYMBOL      is the code number of the error symbol.  If not
58 **                       defined, then do no error processing.
59 */
60 #define YYCODETYPE unsigned char
61 #define YYNOCODE 42
62 #define YYACTIONTYPE unsigned char
63 #define bbparseTOKENTYPE token_t
64 typedef union {
65   bbparseTOKENTYPE yy0;
66   int yy83;
67 } YYMINORTYPE;
68 #define YYSTACKDEPTH 100
69 #define bbparseARG_SDECL lex_t* lex;
70 #define bbparseARG_PDECL ,lex_t* lex
71 #define bbparseARG_FETCH lex_t* lex = yypParser->lex
72 #define bbparseARG_STORE yypParser->lex = lex
73 #define YYNSTATE 74
74 #define YYNRULE 41
75 #define YYERRORSYMBOL 28
76 #define YYERRSYMDT yy83
77 #define YY_NO_ACTION      (YYNSTATE+YYNRULE+2)
78 #define YY_ACCEPT_ACTION  (YYNSTATE+YYNRULE+1)
79 #define YY_ERROR_ACTION   (YYNSTATE+YYNRULE)
80
81 /* Next are that tables used to determine what action to take based on the
82 ** current state and lookahead token.  These tables are used to implement
83 ** functions that take a state number and lookahead value and return an
84 ** action integer.  
85 **
86 ** Suppose the action integer is N.  Then the action is determined as
87 ** follows
88 **
89 **   0 <= N < YYNSTATE                  Shift N.  That is, push the lookahead
90 **                                      token onto the stack and goto state N.
91 **
92 **   YYNSTATE <= N < YYNSTATE+YYNRULE   Reduce by rule N-YYNSTATE.
93 **
94 **   N == YYNSTATE+YYNRULE              A syntax error has occurred.
95 **
96 **   N == YYNSTATE+YYNRULE+1            The parser accepts its input.
97 **
98 **   N == YYNSTATE+YYNRULE+2            No such action.  Denotes unused
99 **                                      slots in the yy_action[] table.
100 **
101 ** The action table is constructed as a single large table named yy_action[].
102 ** Given state S and lookahead X, the action is computed as
103 **
104 **      yy_action[ yy_shift_ofst[S] + X ]
105 **
106 ** If the index value yy_shift_ofst[S]+X is out of range or if the value
107 ** yy_lookahead[yy_shift_ofst[S]+X] is not equal to X or if yy_shift_ofst[S]
108 ** is equal to YY_SHIFT_USE_DFLT, it means that the action is not in the table
109 ** and that yy_default[S] should be used instead.  
110 **
111 ** The formula above is for computing the action when the lookahead is
112 ** a terminal symbol.  If the lookahead is a non-terminal (as occurs after
113 ** a reduce action) then the yy_reduce_ofst[] array is used in place of
114 ** the yy_shift_ofst[] array and YY_REDUCE_USE_DFLT is used in place of
115 ** YY_SHIFT_USE_DFLT.
116 **
117 ** The following are the tables generated in this section:
118 **
119 **  yy_action[]        A single table containing all actions.
120 **  yy_lookahead[]     A table containing the lookahead for each entry in
121 **                     yy_action.  Used to detect hash collisions.
122 **  yy_shift_ofst[]    For each state, the offset into yy_action for
123 **                     shifting terminals.
124 **  yy_reduce_ofst[]   For each state, the offset into yy_action for
125 **                     shifting non-terminals after a reduce.
126 **  yy_default[]       Default action for each state.
127 */
128 static const YYACTIONTYPE yy_action[] = {
129  /*     0 */    28,   47,    5,   57,   33,   58,   30,   25,   24,   37,
130  /*    10 */    45,   14,    2,   29,   41,    3,   16,    4,   23,   39,
131  /*    20 */    69,    8,   11,   17,   26,   48,   47,   32,   21,   42,
132  /*    30 */    31,   57,   57,   73,   44,   10,   66,    7,   34,   38,
133  /*    40 */    57,   51,   72,  116,    1,   62,    6,   49,   52,   35,
134  /*    50 */    36,   59,   54,    9,   20,   64,   43,   22,   40,   50,
135  /*    60 */    46,   71,   67,   60,   15,   65,   61,   70,   53,   56,
136  /*    70 */    27,   12,   68,   63,   84,   55,   18,   84,   13,   84,
137  /*    80 */    84,   84,   84,   84,   84,   84,   84,   84,   84,   84,
138  /*    90 */    84,   19,
139 };
140 static const YYCODETYPE yy_lookahead[] = {
141  /*     0 */     1,    2,    3,   21,    4,   23,    6,    7,    8,    9,
142  /*    10 */    31,   32,   13,   14,    1,   16,   39,   18,   19,   20,
143  /*    20 */    37,   38,   22,   24,   25,    1,    2,    4,   10,    6,
144  /*    30 */     7,   21,   21,   23,   23,   22,   35,   36,   11,   12,
145  /*    40 */    21,    5,   23,   29,   30,   33,   34,    5,    5,   10,
146  /*    50 */    12,   10,    5,   22,   39,   15,   40,   11,   10,    5,
147  /*    60 */    26,   17,   17,   10,   32,   35,   33,   17,    5,    5,
148  /*    70 */     1,   22,   37,    1,   41,    5,   39,   41,   27,   41,
149  /*    80 */    41,   41,   41,   41,   41,   41,   41,   41,   41,   41,
150  /*    90 */    41,   39,
151 };
152 #define YY_SHIFT_USE_DFLT (-19)
153 #define YY_SHIFT_MAX 43
154 static const signed char yy_shift_ofst[] = {
155  /*     0 */   -19,   -1,   18,   40,   45,   24,   18,   40,   45,  -19,
156  /*    10 */   -19,  -19,  -19,  -19,    0,   23,  -18,   13,   19,   10,
157  /*    20 */    11,   27,   53,   50,   63,   64,   69,   49,   51,   72,
158  /*    30 */    70,   36,   42,   43,   39,   38,   41,   47,   48,   44,
159  /*    40 */    46,   31,   54,   34,
160 };
161 #define YY_REDUCE_USE_DFLT (-24)
162 #define YY_REDUCE_MAX 13
163 static const signed char yy_reduce_ofst[] = {
164  /*     0 */    14,  -21,   12,    1,  -17,   32,   33,   30,   35,   37,
165  /*    10 */    52,  -23,   15,   16,
166 };
167 static const YYACTIONTYPE yy_default[] = {
168  /*     0 */    76,   74,  115,  115,  115,  115,   94,   99,  103,  107,
169  /*    10 */   107,  107,  107,  113,  115,  115,  115,  115,  115,  115,
170  /*    20 */   115,   89,  115,  115,  115,  115,  115,  115,   77,  115,
171  /*    30 */   115,  115,  115,  115,  115,   90,  115,  115,  115,  115,
172  /*    40 */    91,  115,  115,  114,  111,   75,  112,   78,   77,   79,
173  /*    50 */    80,   81,   82,   83,   84,   85,   86,  106,  108,   87,
174  /*    60 */    88,   92,   93,   95,   96,   97,   98,  100,  101,  102,
175  /*    70 */   104,  105,  109,  110,
176 };
177 #define YY_SZ_ACTTAB (sizeof(yy_action)/sizeof(yy_action[0]))
178
179 /* The next table maps tokens into fallback tokens.  If a construct
180 ** like the following:
181 ** 
182 **      %fallback ID X Y Z.
183 **
184 ** appears in the grammer, then ID becomes a fallback token for X, Y,
185 ** and Z.  Whenever one of the tokens X, Y, or Z is input to the parser
186 ** but it does not parse, the type of the token is changed to ID and
187 ** the parse is retried before an error is thrown.
188 */
189 #ifdef YYFALLBACK
190 static const YYCODETYPE yyFallback[] = {
191 };
192 #endif /* YYFALLBACK */
193
194 /* The following structure represents a single element of the
195 ** parser's stack.  Information stored includes:
196 **
197 **   +  The state number for the parser at this level of the stack.
198 **
199 **   +  The value of the token stored at this level of the stack.
200 **      (In other words, the "major" token.)
201 **
202 **   +  The semantic value stored at this level of the stack.  This is
203 **      the information used by the action routines in the grammar.
204 **      It is sometimes called the "minor" token.
205 */
206 struct yyStackEntry {
207   int stateno;       /* The state-number */
208   int major;         /* The major token value.  This is the code
209                      ** number for the token at this stack level */
210   YYMINORTYPE minor; /* The user-supplied minor token value.  This
211                      ** is the value of the token  */
212 };
213 typedef struct yyStackEntry yyStackEntry;
214
215 /* The state of the parser is completely contained in an instance of
216 ** the following structure */
217 struct yyParser {
218   int yyidx;                    /* Index of top element in stack */
219   int yyerrcnt;                 /* Shifts left before out of the error */
220   bbparseARG_SDECL                /* A place to hold %extra_argument */
221   yyStackEntry yystack[YYSTACKDEPTH];  /* The parser's stack */
222 };
223 typedef struct yyParser yyParser;
224
225 #ifndef NDEBUG
226 #include <stdio.h>
227 static FILE *yyTraceFILE = 0;
228 static char *yyTracePrompt = 0;
229 #endif /* NDEBUG */
230
231 #ifndef NDEBUG
232 /* 
233 ** Turn parser tracing on by giving a stream to which to write the trace
234 ** and a prompt to preface each trace message.  Tracing is turned off
235 ** by making either argument NULL 
236 **
237 ** Inputs:
238 ** <ul>
239 ** <li> A FILE* to which trace output should be written.
240 **      If NULL, then tracing is turned off.
241 ** <li> A prefix string written at the beginning of every
242 **      line of trace output.  If NULL, then tracing is
243 **      turned off.
244 ** </ul>
245 **
246 ** Outputs:
247 ** None.
248 */
249 void bbparseTrace(FILE *TraceFILE, char *zTracePrompt){
250   yyTraceFILE = TraceFILE;
251   yyTracePrompt = zTracePrompt;
252   if( yyTraceFILE==0 ) yyTracePrompt = 0;
253   else if( yyTracePrompt==0 ) yyTraceFILE = 0;
254 }
255 #endif /* NDEBUG */
256
257 #ifndef NDEBUG
258 /* For tracing shifts, the names of all terminals and nonterminals
259 ** are required.  The following table supplies these names */
260 static const char *const yyTokenName[] = { 
261   "$",             "SYMBOL",        "VARIABLE",      "EXPORT",      
262   "OP_ASSIGN",     "STRING",        "OP_IMMEDIATE",  "OP_COND",     
263   "OP_PREPEND",    "OP_APPEND",     "TSYMBOL",       "BEFORE",      
264   "AFTER",         "ADDTASK",       "ADDHANDLER",    "FSYMBOL",     
265   "EXPORT_FUNC",   "ISYMBOL",       "INHERIT",       "INCLUDE",     
266   "REQUIRE",       "PROC_BODY",     "PROC_OPEN",     "PROC_CLOSE",  
267   "PYTHON",        "FAKEROOT",      "DEF_BODY",      "DEF_ARGS",    
268   "error",         "program",       "statements",    "statement",   
269   "variable",      "task",          "tasks",         "func",        
270   "funcs",         "inherit",       "inherits",      "proc_body",   
271   "def_body",    
272 };
273 #endif /* NDEBUG */
274
275 #ifndef NDEBUG
276 /* For tracing reduce actions, the names of all rules are required.
277 */
278 static const char *const yyRuleName[] = {
279  /*   0 */ "program ::= statements",
280  /*   1 */ "statements ::= statements statement",
281  /*   2 */ "statements ::=",
282  /*   3 */ "variable ::= SYMBOL",
283  /*   4 */ "variable ::= VARIABLE",
284  /*   5 */ "statement ::= EXPORT variable OP_ASSIGN STRING",
285  /*   6 */ "statement ::= EXPORT variable OP_IMMEDIATE STRING",
286  /*   7 */ "statement ::= EXPORT variable OP_COND STRING",
287  /*   8 */ "statement ::= variable OP_ASSIGN STRING",
288  /*   9 */ "statement ::= variable OP_PREPEND STRING",
289  /*  10 */ "statement ::= variable OP_APPEND STRING",
290  /*  11 */ "statement ::= variable OP_IMMEDIATE STRING",
291  /*  12 */ "statement ::= variable OP_COND STRING",
292  /*  13 */ "task ::= TSYMBOL BEFORE TSYMBOL AFTER TSYMBOL",
293  /*  14 */ "task ::= TSYMBOL AFTER TSYMBOL BEFORE TSYMBOL",
294  /*  15 */ "task ::= TSYMBOL",
295  /*  16 */ "task ::= TSYMBOL BEFORE TSYMBOL",
296  /*  17 */ "task ::= TSYMBOL AFTER TSYMBOL",
297  /*  18 */ "tasks ::= tasks task",
298  /*  19 */ "tasks ::= task",
299  /*  20 */ "statement ::= ADDTASK tasks",
300  /*  21 */ "statement ::= ADDHANDLER SYMBOL",
301  /*  22 */ "func ::= FSYMBOL",
302  /*  23 */ "funcs ::= funcs func",
303  /*  24 */ "funcs ::= func",
304  /*  25 */ "statement ::= EXPORT_FUNC funcs",
305  /*  26 */ "inherit ::= ISYMBOL",
306  /*  27 */ "inherits ::= inherits inherit",
307  /*  28 */ "inherits ::= inherit",
308  /*  29 */ "statement ::= INHERIT inherits",
309  /*  30 */ "statement ::= INCLUDE ISYMBOL",
310  /*  31 */ "statement ::= REQUIRE ISYMBOL",
311  /*  32 */ "proc_body ::= proc_body PROC_BODY",
312  /*  33 */ "proc_body ::=",
313  /*  34 */ "statement ::= variable PROC_OPEN proc_body PROC_CLOSE",
314  /*  35 */ "statement ::= PYTHON SYMBOL PROC_OPEN proc_body PROC_CLOSE",
315  /*  36 */ "statement ::= PYTHON PROC_OPEN proc_body PROC_CLOSE",
316  /*  37 */ "statement ::= FAKEROOT SYMBOL PROC_OPEN proc_body PROC_CLOSE",
317  /*  38 */ "def_body ::= def_body DEF_BODY",
318  /*  39 */ "def_body ::=",
319  /*  40 */ "statement ::= SYMBOL DEF_ARGS def_body",
320 };
321 #endif /* NDEBUG */
322
323 /*
324 ** This function returns the symbolic name associated with a token
325 ** value.
326 */
327 const char *bbparseTokenName(int tokenType){
328 #ifndef NDEBUG
329   if( tokenType>0 && tokenType<(sizeof(yyTokenName)/sizeof(yyTokenName[0])) ){
330     return yyTokenName[tokenType];
331   }else{
332     return "Unknown";
333   }
334 #else
335   return "";
336 #endif
337 }
338
339 /* 
340 ** This function allocates a new parser.
341 ** The only argument is a pointer to a function which works like
342 ** malloc.
343 **
344 ** Inputs:
345 ** A pointer to the function used to allocate memory.
346 **
347 ** Outputs:
348 ** A pointer to a parser.  This pointer is used in subsequent calls
349 ** to bbparse and bbparseFree.
350 */
351 void *bbparseAlloc(void *(*mallocProc)(size_t)){
352   yyParser *pParser;
353   pParser = (yyParser*)(*mallocProc)( (size_t)sizeof(yyParser) );
354   if( pParser ){
355     pParser->yyidx = -1;
356   }
357   return pParser;
358 }
359
360 /* The following function deletes the value associated with a
361 ** symbol.  The symbol can be either a terminal or nonterminal.
362 ** "yymajor" is the symbol code, and "yypminor" is a pointer to
363 ** the value.
364 */
365 static void yy_destructor(YYCODETYPE yymajor, YYMINORTYPE *yypminor){
366   switch( yymajor ){
367     /* Here is inserted the actions which take place when a
368     ** terminal or non-terminal is destroyed.  This can happen
369     ** when the symbol is popped from the stack during a
370     ** reduce or during error processing or when a parser is 
371     ** being destroyed before it is finished parsing.
372     **
373     ** Note: during a reduce, the only symbols destroyed are those
374     ** which appear on the RHS of the rule, but which are not used
375     ** inside the C code.
376     */
377     case 1:
378     case 2:
379     case 3:
380     case 4:
381     case 5:
382     case 6:
383     case 7:
384     case 8:
385     case 9:
386     case 10:
387     case 11:
388     case 12:
389     case 13:
390     case 14:
391     case 15:
392     case 16:
393     case 17:
394     case 18:
395     case 19:
396     case 20:
397     case 21:
398     case 22:
399     case 23:
400     case 24:
401     case 25:
402     case 26:
403     case 27:
404 #line 49 "bitbakeparser.y"
405 { (yypminor->yy0).release_this (); }
406 #line 408 "bitbakeparser.c"
407       break;
408     default:  break;   /* If no destructor action specified: do nothing */
409   }
410 }
411
412 /*
413 ** Pop the parser's stack once.
414 **
415 ** If there is a destructor routine associated with the token which
416 ** is popped from the stack, then call it.
417 **
418 ** Return the major token number for the symbol popped.
419 */
420 static int yy_pop_parser_stack(yyParser *pParser){
421   YYCODETYPE yymajor;
422   yyStackEntry *yytos = &pParser->yystack[pParser->yyidx];
423
424   if( pParser->yyidx<0 ) return 0;
425 #ifndef NDEBUG
426   if( yyTraceFILE && pParser->yyidx>=0 ){
427     fprintf(yyTraceFILE,"%sPopping %s\n",
428       yyTracePrompt,
429       yyTokenName[yytos->major]);
430   }
431 #endif
432   yymajor = yytos->major;
433   yy_destructor( yymajor, &yytos->minor);
434   pParser->yyidx--;
435   return yymajor;
436 }
437
438 /* 
439 ** Deallocate and destroy a parser.  Destructors are all called for
440 ** all stack elements before shutting the parser down.
441 **
442 ** Inputs:
443 ** <ul>
444 ** <li>  A pointer to the parser.  This should be a pointer
445 **       obtained from bbparseAlloc.
446 ** <li>  A pointer to a function used to reclaim memory obtained
447 **       from malloc.
448 ** </ul>
449 */
450 void bbparseFree(
451   void *p,                    /* The parser to be deleted */
452   void (*freeProc)(void*)     /* Function used to reclaim memory */
453 ){
454   yyParser *pParser = (yyParser*)p;
455   if( pParser==0 ) return;
456   while( pParser->yyidx>=0 ) yy_pop_parser_stack(pParser);
457   (*freeProc)((void*)pParser);
458 }
459
460 /*
461 ** Find the appropriate action for a parser given the terminal
462 ** look-ahead token iLookAhead.
463 **
464 ** If the look-ahead token is YYNOCODE, then check to see if the action is
465 ** independent of the look-ahead.  If it is, return the action, otherwise
466 ** return YY_NO_ACTION.
467 */
468 static int yy_find_shift_action(
469   yyParser *pParser,        /* The parser */
470   int iLookAhead            /* The look-ahead token */
471 ){
472   int i;
473   int stateno = pParser->yystack[pParser->yyidx].stateno;
474  
475   if( stateno>YY_SHIFT_MAX || (i = yy_shift_ofst[stateno])==YY_SHIFT_USE_DFLT ){
476     return yy_default[stateno];
477   }
478   if( iLookAhead==YYNOCODE ){
479     return YY_NO_ACTION;
480   }
481   i += iLookAhead;
482   if( i<0 || i>=YY_SZ_ACTTAB || yy_lookahead[i]!=iLookAhead ){
483 #ifdef YYFALLBACK
484     int iFallback;            /* Fallback token */
485     if( iLookAhead<sizeof(yyFallback)/sizeof(yyFallback[0])
486            && (iFallback = yyFallback[iLookAhead])!=0 ){
487 #ifndef NDEBUG
488       if( yyTraceFILE ){
489         fprintf(yyTraceFILE, "%sFALLBACK %s => %s\n",
490            yyTracePrompt, yyTokenName[iLookAhead], yyTokenName[iFallback]);
491       }
492 #endif
493       return yy_find_shift_action(pParser, iFallback);
494     }
495 #endif
496     return yy_default[stateno];
497   }else{
498     return yy_action[i];
499   }
500 }
501
502 /*
503 ** Find the appropriate action for a parser given the non-terminal
504 ** look-ahead token iLookAhead.
505 **
506 ** If the look-ahead token is YYNOCODE, then check to see if the action is
507 ** independent of the look-ahead.  If it is, return the action, otherwise
508 ** return YY_NO_ACTION.
509 */
510 static int yy_find_reduce_action(
511   int stateno,              /* Current state number */
512   int iLookAhead            /* The look-ahead token */
513 ){
514   int i;
515   /* int stateno = pParser->yystack[pParser->yyidx].stateno; */
516  
517   if( stateno>YY_REDUCE_MAX ||
518       (i = yy_reduce_ofst[stateno])==YY_REDUCE_USE_DFLT ){
519     return yy_default[stateno];
520   }
521   if( iLookAhead==YYNOCODE ){
522     return YY_NO_ACTION;
523   }
524   i += iLookAhead;
525   if( i<0 || i>=YY_SZ_ACTTAB || yy_lookahead[i]!=iLookAhead ){
526     return yy_default[stateno];
527   }else{
528     return yy_action[i];
529   }
530 }
531
532 /*
533 ** Perform a shift action.
534 */
535 static void yy_shift(
536   yyParser *yypParser,          /* The parser to be shifted */
537   int yyNewState,               /* The new state to shift in */
538   int yyMajor,                  /* The major token to shift in */
539   YYMINORTYPE *yypMinor         /* Pointer ot the minor token to shift in */
540 ){
541   yyStackEntry *yytos;
542   yypParser->yyidx++;
543   if( yypParser->yyidx>=YYSTACKDEPTH ){
544      bbparseARG_FETCH;
545      yypParser->yyidx--;
546 #ifndef NDEBUG
547      if( yyTraceFILE ){
548        fprintf(yyTraceFILE,"%sStack Overflow!\n",yyTracePrompt);
549      }
550 #endif
551      while( yypParser->yyidx>=0 ) yy_pop_parser_stack(yypParser);
552      /* Here code is inserted which will execute if the parser
553      ** stack every overflows */
554      bbparseARG_STORE; /* Suppress warning about unused %extra_argument var */
555      return;
556   }
557   yytos = &yypParser->yystack[yypParser->yyidx];
558   yytos->stateno = yyNewState;
559   yytos->major = yyMajor;
560   yytos->minor = *yypMinor;
561 #ifndef NDEBUG
562   if( yyTraceFILE && yypParser->yyidx>0 ){
563     int i;
564     fprintf(yyTraceFILE,"%sShift %d\n",yyTracePrompt,yyNewState);
565     fprintf(yyTraceFILE,"%sStack:",yyTracePrompt);
566     for(i=1; i<=yypParser->yyidx; i++)
567       fprintf(yyTraceFILE," %s",yyTokenName[yypParser->yystack[i].major]);
568     fprintf(yyTraceFILE,"\n");
569   }
570 #endif
571 }
572
573 /* The following table contains information about every rule that
574 ** is used during the reduce.
575 */
576 static const struct {
577   YYCODETYPE lhs;         /* Symbol on the left-hand side of the rule */
578   unsigned char nrhs;     /* Number of right-hand side symbols in the rule */
579 } yyRuleInfo[] = {
580   { 29, 1 },
581   { 30, 2 },
582   { 30, 0 },
583   { 32, 1 },
584   { 32, 1 },
585   { 31, 4 },
586   { 31, 4 },
587   { 31, 4 },
588   { 31, 3 },
589   { 31, 3 },
590   { 31, 3 },
591   { 31, 3 },
592   { 31, 3 },
593   { 33, 5 },
594   { 33, 5 },
595   { 33, 1 },
596   { 33, 3 },
597   { 33, 3 },
598   { 34, 2 },
599   { 34, 1 },
600   { 31, 2 },
601   { 31, 2 },
602   { 35, 1 },
603   { 36, 2 },
604   { 36, 1 },
605   { 31, 2 },
606   { 37, 1 },
607   { 38, 2 },
608   { 38, 1 },
609   { 31, 2 },
610   { 31, 2 },
611   { 31, 2 },
612   { 39, 2 },
613   { 39, 0 },
614   { 31, 4 },
615   { 31, 5 },
616   { 31, 4 },
617   { 31, 5 },
618   { 40, 2 },
619   { 40, 0 },
620   { 31, 3 },
621 };
622
623 static void yy_accept(yyParser*);  /* Forward Declaration */
624
625 /*
626 ** Perform a reduce action and the shift that must immediately
627 ** follow the reduce.
628 */
629 static void yy_reduce(
630   yyParser *yypParser,         /* The parser */
631   int yyruleno                 /* Number of the rule by which to reduce */
632 ){
633   int yygoto;                     /* The next state */
634   int yyact;                      /* The next action */
635   YYMINORTYPE yygotominor;        /* The LHS of the rule reduced */
636   yyStackEntry *yymsp;            /* The top of the parser's stack */
637   int yysize;                     /* Amount to pop the stack */
638   bbparseARG_FETCH;
639   yymsp = &yypParser->yystack[yypParser->yyidx];
640 #ifndef NDEBUG
641   if( yyTraceFILE && yyruleno>=0 
642         && yyruleno<sizeof(yyRuleName)/sizeof(yyRuleName[0]) ){
643     fprintf(yyTraceFILE, "%sReduce [%s].\n", yyTracePrompt,
644       yyRuleName[yyruleno]);
645   }
646 #endif /* NDEBUG */
647
648 #ifndef NDEBUG
649   /* Silence complaints from purify about yygotominor being uninitialized
650   ** in some cases when it is copied into the stack after the following
651   ** switch.  yygotominor is uninitialized when a rule reduces that does
652   ** not set the value of its left-hand side nonterminal.  Leaving the
653   ** value of the nonterminal uninitialized is utterly harmless as long
654   ** as the value is never used.  So really the only thing this code
655   ** accomplishes is to quieten purify.  
656   */
657   memset(&yygotominor, 0, sizeof(yygotominor));
658 #endif
659
660   switch( yyruleno ){
661   /* Beginning here are the reduction cases.  A typical example
662   ** follows:
663   **   case 0:
664   **  #line <lineno> <grammarfile>
665   **     { ... }           // User supplied code
666   **  #line <lineno> <thisfile>
667   **     break;
668   */
669       case 3:
670 #line 59 "bitbakeparser.y"
671 { yygotominor.yy0.assignString( (char*)yymsp[0].minor.yy0.string() );
672           yymsp[0].minor.yy0.assignString( 0 );
673           yymsp[0].minor.yy0.release_this(); }
674 #line 676 "bitbakeparser.c"
675         break;
676       case 4:
677 #line 63 "bitbakeparser.y"
678 {
679           yygotominor.yy0.assignString( (char*)yymsp[0].minor.yy0.string() );
680           yymsp[0].minor.yy0.assignString( 0 );
681           yymsp[0].minor.yy0.release_this(); }
682 #line 684 "bitbakeparser.c"
683         break;
684       case 5:
685 #line 69 "bitbakeparser.y"
686 { e_assign( yymsp[-2].minor.yy0.string(), yymsp[0].minor.yy0.string() );
687           e_export( yymsp[-2].minor.yy0.string() );
688           yymsp[-2].minor.yy0.release_this(); yymsp[0].minor.yy0.release_this();   yy_destructor(3,&yymsp[-3].minor);
689   yy_destructor(4,&yymsp[-1].minor);
690 }
691 #line 693 "bitbakeparser.c"
692         break;
693       case 6:
694 #line 73 "bitbakeparser.y"
695 { e_immediate (yymsp[-2].minor.yy0.string(), yymsp[0].minor.yy0.string() );
696           e_export( yymsp[-2].minor.yy0.string() );
697           yymsp[-2].minor.yy0.release_this(); yymsp[0].minor.yy0.release_this();   yy_destructor(3,&yymsp[-3].minor);
698   yy_destructor(6,&yymsp[-1].minor);
699 }
700 #line 702 "bitbakeparser.c"
701         break;
702       case 7:
703 #line 77 "bitbakeparser.y"
704 { e_cond( yymsp[-2].minor.yy0.string(), yymsp[0].minor.yy0.string() );
705           yymsp[-2].minor.yy0.release_this(); yymsp[0].minor.yy0.release_this();   yy_destructor(3,&yymsp[-3].minor);
706   yy_destructor(7,&yymsp[-1].minor);
707 }
708 #line 710 "bitbakeparser.c"
709         break;
710       case 8:
711 #line 81 "bitbakeparser.y"
712 { e_assign( yymsp[-2].minor.yy0.string(), yymsp[0].minor.yy0.string() );
713           yymsp[-2].minor.yy0.release_this(); yymsp[0].minor.yy0.release_this();   yy_destructor(4,&yymsp[-1].minor);
714 }
715 #line 717 "bitbakeparser.c"
716         break;
717       case 9:
718 #line 84 "bitbakeparser.y"
719 { e_prepend( yymsp[-2].minor.yy0.string(), yymsp[0].minor.yy0.string() );
720           yymsp[-2].minor.yy0.release_this(); yymsp[0].minor.yy0.release_this();   yy_destructor(8,&yymsp[-1].minor);
721 }
722 #line 724 "bitbakeparser.c"
723         break;
724       case 10:
725 #line 87 "bitbakeparser.y"
726 { e_append( yymsp[-2].minor.yy0.string() , yymsp[0].minor.yy0.string() );
727           yymsp[-2].minor.yy0.release_this(); yymsp[0].minor.yy0.release_this();   yy_destructor(9,&yymsp[-1].minor);
728 }
729 #line 731 "bitbakeparser.c"
730         break;
731       case 11:
732 #line 90 "bitbakeparser.y"
733 { e_immediate( yymsp[-2].minor.yy0.string(), yymsp[0].minor.yy0.string() );
734           yymsp[-2].minor.yy0.release_this(); yymsp[0].minor.yy0.release_this();   yy_destructor(6,&yymsp[-1].minor);
735 }
736 #line 738 "bitbakeparser.c"
737         break;
738       case 12:
739 #line 93 "bitbakeparser.y"
740 { e_cond( yymsp[-2].minor.yy0.string(), yymsp[0].minor.yy0.string() );
741           yymsp[-2].minor.yy0.release_this(); yymsp[0].minor.yy0.release_this();   yy_destructor(7,&yymsp[-1].minor);
742 }
743 #line 745 "bitbakeparser.c"
744         break;
745       case 13:
746 #line 97 "bitbakeparser.y"
747 { e_addtask( yymsp[-4].minor.yy0.string(), yymsp[-2].minor.yy0.string(), yymsp[0].minor.yy0.string() );
748           yymsp[-4].minor.yy0.release_this(); yymsp[-2].minor.yy0.release_this(); yymsp[0].minor.yy0.release_this();   yy_destructor(11,&yymsp[-3].minor);
749   yy_destructor(12,&yymsp[-1].minor);
750 }
751 #line 753 "bitbakeparser.c"
752         break;
753       case 14:
754 #line 100 "bitbakeparser.y"
755 { e_addtask( yymsp[-4].minor.yy0.string(), yymsp[0].minor.yy0.string(), yymsp[-2].minor.yy0.string());
756           yymsp[-4].minor.yy0.release_this(); yymsp[-2].minor.yy0.release_this(); yymsp[0].minor.yy0.release_this();   yy_destructor(12,&yymsp[-3].minor);
757   yy_destructor(11,&yymsp[-1].minor);
758 }
759 #line 761 "bitbakeparser.c"
760         break;
761       case 15:
762 #line 103 "bitbakeparser.y"
763 { e_addtask( yymsp[0].minor.yy0.string(), NULL, NULL);
764           yymsp[0].minor.yy0.release_this();}
765 #line 767 "bitbakeparser.c"
766         break;
767       case 16:
768 #line 106 "bitbakeparser.y"
769 { e_addtask( yymsp[-2].minor.yy0.string(), yymsp[0].minor.yy0.string(), NULL);
770           yymsp[-2].minor.yy0.release_this(); yymsp[0].minor.yy0.release_this();   yy_destructor(11,&yymsp[-1].minor);
771 }
772 #line 774 "bitbakeparser.c"
773         break;
774       case 17:
775 #line 109 "bitbakeparser.y"
776 { e_addtask( yymsp[-2].minor.yy0.string(), NULL, yymsp[0].minor.yy0.string());
777           yymsp[-2].minor.yy0.release_this(); yymsp[0].minor.yy0.release_this();   yy_destructor(12,&yymsp[-1].minor);
778 }
779 #line 781 "bitbakeparser.c"
780         break;
781       case 21:
782 #line 116 "bitbakeparser.y"
783 { e_addhandler( yymsp[0].minor.yy0.string()); yymsp[0].minor.yy0.release_this ();   yy_destructor(14,&yymsp[-1].minor);
784 }
785 #line 787 "bitbakeparser.c"
786         break;
787       case 22:
788 #line 118 "bitbakeparser.y"
789 { e_export_func(yymsp[0].minor.yy0.string()); yymsp[0].minor.yy0.release_this(); }
790 #line 792 "bitbakeparser.c"
791         break;
792       case 26:
793 #line 123 "bitbakeparser.y"
794 { e_inherit(yymsp[0].minor.yy0.string() ); yymsp[0].minor.yy0.release_this (); }
795 #line 797 "bitbakeparser.c"
796         break;
797       case 30:
798 #line 129 "bitbakeparser.y"
799 { e_include(yymsp[0].minor.yy0.string() ); yymsp[0].minor.yy0.release_this();   yy_destructor(19,&yymsp[-1].minor);
800 }
801 #line 803 "bitbakeparser.c"
802         break;
803       case 31:
804 #line 132 "bitbakeparser.y"
805 { e_require(yymsp[0].minor.yy0.string() ); yymsp[0].minor.yy0.release_this();   yy_destructor(20,&yymsp[-1].minor);
806 }
807 #line 809 "bitbakeparser.c"
808         break;
809       case 32:
810 #line 135 "bitbakeparser.y"
811 { /* concatenate body lines */
812           yygotominor.yy0.assignString( token_t::concatString(yymsp[-1].minor.yy0.string(), yymsp[0].minor.yy0.string()) );
813           yymsp[-1].minor.yy0.release_this ();
814           yymsp[0].minor.yy0.release_this ();
815         }
816 #line 818 "bitbakeparser.c"
817         break;
818       case 33:
819 #line 140 "bitbakeparser.y"
820 { yygotominor.yy0.assignString(0); }
821 #line 823 "bitbakeparser.c"
822         break;
823       case 34:
824 #line 142 "bitbakeparser.y"
825 { e_proc( yymsp[-3].minor.yy0.string(), yymsp[-1].minor.yy0.string() );
826           yymsp[-3].minor.yy0.release_this(); yymsp[-1].minor.yy0.release_this();   yy_destructor(22,&yymsp[-2].minor);
827   yy_destructor(23,&yymsp[0].minor);
828 }
829 #line 831 "bitbakeparser.c"
830         break;
831       case 35:
832 #line 145 "bitbakeparser.y"
833 { e_proc_python (yymsp[-3].minor.yy0.string(), yymsp[-1].minor.yy0.string() );
834           yymsp[-3].minor.yy0.release_this(); yymsp[-1].minor.yy0.release_this();   yy_destructor(24,&yymsp[-4].minor);
835   yy_destructor(22,&yymsp[-2].minor);
836   yy_destructor(23,&yymsp[0].minor);
837 }
838 #line 840 "bitbakeparser.c"
839         break;
840       case 36:
841 #line 148 "bitbakeparser.y"
842 { e_proc_python( NULL, yymsp[-1].minor.yy0.string());
843           yymsp[-1].minor.yy0.release_this ();   yy_destructor(24,&yymsp[-3].minor);
844   yy_destructor(22,&yymsp[-2].minor);
845   yy_destructor(23,&yymsp[0].minor);
846 }
847 #line 849 "bitbakeparser.c"
848         break;
849       case 37:
850 #line 152 "bitbakeparser.y"
851 { e_proc_fakeroot(yymsp[-3].minor.yy0.string(), yymsp[-1].minor.yy0.string() );
852           yymsp[-3].minor.yy0.release_this (); yymsp[-1].minor.yy0.release_this ();   yy_destructor(25,&yymsp[-4].minor);
853   yy_destructor(22,&yymsp[-2].minor);
854   yy_destructor(23,&yymsp[0].minor);
855 }
856 #line 858 "bitbakeparser.c"
857         break;
858       case 38:
859 #line 156 "bitbakeparser.y"
860 { /* concatenate body lines */
861           yygotominor.yy0.assignString( token_t::concatString(yymsp[-1].minor.yy0.string(), yymsp[0].minor.yy0.string()) );
862           yymsp[-1].minor.yy0.release_this (); yymsp[0].minor.yy0.release_this ();
863         }
864 #line 866 "bitbakeparser.c"
865         break;
866       case 39:
867 #line 160 "bitbakeparser.y"
868 { yygotominor.yy0.assignString( 0 ); }
869 #line 871 "bitbakeparser.c"
870         break;
871       case 40:
872 #line 162 "bitbakeparser.y"
873 { e_def( yymsp[-2].minor.yy0.string(), yymsp[-1].minor.yy0.string(), yymsp[0].minor.yy0.string());
874           yymsp[-2].minor.yy0.release_this(); yymsp[-1].minor.yy0.release_this(); yymsp[0].minor.yy0.release_this(); }
875 #line 877 "bitbakeparser.c"
876         break;
877   };
878   yygoto = yyRuleInfo[yyruleno].lhs;
879   yysize = yyRuleInfo[yyruleno].nrhs;
880   yypParser->yyidx -= yysize;
881   yyact = yy_find_reduce_action(yymsp[-yysize].stateno,yygoto);
882   if( yyact < YYNSTATE ){
883 #ifdef NDEBUG
884     /* If we are not debugging and the reduce action popped at least
885     ** one element off the stack, then we can push the new element back
886     ** onto the stack here, and skip the stack overflow test in yy_shift().
887     ** That gives a significant speed improvement. */
888     if( yysize ){
889       yypParser->yyidx++;
890       yymsp -= yysize-1;
891       yymsp->stateno = yyact;
892       yymsp->major = yygoto;
893       yymsp->minor = yygotominor;
894     }else
895 #endif
896     {
897       yy_shift(yypParser,yyact,yygoto,&yygotominor);
898     }
899   }else if( yyact == YYNSTATE + YYNRULE + 1 ){
900     yy_accept(yypParser);
901   }
902 }
903
904 /*
905 ** The following code executes when the parse fails
906 */
907 static void yy_parse_failed(
908   yyParser *yypParser           /* The parser */
909 ){
910   bbparseARG_FETCH;
911 #ifndef NDEBUG
912   if( yyTraceFILE ){
913     fprintf(yyTraceFILE,"%sFail!\n",yyTracePrompt);
914   }
915 #endif
916   while( yypParser->yyidx>=0 ) yy_pop_parser_stack(yypParser);
917   /* Here code is inserted which will be executed whenever the
918   ** parser fails */
919   bbparseARG_STORE; /* Suppress warning about unused %extra_argument variable */
920 }
921
922 /*
923 ** The following code executes when a syntax error first occurs.
924 */
925 static void yy_syntax_error(
926   yyParser *yypParser,           /* The parser */
927   int yymajor,                   /* The major type of the error token */
928   YYMINORTYPE yyminor            /* The minor type of the error token */
929 ){
930   bbparseARG_FETCH;
931 #define TOKEN (yyminor.yy0)
932 #line 51 "bitbakeparser.y"
933  e_parse_error( lex->filename(), lex->line() ); 
934 #line 937 "bitbakeparser.c"
935   bbparseARG_STORE; /* Suppress warning about unused %extra_argument variable */
936 }
937
938 /*
939 ** The following is executed when the parser accepts
940 */
941 static void yy_accept(
942   yyParser *yypParser           /* The parser */
943 ){
944   bbparseARG_FETCH;
945 #ifndef NDEBUG
946   if( yyTraceFILE ){
947     fprintf(yyTraceFILE,"%sAccept!\n",yyTracePrompt);
948   }
949 #endif
950   while( yypParser->yyidx>=0 ) yy_pop_parser_stack(yypParser);
951   /* Here code is inserted which will be executed whenever the
952   ** parser accepts */
953   bbparseARG_STORE; /* Suppress warning about unused %extra_argument variable */
954 }
955
956 /* The main parser program.
957 ** The first argument is a pointer to a structure obtained from
958 ** "bbparseAlloc" which describes the current state of the parser.
959 ** The second argument is the major token number.  The third is
960 ** the minor token.  The fourth optional argument is whatever the
961 ** user wants (and specified in the grammar) and is available for
962 ** use by the action routines.
963 **
964 ** Inputs:
965 ** <ul>
966 ** <li> A pointer to the parser (an opaque structure.)
967 ** <li> The major token number.
968 ** <li> The minor token number.
969 ** <li> An option argument of a grammar-specified type.
970 ** </ul>
971 **
972 ** Outputs:
973 ** None.
974 */
975 void bbparse(
976   void *yyp,                   /* The parser */
977   int yymajor,                 /* The major token code number */
978   bbparseTOKENTYPE yyminor       /* The value for the token */
979   bbparseARG_PDECL               /* Optional %extra_argument parameter */
980 ){
981   YYMINORTYPE yyminorunion;
982   int yyact;            /* The parser action. */
983   int yyendofinput;     /* True if we are at the end of input */
984   int yyerrorhit = 0;   /* True if yymajor has invoked an error */
985   yyParser *yypParser;  /* The parser */
986
987   /* (re)initialize the parser, if necessary */
988   yypParser = (yyParser*)yyp;
989   if( yypParser->yyidx<0 ){
990     /* if( yymajor==0 ) return; // not sure why this was here... */
991     yypParser->yyidx = 0;
992     yypParser->yyerrcnt = -1;
993     yypParser->yystack[0].stateno = 0;
994     yypParser->yystack[0].major = 0;
995   }
996   yyminorunion.yy0 = yyminor;
997   yyendofinput = (yymajor==0);
998   bbparseARG_STORE;
999
1000 #ifndef NDEBUG
1001   if( yyTraceFILE ){
1002     fprintf(yyTraceFILE,"%sInput %s\n",yyTracePrompt,yyTokenName[yymajor]);
1003   }
1004 #endif
1005
1006   do{
1007     yyact = yy_find_shift_action(yypParser,yymajor);
1008     if( yyact<YYNSTATE ){
1009       yy_shift(yypParser,yyact,yymajor,&yyminorunion);
1010       yypParser->yyerrcnt--;
1011       if( yyendofinput && yypParser->yyidx>=0 ){
1012         yymajor = 0;
1013       }else{
1014         yymajor = YYNOCODE;
1015       }
1016     }else if( yyact < YYNSTATE + YYNRULE ){
1017       yy_reduce(yypParser,yyact-YYNSTATE);
1018     }else if( yyact == YY_ERROR_ACTION ){
1019       int yymx;
1020 #ifndef NDEBUG
1021       if( yyTraceFILE ){
1022         fprintf(yyTraceFILE,"%sSyntax Error!\n",yyTracePrompt);
1023       }
1024 #endif
1025 #ifdef YYERRORSYMBOL
1026       /* A syntax error has occurred.
1027       ** The response to an error depends upon whether or not the
1028       ** grammar defines an error token "ERROR".  
1029       **
1030       ** This is what we do if the grammar does define ERROR:
1031       **
1032       **  * Call the %syntax_error function.
1033       **
1034       **  * Begin popping the stack until we enter a state where
1035       **    it is legal to shift the error symbol, then shift
1036       **    the error symbol.
1037       **
1038       **  * Set the error count to three.
1039       **
1040       **  * Begin accepting and shifting new tokens.  No new error
1041       **    processing will occur until three tokens have been
1042       **    shifted successfully.
1043       **
1044       */
1045       if( yypParser->yyerrcnt<0 ){
1046         yy_syntax_error(yypParser,yymajor,yyminorunion);
1047       }
1048       yymx = yypParser->yystack[yypParser->yyidx].major;
1049       if( yymx==YYERRORSYMBOL || yyerrorhit ){
1050 #ifndef NDEBUG
1051         if( yyTraceFILE ){
1052           fprintf(yyTraceFILE,"%sDiscard input token %s\n",
1053              yyTracePrompt,yyTokenName[yymajor]);
1054         }
1055 #endif
1056         yy_destructor(yymajor,&yyminorunion);
1057         yymajor = YYNOCODE;
1058       }else{
1059          while(
1060           yypParser->yyidx >= 0 &&
1061           yymx != YYERRORSYMBOL &&
1062           (yyact = yy_find_shift_action(yypParser,YYERRORSYMBOL)) >= YYNSTATE
1063         ){
1064           yy_pop_parser_stack(yypParser);
1065         }
1066         if( yypParser->yyidx < 0 || yymajor==0 ){
1067           yy_destructor(yymajor,&yyminorunion);
1068           yy_parse_failed(yypParser);
1069           yymajor = YYNOCODE;
1070         }else if( yymx!=YYERRORSYMBOL ){
1071           YYMINORTYPE u2;
1072           u2.YYERRSYMDT = 0;
1073           yy_shift(yypParser,yyact,YYERRORSYMBOL,&u2);
1074         }
1075       }
1076       yypParser->yyerrcnt = 3;
1077       yyerrorhit = 1;
1078 #else  /* YYERRORSYMBOL is not defined */
1079       /* This is what we do if the grammar does not define ERROR:
1080       **
1081       **  * Report an error message, and throw away the input token.
1082       **
1083       **  * If the input token is $, then fail the parse.
1084       **
1085       ** As before, subsequent error messages are suppressed until
1086       ** three input tokens have been successfully shifted.
1087       */
1088       if( yypParser->yyerrcnt<=0 ){
1089         yy_syntax_error(yypParser,yymajor,yyminorunion);
1090       }
1091       yypParser->yyerrcnt = 3;
1092       yy_destructor(yymajor,&yyminorunion);
1093       if( yyendofinput ){
1094         yy_parse_failed(yypParser);
1095       }
1096       yymajor = YYNOCODE;
1097 #endif
1098     }else{
1099       yy_accept(yypParser);
1100       yymajor = YYNOCODE;
1101     }
1102   }while( yymajor!=YYNOCODE && yypParser->yyidx>=0 );
1103   return;
1104 }