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