xref: /PHP-7.4/ext/ffi/ffi_parser.c (revision 0badc7de)
1 /*
2    +----------------------------------------------------------------------+
3    | PHP Version 7                                                        |
4    +----------------------------------------------------------------------+
5    | Copyright (c) The PHP Group                                          |
6    +----------------------------------------------------------------------+
7    | This source file is subject to version 3.01 of the PHP license,      |
8    | that is bundled with this package in the file LICENSE, and is        |
9    | available through the world-wide-web at the following url:           |
10    | http://www.php.net/license/3_01.txt                                  |
11    | If you did not receive a copy of the PHP license and are unable to   |
12    | obtain it through the world-wide-web, please send a note to          |
13    | license@php.net so we can mail you a copy immediately.               |
14    +----------------------------------------------------------------------+
15    | Author: Dmitry Stogov <dmitry@zend.com>                              |
16    +----------------------------------------------------------------------+
17 */
18 
19 #ifdef HAVE_CONFIG_H
20 # include "config.h"
21 #endif
22 
23 #include "php.h"
24 #include "php_ffi.h"
25 
26 #include <stdio.h>
27 #include <stdlib.h>
28 #include <string.h>
29 
30 #define yy_buf  FFI_G(buf)
31 #define yy_end  FFI_G(end)
32 #define yy_pos  FFI_G(pos)
33 #define yy_text FFI_G(text)
34 #define yy_line FFI_G(line)
35 
36 /* forward declarations */
37 static void yy_error(const char *msg);
38 static void yy_error_sym(const char *msg, int sym);
39 
40 #define YYPOS cpos
41 #define YYEND cend
42 
43 #define YY_EOF 0
44 #define YY___EXTENSION__ 1
45 #define YY___ASM__ 2
46 #define YY__LPAREN 3
47 #define YY__RPAREN 4
48 #define YY__COMMA 5
49 #define YY__SEMICOLON 6
50 #define YY_TYPEDEF 7
51 #define YY_EXTERN 8
52 #define YY_STATIC 9
53 #define YY_AUTO 10
54 #define YY_REGISTER 11
55 #define YY_INLINE 12
56 #define YY___INLINE 13
57 #define YY___INLINE__ 14
58 #define YY__NORETURN 15
59 #define YY__ALIGNAS 16
60 #define YY_CONST 17
61 #define YY___CONST 18
62 #define YY___CONST__ 19
63 #define YY_RESTRICT 20
64 #define YY___RESTRICT 21
65 #define YY___RESTRICT__ 22
66 #define YY_VOLATILE 23
67 #define YY___VOLATILE 24
68 #define YY___VOLATILE__ 25
69 #define YY__ATOMIC 26
70 #define YY_VOID 27
71 #define YY_CHAR 28
72 #define YY_SHORT 29
73 #define YY_INT 30
74 #define YY_LONG 31
75 #define YY_FLOAT 32
76 #define YY_DOUBLE 33
77 #define YY_SIGNED 34
78 #define YY_UNSIGNED 35
79 #define YY__BOOL 36
80 #define YY__COMPLEX 37
81 #define YY_COMPLEX 38
82 #define YY___COMPLEX 39
83 #define YY___COMPLEX__ 40
84 #define YY_STRUCT 41
85 #define YY_UNION 42
86 #define YY__LBRACE 43
87 #define YY__RBRACE 44
88 #define YY__COLON 45
89 #define YY_ENUM 46
90 #define YY__EQUAL 47
91 #define YY__STAR 48
92 #define YY__LBRACK 49
93 #define YY__RBRACK 50
94 #define YY__POINT_POINT_POINT 51
95 #define YY___ATTRIBUTE 52
96 #define YY___ATTRIBUTE__ 53
97 #define YY___DECLSPEC 54
98 #define YY___CDECL 55
99 #define YY___STDCALL 56
100 #define YY___FASTCALL 57
101 #define YY___THISCALL 58
102 #define YY___VECTORCALL 59
103 #define YY__POINT 60
104 #define YY__QUERY 61
105 #define YY__BAR_BAR 62
106 #define YY__AND_AND 63
107 #define YY__BAR 64
108 #define YY__UPARROW 65
109 #define YY__AND 66
110 #define YY__EQUAL_EQUAL 67
111 #define YY__BANG_EQUAL 68
112 #define YY__LESS 69
113 #define YY__GREATER 70
114 #define YY__LESS_EQUAL 71
115 #define YY__GREATER_EQUAL 72
116 #define YY__LESS_LESS 73
117 #define YY__GREATER_GREATER 74
118 #define YY__PLUS 75
119 #define YY__MINUS 76
120 #define YY__SLASH 77
121 #define YY__PERCENT 78
122 #define YY__MINUS_GREATER 79
123 #define YY__PLUS_PLUS 80
124 #define YY__MINUS_MINUS 81
125 #define YY__TILDE 82
126 #define YY__BANG 83
127 #define YY_SIZEOF 84
128 #define YY__ALIGNOF 85
129 #define YY___ALIGNOF 86
130 #define YY___ALIGNOF__ 87
131 #define YY___RESTICT 88
132 #define YY_ID 89
133 #define YY_OCTNUMBER 90
134 #define YY_DECNUMBER 91
135 #define YY_HEXNUMBER 92
136 #define YY_FLOATNUMBER 93
137 #define YY_STRING 94
138 #define YY_CHARACTER 95
139 #define YY_EOL 96
140 #define YY_WS 97
141 #define YY_ONE_LINE_COMMENT 98
142 #define YY_COMMENT 99
143 
144 static const char * sym_name[] = {
145 	"<EOF>",
146 	"__extension__",
147 	"__asm__",
148 	"(",
149 	")",
150 	",",
151 	";",
152 	"typedef",
153 	"extern",
154 	"static",
155 	"auto",
156 	"register",
157 	"inline",
158 	"__inline",
159 	"__inline__",
160 	"_Noreturn",
161 	"_Alignas",
162 	"const",
163 	"__const",
164 	"__const__",
165 	"restrict",
166 	"__restrict",
167 	"__restrict__",
168 	"volatile",
169 	"__volatile",
170 	"__volatile__",
171 	"_Atomic",
172 	"void",
173 	"char",
174 	"short",
175 	"int",
176 	"long",
177 	"float",
178 	"double",
179 	"signed",
180 	"unsigned",
181 	"_Bool",
182 	"_Complex",
183 	"complex",
184 	"__complex",
185 	"__complex__",
186 	"struct",
187 	"union",
188 	"{",
189 	"}",
190 	":",
191 	"enum",
192 	"=",
193 	"*",
194 	"[",
195 	"]",
196 	"...",
197 	"__attribute",
198 	"__attribute__",
199 	"__declspec",
200 	"__cdecl",
201 	"__stdcall",
202 	"__fastcall",
203 	"__thiscall",
204 	"__vectorcall",
205 	".",
206 	"?",
207 	"||",
208 	"&&",
209 	"|",
210 	"^",
211 	"&",
212 	"==",
213 	"!=",
214 	"<",
215 	">",
216 	"<=",
217 	">=",
218 	"<<",
219 	">>",
220 	"+",
221 	"-",
222 	"/",
223 	"%",
224 	"->",
225 	"++",
226 	"--",
227 	"~",
228 	"!",
229 	"sizeof",
230 	"_Alignof",
231 	"__alignof",
232 	"__alignof__",
233 	"__restict",
234 	"<ID>",
235 	"<OCTNUMBER>",
236 	"<DECNUMBER>",
237 	"<HEXNUMBER>",
238 	"<FLOATNUMBER>",
239 	"<STRING>",
240 	"<CHARACTER>",
241 	"<EOL>",
242 	"<WS>",
243 	"<ONE_LINE_COMMENT>",
244 	"<COMMENT>",
245 	NULL
246 };
247 
248 #define YY_IN_SET(sym, set, bitset) \
249 	(bitset[sym>>3] & (1 << (sym & 0x7)))
250 
251 static int skip_EOL(int sym);
252 static int skip_WS(int sym);
253 static int skip_ONE_LINE_COMMENT(int sym);
254 static int skip_COMMENT(int sym);
255 static int get_sym(void);
256 static int check_nested_declarator_start(int sym);
257 static int check_type_name_start(int sym);
258 static int check_ID(int sym);
259 static int parse_declarations(int sym);
260 static int parse_declaration_specifiers(int sym, zend_ffi_dcl *dcl);
261 static int parse_specifier_qualifier_list(int sym, zend_ffi_dcl *dcl);
262 static int parse_type_qualifier_list(int sym, zend_ffi_dcl *dcl);
263 static int parse_type_qualifier(int sym, zend_ffi_dcl *dcl);
264 static int parse_type_specifier(int sym, zend_ffi_dcl *dcl);
265 static int parse_struct_or_union_specifier(int sym, zend_ffi_dcl *dcl);
266 static int parse_struct_contents(int sym, zend_ffi_dcl *dcl);
267 static int parse_struct_declaration(int sym, zend_ffi_dcl *struct_dcl);
268 static int parse_struct_declarator(int sym, zend_ffi_dcl *struct_dcl, zend_ffi_dcl *field_dcl);
269 static int parse_enum_specifier(int sym, zend_ffi_dcl *dcl);
270 static int parse_enumerator_list(int sym, zend_ffi_dcl *enum_dcl);
271 static int parse_enumerator(int sym, zend_ffi_dcl *enum_dcl, int64_t *min, int64_t *max, int64_t *last);
272 static int parse_declarator(int sym, zend_ffi_dcl *dcl, const char **name, size_t *name_len);
273 static int parse_abstract_declarator(int sym, zend_ffi_dcl *dcl);
274 static int parse_parameter_declarator(int sym, zend_ffi_dcl *dcl, const char **name, size_t *name_len);
275 static int parse_pointer(int sym, zend_ffi_dcl *dcl);
276 static int parse_array_or_function_declarators(int sym, zend_ffi_dcl *dcl, zend_ffi_dcl *nested_dcl);
277 static int parse_parameter_declaration(int sym, HashTable **args);
278 static int parse_type_name(int sym, zend_ffi_dcl *dcl);
279 static int parse_attributes(int sym, zend_ffi_dcl *dcl);
280 static int parse_attrib(int sym, zend_ffi_dcl *dcl);
281 static int parse_initializer(int sym);
282 static int parse_designation(int sym);
283 static int parse_expr_list(int sym);
284 static int parse_expression(int sym, zend_ffi_val *val);
285 static int parse_assignment_expression(int sym, zend_ffi_val *val);
286 static int parse_constant_expression(int sym, zend_ffi_val *val);
287 static int parse_conditional_expression(int sym, zend_ffi_val *val);
288 static int parse_logical_or_expression(int sym, zend_ffi_val *val);
289 static int parse_logical_and_expression(int sym, zend_ffi_val *val);
290 static int parse_inclusive_or_expression(int sym, zend_ffi_val *val);
291 static int parse_exclusive_or_expression(int sym, zend_ffi_val *val);
292 static int parse_and_expression(int sym, zend_ffi_val *val);
293 static int parse_equality_expression(int sym, zend_ffi_val *val);
294 static int parse_relational_expression(int sym, zend_ffi_val *val);
295 static int parse_shift_expression(int sym, zend_ffi_val *val);
296 static int parse_additive_expression(int sym, zend_ffi_val *val);
297 static int parse_multiplicative_expression(int sym, zend_ffi_val *val);
298 static int parse_cast_expression(int sym, zend_ffi_val *val);
299 static int parse_unary_expression(int sym, zend_ffi_val *val);
300 static int parse_ID(int sym, const char **name, size_t *name_len);
301 static int parse_OCTNUMBER(int sym, zend_ffi_val *val);
302 static int parse_DECNUMBER(int sym, zend_ffi_val *val);
303 static int parse_HEXNUMBER(int sym, zend_ffi_val *val);
304 static int parse_FLOATNUMBER(int sym, zend_ffi_val *val);
305 static int parse_STRING(int sym, zend_ffi_val *val);
306 static int parse_CHARACTER(int sym, zend_ffi_val *val);
307 static int synpred_1(int sym);
308 static int synpred_2(int sym);
309 static int synpred_3(int sym);
310 static int synpred_4(int sym);
311 static int synpred_5(int sym);
312 static int synpred_6(int sym);
313 
get_skip_sym(void)314 static int get_skip_sym(void) {
315 	int ch;
316 	int ret;
317 	int accept = -1;
318 	const unsigned char *accept_pos;
319 	const unsigned char *cpos = yy_pos;
320 	const unsigned char *cend = yy_end;
321 
322 _yy_state_start:
323 	yy_text = YYPOS;
324 	ch = *YYPOS;
325 	switch (ch) {
326 		case '_':
327 			ch = *++YYPOS;
328 			switch (ch) {
329 				case '_':
330 					ch = *++YYPOS;
331 					switch (ch) {
332 						case 'e':
333 							ch = *++YYPOS;
334 							if (ch != 'x') goto _yy_tunnel_9;
335 							ch = *++YYPOS;
336 							if (ch != 't') goto _yy_tunnel_9;
337 							ch = *++YYPOS;
338 							if (ch != 'e') goto _yy_tunnel_9;
339 							ch = *++YYPOS;
340 							if (ch != 'n') goto _yy_tunnel_9;
341 							ch = *++YYPOS;
342 							if (ch != 's') goto _yy_tunnel_9;
343 							ch = *++YYPOS;
344 							if (ch != 'i') goto _yy_tunnel_9;
345 							ch = *++YYPOS;
346 							if (ch != 'o') goto _yy_tunnel_9;
347 							ch = *++YYPOS;
348 							if (ch != 'n') goto _yy_tunnel_9;
349 							ch = *++YYPOS;
350 							if (ch != '_') goto _yy_tunnel_9;
351 							ch = *++YYPOS;
352 							if (ch != '_') goto _yy_tunnel_9;
353 							ret = YY___EXTENSION__;
354 							goto _yy_state_390;
355 						case 'i':
356 							ch = *++YYPOS;
357 							if (ch != 'n') goto _yy_tunnel_9;
358 							ch = *++YYPOS;
359 							if (ch != 'l') goto _yy_tunnel_9;
360 							ch = *++YYPOS;
361 							if (ch != 'i') goto _yy_tunnel_9;
362 							ch = *++YYPOS;
363 							if (ch != 'n') goto _yy_tunnel_9;
364 							ch = *++YYPOS;
365 							if (ch != 'e') goto _yy_tunnel_9;
366 							ch = *++YYPOS;
367 							if (ch != '_') {ret = YY___INLINE; goto _yy_tunnel_390;}
368 							ch = *++YYPOS;
369 							if (ch != '_') goto _yy_tunnel_9;
370 							ret = YY___INLINE__;
371 							goto _yy_state_390;
372 						case 'a':
373 							ch = *++YYPOS;
374 							if (ch == 'l') {
375 								ch = *++YYPOS;
376 								if (ch != 'i') goto _yy_tunnel_9;
377 								ch = *++YYPOS;
378 								if (ch != 'g') goto _yy_tunnel_9;
379 								ch = *++YYPOS;
380 								if (ch != 'n') goto _yy_tunnel_9;
381 								ch = *++YYPOS;
382 								if (ch != 'o') goto _yy_tunnel_9;
383 								ch = *++YYPOS;
384 								if (ch != 'f') goto _yy_tunnel_9;
385 								ch = *++YYPOS;
386 								if (ch != '_') {ret = YY___ALIGNOF; goto _yy_tunnel_390;}
387 								ch = *++YYPOS;
388 								if (ch != '_') goto _yy_tunnel_9;
389 								ret = YY___ALIGNOF__;
390 								goto _yy_state_390;
391 							} else if (ch == 's') {
392 								ch = *++YYPOS;
393 								if (ch != 'm') goto _yy_tunnel_9;
394 								ch = *++YYPOS;
395 								if (ch != '_') goto _yy_tunnel_9;
396 								ch = *++YYPOS;
397 								if (ch != '_') goto _yy_tunnel_9;
398 								ret = YY___ASM__;
399 								goto _yy_state_390;
400 							} else if (ch == 't') {
401 								ch = *++YYPOS;
402 								if (ch != 't') goto _yy_tunnel_9;
403 								ch = *++YYPOS;
404 								if (ch != 'r') goto _yy_tunnel_9;
405 								ch = *++YYPOS;
406 								if (ch != 'i') goto _yy_tunnel_9;
407 								ch = *++YYPOS;
408 								if (ch != 'b') goto _yy_tunnel_9;
409 								ch = *++YYPOS;
410 								if (ch != 'u') goto _yy_tunnel_9;
411 								ch = *++YYPOS;
412 								if (ch != 't') goto _yy_tunnel_9;
413 								ch = *++YYPOS;
414 								if (ch != 'e') goto _yy_tunnel_9;
415 								ch = *++YYPOS;
416 								if (ch != '_') {ret = YY___ATTRIBUTE; goto _yy_tunnel_390;}
417 								ch = *++YYPOS;
418 								if (ch != '_') goto _yy_tunnel_9;
419 								ret = YY___ATTRIBUTE__;
420 								goto _yy_state_390;
421 							} else {
422 								goto _yy_tunnel_9;
423 							}
424 						case 'c':
425 							ch = *++YYPOS;
426 							if (ch == 'd') {
427 								ch = *++YYPOS;
428 								if (ch != 'e') goto _yy_tunnel_9;
429 								ch = *++YYPOS;
430 								if (ch != 'c') goto _yy_tunnel_9;
431 								ch = *++YYPOS;
432 								if (ch != 'l') goto _yy_tunnel_9;
433 								ret = YY___CDECL;
434 								goto _yy_state_390;
435 							} else if (ch == 'o') {
436 								ch = *++YYPOS;
437 								if (ch == 'm') {
438 									ch = *++YYPOS;
439 									if (ch != 'p') goto _yy_tunnel_9;
440 									ch = *++YYPOS;
441 									if (ch != 'l') goto _yy_tunnel_9;
442 									ch = *++YYPOS;
443 									if (ch != 'e') goto _yy_tunnel_9;
444 									ch = *++YYPOS;
445 									if (ch != 'x') goto _yy_tunnel_9;
446 									ch = *++YYPOS;
447 									if (ch != '_') {ret = YY___COMPLEX; goto _yy_tunnel_390;}
448 									ch = *++YYPOS;
449 									if (ch != '_') goto _yy_tunnel_9;
450 									ret = YY___COMPLEX__;
451 									goto _yy_state_390;
452 								} else if (ch == 'n') {
453 									ch = *++YYPOS;
454 									if (ch != 's') goto _yy_tunnel_9;
455 									ch = *++YYPOS;
456 									if (ch != 't') goto _yy_tunnel_9;
457 									ch = *++YYPOS;
458 									if (ch != '_') {ret = YY___CONST; goto _yy_tunnel_390;}
459 									ch = *++YYPOS;
460 									if (ch != '_') goto _yy_tunnel_9;
461 									ret = YY___CONST__;
462 									goto _yy_state_390;
463 								} else {
464 									goto _yy_tunnel_9;
465 								}
466 							} else {
467 								goto _yy_tunnel_9;
468 							}
469 						case 'd':
470 							ch = *++YYPOS;
471 							if (ch != 'e') goto _yy_tunnel_9;
472 							ch = *++YYPOS;
473 							if (ch != 'c') goto _yy_tunnel_9;
474 							ch = *++YYPOS;
475 							if (ch != 'l') goto _yy_tunnel_9;
476 							ch = *++YYPOS;
477 							if (ch != 's') goto _yy_tunnel_9;
478 							ch = *++YYPOS;
479 							if (ch != 'p') goto _yy_tunnel_9;
480 							ch = *++YYPOS;
481 							if (ch != 'e') goto _yy_tunnel_9;
482 							ch = *++YYPOS;
483 							if (ch != 'c') goto _yy_tunnel_9;
484 							ret = YY___DECLSPEC;
485 							goto _yy_state_390;
486 						case 'f':
487 							ch = *++YYPOS;
488 							if (ch != 'a') goto _yy_tunnel_9;
489 							ch = *++YYPOS;
490 							if (ch != 's') goto _yy_tunnel_9;
491 							ch = *++YYPOS;
492 							if (ch != 't') goto _yy_tunnel_9;
493 							ch = *++YYPOS;
494 							if (ch != 'c') goto _yy_tunnel_9;
495 							ch = *++YYPOS;
496 							if (ch != 'a') goto _yy_tunnel_9;
497 							ch = *++YYPOS;
498 							if (ch != 'l') goto _yy_tunnel_9;
499 							ch = *++YYPOS;
500 							if (ch != 'l') goto _yy_tunnel_9;
501 							ret = YY___FASTCALL;
502 							goto _yy_state_390;
503 						case 'r':
504 							ch = *++YYPOS;
505 							if (ch != 'e') goto _yy_tunnel_9;
506 							ch = *++YYPOS;
507 							if (ch != 's') goto _yy_tunnel_9;
508 							ch = *++YYPOS;
509 							if (ch != 't') goto _yy_tunnel_9;
510 							ch = *++YYPOS;
511 							if (ch == 'i') {
512 								ch = *++YYPOS;
513 								if (ch != 'c') goto _yy_tunnel_9;
514 								ch = *++YYPOS;
515 								if (ch != 't') goto _yy_tunnel_9;
516 								ret = YY___RESTICT;
517 								goto _yy_state_390;
518 							} else if (ch == 'r') {
519 								ch = *++YYPOS;
520 								if (ch != 'i') goto _yy_tunnel_9;
521 								ch = *++YYPOS;
522 								if (ch != 'c') goto _yy_tunnel_9;
523 								ch = *++YYPOS;
524 								if (ch != 't') goto _yy_tunnel_9;
525 								ch = *++YYPOS;
526 								if (ch != '_') {ret = YY___RESTRICT; goto _yy_tunnel_390;}
527 								ch = *++YYPOS;
528 								if (ch != '_') goto _yy_tunnel_9;
529 								ret = YY___RESTRICT__;
530 								goto _yy_state_390;
531 							} else {
532 								goto _yy_tunnel_9;
533 							}
534 						case 's':
535 							ch = *++YYPOS;
536 							if (ch != 't') goto _yy_tunnel_9;
537 							ch = *++YYPOS;
538 							if (ch != 'd') goto _yy_tunnel_9;
539 							ch = *++YYPOS;
540 							if (ch != 'c') goto _yy_tunnel_9;
541 							ch = *++YYPOS;
542 							if (ch != 'a') goto _yy_tunnel_9;
543 							ch = *++YYPOS;
544 							if (ch != 'l') goto _yy_tunnel_9;
545 							ch = *++YYPOS;
546 							if (ch != 'l') goto _yy_tunnel_9;
547 							ret = YY___STDCALL;
548 							goto _yy_state_390;
549 						case 't':
550 							ch = *++YYPOS;
551 							if (ch != 'h') goto _yy_tunnel_9;
552 							ch = *++YYPOS;
553 							if (ch != 'i') goto _yy_tunnel_9;
554 							ch = *++YYPOS;
555 							if (ch != 's') goto _yy_tunnel_9;
556 							ch = *++YYPOS;
557 							if (ch != 'c') goto _yy_tunnel_9;
558 							ch = *++YYPOS;
559 							if (ch != 'a') goto _yy_tunnel_9;
560 							ch = *++YYPOS;
561 							if (ch != 'l') goto _yy_tunnel_9;
562 							ch = *++YYPOS;
563 							if (ch != 'l') goto _yy_tunnel_9;
564 							ret = YY___THISCALL;
565 							goto _yy_state_390;
566 						case 'v':
567 							ch = *++YYPOS;
568 							if (ch == 'e') {
569 								ch = *++YYPOS;
570 								if (ch != 'c') goto _yy_tunnel_9;
571 								ch = *++YYPOS;
572 								if (ch != 't') goto _yy_tunnel_9;
573 								ch = *++YYPOS;
574 								if (ch != 'o') goto _yy_tunnel_9;
575 								ch = *++YYPOS;
576 								if (ch != 'r') goto _yy_tunnel_9;
577 								ch = *++YYPOS;
578 								if (ch != 'c') goto _yy_tunnel_9;
579 								ch = *++YYPOS;
580 								if (ch != 'a') goto _yy_tunnel_9;
581 								ch = *++YYPOS;
582 								if (ch != 'l') goto _yy_tunnel_9;
583 								ch = *++YYPOS;
584 								if (ch != 'l') goto _yy_tunnel_9;
585 								ret = YY___VECTORCALL;
586 								goto _yy_state_390;
587 							} else if (ch == 'o') {
588 								ch = *++YYPOS;
589 								if (ch != 'l') goto _yy_tunnel_9;
590 								ch = *++YYPOS;
591 								if (ch != 'a') goto _yy_tunnel_9;
592 								ch = *++YYPOS;
593 								if (ch != 't') goto _yy_tunnel_9;
594 								ch = *++YYPOS;
595 								if (ch != 'i') goto _yy_tunnel_9;
596 								ch = *++YYPOS;
597 								if (ch != 'l') goto _yy_tunnel_9;
598 								ch = *++YYPOS;
599 								if (ch != 'e') goto _yy_tunnel_9;
600 								ch = *++YYPOS;
601 								if (ch != '_') {ret = YY___VOLATILE; goto _yy_tunnel_390;}
602 								ch = *++YYPOS;
603 								if (ch != '_') goto _yy_tunnel_9;
604 								ret = YY___VOLATILE__;
605 								goto _yy_state_390;
606 							} else {
607 								goto _yy_tunnel_9;
608 							}
609 						default:
610 							goto _yy_tunnel_9;
611 					}
612 				case 'N':
613 					ch = *++YYPOS;
614 					if (ch != 'o') goto _yy_tunnel_9;
615 					ch = *++YYPOS;
616 					if (ch != 'r') goto _yy_tunnel_9;
617 					ch = *++YYPOS;
618 					if (ch != 'e') goto _yy_tunnel_9;
619 					ch = *++YYPOS;
620 					if (ch != 't') goto _yy_tunnel_9;
621 					ch = *++YYPOS;
622 					if (ch != 'u') goto _yy_tunnel_9;
623 					ch = *++YYPOS;
624 					if (ch != 'r') goto _yy_tunnel_9;
625 					ch = *++YYPOS;
626 					if (ch != 'n') goto _yy_tunnel_9;
627 					ret = YY__NORETURN;
628 					goto _yy_state_390;
629 				case 'A':
630 					ch = *++YYPOS;
631 					if (ch == 'l') {
632 						ch = *++YYPOS;
633 						if (ch != 'i') goto _yy_tunnel_9;
634 						ch = *++YYPOS;
635 						if (ch != 'g') goto _yy_tunnel_9;
636 						ch = *++YYPOS;
637 						if (ch != 'n') goto _yy_tunnel_9;
638 						ch = *++YYPOS;
639 						if (ch == 'a') {
640 							ch = *++YYPOS;
641 							if (ch != 's') goto _yy_tunnel_9;
642 							ret = YY__ALIGNAS;
643 							goto _yy_state_390;
644 						} else if (ch == 'o') {
645 							ch = *++YYPOS;
646 							if (ch != 'f') goto _yy_tunnel_9;
647 							ret = YY__ALIGNOF;
648 							goto _yy_state_390;
649 						} else {
650 							goto _yy_tunnel_9;
651 						}
652 					} else if (ch == 't') {
653 						ch = *++YYPOS;
654 						if (ch != 'o') goto _yy_tunnel_9;
655 						ch = *++YYPOS;
656 						if (ch != 'm') goto _yy_tunnel_9;
657 						ch = *++YYPOS;
658 						if (ch != 'i') goto _yy_tunnel_9;
659 						ch = *++YYPOS;
660 						if (ch != 'c') goto _yy_tunnel_9;
661 						ret = YY__ATOMIC;
662 						goto _yy_state_390;
663 					} else {
664 						goto _yy_tunnel_9;
665 					}
666 				case 'B':
667 					ch = *++YYPOS;
668 					if (ch != 'o') goto _yy_tunnel_9;
669 					ch = *++YYPOS;
670 					if (ch != 'o') goto _yy_tunnel_9;
671 					ch = *++YYPOS;
672 					if (ch != 'l') goto _yy_tunnel_9;
673 					ret = YY__BOOL;
674 					goto _yy_state_390;
675 				case 'C':
676 					ch = *++YYPOS;
677 					if (ch != 'o') goto _yy_tunnel_9;
678 					ch = *++YYPOS;
679 					if (ch != 'm') goto _yy_tunnel_9;
680 					ch = *++YYPOS;
681 					if (ch != 'p') goto _yy_tunnel_9;
682 					ch = *++YYPOS;
683 					if (ch != 'l') goto _yy_tunnel_9;
684 					ch = *++YYPOS;
685 					if (ch != 'e') goto _yy_tunnel_9;
686 					ch = *++YYPOS;
687 					if (ch != 'x') goto _yy_tunnel_9;
688 					ret = YY__COMPLEX;
689 					goto _yy_state_390;
690 				default:
691 					goto _yy_tunnel_9;
692 			}
693 		case 't':
694 			ch = *++YYPOS;
695 			if (ch != 'y') goto _yy_tunnel_9;
696 			ch = *++YYPOS;
697 			if (ch != 'p') goto _yy_tunnel_9;
698 			ch = *++YYPOS;
699 			if (ch != 'e') goto _yy_tunnel_9;
700 			ch = *++YYPOS;
701 			if (ch != 'd') goto _yy_tunnel_9;
702 			ch = *++YYPOS;
703 			if (ch != 'e') goto _yy_tunnel_9;
704 			ch = *++YYPOS;
705 			if (ch != 'f') goto _yy_tunnel_9;
706 			ret = YY_TYPEDEF;
707 			goto _yy_state_390;
708 		case 'e':
709 			ch = *++YYPOS;
710 			if (ch == 'x') {
711 				ch = *++YYPOS;
712 				if (ch != 't') goto _yy_tunnel_9;
713 				ch = *++YYPOS;
714 				if (ch != 'e') goto _yy_tunnel_9;
715 				ch = *++YYPOS;
716 				if (ch != 'r') goto _yy_tunnel_9;
717 				ch = *++YYPOS;
718 				if (ch != 'n') goto _yy_tunnel_9;
719 				ret = YY_EXTERN;
720 				goto _yy_state_390;
721 			} else if (ch == 'n') {
722 				ch = *++YYPOS;
723 				if (ch != 'u') goto _yy_tunnel_9;
724 				ch = *++YYPOS;
725 				if (ch != 'm') goto _yy_tunnel_9;
726 				ret = YY_ENUM;
727 				goto _yy_state_390;
728 			} else {
729 				goto _yy_tunnel_9;
730 			}
731 		case 's':
732 			ch = *++YYPOS;
733 			if (ch == 't') {
734 				ch = *++YYPOS;
735 				if (ch == 'a') {
736 					ch = *++YYPOS;
737 					if (ch != 't') goto _yy_tunnel_9;
738 					ch = *++YYPOS;
739 					if (ch != 'i') goto _yy_tunnel_9;
740 					ch = *++YYPOS;
741 					if (ch != 'c') goto _yy_tunnel_9;
742 					ret = YY_STATIC;
743 					goto _yy_state_390;
744 				} else if (ch == 'r') {
745 					ch = *++YYPOS;
746 					if (ch != 'u') goto _yy_tunnel_9;
747 					ch = *++YYPOS;
748 					if (ch != 'c') goto _yy_tunnel_9;
749 					ch = *++YYPOS;
750 					if (ch != 't') goto _yy_tunnel_9;
751 					ret = YY_STRUCT;
752 					goto _yy_state_390;
753 				} else {
754 					goto _yy_tunnel_9;
755 				}
756 			} else if (ch == 'h') {
757 				ch = *++YYPOS;
758 				if (ch != 'o') goto _yy_tunnel_9;
759 				ch = *++YYPOS;
760 				if (ch != 'r') goto _yy_tunnel_9;
761 				ch = *++YYPOS;
762 				if (ch != 't') goto _yy_tunnel_9;
763 				ret = YY_SHORT;
764 				goto _yy_state_390;
765 			} else if (ch == 'i') {
766 				ch = *++YYPOS;
767 				if (ch == 'g') {
768 					ch = *++YYPOS;
769 					if (ch != 'n') goto _yy_tunnel_9;
770 					ch = *++YYPOS;
771 					if (ch != 'e') goto _yy_tunnel_9;
772 					ch = *++YYPOS;
773 					if (ch != 'd') goto _yy_tunnel_9;
774 					ret = YY_SIGNED;
775 					goto _yy_state_390;
776 				} else if (ch == 'z') {
777 					ch = *++YYPOS;
778 					if (ch != 'e') goto _yy_tunnel_9;
779 					ch = *++YYPOS;
780 					if (ch != 'o') goto _yy_tunnel_9;
781 					ch = *++YYPOS;
782 					if (ch != 'f') goto _yy_tunnel_9;
783 					ret = YY_SIZEOF;
784 					goto _yy_state_390;
785 				} else {
786 					goto _yy_tunnel_9;
787 				}
788 			} else {
789 				goto _yy_tunnel_9;
790 			}
791 		case 'a':
792 			ch = *++YYPOS;
793 			if (ch != 'u') goto _yy_tunnel_9;
794 			ch = *++YYPOS;
795 			if (ch != 't') goto _yy_tunnel_9;
796 			ch = *++YYPOS;
797 			if (ch != 'o') goto _yy_tunnel_9;
798 			ret = YY_AUTO;
799 			goto _yy_state_390;
800 		case 'r':
801 			ch = *++YYPOS;
802 			if (ch != 'e') goto _yy_tunnel_9;
803 			ch = *++YYPOS;
804 			if (ch == 'g') {
805 				ch = *++YYPOS;
806 				if (ch != 'i') goto _yy_tunnel_9;
807 				ch = *++YYPOS;
808 				if (ch != 's') goto _yy_tunnel_9;
809 				ch = *++YYPOS;
810 				if (ch != 't') goto _yy_tunnel_9;
811 				ch = *++YYPOS;
812 				if (ch != 'e') goto _yy_tunnel_9;
813 				ch = *++YYPOS;
814 				if (ch != 'r') goto _yy_tunnel_9;
815 				ret = YY_REGISTER;
816 				goto _yy_state_390;
817 			} else if (ch == 's') {
818 				ch = *++YYPOS;
819 				if (ch != 't') goto _yy_tunnel_9;
820 				ch = *++YYPOS;
821 				if (ch != 'r') goto _yy_tunnel_9;
822 				ch = *++YYPOS;
823 				if (ch != 'i') goto _yy_tunnel_9;
824 				ch = *++YYPOS;
825 				if (ch != 'c') goto _yy_tunnel_9;
826 				ch = *++YYPOS;
827 				if (ch != 't') goto _yy_tunnel_9;
828 				ret = YY_RESTRICT;
829 				goto _yy_state_390;
830 			} else {
831 				goto _yy_tunnel_9;
832 			}
833 		case 'i':
834 			ch = *++YYPOS;
835 			if (ch != 'n') goto _yy_tunnel_9;
836 			ch = *++YYPOS;
837 			if (ch == 'l') {
838 				ch = *++YYPOS;
839 				if (ch != 'i') goto _yy_tunnel_9;
840 				ch = *++YYPOS;
841 				if (ch != 'n') goto _yy_tunnel_9;
842 				ch = *++YYPOS;
843 				if (ch != 'e') goto _yy_tunnel_9;
844 				ret = YY_INLINE;
845 				goto _yy_state_390;
846 			} else if (ch == 't') {
847 				ret = YY_INT;
848 				goto _yy_state_390;
849 			} else {
850 				goto _yy_tunnel_9;
851 			}
852 		case '(':
853 			YYPOS++;
854 			ret = YY__LPAREN;
855 			goto _yy_fin;
856 		case 'A':
857 		case 'B':
858 		case 'C':
859 		case 'D':
860 		case 'E':
861 		case 'F':
862 		case 'G':
863 		case 'H':
864 		case 'I':
865 		case 'J':
866 		case 'K':
867 		case 'M':
868 		case 'N':
869 		case 'O':
870 		case 'P':
871 		case 'Q':
872 		case 'R':
873 		case 'S':
874 		case 'T':
875 		case 'V':
876 		case 'W':
877 		case 'X':
878 		case 'Y':
879 		case 'Z':
880 		case 'b':
881 		case 'g':
882 		case 'h':
883 		case 'j':
884 		case 'k':
885 		case 'm':
886 		case 'n':
887 		case 'o':
888 		case 'p':
889 		case 'q':
890 		case 'w':
891 		case 'x':
892 		case 'y':
893 		case 'z':
894 			goto _yy_state_9;
895 		case 'L':
896 		case 'U':
897 			ch = *++YYPOS;
898 			if (ch == '"') {
899 				goto _yy_state_27;
900 			} else if (ch == '\'') {
901 				goto _yy_state_28;
902 			} else {
903 				goto _yy_tunnel_9;
904 			}
905 		case 'c':
906 			ch = *++YYPOS;
907 			if (ch == 'h') {
908 				ch = *++YYPOS;
909 				if (ch != 'a') goto _yy_tunnel_9;
910 				ch = *++YYPOS;
911 				if (ch != 'r') goto _yy_tunnel_9;
912 				ret = YY_CHAR;
913 				goto _yy_state_390;
914 			} else if (ch == 'o') {
915 				ch = *++YYPOS;
916 				if (ch == 'm') {
917 					ch = *++YYPOS;
918 					if (ch != 'p') goto _yy_tunnel_9;
919 					ch = *++YYPOS;
920 					if (ch != 'l') goto _yy_tunnel_9;
921 					ch = *++YYPOS;
922 					if (ch != 'e') goto _yy_tunnel_9;
923 					ch = *++YYPOS;
924 					if (ch != 'x') goto _yy_tunnel_9;
925 					ret = YY_COMPLEX;
926 					goto _yy_state_390;
927 				} else if (ch == 'n') {
928 					ch = *++YYPOS;
929 					if (ch != 's') goto _yy_tunnel_9;
930 					ch = *++YYPOS;
931 					if (ch != 't') goto _yy_tunnel_9;
932 					ret = YY_CONST;
933 					goto _yy_state_390;
934 				} else {
935 					goto _yy_tunnel_9;
936 				}
937 			} else {
938 				goto _yy_tunnel_9;
939 			}
940 		case 'd':
941 			ch = *++YYPOS;
942 			if (ch != 'o') goto _yy_tunnel_9;
943 			ch = *++YYPOS;
944 			if (ch != 'u') goto _yy_tunnel_9;
945 			ch = *++YYPOS;
946 			if (ch != 'b') goto _yy_tunnel_9;
947 			ch = *++YYPOS;
948 			if (ch != 'l') goto _yy_tunnel_9;
949 			ch = *++YYPOS;
950 			if (ch != 'e') goto _yy_tunnel_9;
951 			ret = YY_DOUBLE;
952 			goto _yy_state_390;
953 		case 'f':
954 			ch = *++YYPOS;
955 			if (ch != 'l') goto _yy_tunnel_9;
956 			ch = *++YYPOS;
957 			if (ch != 'o') goto _yy_tunnel_9;
958 			ch = *++YYPOS;
959 			if (ch != 'a') goto _yy_tunnel_9;
960 			ch = *++YYPOS;
961 			if (ch != 't') goto _yy_tunnel_9;
962 			ret = YY_FLOAT;
963 			goto _yy_state_390;
964 		case 'l':
965 			ch = *++YYPOS;
966 			if (ch != 'o') goto _yy_tunnel_9;
967 			ch = *++YYPOS;
968 			if (ch != 'n') goto _yy_tunnel_9;
969 			ch = *++YYPOS;
970 			if (ch != 'g') goto _yy_tunnel_9;
971 			ret = YY_LONG;
972 			goto _yy_state_390;
973 		case 'u':
974 			ch = *++YYPOS;
975 			if (ch == 'n') {
976 				ch = *++YYPOS;
977 				if (ch == 'i') {
978 					ch = *++YYPOS;
979 					if (ch != 'o') goto _yy_tunnel_9;
980 					ch = *++YYPOS;
981 					if (ch != 'n') goto _yy_tunnel_9;
982 					ret = YY_UNION;
983 					goto _yy_state_390;
984 				} else if (ch == 's') {
985 					ch = *++YYPOS;
986 					if (ch != 'i') goto _yy_tunnel_9;
987 					ch = *++YYPOS;
988 					if (ch != 'g') goto _yy_tunnel_9;
989 					ch = *++YYPOS;
990 					if (ch != 'n') goto _yy_tunnel_9;
991 					ch = *++YYPOS;
992 					if (ch != 'e') goto _yy_tunnel_9;
993 					ch = *++YYPOS;
994 					if (ch != 'd') goto _yy_tunnel_9;
995 					ret = YY_UNSIGNED;
996 					goto _yy_state_390;
997 				} else {
998 					goto _yy_tunnel_9;
999 				}
1000 			} else if (ch == '8') {
1001 				ch = *++YYPOS;
1002 				if (ch != '"') goto _yy_tunnel_9;
1003 				goto _yy_state_27;
1004 			} else if (ch == '"') {
1005 				goto _yy_state_27;
1006 			} else if (ch == '\'') {
1007 				goto _yy_state_28;
1008 			} else {
1009 				goto _yy_tunnel_9;
1010 			}
1011 		case 'v':
1012 			ch = *++YYPOS;
1013 			if (ch != 'o') goto _yy_tunnel_9;
1014 			ch = *++YYPOS;
1015 			if (ch == 'i') {
1016 				ch = *++YYPOS;
1017 				if (ch != 'd') goto _yy_tunnel_9;
1018 				ret = YY_VOID;
1019 				goto _yy_state_390;
1020 			} else if (ch == 'l') {
1021 				ch = *++YYPOS;
1022 				if (ch != 'a') goto _yy_tunnel_9;
1023 				ch = *++YYPOS;
1024 				if (ch != 't') goto _yy_tunnel_9;
1025 				ch = *++YYPOS;
1026 				if (ch != 'i') goto _yy_tunnel_9;
1027 				ch = *++YYPOS;
1028 				if (ch != 'l') goto _yy_tunnel_9;
1029 				ch = *++YYPOS;
1030 				if (ch != 'e') goto _yy_tunnel_9;
1031 				ret = YY_VOLATILE;
1032 				goto _yy_state_390;
1033 			} else {
1034 				goto _yy_tunnel_9;
1035 			}
1036 		case ')':
1037 			YYPOS++;
1038 			ret = YY__RPAREN;
1039 			goto _yy_fin;
1040 		case '[':
1041 			YYPOS++;
1042 			ret = YY__LBRACK;
1043 			goto _yy_fin;
1044 		case ',':
1045 			YYPOS++;
1046 			ret = YY__COMMA;
1047 			goto _yy_fin;
1048 		case ']':
1049 			YYPOS++;
1050 			ret = YY__RBRACK;
1051 			goto _yy_fin;
1052 		case '.':
1053 			ch = *++YYPOS;
1054 			accept = YY__POINT;
1055 			accept_pos = yy_pos;
1056 			if ((ch >= '0' && ch <= '9')) {
1057 				goto _yy_state_73;
1058 			} else if (ch == '.') {
1059 				ch = *++YYPOS;
1060 				if (ch == '.') {
1061 					YYPOS++;
1062 					ret = YY__POINT_POINT_POINT;
1063 					goto _yy_fin;
1064 				} else {
1065 					goto _yy_state_error;
1066 				}
1067 			} else {
1068 				ret = YY__POINT;
1069 				goto _yy_fin;
1070 			}
1071 		case '-':
1072 			ch = *++YYPOS;
1073 			if (ch == '>') {
1074 				YYPOS++;
1075 				ret = YY__MINUS_GREATER;
1076 				goto _yy_fin;
1077 			} else if (ch == '-') {
1078 				YYPOS++;
1079 				ret = YY__MINUS_MINUS;
1080 				goto _yy_fin;
1081 			} else {
1082 				ret = YY__MINUS;
1083 				goto _yy_fin;
1084 			}
1085 		case '+':
1086 			ch = *++YYPOS;
1087 			if (ch == '+') {
1088 				YYPOS++;
1089 				ret = YY__PLUS_PLUS;
1090 				goto _yy_fin;
1091 			} else {
1092 				ret = YY__PLUS;
1093 				goto _yy_fin;
1094 			}
1095 		case '0':
1096 			ch = *++YYPOS;
1097 			if (ch != 'X' && ch != 'x') goto _yy_tunnel_78;
1098 			ch = *++YYPOS;
1099 			if ((ch >= '0' && ch <= '9') || (ch >= 'A' && ch <= 'F') || (ch >= 'a' && ch <= 'f')) {
1100 				goto _yy_state_156;
1101 			} else {
1102 				goto _yy_state_error;
1103 			}
1104 		case '1':
1105 		case '2':
1106 		case '3':
1107 		case '4':
1108 		case '5':
1109 		case '6':
1110 		case '7':
1111 		case '8':
1112 		case '9':
1113 			goto _yy_state_26;
1114 		case '"':
1115 			goto _yy_state_27;
1116 		case '\'':
1117 			goto _yy_state_28;
1118 		case '&':
1119 			ch = *++YYPOS;
1120 			if (ch == '&') {
1121 				YYPOS++;
1122 				ret = YY__AND_AND;
1123 				goto _yy_fin;
1124 			} else {
1125 				ret = YY__AND;
1126 				goto _yy_fin;
1127 			}
1128 		case '*':
1129 			YYPOS++;
1130 			ret = YY__STAR;
1131 			goto _yy_fin;
1132 		case '~':
1133 			YYPOS++;
1134 			ret = YY__TILDE;
1135 			goto _yy_fin;
1136 		case '!':
1137 			ch = *++YYPOS;
1138 			if (ch == '=') {
1139 				YYPOS++;
1140 				ret = YY__BANG_EQUAL;
1141 				goto _yy_fin;
1142 			} else {
1143 				ret = YY__BANG;
1144 				goto _yy_fin;
1145 			}
1146 		case '/':
1147 			ch = *++YYPOS;
1148 			accept = YY__SLASH;
1149 			accept_pos = yy_pos;
1150 			if (ch == '*') {
1151 				goto _yy_state_99;
1152 			} else if (ch == '/') {
1153 				goto _yy_state_48;
1154 			} else {
1155 				ret = YY__SLASH;
1156 				goto _yy_fin;
1157 			}
1158 		case '%':
1159 			YYPOS++;
1160 			ret = YY__PERCENT;
1161 			goto _yy_fin;
1162 		case '<':
1163 			ch = *++YYPOS;
1164 			if (ch == '<') {
1165 				YYPOS++;
1166 				ret = YY__LESS_LESS;
1167 				goto _yy_fin;
1168 			} else if (ch == '=') {
1169 				YYPOS++;
1170 				ret = YY__LESS_EQUAL;
1171 				goto _yy_fin;
1172 			} else {
1173 				ret = YY__LESS;
1174 				goto _yy_fin;
1175 			}
1176 		case '>':
1177 			ch = *++YYPOS;
1178 			if (ch == '>') {
1179 				YYPOS++;
1180 				ret = YY__GREATER_GREATER;
1181 				goto _yy_fin;
1182 			} else if (ch == '=') {
1183 				YYPOS++;
1184 				ret = YY__GREATER_EQUAL;
1185 				goto _yy_fin;
1186 			} else {
1187 				ret = YY__GREATER;
1188 				goto _yy_fin;
1189 			}
1190 		case '=':
1191 			ch = *++YYPOS;
1192 			if (ch == '=') {
1193 				YYPOS++;
1194 				ret = YY__EQUAL_EQUAL;
1195 				goto _yy_fin;
1196 			} else {
1197 				ret = YY__EQUAL;
1198 				goto _yy_fin;
1199 			}
1200 		case '^':
1201 			YYPOS++;
1202 			ret = YY__UPARROW;
1203 			goto _yy_fin;
1204 		case '|':
1205 			ch = *++YYPOS;
1206 			if (ch == '|') {
1207 				YYPOS++;
1208 				ret = YY__BAR_BAR;
1209 				goto _yy_fin;
1210 			} else {
1211 				ret = YY__BAR;
1212 				goto _yy_fin;
1213 			}
1214 		case '?':
1215 			YYPOS++;
1216 			ret = YY__QUERY;
1217 			goto _yy_fin;
1218 		case ':':
1219 			YYPOS++;
1220 			ret = YY__COLON;
1221 			goto _yy_fin;
1222 		case '{':
1223 			YYPOS++;
1224 			ret = YY__LBRACE;
1225 			goto _yy_fin;
1226 		case ';':
1227 			YYPOS++;
1228 			ret = YY__SEMICOLON;
1229 			goto _yy_fin;
1230 		case '}':
1231 			YYPOS++;
1232 			ret = YY__RBRACE;
1233 			goto _yy_fin;
1234 		case '\r':
1235 			ch = *++YYPOS;
1236 			if (ch == '\n') {
1237 				yy_line++;
1238 				YYPOS++;
1239 				ret = YY_EOL;
1240 				goto _yy_fin;
1241 			} else {
1242 				ret = YY_EOL;
1243 				goto _yy_fin;
1244 			}
1245 		case '\n':
1246 			yy_line++;
1247 			YYPOS++;
1248 			ret = YY_EOL;
1249 			goto _yy_fin;
1250 		case ' ':
1251 		case '\t':
1252 		case '\f':
1253 		case '\v':
1254 			goto _yy_state_47;
1255 		case '#':
1256 			goto _yy_state_48;
1257 		case '\0':
1258 			if (ch == 0 && YYPOS < YYEND) goto _yy_state_error;
1259 			YYPOS++;
1260 			ret = YY_EOF;
1261 			goto _yy_fin;
1262 		default:
1263 			goto _yy_state_error;
1264 	}
1265 _yy_state_9:
1266 	ch = *++YYPOS;
1267 _yy_tunnel_9:
1268 	if ((ch >= '0' && ch <= '9') || (ch >= 'A' && ch <= 'Z') || ch == '_' || (ch >= 'a' && ch <= 'z')) {
1269 		goto _yy_state_9;
1270 	} else {
1271 		ret = YY_ID;
1272 		goto _yy_fin;
1273 	}
1274 _yy_state_26:
1275 	ch = *++YYPOS;
1276 	accept = YY_DECNUMBER;
1277 	accept_pos = yy_pos;
1278 	switch (ch) {
1279 		case 'U':
1280 		case 'u':
1281 			ch = *++YYPOS;
1282 			if (ch == 'L') {
1283 				ch = *++YYPOS;
1284 				if (ch == 'L') {
1285 					YYPOS++;
1286 					ret = YY_DECNUMBER;
1287 					goto _yy_fin;
1288 				} else {
1289 					ret = YY_DECNUMBER;
1290 					goto _yy_fin;
1291 				}
1292 			} else if (ch == 'l') {
1293 				YYPOS++;
1294 				ret = YY_DECNUMBER;
1295 				goto _yy_fin;
1296 			} else {
1297 				ret = YY_DECNUMBER;
1298 				goto _yy_fin;
1299 			}
1300 		case 'L':
1301 			ch = *++YYPOS;
1302 			accept = YY_DECNUMBER;
1303 			accept_pos = yy_pos;
1304 			if (ch == 'L') {
1305 				goto _yy_state_163;
1306 			} else if (ch == 'U' || ch == 'u') {
1307 				YYPOS++;
1308 				ret = YY_DECNUMBER;
1309 				goto _yy_fin;
1310 			} else {
1311 				ret = YY_DECNUMBER;
1312 				goto _yy_fin;
1313 			}
1314 		case 'l':
1315 			ch = *++YYPOS;
1316 			accept = YY_DECNUMBER;
1317 			accept_pos = yy_pos;
1318 			if (ch == 'U' || ch == 'u') {
1319 				YYPOS++;
1320 				ret = YY_DECNUMBER;
1321 				goto _yy_fin;
1322 			} else if (ch == 'l') {
1323 				goto _yy_state_163;
1324 			} else {
1325 				ret = YY_DECNUMBER;
1326 				goto _yy_fin;
1327 			}
1328 		case 'E':
1329 		case 'e':
1330 			goto _yy_state_85;
1331 		case '0':
1332 		case '1':
1333 		case '2':
1334 		case '3':
1335 		case '4':
1336 		case '5':
1337 		case '6':
1338 		case '7':
1339 		case '8':
1340 		case '9':
1341 			goto _yy_state_26;
1342 		case '.':
1343 			goto _yy_state_73;
1344 		default:
1345 			ret = YY_DECNUMBER;
1346 			goto _yy_fin;
1347 	}
1348 _yy_state_27:
1349 	ch = *++YYPOS;
1350 	if (ch == '\\') {
1351 		ch = *++YYPOS;
1352 		if (YYPOS < YYEND) {
1353 			if (ch == '\n') {
1354 				yy_line++;
1355 			}
1356 			goto _yy_state_27;
1357 		} else {
1358 			goto _yy_state_error;
1359 		}
1360 	} else if (ch == '"') {
1361 		YYPOS++;
1362 		ret = YY_STRING;
1363 		goto _yy_fin;
1364 	} else if (YYPOS < YYEND && (ch <= '!' || (ch >= '#' && ch <= '[') || ch >= ']')) {
1365 		if (ch == '\n') {
1366 			yy_line++;
1367 		}
1368 		goto _yy_state_27;
1369 	} else {
1370 		goto _yy_state_error;
1371 	}
1372 _yy_state_28:
1373 	ch = *++YYPOS;
1374 	if (ch == '\\') {
1375 		ch = *++YYPOS;
1376 		if (YYPOS < YYEND) {
1377 			if (ch == '\n') {
1378 				yy_line++;
1379 			}
1380 			goto _yy_state_28;
1381 		} else {
1382 			goto _yy_state_error;
1383 		}
1384 	} else if (ch == '\'') {
1385 		YYPOS++;
1386 		ret = YY_CHARACTER;
1387 		goto _yy_fin;
1388 	} else if (YYPOS < YYEND && (ch <= '&' || (ch >= '(' && ch <= '[') || ch >= ']')) {
1389 		if (ch == '\n') {
1390 			yy_line++;
1391 		}
1392 		goto _yy_state_28;
1393 	} else {
1394 		goto _yy_state_error;
1395 	}
1396 _yy_state_47:
1397 	ch = *++YYPOS;
1398 	if (ch == '\t' || ch == '\v' || ch == '\f' || ch == ' ') {
1399 		goto _yy_state_47;
1400 	} else {
1401 		ret = YY_WS;
1402 		goto _yy_fin;
1403 	}
1404 _yy_state_48:
1405 	ch = *++YYPOS;
1406 	if (ch == '\r') {
1407 		ch = *++YYPOS;
1408 		if (ch == '\n') {
1409 			yy_line++;
1410 			YYPOS++;
1411 			ret = YY_ONE_LINE_COMMENT;
1412 			goto _yy_fin;
1413 		} else {
1414 			ret = YY_ONE_LINE_COMMENT;
1415 			goto _yy_fin;
1416 		}
1417 	} else if (ch == '\n') {
1418 		yy_line++;
1419 		YYPOS++;
1420 		ret = YY_ONE_LINE_COMMENT;
1421 		goto _yy_fin;
1422 	} else if (YYPOS < YYEND && (ch <= '\t' || ch == '\v' || ch == '\f' || ch >= '\016')) {
1423 		goto _yy_state_48;
1424 	} else {
1425 		goto _yy_state_error;
1426 	}
1427 _yy_state_73:
1428 	ch = *++YYPOS;
1429 	accept = YY_FLOATNUMBER;
1430 	accept_pos = yy_pos;
1431 	if ((ch >= '0' && ch <= '9')) {
1432 		goto _yy_state_73;
1433 	} else if (ch == 'F' || ch == 'L' || ch == 'f' || ch == 'l') {
1434 		YYPOS++;
1435 		ret = YY_FLOATNUMBER;
1436 		goto _yy_fin;
1437 	} else if (ch == 'E' || ch == 'e') {
1438 		goto _yy_state_85;
1439 	} else {
1440 		ret = YY_FLOATNUMBER;
1441 		goto _yy_fin;
1442 	}
1443 _yy_state_78:
1444 	ch = *++YYPOS;
1445 _yy_tunnel_78:
1446 	accept = YY_OCTNUMBER;
1447 	accept_pos = yy_pos;
1448 	switch (ch) {
1449 		case '0':
1450 		case '1':
1451 		case '2':
1452 		case '3':
1453 		case '4':
1454 		case '5':
1455 		case '6':
1456 		case '7':
1457 			goto _yy_state_78;
1458 		case 'U':
1459 		case 'u':
1460 			ch = *++YYPOS;
1461 			if (ch == 'L') {
1462 				ch = *++YYPOS;
1463 				if (ch == 'L') {
1464 					YYPOS++;
1465 					ret = YY_OCTNUMBER;
1466 					goto _yy_fin;
1467 				} else {
1468 					ret = YY_OCTNUMBER;
1469 					goto _yy_fin;
1470 				}
1471 			} else if (ch == 'l') {
1472 				YYPOS++;
1473 				ret = YY_OCTNUMBER;
1474 				goto _yy_fin;
1475 			} else {
1476 				ret = YY_OCTNUMBER;
1477 				goto _yy_fin;
1478 			}
1479 		case 'L':
1480 			ch = *++YYPOS;
1481 			accept = YY_OCTNUMBER;
1482 			accept_pos = yy_pos;
1483 			if (ch == 'L') {
1484 				goto _yy_state_154;
1485 			} else if (ch == 'U' || ch == 'u') {
1486 				YYPOS++;
1487 				ret = YY_OCTNUMBER;
1488 				goto _yy_fin;
1489 			} else {
1490 				ret = YY_OCTNUMBER;
1491 				goto _yy_fin;
1492 			}
1493 		case 'l':
1494 			ch = *++YYPOS;
1495 			accept = YY_OCTNUMBER;
1496 			accept_pos = yy_pos;
1497 			if (ch == 'l') {
1498 				goto _yy_state_154;
1499 			} else if (ch == 'U' || ch == 'u') {
1500 				YYPOS++;
1501 				ret = YY_OCTNUMBER;
1502 				goto _yy_fin;
1503 			} else {
1504 				ret = YY_OCTNUMBER;
1505 				goto _yy_fin;
1506 			}
1507 		case '8':
1508 		case '9':
1509 			goto _yy_state_83;
1510 		case 'E':
1511 		case 'e':
1512 			goto _yy_state_85;
1513 		case '.':
1514 			goto _yy_state_73;
1515 		default:
1516 			ret = YY_OCTNUMBER;
1517 			goto _yy_fin;
1518 	}
1519 _yy_state_83:
1520 	ch = *++YYPOS;
1521 	if ((ch >= '0' && ch <= '9')) {
1522 		goto _yy_state_83;
1523 	} else if (ch == 'E' || ch == 'e') {
1524 		goto _yy_state_85;
1525 	} else if (ch == '.') {
1526 		goto _yy_state_73;
1527 	} else {
1528 		goto _yy_state_error;
1529 	}
1530 _yy_state_85:
1531 	ch = *++YYPOS;
1532 	if (ch == '+' || ch == '-') {
1533 		ch = *++YYPOS;
1534 		if ((ch >= '0' && ch <= '9')) {
1535 			goto _yy_state_159;
1536 		} else {
1537 			goto _yy_state_error;
1538 		}
1539 	} else if ((ch >= '0' && ch <= '9')) {
1540 		goto _yy_state_159;
1541 	} else {
1542 		goto _yy_state_error;
1543 	}
1544 _yy_state_99:
1545 	ch = *++YYPOS;
1546 _yy_tunnel_99:
1547 	if (ch == '*') {
1548 		ch = *++YYPOS;
1549 		if (ch != '/') goto _yy_tunnel_99;
1550 		YYPOS++;
1551 		ret = YY_COMMENT;
1552 		goto _yy_fin;
1553 	} else if (YYPOS < YYEND && (ch <= ')' || ch >= '+')) {
1554 		if (ch == '\n') {
1555 			yy_line++;
1556 		}
1557 		goto _yy_state_99;
1558 	} else {
1559 		goto _yy_state_error;
1560 	}
1561 _yy_state_154:
1562 	ch = *++YYPOS;
1563 	if (ch == 'U' || ch == 'u') {
1564 		YYPOS++;
1565 		ret = YY_OCTNUMBER;
1566 		goto _yy_fin;
1567 	} else {
1568 		goto _yy_state_error;
1569 	}
1570 _yy_state_156:
1571 	ch = *++YYPOS;
1572 	if (ch == 'U' || ch == 'u') {
1573 		ch = *++YYPOS;
1574 		if (ch == 'L') {
1575 			ch = *++YYPOS;
1576 			if (ch == 'L') {
1577 				YYPOS++;
1578 				ret = YY_HEXNUMBER;
1579 				goto _yy_fin;
1580 			} else {
1581 				ret = YY_HEXNUMBER;
1582 				goto _yy_fin;
1583 			}
1584 		} else if (ch == 'l') {
1585 			YYPOS++;
1586 			ret = YY_HEXNUMBER;
1587 			goto _yy_fin;
1588 		} else {
1589 			ret = YY_HEXNUMBER;
1590 			goto _yy_fin;
1591 		}
1592 	} else if (ch == 'L') {
1593 		ch = *++YYPOS;
1594 		accept = YY_HEXNUMBER;
1595 		accept_pos = yy_pos;
1596 		if (ch == 'L') {
1597 			goto _yy_state_265;
1598 		} else if (ch == 'U' || ch == 'u') {
1599 			YYPOS++;
1600 			ret = YY_HEXNUMBER;
1601 			goto _yy_fin;
1602 		} else {
1603 			ret = YY_HEXNUMBER;
1604 			goto _yy_fin;
1605 		}
1606 	} else if (ch == 'l') {
1607 		ch = *++YYPOS;
1608 		accept = YY_HEXNUMBER;
1609 		accept_pos = yy_pos;
1610 		if (ch == 'U' || ch == 'u') {
1611 			YYPOS++;
1612 			ret = YY_HEXNUMBER;
1613 			goto _yy_fin;
1614 		} else if (ch == 'l') {
1615 			goto _yy_state_265;
1616 		} else {
1617 			ret = YY_HEXNUMBER;
1618 			goto _yy_fin;
1619 		}
1620 	} else if ((ch >= '0' && ch <= '9') || (ch >= 'A' && ch <= 'F') || (ch >= 'a' && ch <= 'f')) {
1621 		goto _yy_state_156;
1622 	} else {
1623 		ret = YY_HEXNUMBER;
1624 		goto _yy_fin;
1625 	}
1626 _yy_state_159:
1627 	ch = *++YYPOS;
1628 	if ((ch >= '0' && ch <= '9')) {
1629 		goto _yy_state_159;
1630 	} else if (ch == 'F' || ch == 'L' || ch == 'f' || ch == 'l') {
1631 		YYPOS++;
1632 		ret = YY_FLOATNUMBER;
1633 		goto _yy_fin;
1634 	} else {
1635 		ret = YY_FLOATNUMBER;
1636 		goto _yy_fin;
1637 	}
1638 _yy_state_163:
1639 	ch = *++YYPOS;
1640 	if (ch == 'U' || ch == 'u') {
1641 		YYPOS++;
1642 		ret = YY_DECNUMBER;
1643 		goto _yy_fin;
1644 	} else {
1645 		goto _yy_state_error;
1646 	}
1647 _yy_state_265:
1648 	ch = *++YYPOS;
1649 	if (ch == 'U' || ch == 'u') {
1650 		YYPOS++;
1651 		ret = YY_HEXNUMBER;
1652 		goto _yy_fin;
1653 	} else {
1654 		goto _yy_state_error;
1655 	}
1656 _yy_state_390:
1657 	ch = *++YYPOS;
1658 _yy_tunnel_390:
1659 	if ((ch >= '0' && ch <= '9') || (ch >= 'A' && ch <= 'Z') || ch == '_' || (ch >= 'a' && ch <= 'z')) {
1660 		goto _yy_state_9;
1661 	} else {
1662 		goto _yy_fin;
1663 	}
1664 _yy_state_error:
1665 	if (accept >= 0) {
1666 		yy_pos = accept_pos;
1667 		return accept;
1668 	}
1669 	if (YYPOS >= YYEND) {
1670 		yy_error("unexpected <EOF>");
1671 	} else if (YYPOS == yy_text) {
1672 		yy_error("unexpected character 'escape_char(ch)'");
1673 	} else {
1674 		yy_error("unexpected sequence 'escape_string(yy_text, 1 + YYPOS - yy_text))'");
1675 	}
1676 	YYPOS++;
1677 	goto _yy_state_start;
1678 _yy_fin:
1679 	yy_pos = YYPOS;
1680 	return ret;
1681 }
1682 
skip_EOL(int sym)1683 static int skip_EOL(int sym) {
1684 	if (sym != YY_EOL) {
1685 		yy_error_sym("<EOL> expected, got", sym);
1686 	}
1687 	sym = get_skip_sym();
1688 	return sym;
1689 }
1690 
skip_WS(int sym)1691 static int skip_WS(int sym) {
1692 	if (sym != YY_WS) {
1693 		yy_error_sym("<WS> expected, got", sym);
1694 	}
1695 	sym = get_skip_sym();
1696 	return sym;
1697 }
1698 
skip_ONE_LINE_COMMENT(int sym)1699 static int skip_ONE_LINE_COMMENT(int sym) {
1700 	if (sym != YY_ONE_LINE_COMMENT) {
1701 		yy_error_sym("<ONE_LINE_COMMENT> expected, got", sym);
1702 	}
1703 	sym = get_skip_sym();
1704 	return sym;
1705 }
1706 
skip_COMMENT(int sym)1707 static int skip_COMMENT(int sym) {
1708 	if (sym != YY_COMMENT) {
1709 		yy_error_sym("<COMMENT> expected, got", sym);
1710 	}
1711 	sym = get_skip_sym();
1712 	return sym;
1713 }
1714 
get_sym(void)1715 static int get_sym(void) {
1716 	int sym;
1717 	sym = get_skip_sym();
1718 	while (sym == YY_EOL || sym == YY_WS || sym == YY_ONE_LINE_COMMENT || sym == YY_COMMENT) {
1719 		if (sym == YY_EOL) {
1720 			sym = skip_EOL(sym);
1721 		} else if (sym == YY_WS) {
1722 			sym = skip_WS(sym);
1723 		} else if (sym == YY_ONE_LINE_COMMENT) {
1724 			sym = skip_ONE_LINE_COMMENT(sym);
1725 		} else {
1726 			sym = skip_COMMENT(sym);
1727 		}
1728 	}
1729 	return sym;
1730 }
1731 
check_nested_declarator_start(int sym)1732 static int check_nested_declarator_start(int sym) {
1733 	if (sym != YY__LPAREN) {
1734 		return -1;
1735 	}
1736 	sym = get_sym();
1737 	if ((sym == YY_ID) && (!zend_ffi_is_typedef_name((const char*)yy_text, yy_pos - yy_text))) {
1738 		sym = check_ID(sym);
1739 		if (sym == -1) {
1740 			return -1;
1741 		}
1742 	} else {
1743 		switch (sym) {
1744 			case YY___ATTRIBUTE:
1745 				sym = get_sym();
1746 				break;
1747 			case YY___ATTRIBUTE__:
1748 				sym = get_sym();
1749 				break;
1750 			case YY___DECLSPEC:
1751 				sym = get_sym();
1752 				break;
1753 			case YY__STAR:
1754 				sym = get_sym();
1755 				break;
1756 			case YY__LPAREN:
1757 				sym = get_sym();
1758 				break;
1759 			case YY__LBRACK:
1760 				sym = get_sym();
1761 				break;
1762 			default:
1763 				return -1;
1764 		}
1765 	}
1766 	return sym;
1767 }
1768 
check_type_name_start(int sym)1769 static int check_type_name_start(int sym) {
1770 	if ((sym == YY_ID) && (zend_ffi_is_typedef_name((const char*)yy_text, yy_pos - yy_text))) {
1771 		sym = check_ID(sym);
1772 		if (sym == -1) {
1773 			return -1;
1774 		}
1775 	} else {
1776 		switch (sym) {
1777 			case YY_VOID:
1778 				sym = get_sym();
1779 				break;
1780 			case YY_CHAR:
1781 				sym = get_sym();
1782 				break;
1783 			case YY_SHORT:
1784 				sym = get_sym();
1785 				break;
1786 			case YY_INT:
1787 				sym = get_sym();
1788 				break;
1789 			case YY_LONG:
1790 				sym = get_sym();
1791 				break;
1792 			case YY_FLOAT:
1793 				sym = get_sym();
1794 				break;
1795 			case YY_DOUBLE:
1796 				sym = get_sym();
1797 				break;
1798 			case YY_SIGNED:
1799 				sym = get_sym();
1800 				break;
1801 			case YY_UNSIGNED:
1802 				sym = get_sym();
1803 				break;
1804 			case YY__BOOL:
1805 				sym = get_sym();
1806 				break;
1807 			case YY__COMPLEX:
1808 				sym = get_sym();
1809 				break;
1810 			case YY_COMPLEX:
1811 				sym = get_sym();
1812 				break;
1813 			case YY___COMPLEX:
1814 				sym = get_sym();
1815 				break;
1816 			case YY___COMPLEX__:
1817 				sym = get_sym();
1818 				break;
1819 			case YY_STRUCT:
1820 				sym = get_sym();
1821 				break;
1822 			case YY_UNION:
1823 				sym = get_sym();
1824 				break;
1825 			case YY_ENUM:
1826 				sym = get_sym();
1827 				break;
1828 			case YY_CONST:
1829 				sym = get_sym();
1830 				break;
1831 			case YY___CONST:
1832 				sym = get_sym();
1833 				break;
1834 			case YY___CONST__:
1835 				sym = get_sym();
1836 				break;
1837 			case YY_RESTRICT:
1838 				sym = get_sym();
1839 				break;
1840 			case YY___RESTICT:
1841 				sym = get_sym();
1842 				break;
1843 			case YY___RESTRICT__:
1844 				sym = get_sym();
1845 				break;
1846 			case YY_VOLATILE:
1847 				sym = get_sym();
1848 				break;
1849 			case YY___VOLATILE:
1850 				sym = get_sym();
1851 				break;
1852 			case YY___VOLATILE__:
1853 				sym = get_sym();
1854 				break;
1855 			case YY__ATOMIC:
1856 				sym = get_sym();
1857 				break;
1858 			case YY___ATTRIBUTE:
1859 				sym = get_sym();
1860 				break;
1861 			case YY___ATTRIBUTE__:
1862 				sym = get_sym();
1863 				break;
1864 			case YY___DECLSPEC:
1865 				sym = get_sym();
1866 				break;
1867 			default:
1868 				return -1;
1869 		}
1870 	}
1871 	return sym;
1872 }
1873 
check_ID(int sym)1874 static int check_ID(int sym) {
1875 	if (sym != YY_ID) {
1876 		return -1;
1877 	}
1878 	sym = get_sym();
1879 	return sym;
1880 }
1881 
synpred_1(int sym)1882 static int synpred_1(int sym) {
1883 	int ret;
1884 	const unsigned char *save_pos;
1885 	const unsigned char *save_text;
1886 	int   save_line;
1887 
1888 	save_pos  = yy_pos;
1889 	save_text = yy_text;
1890 	save_line = yy_line;
1891 	ret = check_type_name_start(sym) != -1;
1892 	yy_pos  = save_pos;
1893 	yy_text = save_text;
1894 	yy_line = save_line;
1895 	return ret;
1896 }
1897 
synpred_2(int sym)1898 static int synpred_2(int sym) {
1899 	int ret;
1900 	const unsigned char *save_pos;
1901 	const unsigned char *save_text;
1902 	int   save_line;
1903 
1904 	save_pos  = yy_pos;
1905 	save_text = yy_text;
1906 	save_line = yy_line;
1907 	ret = check_nested_declarator_start(sym) != -1;
1908 	yy_pos  = save_pos;
1909 	yy_text = save_text;
1910 	yy_line = save_line;
1911 	return ret;
1912 }
1913 
synpred_3(int sym)1914 static int synpred_3(int sym) {
1915 	int ret;
1916 	const unsigned char *save_pos;
1917 	const unsigned char *save_text;
1918 	int   save_line;
1919 
1920 	save_pos  = yy_pos;
1921 	save_text = yy_text;
1922 	save_line = yy_line;
1923 	ret = check_nested_declarator_start(sym) != -1;
1924 	yy_pos  = save_pos;
1925 	yy_text = save_text;
1926 	yy_line = save_line;
1927 	return ret;
1928 }
1929 
_synpred_4(int sym)1930 static int _synpred_4(int sym) {
1931 	if (sym != YY__LPAREN) {
1932 		return -1;
1933 	}
1934 	sym = get_sym();
1935 	sym = check_type_name_start(sym);
1936 	if (sym == -1) {
1937 		return -1;
1938 	}
1939 	return sym;
1940 }
1941 
synpred_4(int sym)1942 static int synpred_4(int sym) {
1943 	int ret;
1944 	const unsigned char *save_pos;
1945 	const unsigned char *save_text;
1946 	int   save_line;
1947 
1948 	save_pos  = yy_pos;
1949 	save_text = yy_text;
1950 	save_line = yy_line;
1951 	ret = _synpred_4(sym) != -1;
1952 	yy_pos  = save_pos;
1953 	yy_text = save_text;
1954 	yy_line = save_line;
1955 	return ret;
1956 }
1957 
_synpred_5(int sym)1958 static int _synpred_5(int sym) {
1959 	if (sym != YY__LPAREN) {
1960 		return -1;
1961 	}
1962 	sym = get_sym();
1963 	sym = check_type_name_start(sym);
1964 	if (sym == -1) {
1965 		return -1;
1966 	}
1967 	return sym;
1968 }
1969 
synpred_5(int sym)1970 static int synpred_5(int sym) {
1971 	int ret;
1972 	const unsigned char *save_pos;
1973 	const unsigned char *save_text;
1974 	int   save_line;
1975 
1976 	save_pos  = yy_pos;
1977 	save_text = yy_text;
1978 	save_line = yy_line;
1979 	ret = _synpred_5(sym) != -1;
1980 	yy_pos  = save_pos;
1981 	yy_text = save_text;
1982 	yy_line = save_line;
1983 	return ret;
1984 }
1985 
_synpred_6(int sym)1986 static int _synpred_6(int sym) {
1987 	if (sym != YY__LPAREN) {
1988 		return -1;
1989 	}
1990 	sym = get_sym();
1991 	sym = check_type_name_start(sym);
1992 	if (sym == -1) {
1993 		return -1;
1994 	}
1995 	return sym;
1996 }
1997 
synpred_6(int sym)1998 static int synpred_6(int sym) {
1999 	int ret;
2000 	const unsigned char *save_pos;
2001 	const unsigned char *save_text;
2002 	int   save_line;
2003 
2004 	save_pos  = yy_pos;
2005 	save_text = yy_text;
2006 	save_line = yy_line;
2007 	ret = _synpred_6(sym) != -1;
2008 	yy_pos  = save_pos;
2009 	yy_text = save_text;
2010 	yy_line = save_line;
2011 	return ret;
2012 }
2013 
parse_declarations(int sym)2014 static int parse_declarations(int sym) {
2015 	while (YY_IN_SET(sym, (YY___EXTENSION__,YY_TYPEDEF,YY_EXTERN,YY_STATIC,YY_AUTO,YY_REGISTER,YY_INLINE,YY___INLINE,YY___INLINE__,YY__NORETURN,YY__ALIGNAS,YY___ATTRIBUTE,YY___ATTRIBUTE__,YY___DECLSPEC,YY___CDECL,YY___STDCALL,YY___FASTCALL,YY___THISCALL,YY___VECTORCALL,YY_CONST,YY___CONST,YY___CONST__,YY_RESTRICT,YY___RESTRICT,YY___RESTRICT__,YY_VOLATILE,YY___VOLATILE,YY___VOLATILE__,YY__ATOMIC,YY_VOID,YY_CHAR,YY_SHORT,YY_INT,YY_LONG,YY_FLOAT,YY_DOUBLE,YY_SIGNED,YY_UNSIGNED,YY__BOOL,YY__COMPLEX,YY_COMPLEX,YY___COMPLEX,YY___COMPLEX__,YY_STRUCT,YY_UNION,YY_ENUM,YY_ID), "\202\377\377\377\377\107\360\017\000\000\000\002\000")) {
2016 		zend_ffi_dcl common_dcl = ZEND_FFI_ATTR_INIT;
2017 		if (sym == YY___EXTENSION__) {
2018 			sym = get_sym();
2019 		}
2020 		sym = parse_declaration_specifiers(sym, &common_dcl);
2021 		if (sym == YY__STAR || sym == YY_ID || sym == YY__LPAREN) {
2022 			const char *name;
2023 			size_t name_len;
2024 			zend_ffi_dcl dcl;
2025 			dcl = common_dcl;
2026 			sym = parse_declarator(sym, &dcl, &name, &name_len);
2027 			if (sym == YY___ASM__) {
2028 				zend_ffi_val asm_str;
2029 				sym = get_sym();
2030 				if (sym != YY__LPAREN) {
2031 					yy_error_sym("'(' expected, got", sym);
2032 				}
2033 				sym = get_sym();
2034 				do {
2035 					sym = parse_STRING(sym, &asm_str);
2036 				} while (sym == YY_STRING);
2037 				if (sym != YY__RPAREN) {
2038 					yy_error_sym("')' expected, got", sym);
2039 				}
2040 				sym = get_sym();
2041 			}
2042 			if (YY_IN_SET(sym, (YY___ATTRIBUTE,YY___ATTRIBUTE__,YY___DECLSPEC,YY___CDECL,YY___STDCALL,YY___FASTCALL,YY___THISCALL,YY___VECTORCALL), "\000\000\000\000\000\000\360\017\000\000\000\000\000")) {
2043 				sym = parse_attributes(sym, &dcl);
2044 			}
2045 			if (sym == YY__EQUAL) {
2046 				sym = parse_initializer(sym);
2047 			}
2048 			zend_ffi_declare(name, name_len, &dcl);
2049 			while (sym == YY__COMMA) {
2050 				sym = get_sym();
2051 				dcl = common_dcl;
2052 				sym = parse_declarator(sym, &dcl, &name, &name_len);
2053 				if (YY_IN_SET(sym, (YY___ATTRIBUTE,YY___ATTRIBUTE__,YY___DECLSPEC,YY___CDECL,YY___STDCALL,YY___FASTCALL,YY___THISCALL,YY___VECTORCALL), "\000\000\000\000\000\000\360\017\000\000\000\000\000")) {
2054 					sym = parse_attributes(sym, &dcl);
2055 				}
2056 				if (sym == YY__EQUAL) {
2057 					sym = parse_initializer(sym);
2058 				}
2059 				zend_ffi_declare(name, name_len, &dcl);
2060 			}
2061 		}
2062 		if (sym != YY__SEMICOLON) {
2063 			yy_error_sym("';' expected, got", sym);
2064 		}
2065 		sym = get_sym();
2066 	}
2067 	return sym;
2068 }
2069 
parse_declaration_specifiers(int sym,zend_ffi_dcl * dcl)2070 static int parse_declaration_specifiers(int sym, zend_ffi_dcl *dcl) {
2071 	do {
2072 		switch (sym) {
2073 			case YY_TYPEDEF:
2074 				if (dcl->flags & ZEND_FFI_DCL_STORAGE_CLASS) yy_error_sym("unexpected", sym);
2075 				sym = get_sym();
2076 				dcl->flags |= ZEND_FFI_DCL_TYPEDEF;
2077 				break;
2078 			case YY_EXTERN:
2079 				if (dcl->flags & ZEND_FFI_DCL_STORAGE_CLASS) yy_error_sym("unexpected", sym);
2080 				sym = get_sym();
2081 				dcl->flags |= ZEND_FFI_DCL_EXTERN;
2082 				break;
2083 			case YY_STATIC:
2084 				if (dcl->flags & ZEND_FFI_DCL_STORAGE_CLASS) yy_error_sym("unexpected", sym);
2085 				sym = get_sym();
2086 				dcl->flags |= ZEND_FFI_DCL_STATIC;
2087 				break;
2088 			case YY_AUTO:
2089 				if (dcl->flags & ZEND_FFI_DCL_STORAGE_CLASS) yy_error_sym("unexpected", sym);
2090 				sym = get_sym();
2091 				dcl->flags |= ZEND_FFI_DCL_AUTO;
2092 				break;
2093 			case YY_REGISTER:
2094 				if (dcl->flags & ZEND_FFI_DCL_STORAGE_CLASS) yy_error_sym("unexpected", sym);
2095 				sym = get_sym();
2096 				dcl->flags |= ZEND_FFI_DCL_REGISTER;
2097 				break;
2098 			case YY_INLINE:
2099 			case YY___INLINE:
2100 			case YY___INLINE__:
2101 				sym = get_sym();
2102 				dcl->flags |= ZEND_FFI_DCL_INLINE;
2103 				break;
2104 			case YY__NORETURN:
2105 				sym = get_sym();
2106 				dcl->flags |= ZEND_FFI_DCL_NO_RETURN;
2107 				break;
2108 			case YY__ALIGNAS:
2109 				sym = get_sym();
2110 				if (sym != YY__LPAREN) {
2111 					yy_error_sym("'(' expected, got", sym);
2112 				}
2113 				sym = get_sym();
2114 				if ((YY_IN_SET(sym, (YY___EXTENSION__,YY_VOID,YY_CHAR,YY_SHORT,YY_INT,YY_LONG,YY_FLOAT,YY_DOUBLE,YY_SIGNED,YY_UNSIGNED,YY__BOOL,YY__COMPLEX,YY_COMPLEX,YY___COMPLEX,YY___COMPLEX__,YY_STRUCT,YY_UNION,YY_ENUM,YY_ID,YY_CONST,YY___CONST,YY___CONST__,YY_RESTRICT,YY___RESTRICT,YY___RESTRICT__,YY_VOLATILE,YY___VOLATILE,YY___VOLATILE__,YY__ATOMIC,YY___ATTRIBUTE,YY___ATTRIBUTE__,YY___DECLSPEC,YY___CDECL,YY___STDCALL,YY___FASTCALL,YY___THISCALL,YY___VECTORCALL), "\002\000\376\377\377\107\360\017\000\000\000\002\000")) && synpred_1(sym)) {
2115 					zend_ffi_dcl align_dcl = ZEND_FFI_ATTR_INIT;
2116 					sym = parse_type_name(sym, &align_dcl);
2117 					zend_ffi_align_as_type(dcl, &align_dcl);
2118 				} else if (YY_IN_SET(sym, (YY__LPAREN,YY_ID,YY_OCTNUMBER,YY_DECNUMBER,YY_HEXNUMBER,YY_FLOATNUMBER,YY_STRING,YY_CHARACTER,YY__PLUS_PLUS,YY__MINUS_MINUS,YY__AND,YY__STAR,YY__PLUS,YY__MINUS,YY__TILDE,YY__BANG,YY_SIZEOF,YY__ALIGNOF,YY___ALIGNOF,YY___ALIGNOF__), "\010\000\000\000\000\000\001\000\004\030\377\376\000")) {
2119 					zend_ffi_val align_val;
2120 					sym = parse_constant_expression(sym, &align_val);
2121 					zend_ffi_align_as_val(dcl, &align_val);
2122 				} else {
2123 					yy_error_sym("unexpected", sym);
2124 				}
2125 				if (sym != YY__RPAREN) {
2126 					yy_error_sym("')' expected, got", sym);
2127 				}
2128 				sym = get_sym();
2129 				break;
2130 			case YY___ATTRIBUTE:
2131 			case YY___ATTRIBUTE__:
2132 			case YY___DECLSPEC:
2133 			case YY___CDECL:
2134 			case YY___STDCALL:
2135 			case YY___FASTCALL:
2136 			case YY___THISCALL:
2137 			case YY___VECTORCALL:
2138 				sym = parse_attributes(sym, dcl);
2139 				break;
2140 			case YY_CONST:
2141 			case YY___CONST:
2142 			case YY___CONST__:
2143 			case YY_RESTRICT:
2144 			case YY___RESTRICT:
2145 			case YY___RESTRICT__:
2146 			case YY_VOLATILE:
2147 			case YY___VOLATILE:
2148 			case YY___VOLATILE__:
2149 			case YY__ATOMIC:
2150 				sym = parse_type_qualifier(sym, dcl);
2151 				break;
2152 			case YY_VOID:
2153 			case YY_CHAR:
2154 			case YY_SHORT:
2155 			case YY_INT:
2156 			case YY_LONG:
2157 			case YY_FLOAT:
2158 			case YY_DOUBLE:
2159 			case YY_SIGNED:
2160 			case YY_UNSIGNED:
2161 			case YY__BOOL:
2162 			case YY__COMPLEX:
2163 			case YY_COMPLEX:
2164 			case YY___COMPLEX:
2165 			case YY___COMPLEX__:
2166 			case YY_STRUCT:
2167 			case YY_UNION:
2168 			case YY_ENUM:
2169 			case YY_ID:
2170 				sym = parse_type_specifier(sym, dcl);
2171 				break;
2172 			default:
2173 				yy_error_sym("unexpected", sym);
2174 		}
2175 	} while ((YY_IN_SET(sym, (YY_TYPEDEF,YY_EXTERN,YY_STATIC,YY_AUTO,YY_REGISTER,YY_INLINE,YY___INLINE,YY___INLINE__,YY__NORETURN,YY__ALIGNAS,YY___ATTRIBUTE,YY___ATTRIBUTE__,YY___DECLSPEC,YY___CDECL,YY___STDCALL,YY___FASTCALL,YY___THISCALL,YY___VECTORCALL,YY_CONST,YY___CONST,YY___CONST__,YY_RESTRICT,YY___RESTRICT,YY___RESTRICT__,YY_VOLATILE,YY___VOLATILE,YY___VOLATILE__,YY__ATOMIC,YY_VOID,YY_CHAR,YY_SHORT,YY_INT,YY_LONG,YY_FLOAT,YY_DOUBLE,YY_SIGNED,YY_UNSIGNED,YY__BOOL,YY__COMPLEX,YY_COMPLEX,YY___COMPLEX,YY___COMPLEX__,YY_STRUCT,YY_UNION,YY_ENUM,YY_ID), "\200\377\377\377\377\107\360\017\000\000\000\002\000")) && (sym != YY_ID || !(dcl->flags & ZEND_FFI_DCL_TYPE_SPECIFIERS)));
2176 	return sym;
2177 }
2178 
parse_specifier_qualifier_list(int sym,zend_ffi_dcl * dcl)2179 static int parse_specifier_qualifier_list(int sym, zend_ffi_dcl *dcl) {
2180 	if (sym == YY___EXTENSION__) {
2181 		sym = get_sym();
2182 	}
2183 	do {
2184 		if (YY_IN_SET(sym, (YY_VOID,YY_CHAR,YY_SHORT,YY_INT,YY_LONG,YY_FLOAT,YY_DOUBLE,YY_SIGNED,YY_UNSIGNED,YY__BOOL,YY__COMPLEX,YY_COMPLEX,YY___COMPLEX,YY___COMPLEX__,YY_STRUCT,YY_UNION,YY_ENUM,YY_ID), "\000\000\000\370\377\107\000\000\000\000\000\002\000")) {
2185 			sym = parse_type_specifier(sym, dcl);
2186 		} else if (YY_IN_SET(sym, (YY_CONST,YY___CONST,YY___CONST__,YY_RESTRICT,YY___RESTRICT,YY___RESTRICT__,YY_VOLATILE,YY___VOLATILE,YY___VOLATILE__,YY__ATOMIC), "\000\000\376\007\000\000\000\000\000\000\000\000\000")) {
2187 			sym = parse_type_qualifier(sym, dcl);
2188 		} else if (YY_IN_SET(sym, (YY___ATTRIBUTE,YY___ATTRIBUTE__,YY___DECLSPEC,YY___CDECL,YY___STDCALL,YY___FASTCALL,YY___THISCALL,YY___VECTORCALL), "\000\000\000\000\000\000\360\017\000\000\000\000\000")) {
2189 			sym = parse_attributes(sym, dcl);
2190 		} else {
2191 			yy_error_sym("unexpected", sym);
2192 		}
2193 	} while ((YY_IN_SET(sym, (YY_VOID,YY_CHAR,YY_SHORT,YY_INT,YY_LONG,YY_FLOAT,YY_DOUBLE,YY_SIGNED,YY_UNSIGNED,YY__BOOL,YY__COMPLEX,YY_COMPLEX,YY___COMPLEX,YY___COMPLEX__,YY_STRUCT,YY_UNION,YY_ENUM,YY_ID,YY_CONST,YY___CONST,YY___CONST__,YY_RESTRICT,YY___RESTRICT,YY___RESTRICT__,YY_VOLATILE,YY___VOLATILE,YY___VOLATILE__,YY__ATOMIC,YY___ATTRIBUTE,YY___ATTRIBUTE__,YY___DECLSPEC,YY___CDECL,YY___STDCALL,YY___FASTCALL,YY___THISCALL,YY___VECTORCALL), "\000\000\376\377\377\107\360\017\000\000\000\002\000")) && (sym != YY_ID || zend_ffi_is_typedef_name((const char*)yy_text, yy_pos - yy_text) || (dcl->flags & ZEND_FFI_DCL_TYPE_SPECIFIERS) == 0));
2194 	return sym;
2195 }
2196 
parse_type_qualifier_list(int sym,zend_ffi_dcl * dcl)2197 static int parse_type_qualifier_list(int sym, zend_ffi_dcl *dcl) {
2198 	do {
2199 		if (YY_IN_SET(sym, (YY_CONST,YY___CONST,YY___CONST__,YY_RESTRICT,YY___RESTRICT,YY___RESTRICT__,YY_VOLATILE,YY___VOLATILE,YY___VOLATILE__,YY__ATOMIC), "\000\000\376\007\000\000\000\000\000\000\000\000\000")) {
2200 			sym = parse_type_qualifier(sym, dcl);
2201 		} else if (YY_IN_SET(sym, (YY___ATTRIBUTE,YY___ATTRIBUTE__,YY___DECLSPEC,YY___CDECL,YY___STDCALL,YY___FASTCALL,YY___THISCALL,YY___VECTORCALL), "\000\000\000\000\000\000\360\017\000\000\000\000\000")) {
2202 			sym = parse_attributes(sym, dcl);
2203 		} else {
2204 			yy_error_sym("unexpected", sym);
2205 		}
2206 	} while (YY_IN_SET(sym, (YY_CONST,YY___CONST,YY___CONST__,YY_RESTRICT,YY___RESTRICT,YY___RESTRICT__,YY_VOLATILE,YY___VOLATILE,YY___VOLATILE__,YY__ATOMIC,YY___ATTRIBUTE,YY___ATTRIBUTE__,YY___DECLSPEC,YY___CDECL,YY___STDCALL,YY___FASTCALL,YY___THISCALL,YY___VECTORCALL), "\000\000\376\007\000\000\360\017\000\000\000\000\000"));
2207 	return sym;
2208 }
2209 
parse_type_qualifier(int sym,zend_ffi_dcl * dcl)2210 static int parse_type_qualifier(int sym, zend_ffi_dcl *dcl) {
2211 	if (sym == YY_CONST || sym == YY___CONST || sym == YY___CONST__) {
2212 		sym = get_sym();
2213 		dcl->flags |= ZEND_FFI_DCL_CONST;
2214 		dcl->attr |= ZEND_FFI_ATTR_CONST;
2215 	} else if (sym == YY_RESTRICT || sym == YY___RESTRICT || sym == YY___RESTRICT__) {
2216 		sym = get_sym();
2217 		dcl->flags |= ZEND_FFI_DCL_RESTRICT;
2218 	} else if (sym == YY_VOLATILE || sym == YY___VOLATILE || sym == YY___VOLATILE__) {
2219 		sym = get_sym();
2220 		dcl->flags |= ZEND_FFI_DCL_VOLATILE;
2221 	} else if (sym == YY__ATOMIC) {
2222 		sym = get_sym();
2223 		dcl->flags |= ZEND_FFI_DCL_ATOMIC;
2224 	} else {
2225 		yy_error_sym("unexpected", sym);
2226 	}
2227 	return sym;
2228 }
2229 
parse_type_specifier(int sym,zend_ffi_dcl * dcl)2230 static int parse_type_specifier(int sym, zend_ffi_dcl *dcl) {
2231 	const char *name;
2232 	size_t name_len;
2233 	switch (sym) {
2234 		case YY_VOID:
2235 			if (dcl->flags & ZEND_FFI_DCL_TYPE_SPECIFIERS) yy_error_sym("unexpected", sym);
2236 			sym = get_sym();
2237 			dcl->flags |= ZEND_FFI_DCL_VOID;
2238 			break;
2239 		case YY_CHAR:
2240 			if (dcl->flags & (ZEND_FFI_DCL_TYPE_SPECIFIERS-(ZEND_FFI_DCL_SIGNED|ZEND_FFI_DCL_UNSIGNED))) yy_error_sym("unexpected", sym);
2241 			sym = get_sym();
2242 			dcl->flags |= ZEND_FFI_DCL_CHAR;
2243 			break;
2244 		case YY_SHORT:
2245 			if (dcl->flags & (ZEND_FFI_DCL_TYPE_SPECIFIERS-(ZEND_FFI_DCL_SIGNED|ZEND_FFI_DCL_UNSIGNED|ZEND_FFI_DCL_INT))) yy_error_sym("unexpected", sym);
2246 			sym = get_sym();
2247 			dcl->flags |= ZEND_FFI_DCL_SHORT;
2248 			break;
2249 		case YY_INT:
2250 			if (dcl->flags & (ZEND_FFI_DCL_TYPE_SPECIFIERS-(ZEND_FFI_DCL_SIGNED|ZEND_FFI_DCL_UNSIGNED|ZEND_FFI_DCL_SHORT|ZEND_FFI_DCL_LONG|ZEND_FFI_DCL_LONG_LONG))) yy_error_sym("unexpected", sym);
2251 			sym = get_sym();
2252 			dcl->flags |= ZEND_FFI_DCL_INT;
2253 			break;
2254 		case YY_LONG:
2255 			if (dcl->flags & ZEND_FFI_DCL_LONG) {
2256 				if (dcl->flags & (ZEND_FFI_DCL_TYPE_SPECIFIERS-(ZEND_FFI_DCL_LONG|ZEND_FFI_DCL_SIGNED|ZEND_FFI_DCL_UNSIGNED|ZEND_FFI_DCL_INT))) yy_error_sym("unexpected", sym);
2257 				dcl->flags |= ZEND_FFI_DCL_LONG_LONG;
2258 			} else {
2259 				if (dcl->flags & (ZEND_FFI_DCL_TYPE_SPECIFIERS-(ZEND_FFI_DCL_LONG|ZEND_FFI_DCL_SIGNED|ZEND_FFI_DCL_UNSIGNED|ZEND_FFI_DCL_INT|ZEND_FFI_DCL_DOUBLE|ZEND_FFI_DCL_COMPLEX))) yy_error_sym("unexpected", sym);
2260 				dcl->flags |= ZEND_FFI_DCL_LONG;
2261 			}
2262 			sym = get_sym();
2263 			break;
2264 		case YY_FLOAT:
2265 			if (dcl->flags & (ZEND_FFI_DCL_TYPE_SPECIFIERS-(ZEND_FFI_DCL_COMPLEX))) yy_error_sym("unexpected", sym);
2266 			sym = get_sym();
2267 			dcl->flags |= ZEND_FFI_DCL_FLOAT;
2268 			break;
2269 		case YY_DOUBLE:
2270 			if (dcl->flags & (ZEND_FFI_DCL_TYPE_SPECIFIERS-(ZEND_FFI_DCL_LONG|ZEND_FFI_DCL_COMPLEX))) yy_error_sym("unexpected", sym);
2271 			sym = get_sym();
2272 			dcl->flags |= ZEND_FFI_DCL_DOUBLE;
2273 			break;
2274 		case YY_SIGNED:
2275 			if (dcl->flags & (ZEND_FFI_DCL_TYPE_SPECIFIERS-(ZEND_FFI_DCL_CHAR|ZEND_FFI_DCL_SHORT|ZEND_FFI_DCL_LONG|ZEND_FFI_DCL_LONG_LONG|ZEND_FFI_DCL_INT))) yy_error_sym("unexpected", sym);
2276 			sym = get_sym();
2277 			dcl->flags |= ZEND_FFI_DCL_SIGNED;
2278 			break;
2279 		case YY_UNSIGNED:
2280 			if (dcl->flags & (ZEND_FFI_DCL_TYPE_SPECIFIERS-(ZEND_FFI_DCL_CHAR|ZEND_FFI_DCL_SHORT|ZEND_FFI_DCL_LONG|ZEND_FFI_DCL_LONG_LONG|ZEND_FFI_DCL_INT))) yy_error_sym("unexpected", sym);
2281 			sym = get_sym();
2282 			dcl->flags |= ZEND_FFI_DCL_UNSIGNED;
2283 			break;
2284 		case YY__BOOL:
2285 			if (dcl->flags & ZEND_FFI_DCL_TYPE_SPECIFIERS) yy_error_sym("unexpected", sym);
2286 			sym = get_sym();
2287 			dcl->flags |= ZEND_FFI_DCL_BOOL;
2288 			break;
2289 		case YY__COMPLEX:
2290 		case YY_COMPLEX:
2291 		case YY___COMPLEX:
2292 		case YY___COMPLEX__:
2293 			if (dcl->flags & (ZEND_FFI_DCL_TYPE_SPECIFIERS-(ZEND_FFI_DCL_FLOAT|ZEND_FFI_DCL_DOUBLE|ZEND_FFI_DCL_LONG))) yy_error_sym("unexpected", sym);
2294 			sym = get_sym();
2295 			dcl->flags |= ZEND_FFI_DCL_COMPLEX;
2296 			break;
2297 		case YY_STRUCT:
2298 		case YY_UNION:
2299 			if (dcl->flags & ZEND_FFI_DCL_TYPE_SPECIFIERS) yy_error_sym("unexpected", sym);
2300 			sym = parse_struct_or_union_specifier(sym, dcl);
2301 			break;
2302 		case YY_ENUM:
2303 			if (dcl->flags & ZEND_FFI_DCL_TYPE_SPECIFIERS) yy_error_sym("unexpected", sym);
2304 			sym = parse_enum_specifier(sym, dcl);
2305 			break;
2306 		case YY_ID:
2307 			if (dcl->flags & ZEND_FFI_DCL_TYPE_SPECIFIERS) yy_error_sym("unexpected", sym);
2308 			/*redeclaration of '%.*s' ??? */
2309 			sym = parse_ID(sym, &name, &name_len);
2310 			dcl->flags |= ZEND_FFI_DCL_TYPEDEF_NAME;
2311 			zend_ffi_resolve_typedef(name, name_len, dcl);
2312 			break;
2313 		default:
2314 			yy_error_sym("unexpected", sym);
2315 	}
2316 	return sym;
2317 }
2318 
parse_struct_or_union_specifier(int sym,zend_ffi_dcl * dcl)2319 static int parse_struct_or_union_specifier(int sym, zend_ffi_dcl *dcl) {
2320 	if (sym == YY_STRUCT) {
2321 		sym = get_sym();
2322 		dcl->flags |= ZEND_FFI_DCL_STRUCT;
2323 	} else if (sym == YY_UNION) {
2324 		sym = get_sym();
2325 		dcl->flags |= ZEND_FFI_DCL_UNION;
2326 	} else {
2327 		yy_error_sym("unexpected", sym);
2328 	}
2329 	if (YY_IN_SET(sym, (YY___ATTRIBUTE,YY___ATTRIBUTE__,YY___DECLSPEC,YY___CDECL,YY___STDCALL,YY___FASTCALL,YY___THISCALL,YY___VECTORCALL), "\000\000\000\000\000\000\360\017\000\000\000\000\000")) {
2330 		sym = parse_attributes(sym, dcl);
2331 	}
2332 	if (sym == YY_ID) {
2333 		const char *name;
2334 		size_t name_len;
2335 		sym = parse_ID(sym, &name, &name_len);
2336 		zend_ffi_declare_tag(name, name_len, dcl, 1);
2337 		if (sym == YY__LBRACE) {
2338 			sym = parse_struct_contents(sym, dcl);
2339 			zend_ffi_declare_tag(name, name_len, dcl, 0);
2340 		}
2341 	} else if (sym == YY__LBRACE) {
2342 		zend_ffi_make_struct_type(dcl);
2343 		sym = parse_struct_contents(sym, dcl);
2344 	} else {
2345 		yy_error_sym("unexpected", sym);
2346 	}
2347 	return sym;
2348 }
2349 
parse_struct_contents(int sym,zend_ffi_dcl * dcl)2350 static int parse_struct_contents(int sym, zend_ffi_dcl *dcl) {
2351 	int   sym2;
2352 	const unsigned char *save_pos;
2353 	const unsigned char *save_text;
2354 	int   save_line;
2355 	int alt2;
2356 	if (sym != YY__LBRACE) {
2357 		yy_error_sym("'{' expected, got", sym);
2358 	}
2359 	sym = get_sym();
2360 	if (YY_IN_SET(sym, (YY___EXTENSION__,YY_VOID,YY_CHAR,YY_SHORT,YY_INT,YY_LONG,YY_FLOAT,YY_DOUBLE,YY_SIGNED,YY_UNSIGNED,YY__BOOL,YY__COMPLEX,YY_COMPLEX,YY___COMPLEX,YY___COMPLEX__,YY_STRUCT,YY_UNION,YY_ENUM,YY_ID,YY_CONST,YY___CONST,YY___CONST__,YY_RESTRICT,YY___RESTRICT,YY___RESTRICT__,YY_VOLATILE,YY___VOLATILE,YY___VOLATILE__,YY__ATOMIC,YY___ATTRIBUTE,YY___ATTRIBUTE__,YY___DECLSPEC,YY___CDECL,YY___STDCALL,YY___FASTCALL,YY___THISCALL,YY___VECTORCALL), "\002\000\376\377\377\107\360\017\000\000\000\002\000")) {
2361 		sym = parse_struct_declaration(sym, dcl);
2362 		while (1) {
2363 			save_pos  = yy_pos;
2364 			save_text = yy_text;
2365 			save_line = yy_line;
2366 			alt2 = -2;
2367 			sym2 = sym;
2368 			if (sym2 == YY__SEMICOLON) {
2369 				sym2 = get_sym();
2370 				goto _yy_state_2_1;
2371 			} else if (sym2 == YY__RBRACE) {
2372 				alt2 = 6;
2373 				goto _yy_state_2;
2374 			} else {
2375 				yy_error_sym("unexpected", sym2);
2376 			}
2377 _yy_state_2_1:
2378 			if (YY_IN_SET(sym2, (YY___EXTENSION__,YY_VOID,YY_CHAR,YY_SHORT,YY_INT,YY_LONG,YY_FLOAT,YY_DOUBLE,YY_SIGNED,YY_UNSIGNED,YY__BOOL,YY__COMPLEX,YY_COMPLEX,YY___COMPLEX,YY___COMPLEX__,YY_STRUCT,YY_UNION,YY_ENUM,YY_ID,YY_CONST,YY___CONST,YY___CONST__,YY_RESTRICT,YY___RESTRICT,YY___RESTRICT__,YY_VOLATILE,YY___VOLATILE,YY___VOLATILE__,YY__ATOMIC,YY___ATTRIBUTE,YY___ATTRIBUTE__,YY___DECLSPEC,YY___CDECL,YY___STDCALL,YY___FASTCALL,YY___THISCALL,YY___VECTORCALL), "\002\000\376\377\377\107\360\017\000\000\000\002\000")) {
2379 				alt2 = 3;
2380 				goto _yy_state_2;
2381 			} else if (sym2 == YY__RBRACE) {
2382 				alt2 = 5;
2383 				goto _yy_state_2;
2384 			} else {
2385 				yy_error_sym("unexpected", sym2);
2386 			}
2387 _yy_state_2:
2388 			yy_pos  = save_pos;
2389 			yy_text = save_text;
2390 			yy_line = save_line;
2391 			if (alt2 != 3) {
2392 				break;
2393 			}
2394 			sym = get_sym();
2395 			sym = parse_struct_declaration(sym, dcl);
2396 		}
2397 		if (alt2 == 5) {
2398 			sym = get_sym();
2399 		}
2400 	}
2401 	if (sym != YY__RBRACE) {
2402 		yy_error_sym("'}' expected, got", sym);
2403 	}
2404 	sym = get_sym();
2405 	if (YY_IN_SET(sym, (YY___ATTRIBUTE,YY___ATTRIBUTE__,YY___DECLSPEC,YY___CDECL,YY___STDCALL,YY___FASTCALL,YY___THISCALL,YY___VECTORCALL), "\000\000\000\000\000\000\360\017\000\000\000\000\000")) {
2406 		sym = parse_attributes(sym, dcl);
2407 	}
2408 	zend_ffi_adjust_struct_size(dcl);
2409 	return sym;
2410 }
2411 
parse_struct_declaration(int sym,zend_ffi_dcl * struct_dcl)2412 static int parse_struct_declaration(int sym, zend_ffi_dcl *struct_dcl) {
2413 	zend_ffi_dcl common_field_dcl = ZEND_FFI_ATTR_INIT;
2414 	sym = parse_specifier_qualifier_list(sym, &common_field_dcl);
2415 	if (sym == YY__SEMICOLON || sym == YY__RBRACE) {
2416 		zend_ffi_add_anonymous_field(struct_dcl, &common_field_dcl);
2417 	} else if (sym == YY__STAR || sym == YY_ID || sym == YY__LPAREN || sym == YY__COLON) {
2418 		sym = parse_struct_declarator(sym, struct_dcl, &common_field_dcl);
2419 		while (sym == YY__COMMA) {
2420 			sym = get_sym();
2421 			zend_ffi_dcl field_dcl = common_field_dcl;
2422 			if (YY_IN_SET(sym, (YY___ATTRIBUTE,YY___ATTRIBUTE__,YY___DECLSPEC,YY___CDECL,YY___STDCALL,YY___FASTCALL,YY___THISCALL,YY___VECTORCALL), "\000\000\000\000\000\000\360\017\000\000\000\000\000")) {
2423 				sym = parse_attributes(sym, &field_dcl);
2424 			}
2425 			sym = parse_struct_declarator(sym, struct_dcl, &field_dcl);
2426 		}
2427 	} else {
2428 		yy_error_sym("unexpected", sym);
2429 	}
2430 	return sym;
2431 }
2432 
parse_struct_declarator(int sym,zend_ffi_dcl * struct_dcl,zend_ffi_dcl * field_dcl)2433 static int parse_struct_declarator(int sym, zend_ffi_dcl *struct_dcl, zend_ffi_dcl *field_dcl) {
2434 	const char *name = NULL;
2435 	size_t name_len = 0;
2436 	zend_ffi_val bits;
2437 	if (sym == YY__STAR || sym == YY_ID || sym == YY__LPAREN) {
2438 		sym = parse_declarator(sym, field_dcl, &name, &name_len);
2439 		if (sym == YY__COLON) {
2440 			sym = get_sym();
2441 			sym = parse_constant_expression(sym, &bits);
2442 			if (YY_IN_SET(sym, (YY___ATTRIBUTE,YY___ATTRIBUTE__,YY___DECLSPEC,YY___CDECL,YY___STDCALL,YY___FASTCALL,YY___THISCALL,YY___VECTORCALL), "\000\000\000\000\000\000\360\017\000\000\000\000\000")) {
2443 				sym = parse_attributes(sym, field_dcl);
2444 			}
2445 			zend_ffi_add_bit_field(struct_dcl, name, name_len, field_dcl, &bits);
2446 		} else if (YY_IN_SET(sym, (YY___ATTRIBUTE,YY___ATTRIBUTE__,YY___DECLSPEC,YY___CDECL,YY___STDCALL,YY___FASTCALL,YY___THISCALL,YY___VECTORCALL,YY__COMMA,YY__SEMICOLON,YY__RBRACE), "\140\000\000\000\000\020\360\017\000\000\000\000\000")) {
2447 			if (YY_IN_SET(sym, (YY___ATTRIBUTE,YY___ATTRIBUTE__,YY___DECLSPEC,YY___CDECL,YY___STDCALL,YY___FASTCALL,YY___THISCALL,YY___VECTORCALL), "\000\000\000\000\000\000\360\017\000\000\000\000\000")) {
2448 				sym = parse_attributes(sym, field_dcl);
2449 			}
2450 			zend_ffi_add_field(struct_dcl, name, name_len, field_dcl);
2451 		} else {
2452 			yy_error_sym("unexpected", sym);
2453 		}
2454 	} else if (sym == YY__COLON) {
2455 		sym = get_sym();
2456 		sym = parse_constant_expression(sym, &bits);
2457 		zend_ffi_add_bit_field(struct_dcl, NULL, 0, field_dcl, &bits);
2458 	} else {
2459 		yy_error_sym("unexpected", sym);
2460 	}
2461 	return sym;
2462 }
2463 
parse_enum_specifier(int sym,zend_ffi_dcl * dcl)2464 static int parse_enum_specifier(int sym, zend_ffi_dcl *dcl) {
2465 	if (sym != YY_ENUM) {
2466 		yy_error_sym("'enum' expected, got", sym);
2467 	}
2468 	sym = get_sym();
2469 	dcl->flags |= ZEND_FFI_DCL_ENUM;
2470 	if (YY_IN_SET(sym, (YY___ATTRIBUTE,YY___ATTRIBUTE__,YY___DECLSPEC,YY___CDECL,YY___STDCALL,YY___FASTCALL,YY___THISCALL,YY___VECTORCALL), "\000\000\000\000\000\000\360\017\000\000\000\000\000")) {
2471 		sym = parse_attributes(sym, dcl);
2472 	}
2473 	if (sym == YY_ID) {
2474 		const char *name;
2475 		size_t name_len;
2476 		sym = parse_ID(sym, &name, &name_len);
2477 		if (sym == YY__LBRACE) {
2478 			zend_ffi_declare_tag(name, name_len, dcl, 0);
2479 			sym = get_sym();
2480 			sym = parse_enumerator_list(sym, dcl);
2481 			if (sym != YY__RBRACE) {
2482 				yy_error_sym("'}' expected, got", sym);
2483 			}
2484 			sym = get_sym();
2485 			if (YY_IN_SET(sym, (YY___ATTRIBUTE,YY___ATTRIBUTE__,YY___DECLSPEC,YY___CDECL,YY___STDCALL,YY___FASTCALL,YY___THISCALL,YY___VECTORCALL), "\000\000\000\000\000\000\360\017\000\000\000\000\000")) {
2486 				sym = parse_attributes(sym, dcl);
2487 			}
2488 		} else if (YY_IN_SET(sym, (YY_TYPEDEF,YY_EXTERN,YY_STATIC,YY_AUTO,YY_REGISTER,YY_INLINE,YY___INLINE,YY___INLINE__,YY__NORETURN,YY__ALIGNAS,YY___ATTRIBUTE,YY___ATTRIBUTE__,YY___DECLSPEC,YY___CDECL,YY___STDCALL,YY___FASTCALL,YY___THISCALL,YY___VECTORCALL,YY_CONST,YY___CONST,YY___CONST__,YY_RESTRICT,YY___RESTRICT,YY___RESTRICT__,YY_VOLATILE,YY___VOLATILE,YY___VOLATILE__,YY__ATOMIC,YY_VOID,YY_CHAR,YY_SHORT,YY_INT,YY_LONG,YY_FLOAT,YY_DOUBLE,YY_SIGNED,YY_UNSIGNED,YY__BOOL,YY__COMPLEX,YY_COMPLEX,YY___COMPLEX,YY___COMPLEX__,YY_STRUCT,YY_UNION,YY_ENUM,YY_ID,YY__STAR,YY__LPAREN,YY__SEMICOLON,YY__COLON,YY__LBRACK,YY__RBRACE,YY__COMMA,YY__RPAREN,YY_EOF), "\371\377\377\377\377\167\363\017\000\000\000\002\000")) {
2489 			zend_ffi_declare_tag(name, name_len, dcl, 1);
2490 		} else {
2491 			yy_error_sym("unexpected", sym);
2492 		}
2493 	} else if (sym == YY__LBRACE) {
2494 		sym = get_sym();
2495 		zend_ffi_make_enum_type(dcl);
2496 		sym = parse_enumerator_list(sym, dcl);
2497 		if (sym != YY__RBRACE) {
2498 			yy_error_sym("'}' expected, got", sym);
2499 		}
2500 		sym = get_sym();
2501 		if (YY_IN_SET(sym, (YY___ATTRIBUTE,YY___ATTRIBUTE__,YY___DECLSPEC,YY___CDECL,YY___STDCALL,YY___FASTCALL,YY___THISCALL,YY___VECTORCALL), "\000\000\000\000\000\000\360\017\000\000\000\000\000")) {
2502 			sym = parse_attributes(sym, dcl);
2503 		}
2504 	} else {
2505 		yy_error_sym("unexpected", sym);
2506 	}
2507 	return sym;
2508 }
2509 
parse_enumerator_list(int sym,zend_ffi_dcl * enum_dcl)2510 static int parse_enumerator_list(int sym, zend_ffi_dcl *enum_dcl) {
2511 	int   sym2;
2512 	const unsigned char *save_pos;
2513 	const unsigned char *save_text;
2514 	int   save_line;
2515 	int alt250;
2516 	int64_t min = 0, max = 0, last = -1;
2517 	sym = parse_enumerator(sym, enum_dcl, &min, &max, &last);
2518 	while (1) {
2519 		save_pos  = yy_pos;
2520 		save_text = yy_text;
2521 		save_line = yy_line;
2522 		alt250 = -2;
2523 		sym2 = sym;
2524 		if (sym2 == YY__COMMA) {
2525 			sym2 = get_sym();
2526 			goto _yy_state_250_1;
2527 		} else if (sym2 == YY__RBRACE) {
2528 			alt250 = -1;
2529 			goto _yy_state_250;
2530 		} else {
2531 			yy_error_sym("unexpected", sym2);
2532 		}
2533 _yy_state_250_1:
2534 		if (sym2 == YY_ID) {
2535 			alt250 = 251;
2536 			goto _yy_state_250;
2537 		} else if (sym2 == YY__RBRACE) {
2538 			alt250 = 253;
2539 			goto _yy_state_250;
2540 		} else {
2541 			yy_error_sym("unexpected", sym2);
2542 		}
2543 _yy_state_250:
2544 		yy_pos  = save_pos;
2545 		yy_text = save_text;
2546 		yy_line = save_line;
2547 		if (alt250 != 251) {
2548 			break;
2549 		}
2550 		sym = get_sym();
2551 		sym = parse_enumerator(sym, enum_dcl, &min, &max, &last);
2552 	}
2553 	if (alt250 == 253) {
2554 		sym = get_sym();
2555 	}
2556 	return sym;
2557 }
2558 
parse_enumerator(int sym,zend_ffi_dcl * enum_dcl,int64_t * min,int64_t * max,int64_t * last)2559 static int parse_enumerator(int sym, zend_ffi_dcl *enum_dcl, int64_t *min, int64_t *max, int64_t *last) {
2560 	const char *name;
2561 	size_t name_len;
2562 	zend_ffi_val val = {.kind = ZEND_FFI_VAL_EMPTY};
2563 	sym = parse_ID(sym, &name, &name_len);
2564 	if (sym == YY__EQUAL) {
2565 		sym = get_sym();
2566 		sym = parse_constant_expression(sym, &val);
2567 	}
2568 	zend_ffi_add_enum_val(enum_dcl, name, name_len, &val, min, max, last);
2569 	return sym;
2570 }
2571 
parse_declarator(int sym,zend_ffi_dcl * dcl,const char ** name,size_t * name_len)2572 static int parse_declarator(int sym, zend_ffi_dcl *dcl, const char **name, size_t *name_len) {
2573 	zend_ffi_dcl nested_dcl = {ZEND_FFI_DCL_CHAR, 0, 0, 0, NULL};
2574 	zend_bool nested = 0;
2575 	if (sym == YY__STAR) {
2576 		sym = parse_pointer(sym, dcl);
2577 	}
2578 	if (sym == YY_ID) {
2579 		sym = parse_ID(sym, name, name_len);
2580 	} else if (sym == YY__LPAREN) {
2581 		sym = get_sym();
2582 		if (YY_IN_SET(sym, (YY___ATTRIBUTE,YY___ATTRIBUTE__,YY___DECLSPEC,YY___CDECL,YY___STDCALL,YY___FASTCALL,YY___THISCALL,YY___VECTORCALL), "\000\000\000\000\000\000\360\017\000\000\000\000\000")) {
2583 			sym = parse_attributes(sym, &nested_dcl);
2584 		}
2585 		sym = parse_declarator(sym, &nested_dcl, name, name_len);
2586 		if (sym != YY__RPAREN) {
2587 			yy_error_sym("')' expected, got", sym);
2588 		}
2589 		sym = get_sym();
2590 		nested = 1;
2591 	} else {
2592 		yy_error_sym("unexpected", sym);
2593 	}
2594 	if (sym == YY__LBRACK || sym == YY__LPAREN) {
2595 		sym = parse_array_or_function_declarators(sym, dcl, &nested_dcl);
2596 	}
2597 	if (nested) zend_ffi_nested_declaration(dcl, &nested_dcl);
2598 	return sym;
2599 }
2600 
parse_abstract_declarator(int sym,zend_ffi_dcl * dcl)2601 static int parse_abstract_declarator(int sym, zend_ffi_dcl *dcl) {
2602 	zend_ffi_dcl nested_dcl = {ZEND_FFI_DCL_CHAR, 0, 0, 0, NULL};
2603 	zend_bool nested = 0;
2604 	if (sym == YY__STAR) {
2605 		sym = parse_pointer(sym, dcl);
2606 	}
2607 	if ((sym == YY__LPAREN) && synpred_2(sym)) {
2608 		sym = get_sym();
2609 		if (YY_IN_SET(sym, (YY___ATTRIBUTE,YY___ATTRIBUTE__,YY___DECLSPEC,YY___CDECL,YY___STDCALL,YY___FASTCALL,YY___THISCALL,YY___VECTORCALL), "\000\000\000\000\000\000\360\017\000\000\000\000\000")) {
2610 			sym = parse_attributes(sym, &nested_dcl);
2611 		}
2612 		sym = parse_abstract_declarator(sym, &nested_dcl);
2613 		if (sym != YY__RPAREN) {
2614 			yy_error_sym("')' expected, got", sym);
2615 		}
2616 		sym = get_sym();
2617 		nested = 1;
2618 	}
2619 	if (sym == YY__LBRACK || sym == YY__LPAREN) {
2620 		sym = parse_array_or_function_declarators(sym, dcl, &nested_dcl);
2621 	}
2622 	if (nested) zend_ffi_nested_declaration(dcl, &nested_dcl);
2623 	return sym;
2624 }
2625 
parse_parameter_declarator(int sym,zend_ffi_dcl * dcl,const char ** name,size_t * name_len)2626 static int parse_parameter_declarator(int sym, zend_ffi_dcl *dcl, const char **name, size_t *name_len) {
2627 	zend_ffi_dcl nested_dcl = {ZEND_FFI_DCL_CHAR, 0, 0, 0, NULL};
2628 	zend_bool nested = 0;
2629 	if (sym == YY__STAR) {
2630 		sym = parse_pointer(sym, dcl);
2631 	}
2632 	if ((sym == YY__LPAREN) && synpred_3(sym)) {
2633 		sym = get_sym();
2634 		if (YY_IN_SET(sym, (YY___ATTRIBUTE,YY___ATTRIBUTE__,YY___DECLSPEC,YY___CDECL,YY___STDCALL,YY___FASTCALL,YY___THISCALL,YY___VECTORCALL), "\000\000\000\000\000\000\360\017\000\000\000\000\000")) {
2635 			sym = parse_attributes(sym, &nested_dcl);
2636 		}
2637 		sym = parse_parameter_declarator(sym, &nested_dcl, name, name_len);
2638 		if (sym != YY__RPAREN) {
2639 			yy_error_sym("')' expected, got", sym);
2640 		}
2641 		sym = get_sym();
2642 		nested = 1;
2643 	} else if (sym == YY_ID) {
2644 		sym = parse_ID(sym, name, name_len);
2645 	} else if (sym == YY__LBRACK || sym == YY__LPAREN || sym == YY__RPAREN || sym == YY__COMMA) {
2646 	} else {
2647 		yy_error_sym("unexpected", sym);
2648 	}
2649 	if (sym == YY__LBRACK || sym == YY__LPAREN) {
2650 		sym = parse_array_or_function_declarators(sym, dcl, &nested_dcl);
2651 	}
2652 	if (nested) zend_ffi_nested_declaration(dcl, &nested_dcl);
2653 	return sym;
2654 }
2655 
parse_pointer(int sym,zend_ffi_dcl * dcl)2656 static int parse_pointer(int sym, zend_ffi_dcl *dcl) {
2657 	if (sym != YY__STAR) {
2658 		yy_error_sym("'*' expected, got", sym);
2659 	}
2660 	do {
2661 		sym = get_sym();
2662 		zend_ffi_make_pointer_type(dcl);
2663 		if (YY_IN_SET(sym, (YY_CONST,YY___CONST,YY___CONST__,YY_RESTRICT,YY___RESTRICT,YY___RESTRICT__,YY_VOLATILE,YY___VOLATILE,YY___VOLATILE__,YY__ATOMIC,YY___ATTRIBUTE,YY___ATTRIBUTE__,YY___DECLSPEC,YY___CDECL,YY___STDCALL,YY___FASTCALL,YY___THISCALL,YY___VECTORCALL), "\000\000\376\007\000\000\360\017\000\000\000\000\000")) {
2664 			sym = parse_type_qualifier_list(sym, dcl);
2665 		}
2666 	} while (sym == YY__STAR);
2667 	return sym;
2668 }
2669 
parse_array_or_function_declarators(int sym,zend_ffi_dcl * dcl,zend_ffi_dcl * nested_dcl)2670 static int parse_array_or_function_declarators(int sym, zend_ffi_dcl *dcl, zend_ffi_dcl *nested_dcl) {
2671 	int   sym2;
2672 	const unsigned char *save_pos;
2673 	const unsigned char *save_text;
2674 	int   save_line;
2675 	int alt109;
2676 	int alt105;
2677 	int alt119;
2678 	zend_ffi_dcl dummy = ZEND_FFI_ATTR_INIT;
2679 	zend_ffi_val len = {.kind = ZEND_FFI_VAL_EMPTY};
2680 	HashTable *args = NULL;
2681 	uint32_t attr = 0;
2682 	if (sym == YY__LBRACK) {
2683 		sym = get_sym();
2684 		save_pos  = yy_pos;
2685 		save_text = yy_text;
2686 		save_line = yy_line;
2687 		alt105 = -2;
2688 		sym2 = sym;
2689 		if (sym2 == YY_STATIC) {
2690 			alt105 = 106;
2691 			goto _yy_state_105;
2692 		} else if (YY_IN_SET(sym2, (YY_CONST,YY___CONST,YY___CONST__,YY_RESTRICT,YY___RESTRICT,YY___RESTRICT__,YY_VOLATILE,YY___VOLATILE,YY___VOLATILE__,YY__ATOMIC,YY___ATTRIBUTE,YY___ATTRIBUTE__,YY___DECLSPEC,YY___CDECL,YY___STDCALL,YY___FASTCALL,YY___THISCALL,YY___VECTORCALL), "\000\000\376\007\000\000\360\017\000\000\000\000\000")) {
2693 			alt105 = 109;
2694 			goto _yy_state_105;
2695 		} else if (sym2 == YY__STAR) {
2696 			sym2 = get_sym();
2697 			goto _yy_state_105_20;
2698 		} else if (YY_IN_SET(sym2, (YY__LPAREN,YY__PLUS_PLUS,YY__MINUS_MINUS,YY__AND,YY__PLUS,YY__MINUS,YY__TILDE,YY__BANG,YY_SIZEOF,YY__ALIGNOF,YY___ALIGNOF,YY___ALIGNOF__,YY_ID,YY_OCTNUMBER,YY_DECNUMBER,YY_HEXNUMBER,YY_FLOATNUMBER,YY_STRING,YY_CHARACTER), "\010\000\000\000\000\000\000\000\004\030\377\376\000")) {
2699 			alt105 = 115;
2700 			goto _yy_state_105;
2701 		} else if (sym2 == YY__RBRACK) {
2702 			alt105 = 116;
2703 			goto _yy_state_105;
2704 		} else {
2705 			yy_error_sym("unexpected", sym2);
2706 		}
2707 _yy_state_105_20:
2708 		if (sym2 == YY__RBRACK) {
2709 			alt105 = 114;
2710 			goto _yy_state_105;
2711 		} else if (YY_IN_SET(sym2, (YY__LPAREN,YY__PLUS_PLUS,YY__MINUS_MINUS,YY__AND,YY__PLUS,YY__MINUS,YY__TILDE,YY__BANG,YY_SIZEOF,YY__ALIGNOF,YY___ALIGNOF,YY___ALIGNOF__,YY_ID,YY_OCTNUMBER,YY_DECNUMBER,YY_HEXNUMBER,YY_FLOATNUMBER,YY_STRING,YY_CHARACTER,YY__STAR), "\010\000\000\000\000\000\001\000\004\030\377\376\000")) {
2712 			alt105 = 115;
2713 			goto _yy_state_105;
2714 		} else {
2715 			yy_error_sym("unexpected", sym2);
2716 		}
2717 _yy_state_105:
2718 		yy_pos  = save_pos;
2719 		yy_text = save_text;
2720 		yy_line = save_line;
2721 		if (alt105 == 106) {
2722 			sym = get_sym();
2723 			if (YY_IN_SET(sym, (YY_CONST,YY___CONST,YY___CONST__,YY_RESTRICT,YY___RESTRICT,YY___RESTRICT__,YY_VOLATILE,YY___VOLATILE,YY___VOLATILE__,YY__ATOMIC,YY___ATTRIBUTE,YY___ATTRIBUTE__,YY___DECLSPEC,YY___CDECL,YY___STDCALL,YY___FASTCALL,YY___THISCALL,YY___VECTORCALL), "\000\000\376\007\000\000\360\017\000\000\000\000\000")) {
2724 				sym = parse_type_qualifier_list(sym, &dummy);
2725 			}
2726 			sym = parse_assignment_expression(sym, &len);
2727 		} else if (alt105 == 109) {
2728 			sym = parse_type_qualifier_list(sym, &dummy);
2729 			save_pos  = yy_pos;
2730 			save_text = yy_text;
2731 			save_line = yy_line;
2732 			alt109 = -2;
2733 			sym2 = sym;
2734 			if (sym2 == YY_STATIC) {
2735 				alt109 = 110;
2736 				goto _yy_state_109;
2737 			} else if (sym2 == YY__STAR) {
2738 				sym2 = get_sym();
2739 				goto _yy_state_109_2;
2740 			} else if (YY_IN_SET(sym2, (YY__LPAREN,YY__PLUS_PLUS,YY__MINUS_MINUS,YY__AND,YY__PLUS,YY__MINUS,YY__TILDE,YY__BANG,YY_SIZEOF,YY__ALIGNOF,YY___ALIGNOF,YY___ALIGNOF__,YY_ID,YY_OCTNUMBER,YY_DECNUMBER,YY_HEXNUMBER,YY_FLOATNUMBER,YY_STRING,YY_CHARACTER), "\010\000\000\000\000\000\000\000\004\030\377\376\000")) {
2741 				alt109 = 113;
2742 				goto _yy_state_109;
2743 			} else if (sym2 == YY__RBRACK) {
2744 				alt109 = 116;
2745 				goto _yy_state_109;
2746 			} else {
2747 				yy_error_sym("unexpected", sym2);
2748 			}
2749 _yy_state_109_2:
2750 			if (sym2 == YY__RBRACK) {
2751 				alt109 = 112;
2752 				goto _yy_state_109;
2753 			} else if (YY_IN_SET(sym2, (YY__LPAREN,YY__PLUS_PLUS,YY__MINUS_MINUS,YY__AND,YY__PLUS,YY__MINUS,YY__TILDE,YY__BANG,YY_SIZEOF,YY__ALIGNOF,YY___ALIGNOF,YY___ALIGNOF__,YY_ID,YY_OCTNUMBER,YY_DECNUMBER,YY_HEXNUMBER,YY_FLOATNUMBER,YY_STRING,YY_CHARACTER,YY__STAR), "\010\000\000\000\000\000\001\000\004\030\377\376\000")) {
2754 				alt109 = 113;
2755 				goto _yy_state_109;
2756 			} else {
2757 				yy_error_sym("unexpected", sym2);
2758 			}
2759 _yy_state_109:
2760 			yy_pos  = save_pos;
2761 			yy_text = save_text;
2762 			yy_line = save_line;
2763 			if (alt109 == 110) {
2764 				sym = get_sym();
2765 				sym = parse_assignment_expression(sym, &len);
2766 			} else if (alt109 == 116) {
2767 				attr |= ZEND_FFI_ATTR_INCOMPLETE_ARRAY;
2768 			} else if (alt109 == 112) {
2769 				sym = get_sym();
2770 				attr |= ZEND_FFI_ATTR_VLA;
2771 			} else if (alt109 == 113) {
2772 				sym = parse_assignment_expression(sym, &len);
2773 			} else {
2774 				yy_error_sym("unexpected", sym);
2775 			}
2776 		} else if (alt105 == 116 || alt105 == 114 || alt105 == 115) {
2777 			if (alt105 == 116) {
2778 				attr |= ZEND_FFI_ATTR_INCOMPLETE_ARRAY;
2779 			} else if (alt105 == 114) {
2780 				sym = get_sym();
2781 				attr |= ZEND_FFI_ATTR_VLA;
2782 			} else {
2783 				sym = parse_assignment_expression(sym, &len);
2784 			}
2785 		} else {
2786 			yy_error_sym("unexpected", sym);
2787 		}
2788 		if (sym != YY__RBRACK) {
2789 			yy_error_sym("']' expected, got", sym);
2790 		}
2791 		sym = get_sym();
2792 		if (sym == YY__LBRACK || sym == YY__LPAREN) {
2793 			sym = parse_array_or_function_declarators(sym, dcl, nested_dcl);
2794 		}
2795 		dcl->attr |= attr;
2796 		zend_ffi_make_array_type(dcl, &len);
2797 	} else if (sym == YY__LPAREN) {
2798 		sym = get_sym();
2799 		if (YY_IN_SET(sym, (YY___EXTENSION__,YY_VOID,YY_CHAR,YY_SHORT,YY_INT,YY_LONG,YY_FLOAT,YY_DOUBLE,YY_SIGNED,YY_UNSIGNED,YY__BOOL,YY__COMPLEX,YY_COMPLEX,YY___COMPLEX,YY___COMPLEX__,YY_STRUCT,YY_UNION,YY_ENUM,YY_ID,YY_CONST,YY___CONST,YY___CONST__,YY_RESTRICT,YY___RESTRICT,YY___RESTRICT__,YY_VOLATILE,YY___VOLATILE,YY___VOLATILE__,YY__ATOMIC,YY___ATTRIBUTE,YY___ATTRIBUTE__,YY___DECLSPEC,YY___CDECL,YY___STDCALL,YY___FASTCALL,YY___THISCALL,YY___VECTORCALL,YY__POINT_POINT_POINT), "\002\000\376\377\377\107\370\017\000\000\000\002\000")) {
2800 			if (YY_IN_SET(sym, (YY___EXTENSION__,YY_VOID,YY_CHAR,YY_SHORT,YY_INT,YY_LONG,YY_FLOAT,YY_DOUBLE,YY_SIGNED,YY_UNSIGNED,YY__BOOL,YY__COMPLEX,YY_COMPLEX,YY___COMPLEX,YY___COMPLEX__,YY_STRUCT,YY_UNION,YY_ENUM,YY_ID,YY_CONST,YY___CONST,YY___CONST__,YY_RESTRICT,YY___RESTRICT,YY___RESTRICT__,YY_VOLATILE,YY___VOLATILE,YY___VOLATILE__,YY__ATOMIC,YY___ATTRIBUTE,YY___ATTRIBUTE__,YY___DECLSPEC,YY___CDECL,YY___STDCALL,YY___FASTCALL,YY___THISCALL,YY___VECTORCALL), "\002\000\376\377\377\107\360\017\000\000\000\002\000")) {
2801 				sym = parse_parameter_declaration(sym, &args);
2802 				while (1) {
2803 					save_pos  = yy_pos;
2804 					save_text = yy_text;
2805 					save_line = yy_line;
2806 					alt119 = -2;
2807 					sym2 = sym;
2808 					if (sym2 == YY__COMMA) {
2809 						sym2 = get_sym();
2810 						goto _yy_state_119_1;
2811 					} else if (sym2 == YY__RPAREN) {
2812 						alt119 = 125;
2813 						goto _yy_state_119;
2814 					} else {
2815 						yy_error_sym("unexpected", sym2);
2816 					}
2817 _yy_state_119_1:
2818 					if (YY_IN_SET(sym2, (YY___EXTENSION__,YY_VOID,YY_CHAR,YY_SHORT,YY_INT,YY_LONG,YY_FLOAT,YY_DOUBLE,YY_SIGNED,YY_UNSIGNED,YY__BOOL,YY__COMPLEX,YY_COMPLEX,YY___COMPLEX,YY___COMPLEX__,YY_STRUCT,YY_UNION,YY_ENUM,YY_ID,YY_CONST,YY___CONST,YY___CONST__,YY_RESTRICT,YY___RESTRICT,YY___RESTRICT__,YY_VOLATILE,YY___VOLATILE,YY___VOLATILE__,YY__ATOMIC,YY___ATTRIBUTE,YY___ATTRIBUTE__,YY___DECLSPEC,YY___CDECL,YY___STDCALL,YY___FASTCALL,YY___THISCALL,YY___VECTORCALL), "\002\000\376\377\377\107\360\017\000\000\000\002\000")) {
2819 						alt119 = 120;
2820 						goto _yy_state_119;
2821 					} else if (sym2 == YY__POINT_POINT_POINT) {
2822 						alt119 = 122;
2823 						goto _yy_state_119;
2824 					} else {
2825 						yy_error_sym("unexpected", sym2);
2826 					}
2827 _yy_state_119:
2828 					yy_pos  = save_pos;
2829 					yy_text = save_text;
2830 					yy_line = save_line;
2831 					if (alt119 != 120) {
2832 						break;
2833 					}
2834 					sym = get_sym();
2835 					sym = parse_parameter_declaration(sym, &args);
2836 				}
2837 				if (alt119 == 122) {
2838 					sym = get_sym();
2839 					if (sym != YY__POINT_POINT_POINT) {
2840 						yy_error_sym("'...' expected, got", sym);
2841 					}
2842 					sym = get_sym();
2843 					attr |= ZEND_FFI_ATTR_VARIADIC;
2844 				}
2845 			} else {
2846 				sym = get_sym();
2847 				attr |= ZEND_FFI_ATTR_VARIADIC;
2848 			}
2849 		}
2850 		if (sym != YY__RPAREN) {
2851 			yy_error_sym("')' expected, got", sym);
2852 		}
2853 		sym = get_sym();
2854 		if (sym == YY__LBRACK || sym == YY__LPAREN) {
2855 			sym = parse_array_or_function_declarators(sym, dcl, nested_dcl);
2856 		}
2857 		dcl->attr |= attr;
2858 		zend_ffi_make_func_type(dcl, args, nested_dcl);
2859 	} else {
2860 		yy_error_sym("unexpected", sym);
2861 	}
2862 	return sym;
2863 }
2864 
parse_parameter_declaration(int sym,HashTable ** args)2865 static int parse_parameter_declaration(int sym, HashTable **args) {
2866 	const char *name = NULL;
2867 	size_t name_len = 0;
2868 	zend_bool old_allow_vla = FFI_G(allow_vla);
2869 	FFI_G(allow_vla) = 1;
2870 	zend_ffi_dcl param_dcl = ZEND_FFI_ATTR_INIT;
2871 	sym = parse_specifier_qualifier_list(sym, &param_dcl);
2872 	sym = parse_parameter_declarator(sym, &param_dcl, &name, &name_len);
2873 	zend_ffi_add_arg(args, name, name_len, &param_dcl);
2874 	FFI_G(allow_vla) = old_allow_vla;
2875 	return sym;
2876 }
2877 
parse_type_name(int sym,zend_ffi_dcl * dcl)2878 static int parse_type_name(int sym, zend_ffi_dcl *dcl) {
2879 	sym = parse_specifier_qualifier_list(sym, dcl);
2880 	sym = parse_abstract_declarator(sym, dcl);
2881 	return sym;
2882 }
2883 
parse_attributes(int sym,zend_ffi_dcl * dcl)2884 static int parse_attributes(int sym, zend_ffi_dcl *dcl) {
2885 	const char *name;
2886 	size_t name_len;
2887 	zend_ffi_val val;
2888 	do {
2889 		switch (sym) {
2890 			case YY___ATTRIBUTE:
2891 			case YY___ATTRIBUTE__:
2892 				sym = get_sym();
2893 				if (sym != YY__LPAREN) {
2894 					yy_error_sym("'(' expected, got", sym);
2895 				}
2896 				sym = get_sym();
2897 				if (sym != YY__LPAREN) {
2898 					yy_error_sym("'(' expected, got", sym);
2899 				}
2900 				sym = get_sym();
2901 				sym = parse_attrib(sym, dcl);
2902 				while (sym == YY__COMMA) {
2903 					sym = get_sym();
2904 					sym = parse_attrib(sym, dcl);
2905 				}
2906 				if (sym != YY__RPAREN) {
2907 					yy_error_sym("')' expected, got", sym);
2908 				}
2909 				sym = get_sym();
2910 				if (sym != YY__RPAREN) {
2911 					yy_error_sym("')' expected, got", sym);
2912 				}
2913 				sym = get_sym();
2914 				break;
2915 			case YY___DECLSPEC:
2916 				sym = get_sym();
2917 				if (sym != YY__LPAREN) {
2918 					yy_error_sym("'(' expected, got", sym);
2919 				}
2920 				sym = get_sym();
2921 				do {
2922 					sym = parse_ID(sym, &name, &name_len);
2923 					if (sym == YY__LPAREN) {
2924 						sym = get_sym();
2925 						sym = parse_assignment_expression(sym, &val);
2926 						zend_ffi_add_msvc_attribute_value(dcl, name, name_len, &val);
2927 						if (sym != YY__RPAREN) {
2928 							yy_error_sym("')' expected, got", sym);
2929 						}
2930 						sym = get_sym();
2931 					}
2932 				} while (sym == YY_ID);
2933 				if (sym != YY__RPAREN) {
2934 					yy_error_sym("')' expected, got", sym);
2935 				}
2936 				sym = get_sym();
2937 				break;
2938 			case YY___CDECL:
2939 				sym = get_sym();
2940 				zend_ffi_set_abi(dcl, ZEND_FFI_ABI_CDECL);
2941 				break;
2942 			case YY___STDCALL:
2943 				sym = get_sym();
2944 				zend_ffi_set_abi(dcl, ZEND_FFI_ABI_STDCALL);
2945 				break;
2946 			case YY___FASTCALL:
2947 				sym = get_sym();
2948 				zend_ffi_set_abi(dcl, ZEND_FFI_ABI_FASTCALL);
2949 				break;
2950 			case YY___THISCALL:
2951 				sym = get_sym();
2952 				zend_ffi_set_abi(dcl, ZEND_FFI_ABI_THISCALL);
2953 				break;
2954 			case YY___VECTORCALL:
2955 				sym = get_sym();
2956 				zend_ffi_set_abi(dcl, ZEND_FFI_ABI_VECTORCALL);
2957 				break;
2958 			default:
2959 				yy_error_sym("unexpected", sym);
2960 		}
2961 	} while (YY_IN_SET(sym, (YY___ATTRIBUTE,YY___ATTRIBUTE__,YY___DECLSPEC,YY___CDECL,YY___STDCALL,YY___FASTCALL,YY___THISCALL,YY___VECTORCALL), "\000\000\000\000\000\000\360\017\000\000\000\000\000"));
2962 	return sym;
2963 }
2964 
parse_attrib(int sym,zend_ffi_dcl * dcl)2965 static int parse_attrib(int sym, zend_ffi_dcl *dcl) {
2966 	const char *name;
2967 	size_t name_len;
2968 	int n;
2969 	zend_ffi_val val;
2970 	zend_bool orig_attribute_parsing;
2971 	if (sym == YY_ID || sym == YY_CONST || sym == YY___CONST || sym == YY___CONST__) {
2972 		if (sym == YY_ID) {
2973 			sym = parse_ID(sym, &name, &name_len);
2974 			if (sym == YY__COMMA || sym == YY__RPAREN) {
2975 				zend_ffi_add_attribute(dcl, name, name_len);
2976 			} else if (sym == YY__LPAREN) {
2977 				sym = get_sym();
2978 				orig_attribute_parsing = FFI_G(attribute_parsing);
2979 				FFI_G(attribute_parsing) = 1;
2980 				sym = parse_assignment_expression(sym, &val);
2981 				zend_ffi_add_attribute_value(dcl, name, name_len, 0, &val);
2982 				n = 0;
2983 				while (sym == YY__COMMA) {
2984 					sym = get_sym();
2985 					sym = parse_assignment_expression(sym, &val);
2986 					zend_ffi_add_attribute_value(dcl, name, name_len, ++n, &val);
2987 				}
2988 				FFI_G(attribute_parsing) = orig_attribute_parsing;
2989 				if (sym != YY__RPAREN) {
2990 					yy_error_sym("')' expected, got", sym);
2991 				}
2992 				sym = get_sym();
2993 			} else {
2994 				yy_error_sym("unexpected", sym);
2995 			}
2996 		} else if (sym == YY_CONST) {
2997 			sym = get_sym();
2998 		} else if (sym == YY___CONST) {
2999 			sym = get_sym();
3000 		} else {
3001 			sym = get_sym();
3002 		}
3003 	}
3004 	return sym;
3005 }
3006 
parse_initializer(int sym)3007 static int parse_initializer(int sym) {
3008 	int   sym2;
3009 	const unsigned char *save_pos;
3010 	const unsigned char *save_text;
3011 	int   save_line;
3012 	int alt343;
3013 	zend_ffi_val dummy;
3014 	if (sym != YY__EQUAL) {
3015 		yy_error_sym("'=' expected, got", sym);
3016 	}
3017 	sym = get_sym();
3018 	if (YY_IN_SET(sym, (YY__LPAREN,YY_ID,YY_OCTNUMBER,YY_DECNUMBER,YY_HEXNUMBER,YY_FLOATNUMBER,YY_STRING,YY_CHARACTER,YY__PLUS_PLUS,YY__MINUS_MINUS,YY__AND,YY__STAR,YY__PLUS,YY__MINUS,YY__TILDE,YY__BANG,YY_SIZEOF,YY__ALIGNOF,YY___ALIGNOF,YY___ALIGNOF__), "\010\000\000\000\000\000\001\000\004\030\377\376\000")) {
3019 		sym = parse_assignment_expression(sym, &dummy);
3020 	} else if (sym == YY__LBRACE) {
3021 		sym = get_sym();
3022 		if (sym == YY__LBRACK || sym == YY__POINT) {
3023 			sym = parse_designation(sym);
3024 		}
3025 		sym = parse_initializer(sym);
3026 		while (1) {
3027 			save_pos  = yy_pos;
3028 			save_text = yy_text;
3029 			save_line = yy_line;
3030 			alt343 = -2;
3031 			sym2 = sym;
3032 			if (sym2 == YY__COMMA) {
3033 				sym2 = get_sym();
3034 				goto _yy_state_343_1;
3035 			} else if (sym2 == YY__RBRACE) {
3036 				alt343 = 348;
3037 				goto _yy_state_343;
3038 			} else {
3039 				yy_error_sym("unexpected", sym2);
3040 			}
3041 _yy_state_343_1:
3042 			if (sym2 == YY__LBRACK || sym2 == YY__POINT || sym2 == YY__EQUAL) {
3043 				alt343 = 344;
3044 				goto _yy_state_343;
3045 			} else if (sym2 == YY__RBRACE) {
3046 				alt343 = 347;
3047 				goto _yy_state_343;
3048 			} else {
3049 				yy_error_sym("unexpected", sym2);
3050 			}
3051 _yy_state_343:
3052 			yy_pos  = save_pos;
3053 			yy_text = save_text;
3054 			yy_line = save_line;
3055 			if (alt343 != 344) {
3056 				break;
3057 			}
3058 			sym = get_sym();
3059 			if (sym == YY__LBRACK || sym == YY__POINT) {
3060 				sym = parse_designation(sym);
3061 			}
3062 			sym = parse_initializer(sym);
3063 		}
3064 		if (alt343 == 347) {
3065 			sym = get_sym();
3066 		}
3067 		if (sym != YY__RBRACE) {
3068 			yy_error_sym("'}' expected, got", sym);
3069 		}
3070 		sym = get_sym();
3071 	} else {
3072 		yy_error_sym("unexpected", sym);
3073 	}
3074 	return sym;
3075 }
3076 
parse_designation(int sym)3077 static int parse_designation(int sym) {
3078 	const char *name;
3079 	size_t name_len;
3080 	zend_ffi_val dummy;
3081 	do {
3082 		if (sym == YY__LBRACK) {
3083 			sym = get_sym();
3084 			sym = parse_constant_expression(sym, &dummy);
3085 			if (sym != YY__RBRACK) {
3086 				yy_error_sym("']' expected, got", sym);
3087 			}
3088 			sym = get_sym();
3089 		} else if (sym == YY__POINT) {
3090 			sym = get_sym();
3091 			sym = parse_ID(sym, &name, &name_len);
3092 		} else {
3093 			yy_error_sym("unexpected", sym);
3094 		}
3095 	} while (sym == YY__LBRACK || sym == YY__POINT);
3096 	if (sym != YY__EQUAL) {
3097 		yy_error_sym("'=' expected, got", sym);
3098 	}
3099 	sym = get_sym();
3100 	return sym;
3101 }
3102 
parse_expr_list(int sym)3103 static int parse_expr_list(int sym) {
3104 	zend_ffi_val dummy;
3105 	sym = parse_assignment_expression(sym, &dummy);
3106 	while (sym == YY__COMMA) {
3107 		sym = get_sym();
3108 		sym = parse_assignment_expression(sym, &dummy);
3109 	}
3110 	return sym;
3111 }
3112 
parse_expression(int sym,zend_ffi_val * val)3113 static int parse_expression(int sym, zend_ffi_val *val) {
3114 	sym = parse_assignment_expression(sym, val);
3115 	while (sym == YY__COMMA) {
3116 		sym = get_sym();
3117 		sym = parse_assignment_expression(sym, val);
3118 	}
3119 	return sym;
3120 }
3121 
parse_assignment_expression(int sym,zend_ffi_val * val)3122 static int parse_assignment_expression(int sym, zend_ffi_val *val) {
3123 	sym = parse_conditional_expression(sym, val);
3124 	return sym;
3125 }
3126 
parse_constant_expression(int sym,zend_ffi_val * val)3127 static int parse_constant_expression(int sym, zend_ffi_val *val) {
3128 	sym = parse_conditional_expression(sym, val);
3129 	return sym;
3130 }
3131 
parse_conditional_expression(int sym,zend_ffi_val * val)3132 static int parse_conditional_expression(int sym, zend_ffi_val *val) {
3133 	zend_ffi_val op2, op3;
3134 	sym = parse_logical_or_expression(sym, val);
3135 	if (sym == YY__QUERY) {
3136 		sym = get_sym();
3137 		sym = parse_expression(sym, &op2);
3138 		if (sym != YY__COLON) {
3139 			yy_error_sym("':' expected, got", sym);
3140 		}
3141 		sym = get_sym();
3142 		sym = parse_conditional_expression(sym, &op3);
3143 		zend_ffi_expr_conditional(val, &op2, &op3);
3144 	}
3145 	return sym;
3146 }
3147 
parse_logical_or_expression(int sym,zend_ffi_val * val)3148 static int parse_logical_or_expression(int sym, zend_ffi_val *val) {
3149 	zend_ffi_val op2;
3150 	sym = parse_logical_and_expression(sym, val);
3151 	while (sym == YY__BAR_BAR) {
3152 		sym = get_sym();
3153 		sym = parse_logical_and_expression(sym, &op2);
3154 		zend_ffi_expr_bool_or(val, &op2);
3155 	}
3156 	return sym;
3157 }
3158 
parse_logical_and_expression(int sym,zend_ffi_val * val)3159 static int parse_logical_and_expression(int sym, zend_ffi_val *val) {
3160 	zend_ffi_val op2;
3161 	sym = parse_inclusive_or_expression(sym, val);
3162 	while (sym == YY__AND_AND) {
3163 		sym = get_sym();
3164 		sym = parse_inclusive_or_expression(sym, &op2);
3165 		zend_ffi_expr_bool_and(val, &op2);
3166 	}
3167 	return sym;
3168 }
3169 
parse_inclusive_or_expression(int sym,zend_ffi_val * val)3170 static int parse_inclusive_or_expression(int sym, zend_ffi_val *val) {
3171 	zend_ffi_val op2;
3172 	sym = parse_exclusive_or_expression(sym, val);
3173 	while (sym == YY__BAR) {
3174 		sym = get_sym();
3175 		sym = parse_exclusive_or_expression(sym, &op2);
3176 		zend_ffi_expr_bw_or(val, &op2);
3177 	}
3178 	return sym;
3179 }
3180 
parse_exclusive_or_expression(int sym,zend_ffi_val * val)3181 static int parse_exclusive_or_expression(int sym, zend_ffi_val *val) {
3182 	zend_ffi_val op2;
3183 	sym = parse_and_expression(sym, val);
3184 	while (sym == YY__UPARROW) {
3185 		sym = get_sym();
3186 		sym = parse_and_expression(sym, &op2);
3187 		zend_ffi_expr_bw_xor(val, &op2);
3188 	}
3189 	return sym;
3190 }
3191 
parse_and_expression(int sym,zend_ffi_val * val)3192 static int parse_and_expression(int sym, zend_ffi_val *val) {
3193 	zend_ffi_val op2;
3194 	sym = parse_equality_expression(sym, val);
3195 	while (sym == YY__AND) {
3196 		sym = get_sym();
3197 		sym = parse_equality_expression(sym, &op2);
3198 		zend_ffi_expr_bw_and(val, &op2);
3199 	}
3200 	return sym;
3201 }
3202 
parse_equality_expression(int sym,zend_ffi_val * val)3203 static int parse_equality_expression(int sym, zend_ffi_val *val) {
3204 	zend_ffi_val op2;
3205 	sym = parse_relational_expression(sym, val);
3206 	while (sym == YY__EQUAL_EQUAL || sym == YY__BANG_EQUAL) {
3207 		if (sym == YY__EQUAL_EQUAL) {
3208 			sym = get_sym();
3209 			sym = parse_relational_expression(sym, &op2);
3210 			zend_ffi_expr_is_equal(val, &op2);
3211 		} else {
3212 			sym = get_sym();
3213 			sym = parse_relational_expression(sym, &op2);
3214 			zend_ffi_expr_is_not_equal(val, &op2);
3215 		}
3216 	}
3217 	return sym;
3218 }
3219 
parse_relational_expression(int sym,zend_ffi_val * val)3220 static int parse_relational_expression(int sym, zend_ffi_val *val) {
3221 	zend_ffi_val op2;
3222 	sym = parse_shift_expression(sym, val);
3223 	while (sym == YY__LESS || sym == YY__GREATER || sym == YY__LESS_EQUAL || sym == YY__GREATER_EQUAL) {
3224 		if (sym == YY__LESS) {
3225 			sym = get_sym();
3226 			sym = parse_shift_expression(sym, &op2);
3227 			zend_ffi_expr_is_less(val, &op2);
3228 		} else if (sym == YY__GREATER) {
3229 			sym = get_sym();
3230 			sym = parse_shift_expression(sym, &op2);
3231 			zend_ffi_expr_is_greater(val, &op2);
3232 		} else if (sym == YY__LESS_EQUAL) {
3233 			sym = get_sym();
3234 			sym = parse_shift_expression(sym, &op2);
3235 			zend_ffi_expr_is_less_or_equal(val, &op2);
3236 		} else {
3237 			sym = get_sym();
3238 			sym = parse_shift_expression(sym, &op2);
3239 			zend_ffi_expr_is_greater_or_equal(val, &op2);
3240 		}
3241 	}
3242 	return sym;
3243 }
3244 
parse_shift_expression(int sym,zend_ffi_val * val)3245 static int parse_shift_expression(int sym, zend_ffi_val *val) {
3246 	zend_ffi_val op2;
3247 	sym = parse_additive_expression(sym, val);
3248 	while (sym == YY__LESS_LESS || sym == YY__GREATER_GREATER) {
3249 		if (sym == YY__LESS_LESS) {
3250 			sym = get_sym();
3251 			sym = parse_additive_expression(sym, &op2);
3252 			zend_ffi_expr_shift_left(val, &op2);
3253 		} else {
3254 			sym = get_sym();
3255 			sym = parse_additive_expression(sym, &op2);
3256 			zend_ffi_expr_shift_right(val, &op2);
3257 		}
3258 	}
3259 	return sym;
3260 }
3261 
parse_additive_expression(int sym,zend_ffi_val * val)3262 static int parse_additive_expression(int sym, zend_ffi_val *val) {
3263 	zend_ffi_val op2;
3264 	sym = parse_multiplicative_expression(sym, val);
3265 	while (sym == YY__PLUS || sym == YY__MINUS) {
3266 		if (sym == YY__PLUS) {
3267 			sym = get_sym();
3268 			sym = parse_multiplicative_expression(sym, &op2);
3269 			zend_ffi_expr_add(val, &op2);
3270 		} else {
3271 			sym = get_sym();
3272 			sym = parse_multiplicative_expression(sym, &op2);
3273 			zend_ffi_expr_sub(val, &op2);
3274 		}
3275 	}
3276 	return sym;
3277 }
3278 
parse_multiplicative_expression(int sym,zend_ffi_val * val)3279 static int parse_multiplicative_expression(int sym, zend_ffi_val *val) {
3280 	zend_ffi_val op2;
3281 	sym = parse_cast_expression(sym, val);
3282 	while (sym == YY__STAR || sym == YY__SLASH || sym == YY__PERCENT) {
3283 		if (sym == YY__STAR) {
3284 			sym = get_sym();
3285 			sym = parse_cast_expression(sym, &op2);
3286 			zend_ffi_expr_mul(val, &op2);
3287 		} else if (sym == YY__SLASH) {
3288 			sym = get_sym();
3289 			sym = parse_cast_expression(sym, &op2);
3290 			zend_ffi_expr_div(val, &op2);
3291 		} else {
3292 			sym = get_sym();
3293 			sym = parse_cast_expression(sym, &op2);
3294 			zend_ffi_expr_mod(val, &op2);
3295 		}
3296 	}
3297 	return sym;
3298 }
3299 
parse_cast_expression(int sym,zend_ffi_val * val)3300 static int parse_cast_expression(int sym, zend_ffi_val *val) {
3301 	int do_cast = 0;
3302 	zend_ffi_dcl dcl = ZEND_FFI_ATTR_INIT;
3303 	if ((sym == YY__LPAREN) && synpred_4(sym)) {
3304 		sym = get_sym();
3305 		sym = parse_type_name(sym, &dcl);
3306 		if (sym != YY__RPAREN) {
3307 			yy_error_sym("')' expected, got", sym);
3308 		}
3309 		sym = get_sym();
3310 		do_cast = 1;
3311 	}
3312 	sym = parse_unary_expression(sym, val);
3313 	if (do_cast) zend_ffi_expr_cast(val, &dcl);
3314 	return sym;
3315 }
3316 
parse_unary_expression(int sym,zend_ffi_val * val)3317 static int parse_unary_expression(int sym, zend_ffi_val *val) {
3318 	const char *name;
3319 	size_t name_len;
3320 	zend_ffi_dcl dcl = ZEND_FFI_ATTR_INIT;
3321 	switch (sym) {
3322 		case YY_ID:
3323 			sym = parse_ID(sym, &name, &name_len);
3324 			zend_ffi_resolve_const(name, name_len, val);
3325 			while (YY_IN_SET(sym, (YY__LBRACK,YY__LPAREN,YY__POINT,YY__MINUS_GREATER,YY__PLUS_PLUS,YY__MINUS_MINUS), "\010\000\000\000\000\000\002\020\000\200\003\000\000")) {
3326 				switch (sym) {
3327 					case YY__LBRACK:
3328 						sym = get_sym();
3329 						sym = parse_expr_list(sym);
3330 						if (sym != YY__RBRACK) {
3331 							yy_error_sym("']' expected, got", sym);
3332 						}
3333 						sym = get_sym();
3334 						break;
3335 					case YY__LPAREN:
3336 						sym = get_sym();
3337 						if (YY_IN_SET(sym, (YY__LPAREN,YY_ID,YY_OCTNUMBER,YY_DECNUMBER,YY_HEXNUMBER,YY_FLOATNUMBER,YY_STRING,YY_CHARACTER,YY__PLUS_PLUS,YY__MINUS_MINUS,YY__AND,YY__STAR,YY__PLUS,YY__MINUS,YY__TILDE,YY__BANG,YY_SIZEOF,YY__ALIGNOF,YY___ALIGNOF,YY___ALIGNOF__), "\010\000\000\000\000\000\001\000\004\030\377\376\000")) {
3338 							sym = parse_expr_list(sym);
3339 						}
3340 						if (sym != YY__RPAREN) {
3341 							yy_error_sym("')' expected, got", sym);
3342 						}
3343 						sym = get_sym();
3344 						break;
3345 					case YY__POINT:
3346 						sym = get_sym();
3347 						sym = parse_ID(sym, &name, &name_len);
3348 						break;
3349 					case YY__MINUS_GREATER:
3350 						sym = get_sym();
3351 						sym = parse_ID(sym, &name, &name_len);
3352 						break;
3353 					case YY__PLUS_PLUS:
3354 						sym = get_sym();
3355 						break;
3356 					default:
3357 						sym = get_sym();
3358 						break;
3359 				}
3360 				zend_ffi_val_error(val);
3361 			}
3362 			break;
3363 		case YY_OCTNUMBER:
3364 			sym = parse_OCTNUMBER(sym, val);
3365 			break;
3366 		case YY_DECNUMBER:
3367 			sym = parse_DECNUMBER(sym, val);
3368 			break;
3369 		case YY_HEXNUMBER:
3370 			sym = parse_HEXNUMBER(sym, val);
3371 			break;
3372 		case YY_FLOATNUMBER:
3373 			sym = parse_FLOATNUMBER(sym, val);
3374 			break;
3375 		case YY_STRING:
3376 			sym = parse_STRING(sym, val);
3377 			break;
3378 		case YY_CHARACTER:
3379 			sym = parse_CHARACTER(sym, val);
3380 			break;
3381 		case YY__LPAREN:
3382 			sym = get_sym();
3383 			sym = parse_expression(sym, val);
3384 			if (sym != YY__RPAREN) {
3385 				yy_error_sym("')' expected, got", sym);
3386 			}
3387 			sym = get_sym();
3388 			break;
3389 		case YY__PLUS_PLUS:
3390 			sym = get_sym();
3391 			sym = parse_unary_expression(sym, val);
3392 			zend_ffi_val_error(val);
3393 			break;
3394 		case YY__MINUS_MINUS:
3395 			sym = get_sym();
3396 			sym = parse_unary_expression(sym, val);
3397 			zend_ffi_val_error(val);
3398 			break;
3399 		case YY__AND:
3400 			sym = get_sym();
3401 			sym = parse_cast_expression(sym, val);
3402 			zend_ffi_val_error(val);
3403 			break;
3404 		case YY__STAR:
3405 			sym = get_sym();
3406 			sym = parse_cast_expression(sym, val);
3407 			zend_ffi_val_error(val);
3408 			break;
3409 		case YY__PLUS:
3410 			sym = get_sym();
3411 			sym = parse_cast_expression(sym, val);
3412 			zend_ffi_expr_plus(val);
3413 			break;
3414 		case YY__MINUS:
3415 			sym = get_sym();
3416 			sym = parse_cast_expression(sym, val);
3417 			zend_ffi_expr_neg(val);
3418 			break;
3419 		case YY__TILDE:
3420 			sym = get_sym();
3421 			sym = parse_cast_expression(sym, val);
3422 			zend_ffi_expr_bw_not(val);
3423 			break;
3424 		case YY__BANG:
3425 			sym = get_sym();
3426 			sym = parse_cast_expression(sym, val);
3427 			zend_ffi_expr_bool_not(val);
3428 			break;
3429 		case YY_SIZEOF:
3430 			sym = get_sym();
3431 			if ((sym == YY__LPAREN) && synpred_5(sym)) {
3432 				sym = get_sym();
3433 				sym = parse_type_name(sym, &dcl);
3434 				if (sym != YY__RPAREN) {
3435 					yy_error_sym("')' expected, got", sym);
3436 				}
3437 				sym = get_sym();
3438 				zend_ffi_expr_sizeof_type(val, &dcl);
3439 			} else if (YY_IN_SET(sym, (YY_ID,YY_OCTNUMBER,YY_DECNUMBER,YY_HEXNUMBER,YY_FLOATNUMBER,YY_STRING,YY_CHARACTER,YY__LPAREN,YY__PLUS_PLUS,YY__MINUS_MINUS,YY__AND,YY__STAR,YY__PLUS,YY__MINUS,YY__TILDE,YY__BANG,YY_SIZEOF,YY__ALIGNOF,YY___ALIGNOF,YY___ALIGNOF__), "\010\000\000\000\000\000\001\000\004\030\377\376\000")) {
3440 				sym = parse_unary_expression(sym, val);
3441 				zend_ffi_expr_sizeof_val(val);
3442 			} else {
3443 				yy_error_sym("unexpected", sym);
3444 			}
3445 			break;
3446 		case YY__ALIGNOF:
3447 			sym = get_sym();
3448 			if (sym != YY__LPAREN) {
3449 				yy_error_sym("'(' expected, got", sym);
3450 			}
3451 			sym = get_sym();
3452 			sym = parse_type_name(sym, &dcl);
3453 			if (sym != YY__RPAREN) {
3454 				yy_error_sym("')' expected, got", sym);
3455 			}
3456 			sym = get_sym();
3457 			zend_ffi_expr_alignof_type(val, &dcl);
3458 			break;
3459 		case YY___ALIGNOF:
3460 		case YY___ALIGNOF__:
3461 			sym = get_sym();
3462 			if ((sym == YY__LPAREN) && synpred_6(sym)) {
3463 				sym = get_sym();
3464 				sym = parse_type_name(sym, &dcl);
3465 				if (sym != YY__RPAREN) {
3466 					yy_error_sym("')' expected, got", sym);
3467 				}
3468 				sym = get_sym();
3469 				zend_ffi_expr_alignof_type(val, &dcl);
3470 			} else if (YY_IN_SET(sym, (YY_ID,YY_OCTNUMBER,YY_DECNUMBER,YY_HEXNUMBER,YY_FLOATNUMBER,YY_STRING,YY_CHARACTER,YY__LPAREN,YY__PLUS_PLUS,YY__MINUS_MINUS,YY__AND,YY__STAR,YY__PLUS,YY__MINUS,YY__TILDE,YY__BANG,YY_SIZEOF,YY__ALIGNOF,YY___ALIGNOF,YY___ALIGNOF__), "\010\000\000\000\000\000\001\000\004\030\377\376\000")) {
3471 				sym = parse_unary_expression(sym, val);
3472 				zend_ffi_expr_alignof_val(val);
3473 			} else {
3474 				yy_error_sym("unexpected", sym);
3475 			}
3476 			break;
3477 		default:
3478 			yy_error_sym("unexpected", sym);
3479 	}
3480 	return sym;
3481 }
3482 
parse_ID(int sym,const char ** name,size_t * name_len)3483 static int parse_ID(int sym, const char **name, size_t *name_len) {
3484 	if (sym != YY_ID) {
3485 		yy_error_sym("<ID> expected, got", sym);
3486 	}
3487 	*name = (const char*)yy_text; *name_len = yy_pos - yy_text;
3488 	sym = get_sym();
3489 	return sym;
3490 }
3491 
parse_OCTNUMBER(int sym,zend_ffi_val * val)3492 static int parse_OCTNUMBER(int sym, zend_ffi_val *val) {
3493 	if (sym != YY_OCTNUMBER) {
3494 		yy_error_sym("<OCTNUMBER> expected, got", sym);
3495 	}
3496 	zend_ffi_val_number(val, 8, (const char*)yy_text, yy_pos - yy_text);
3497 	sym = get_sym();
3498 	return sym;
3499 }
3500 
parse_DECNUMBER(int sym,zend_ffi_val * val)3501 static int parse_DECNUMBER(int sym, zend_ffi_val *val) {
3502 	if (sym != YY_DECNUMBER) {
3503 		yy_error_sym("<DECNUMBER> expected, got", sym);
3504 	}
3505 	zend_ffi_val_number(val, 10, (const char*)yy_text, yy_pos - yy_text);
3506 	sym = get_sym();
3507 	return sym;
3508 }
3509 
parse_HEXNUMBER(int sym,zend_ffi_val * val)3510 static int parse_HEXNUMBER(int sym, zend_ffi_val *val) {
3511 	if (sym != YY_HEXNUMBER) {
3512 		yy_error_sym("<HEXNUMBER> expected, got", sym);
3513 	}
3514 	zend_ffi_val_number(val, 16, (const char*)yy_text + 2, yy_pos - yy_text - 2);
3515 	sym = get_sym();
3516 	return sym;
3517 }
3518 
parse_FLOATNUMBER(int sym,zend_ffi_val * val)3519 static int parse_FLOATNUMBER(int sym, zend_ffi_val *val) {
3520 	if (sym != YY_FLOATNUMBER) {
3521 		yy_error_sym("<FLOATNUMBER> expected, got", sym);
3522 	}
3523 	zend_ffi_val_float_number(val, (const char*)yy_text, yy_pos - yy_text);
3524 	sym = get_sym();
3525 	return sym;
3526 }
3527 
parse_STRING(int sym,zend_ffi_val * val)3528 static int parse_STRING(int sym, zend_ffi_val *val) {
3529 	if (sym != YY_STRING) {
3530 		yy_error_sym("<STRING> expected, got", sym);
3531 	}
3532 	zend_ffi_val_string(val, (const char*)yy_text, yy_pos - yy_text);
3533 	sym = get_sym();
3534 	return sym;
3535 }
3536 
parse_CHARACTER(int sym,zend_ffi_val * val)3537 static int parse_CHARACTER(int sym, zend_ffi_val *val) {
3538 	if (sym != YY_CHARACTER) {
3539 		yy_error_sym("<CHARACTER> expected, got", sym);
3540 	}
3541 	zend_ffi_val_character(val, (const char*)yy_text, yy_pos - yy_text);
3542 	sym = get_sym();
3543 	return sym;
3544 }
3545 
parse(void)3546 static void parse(void) {
3547 	int sym;
3548 
3549 	yy_pos = yy_text = yy_buf;
3550 	yy_line = 1;
3551 	sym = parse_declarations(get_sym());
3552 	if (sym != YY_EOF) {
3553 		yy_error_sym("<EOF> expected, got", sym);
3554 	}
3555 }
3556 
zend_ffi_parse_decl(const char * str,size_t len)3557 int zend_ffi_parse_decl(const char *str, size_t len) {
3558 	if (SETJMP(FFI_G(bailout))==0) {
3559 		FFI_G(allow_vla) = 0;
3560 		FFI_G(attribute_parsing) = 0;
3561 		yy_buf = (unsigned char*)str;
3562 		yy_end = yy_buf + len;
3563 		parse();
3564 		return SUCCESS;
3565 	} else {
3566 		return FAILURE;
3567 	}
3568 }
3569 
zend_ffi_parse_type(const char * str,size_t len,zend_ffi_dcl * dcl)3570 int zend_ffi_parse_type(const char *str, size_t len, zend_ffi_dcl *dcl) {
3571 	int sym;
3572 
3573 	if (SETJMP(FFI_G(bailout))==0) {
3574 		FFI_G(allow_vla) = 0;
3575 		FFI_G(attribute_parsing) = 0;
3576 		yy_pos = yy_text = yy_buf = (unsigned char*)str;
3577 		yy_end = yy_buf + len;
3578 		yy_line = 1;
3579 		sym = parse_type_name(get_sym(), dcl);
3580 		if (sym != YY_EOF) {
3581 			yy_error_sym("<EOF> expected, got", sym);
3582 		}
3583 		zend_ffi_validate_type_name(dcl);
3584 		return SUCCESS;
3585 	} else {
3586 		return FAILURE;
3587 	};
3588 }
3589 
yy_error(const char * msg)3590 static void yy_error(const char *msg) {
3591 	zend_ffi_parser_error("%s at line %d", msg, yy_line);
3592 }
3593 
yy_error_sym(const char * msg,int sym)3594 static void yy_error_sym(const char *msg, int sym) {
3595 	zend_ffi_parser_error("%s '%s' at line %d", msg, sym_name[sym], yy_line);
3596 }
3597