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