7 %token IDENTIFIER CONSTANT STRING_LITERAL MACRO SIZEOF
8 %token PTR_OP INC_OP DEC_OP LEFT_OP RIGHT_OP LE_OP GE_OP EQ_OP NE_OP
9 %token AND_OP OR_OP MUL_ASSIGN DIV_ASSIGN MOD_ASSIGN ADD_ASSIGN
10 %token SUB_ASSIGN LEFT_ASSIGN RIGHT_ASSIGN AND_ASSIGN
11 %token XOR_ASSIGN OR_ASSIGN TYPE_NAME
13 %token TYPEDEF EXTERN INLINE STATIC AUTO REGISTER RESTRICT
14 %token CHAR SHORT INT LONG SIGNED UNSIGNED FLOAT DOUBLE CONST VOLATILE VOID
15 %token BOOL COMPLEX IMAGINARY
16 %token STRUCT UNION ENUM ELIPSIS RANGE
18 %token CASE DEFAULT IF ELSE SWITCH WHILE DO FOR GOTO CONTINUE BREAK RETURN
20 %start translation_unit
26 { push_node
(AST_INTEGER
, @$.start
, @$.end
, 0); }
28 { push_node
(AST_STRING
, @$.start
, @$.end
, 0); }
33 : joined_string STRING_LITERAL
39 | postfix_expr
'[' expr
']'
40 { push_node
(AST_GETINDEX
, @$.start
, @$.end
, 2); }
41 | postfix_expr
'(' ')'
42 { push_node
(AST_CALL
, @$.start
, @$.end
, 1); }
43 | postfix_expr
'(' argument_expr_list
')'
44 { push_node
(AST_CALL
, @$.start
, @$.end
, 2); }
45 | postfix_expr
'.' identifier
46 { push_node
(AST_GETATTR
, @$.start
, @$.end
, 2); }
47 | postfix_expr PTR_OP identifier
48 { push_node
(AST_DEREF
, @$.start
, @$.end
, 2); }
50 { push_node
(AST_UNARY
, @$.start
, @$.end
, 1); }
52 { push_node
(AST_UNARY
, @$.start
, @$.end
, 1); }
53 |
'(' type_name
')' '{' initializer_list
'}'
54 { push_node
(AST_C99INIT
, @$.start
, @$.end
, 2); }
55 |
'(' type_name
')' '{' initializer_list
',' '}'
56 { push_node
(AST_C99INIT
, @$.start
, @$.end
, 2); }
61 { push_node
(AST_ARGLIST
, @$.start
, @$.end
, 1); }
62 | argument_expr_list
',' assignment_expr
63 { push_node
(AST_ARGLIST
, @$.start
, @$.end
, 2); }
69 { push_node
(AST_UNARY
, @$.start
, @$.end
, 1); }
71 { push_node
(AST_UNARY
, @$.start
, @$.end
, 1); }
72 | unary_operator cast_expr
73 { push_node
(AST_UNARY
, @$.start
, @$.end
, 2); }
75 { push_node
(AST_SIZEOF
, @$.start
, @$.end
, 1); }
76 | SIZEOF
'(' type_name
')'
77 { push_node
(AST_SIZEOF
, @$.start
, @$.end
, 1); }
82 { push_node
(AST_UNARYOP
, @$.start
, @$.end
, 0); }
84 { push_node
(AST_UNARYOP
, @$.start
, @$.end
, 0); }
86 { push_node
(AST_UNARYOP
, @$.start
, @$.end
, 0); }
88 { push_node
(AST_UNARYOP
, @$.start
, @$.end
, 0); }
90 { push_node
(AST_UNARYOP
, @$.start
, @$.end
, 0); }
92 { push_node
(AST_UNARYOP
, @$.start
, @$.end
, 0); }
97 |
'(' type_name
')' cast_expr
98 { push_node
(AST_CAST
, @$.start
, @$.end
, 2); }
103 | multiplicative_expr
'*' cast_expr
104 { push_node
(AST_BINARY
, @$.start
, @$.end
, 2); }
105 | multiplicative_expr
'/' cast_expr
106 { push_node
(AST_BINARY
, @$.start
, @$.end
, 2); }
107 | multiplicative_expr
'%' cast_expr
108 { push_node
(AST_BINARY
, @$.start
, @$.end
, 2); }
112 : multiplicative_expr
113 | additive_expr
'+' multiplicative_expr
114 { push_node
(AST_BINARY
, @$.start
, @$.end
, 2); }
115 | additive_expr
'-' multiplicative_expr
116 { push_node
(AST_BINARY
, @$.start
, @$.end
, 2); }
121 | shift_expr LEFT_OP additive_expr
122 { push_node
(AST_BINARY
, @$.start
, @$.end
, 2); }
123 | shift_expr RIGHT_OP additive_expr
124 { push_node
(AST_BINARY
, @$.start
, @$.end
, 2); }
129 | relational_expr
'<' shift_expr
130 { push_node
(AST_BINARY
, @$.start
, @$.end
, 2); }
131 | relational_expr
'>' shift_expr
132 { push_node
(AST_BINARY
, @$.start
, @$.end
, 2); }
133 | relational_expr LE_OP shift_expr
134 { push_node
(AST_BINARY
, @$.start
, @$.end
, 2); }
135 | relational_expr GE_OP shift_expr
136 { push_node
(AST_BINARY
, @$.start
, @$.end
, 2); }
141 | equality_expr EQ_OP relational_expr
142 { push_node
(AST_BINARY
, @$.start
, @$.end
, 2); }
143 | equality_expr NE_OP relational_expr
144 { push_node
(AST_BINARY
, @$.start
, @$.end
, 2); }
149 | and_expr
'&' equality_expr
150 { push_node
(AST_BINARY
, @$.start
, @$.end
, 2); }
155 | exclusive_or_expr
'^' and_expr
156 { push_node
(AST_BINARY
, @$.start
, @$.end
, 2); }
161 | inclusive_or_expr
'|' exclusive_or_expr
162 { push_node
(AST_BINARY
, @$.start
, @$.end
, 2); }
167 | logical_and_expr AND_OP inclusive_or_expr
168 { push_node
(AST_BINARY
, @$.start
, @$.end
, 2); }
173 | logical_or_expr OR_OP logical_and_expr
174 { push_node
(AST_BINARY
, @$.start
, @$.end
, 2); }
179 | logical_or_expr
'?' logical_or_expr
':' conditional_expr
180 { push_node
(AST_CONDITIONAL
, @$.start
, @$.end
, 3); }
185 | unary_expr assignment_operator assignment_expr
186 { push_node
(AST_ASSIGN
, @$.start
, @$.end
, 2); }
205 { push_node
(AST_EXPRLIST
, @$.start
, @$.end
, 1); }
206 | expr
',' assignment_expr
207 { push_node
(AST_EXPRLIST
, @$.start
, @$.end
, 2); }
215 : declaration_specifiers
';'
216 { push_node
(AST_DECLSTMT
, @$.start
, @$.end
, 1); }
217 | declaration_specifiers init_declarator_list
';'
218 { push_node
(AST_DECLSTMT
, @$.start
, @$.end
, 2); }
221 declaration_specifiers
222 : storage_class_specifier
223 { push_node
(AST_DECLSPEC
, @$.start
, @$.end
, 1); }
224 | storage_class_specifier declaration_specifiers
225 { push_node
(AST_DECLSPEC
, @$.start
, @$.end
, 2); }
227 { push_node
(AST_DECLSPEC
, @$.start
, @$.end
, 1); }
228 | type_specifier declaration_specifiers
229 { push_node
(AST_DECLSPEC
, @$.start
, @$.end
, 2); }
231 { push_node
(AST_DECLSPEC
, @$.start
, @$.end
, 1); }
232 | type_qualifier declaration_specifiers
233 { push_node
(AST_DECLSPEC
, @$.start
, @$.end
, 2); }
235 { push_node
(AST_DECLSPEC
, @$.start
, @$.end
, 1); }
236 | function_specifier declaration_specifiers
237 { push_node
(AST_DECLSPEC
, @$.start
, @$.end
, 2); }
242 { push_node
(AST_INITLIST
, @$.start
, @$.end
, 1); }
243 | init_declarator_list
',' init_declarator
244 { push_node
(AST_INITLIST
, @$.start
, @$.end
, 2); }
249 | declarator
'=' initializer
250 { push_node
(AST_INIT
, @$.start
, @$.end
, 2); }
253 storage_class_specifier
255 { push_node
(AST_TYPEDEFKW
, @$.start
, @$.end
, 0); }
257 { push_node
(AST_EXTERNKW
, @$.start
, @$.end
, 0); }
259 { push_node
(AST_STATICKW
, @$.start
, @$.end
, 0); }
261 { push_node
(AST_AUTOKW
, @$.start
, @$.end
, 0); }
263 { push_node
(AST_REGISTERKW
, @$.start
, @$.end
, 0); }
268 { push_node
(AST_TYPE
, @$.start
, @$.end
, 0); }
270 { push_node
(AST_TYPE
, @$.start
, @$.end
, 0); }
272 { push_node
(AST_TYPE
, @$.start
, @$.end
, 0); }
274 { push_node
(AST_TYPE
, @$.start
, @$.end
, 0); }
276 { push_node
(AST_TYPE
, @$.start
, @$.end
, 0); }
278 { push_node
(AST_TYPE
, @$.start
, @$.end
, 0); }
280 { push_node
(AST_TYPE
, @$.start
, @$.end
, 0); }
282 { push_node
(AST_TYPE
, @$.start
, @$.end
, 0); }
284 { push_node
(AST_TYPE
, @$.start
, @$.end
, 0); }
286 { push_node
(AST_TYPE
, @$.start
, @$.end
, 0); }
288 { push_node
(AST_TYPE
, @$.start
, @$.end
, 0); }
289 | struct_or_union_specifier
290 { push_node
(AST_TYPE
, @$.start
, @$.end
, 1); }
292 { push_node
(AST_TYPE
, @$.start
, @$.end
, 1); }
294 { push_node_name
(AST_TYPENAME
, @$.start
, @$.end
, $1); }
297 struct_or_union_specifier
298 : struct_or_union identifier
'{' struct_declaration_list
'}'
299 { push_node
(AST_STRUCT
, @$.start
, @$.end
, 3); }
300 | struct_or_union
'{' struct_declaration_list
'}'
301 { push_node
(AST_STRUCT
, @$.start
, @$.end
, 2); }
302 | struct_or_union identifier
303 { push_node
(AST_STRUCT
, @$.start
, @$.end
, 2); }
308 { push_node
(AST_STRUCTKW
, @$.start
, @$.end
, 0); }
310 { push_node
(AST_UNIONKW
, @$.start
, @$.end
, 0); }
313 struct_declaration_list
315 { push_node
(AST_STRUCTLIST
, @$.start
, @$.end
, 1); }
316 | struct_declaration_list struct_declaration
317 { push_node
(AST_STRUCTLIST
, @$.start
, @$.end
, 2); }
321 : specifier_qualifier_list struct_declarator_list
';'
322 { push_node
(AST_STRUCTDECL
, @$.start
, @$.end
, 2); }
325 specifier_qualifier_list
327 { push_node
(AST_STRUCTQUALLIST
, @$.start
, @$.end
, 1); }
328 | type_specifier specifier_qualifier_list
329 { push_node
(AST_STRUCTQUALLIST
, @$.start
, @$.end
, 2); }
331 { push_node
(AST_STRUCTQUALLIST
, @$.start
, @$.end
, 1); }
332 | type_qualifier specifier_qualifier_list
333 { push_node
(AST_STRUCTQUALLIST
, @$.start
, @$.end
, 2); }
336 struct_declarator_list
338 { push_node
(AST_STRUCTDECLLIST
, @$.start
, @$.end
, 1); }
339 | struct_declarator_list
',' struct_declarator
340 { push_node
(AST_STRUCTDECLLIST
, @$.start
, @$.end
, 2); }
346 { push_node
(AST_STRUCTBITS
, @$.start
, @$.end
, 2); }
347 | declarator
':' constant_expr
348 { push_node
(AST_STRUCTBITS
, @$.start
, @$.end
, 2); }
352 : ENUM
'{' enumerator_list
'}'
353 { push_node
(AST_ENUM
, @$.start
, @$.end
, 1); }
354 | ENUM identifier
'{' enumerator_list
'}'
355 { push_node
(AST_ENUM
, @$.start
, @$.end
, 2); }
356 | ENUM
'{' enumerator_list
',' '}'
357 { push_node
(AST_ENUM
, @$.start
, @$.end
, 1); }
358 | ENUM identifier
'{' enumerator_list
',' '}'
359 { push_node
(AST_ENUM
, @$.start
, @$.end
, 2); }
361 { push_node
(AST_ENUM
, @$.start
, @$.end
, 1); }
366 { push_node
(AST_ENUMLIST
, @$.start
, @$.end
, 1); }
367 | enumerator_list
',' enumerator
368 { push_node
(AST_ENUMLIST
, @$.start
, @$.end
, 2); }
373 { push_node
(AST_ENUMVAL
, @$.start
, @$.end
, 1); }
374 | identifier
'=' constant_expr
375 { push_node
(AST_ENUMVAL
, @$.start
, @$.end
, 2); }
380 { push_node
(AST_TYPEQUAL
, @$.start
, @$.end
, 0); }
382 { push_node
(AST_TYPEQUAL
, @$.start
, @$.end
, 0); }
384 { push_node
(AST_TYPEQUAL
, @$.start
, @$.end
, 0); }
389 { push_node
(AST_FUNCSPEC
, @$.start
, @$.end
, 0); }
394 { push_node
(AST_DECL
, @$.start
, @$.end
, 1); }
395 | pointer direct_declarator
396 { push_node
(AST_DECL
, @$.start
, @$.end
, 2); }
401 { push_decl
(AST_DIRDECL
, @$.start
, @$.end
, 1, DECL_ID
); }
403 { push_decl
(AST_DIRDECL
, @$.start
, @$.end
, 1, DECL_INPARENS
); }
405 | direct_declarator
'[' ']'
406 { push_decl
(AST_DIRDECL
, @$.start
, @$.end
, 1, DECL_BRACS
); }
407 | direct_declarator
'[' type_qualifier_list
']'
408 { push_decl
(AST_DIRDECL
, @$.start
, @$.end
, 2, DECL_BRACS_TYPE
); }
409 | direct_declarator
'[' assignment_expr
']'
410 { push_decl
(AST_DIRDECL
, @$.start
, @$.end
, 2, DECL_BRACS_ASSIGN
); }
411 | direct_declarator
'[' type_qualifier_list assignment_expr
']'
412 { push_decl
(AST_DIRDECL
, @$.start
, @$.end
, 3, DECL_BRACS_BOTH
); }
414 | direct_declarator
'[' STATIC assignment_expr
']'
415 { push_decl
(AST_DIRDECL
, @$.start
, @$.end
, 2, DECL_BRACS_STATIC_ASSIGN
); }
416 | direct_declarator
'[' STATIC type_qualifier_list assignment_expr
']'
417 { push_decl
(AST_DIRDECL
, @$.start
, @$.end
, 3, DECL_BRACS_STATIC_BOTH
); }
419 | direct_declarator
'[' '*' ']'
420 { push_decl
(AST_DIRDECL
, @$.start
, @$.end
, 1, DECL_BRACS_STAR
); }
421 | direct_declarator
'[' type_qualifier_list
'*' ']'
422 { push_decl
(AST_DIRDECL
, @$.start
, @$.end
, 2, DECL_BRACS_TYPE_STAR
); }
424 | direct_declarator
'[' type_qualifier_list STATIC assignment_expr
']'
425 { push_decl
(AST_DIRDECL
, @$.start
, @$.end
, 3, DECL_BRACS_BOTH_STATIC
); }
427 | direct_declarator
'(' ')'
428 { push_decl
(AST_DIRDECL
, @$.start
, @$.end
, 1, DECL_PARENS
); }
429 | direct_declarator
'(' parameter_type_list
')'
430 { push_decl
(AST_DIRDECL
, @$.start
, @$.end
, 2, DECL_PARENS_TYPE
); }
431 | direct_declarator
'(' identifier_list
')'
432 { push_decl
(AST_DIRDECL
, @$.start
, @$.end
, 2, DECL_PARENS_ID
); }
437 { push_node
(AST_PTR
, @$.start
, @$.end
, 0); }
438 |
'*' type_qualifier_list
439 { push_node
(AST_PTR
, @$.start
, @$.end
, 1); }
441 { push_node
(AST_PTR
, @$.start
, @$.end
, 1); }
442 |
'*' type_qualifier_list pointer
443 { push_node
(AST_PTR
, @$.start
, @$.end
, 2); }
448 { push_node
(AST_TYPEQUALLIST
, @$.start
, @$.end
, 1); }
449 | type_qualifier_list type_qualifier
450 { push_node
(AST_TYPEQUALLIST
, @$.start
, @$.end
, 2); }
455 | parameter_list
',' ELIPSIS
459 : parameter_declaration
460 { push_node
(AST_PARAMLIST
, @$.start
, @$.end
, 1); }
461 | parameter_list
',' parameter_declaration
462 { push_node
(AST_PARAMLIST
, @$.start
, @$.end
, 2); }
465 parameter_declaration
466 : declaration_specifiers
467 { push_node
(AST_PARAMDECL
, @$.start
, @$.end
, 1); }
468 | declaration_specifiers declarator
469 { push_node
(AST_PARAMDECL
, @$.start
, @$.end
, 2); }
470 | declaration_specifiers abstract_declarator
471 { push_node
(AST_PARAMDECL
, @$.start
, @$.end
, 2); }
476 { push_node
(AST_IDLIST
, @$.start
, @$.end
, 1); }
477 | identifier_list
',' identifier
478 { push_node
(AST_IDLIST
, @$.start
, @$.end
, 2); }
482 : specifier_qualifier_list
483 | specifier_qualifier_list abstract_declarator
484 { push_node
(AST_ATYPE
, @$.start
, @$.end
, 2); }
489 | direct_abstract_declarator
490 | pointer direct_abstract_declarator
491 { push_node
(AST_ADECL
, @$.start
, @$.end
, 2); }
494 direct_abstract_declarator
495 : '(' abstract_declarator
')'
496 { push_node
(AST_ADIRDECL
, @$.start
, @$.end
, 1); }
499 { push_node
(AST_ADIRDECL
, @$.start
, @$.end
, 0); }
500 |
'[' assignment_expr
']'
501 { push_node
(AST_ADIRDECL
, @$.start
, @$.end
, 1); }
502 |
'[' type_qualifier_list
']'
503 { push_node
(AST_ADIRDECL
, @$.start
, @$.end
, 1); }
504 |
'[' type_qualifier_list assignment_expr
']'
505 { push_node
(AST_ADIRDECL
, @$.start
, @$.end
, 2); }
506 | direct_abstract_declarator
'[' ']'
507 { push_node
(AST_ADIRDECL
, @$.start
, @$.end
, 1); }
508 | direct_abstract_declarator
'[' assignment_expr
']'
509 { push_node
(AST_ADIRDECL
, @$.start
, @$.end
, 2); }
510 | direct_abstract_declarator
'[' type_qualifier_list
']'
511 { push_node
(AST_ADIRDECL
, @$.start
, @$.end
, 2); }
512 | direct_abstract_declarator
'[' type_qualifier_list assignment_expr
']'
513 { push_node
(AST_ADIRDECL
, @$.start
, @$.end
, 3); }
515 |
'[' type_qualifier_list STATIC assignment_expr
']'
516 { push_node
(AST_ADIRDECL
, @$.start
, @$.end
, 2); }
517 | direct_abstract_declarator
'[' type_qualifier_list STATIC assignment_expr
']'
518 { push_node
(AST_ADIRDECL
, @$.start
, @$.end
, 3); }
521 { push_node
(AST_ADIRDECL
, @$.start
, @$.end
, 0); }
522 | direct_abstract_declarator
'[' '*' ']'
523 { push_node
(AST_ADIRDECL
, @$.start
, @$.end
, 1); }
526 { push_node
(AST_ADIRDECL
, @$.start
, @$.end
, 0); }
527 |
'(' parameter_type_list
')'
528 { push_node
(AST_ADIRDECL
, @$.start
, @$.end
, 1); }
529 | direct_abstract_declarator
'(' ')'
530 { push_node
(AST_ADIRDECL
, @$.start
, @$.end
, 1); }
531 | direct_abstract_declarator
'(' parameter_type_list
')'
532 { push_node
(AST_ADIRDECL
, @$.start
, @$.end
, 2); }
537 |
'{' initializer_list
'}'
538 { push_node
(AST_INITIALIZER
, @$.start
, @$.end
, 1); }
539 |
'{' initializer_list
',' '}'
540 { push_node
(AST_INITIALIZER
, @$.start
, @$.end
, 1); }
545 { push_node
(AST_INITIALIZERLIST
, @$.start
, @$.end
, 1); }
546 | designation initializer
547 { push_node
(AST_INITIALIZERLIST
, @$.start
, @$.end
, 2); }
549 | initializer_list
',' initializer
550 { push_node
(AST_INITIALIZERLIST
, @$.start
, @$.end
, 2); }
551 | initializer_list
',' designation initializer
552 { push_node
(AST_INITIALIZERLIST
, @$.start
, @$.end
, 3); }
556 : designator_list
'='
557 { push_node
(AST_DESIGNATION
, @$.start
, @$.end
, 1); }
562 { push_node
(AST_DESIGLIST
, @$.start
, @$.end
, 1); }
563 | designator_list designator
564 { push_node
(AST_DESIGLIST
, @$.start
, @$.end
, 2); }
568 : '[' constant_expr
']'
569 { push_node
(AST_DESIGNATOR
, @$.start
, @$.end
, 1); }
571 { push_node
(AST_DESIGNATOR
, @$.start
, @$.end
, 1); }
576 | expression_statement
577 | selection_statement
578 | iteration_statement
584 : identifier
':' statement
585 { push_node
(AST_LABELED
, @$.start
, @$.end
, 2); }
586 | CASE constant_expr
':' statement
587 { push_node
(AST_CASED
, @$.start
, @$.end
, 2); }
588 | DEFAULT
':' statement
589 { push_node
(AST_DEFAULTED
, @$.start
, @$.end
, 1); }
594 { push_node
(AST_BLOCK
, @$.start
, @$.end
, 0); }
595 |
'{' block_item_list
'}'
596 { push_node
(AST_BLOCK
, @$.start
, @$.end
, 1); }
601 { push_node
(AST_BLOCKLIST
, @$.start
, @$.end
, 1); }
602 | block_item_list block_item
603 { push_node
(AST_BLOCKLIST
, @$.start
, @$.end
, 2); }
613 { push_node
(AST_STMT
, @$.start
, @$.end
, 0); }
615 { push_node
(AST_STMT
, @$.start
, @$.end
, 1); }
619 : IF
'(' expr
')' statement
620 { push_node
(AST_IF
, @$.start
, @$.end
, 2); }
621 | IF
'(' expr
')' statement ELSE statement
622 { push_node
(AST_IF
, @$.start
, @$.end
, 3); }
623 | SWITCH
'(' expr
')' statement
624 { push_node
(AST_SWITCH
, @$.start
, @$.end
, 2); }
628 : WHILE
'(' expr
')' statement
629 { push_node
(AST_WHILE
, @$.start
, @$.end
, 2); }
630 | DO statement WHILE
'(' expr
')' ';'
631 { push_node
(AST_DO
, @$.start
, @$.end
, 2); }
632 | FOR
'(' ';' ';' ')' statement
633 { push_node
(AST_FOR
, @$.start
, @$.end
, 1); }
634 | FOR
'(' ';' ';' expr
')' statement
635 { push_node
(AST_FOR
, @$.start
, @$.end
, 2); }
636 | FOR
'(' ';' expr
';' ')' statement
637 { push_node
(AST_FOR
, @$.start
, @$.end
, 2); }
638 | FOR
'(' ';' expr
';' expr
')' statement
639 { push_node
(AST_FOR
, @$.start
, @$.end
, 3); }
640 | FOR
'(' expr
';' ';' ')' statement
641 { push_node
(AST_FOR
, @$.start
, @$.end
, 2); }
642 | FOR
'(' expr
';' ';' expr
')' statement
643 { push_node
(AST_FOR
, @$.start
, @$.end
, 3); }
644 | FOR
'(' expr
';' expr
';' ')' statement
645 { push_node
(AST_FOR
, @$.start
, @$.end
, 3); }
646 | FOR
'(' expr
';' expr
';' expr
')' statement
647 { push_node
(AST_FOR
, @$.start
, @$.end
, 4); }
649 | FOR
'(' declaration
';' ';' ')' statement
650 { push_node
(AST_FOR
, @$.start
, @$.end
, 2); }
651 | FOR
'(' declaration
';' ';' expr
')' statement
652 { push_node
(AST_FOR
, @$.start
, @$.end
, 3); }
653 | FOR
'(' declaration
';' expr
';' ')' statement
654 { push_node
(AST_FOR
, @$.start
, @$.end
, 3); }
655 | FOR
'(' declaration
';' expr
';' expr
')' statement
656 { push_node
(AST_FOR
, @$.start
, @$.end
, 4); }
660 : GOTO identifier
';'
661 { push_node
(AST_GOTO
, @$.start
, @$.end
, 1); }
663 { push_node
(AST_CONTINUE
, @$.start
, @$.end
, 0); }
665 { push_node
(AST_BREAK
, @$.start
, @$.end
, 0); }
667 { push_node
(AST_RETURN
, @$.start
, @$.end
, 0); }
669 { push_node
(AST_RETURN
, @$.start
, @$.end
, 1); }
673 : external_declaration
674 { push_node
(AST_FILE
, @$.start
, @$.end
, 1); }
675 | translation_unit external_declaration
676 { push_node
(AST_FILE
, @$.start
, @$.end
, 2); }
680 : function_definition
686 : declaration_specifiers declarator compound_statement
687 { push_node
(AST_FUNCTION
, @$.start
, @$.end
, 3); }
688 | declaration_specifiers declarator declaration_list compound_statement
689 { push_node
(AST_FUNCTION
, @$.start
, @$.end
, 4); }
694 { push_node
(AST_DECLLIST
, @$.start
, @$.end
, 1); }
695 | declaration_list declaration
696 { push_node
(AST_DECLLIST
, @$.start
, @$.end
, 2); }
701 { push_node
(AST_MACRO
, @$.start
, @$.end
, 0); }
706 { push_node_name
(AST_IDENTIFIER
, @$.start
, @$.end
, $1); }
710 void yyerror(char *s
)
712 extern
long token_offset
;
713 fprintf
(stderr
, "parsing error on %ld: %s\n", token_offset
, s
);