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