Expand PMF_FN_* macros.
[netbsd-mini2440.git] / usr.bin / xlint / lint1 / cgram.y
blobdf0c23187346669f43e11dc946ea053099a1849a
1 %{
2 /* $NetBSD: cgram.y,v 1.47 2009/10/03 01:35:20 christos Exp $ */
4 /*
5 * Copyright (c) 1996 Christopher G. Demetriou. All Rights Reserved.
6 * Copyright (c) 1994, 1995 Jochen Pohl
7 * All Rights Reserved.
9 * Redistribution and use in source and binary forms, with or without
10 * modification, are permitted provided that the following conditions
11 * are met:
12 * 1. Redistributions of source code must retain the above copyright
13 * notice, this list of conditions and the following disclaimer.
14 * 2. Redistributions in binary form must reproduce the above copyright
15 * notice, this list of conditions and the following disclaimer in the
16 * documentation and/or other materials provided with the distribution.
17 * 3. All advertising materials mentioning features or use of this software
18 * must display the following acknowledgement:
19 * This product includes software developed by Jochen Pohl for
20 * The NetBSD Project.
21 * 4. The name of the author may not be used to endorse or promote products
22 * derived from this software without specific prior written permission.
24 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
25 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
26 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
27 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
28 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
29 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
30 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
31 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
33 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
36 #include <sys/cdefs.h>
37 #if defined(__RCSID) && !defined(lint)
38 __RCSID("$NetBSD: cgram.y,v 1.47 2009/10/03 01:35:20 christos Exp $");
39 #endif
41 #include <stdlib.h>
42 #include <string.h>
43 #include <limits.h>
45 #include "lint1.h"
47 extern char *yytext;
49 * Contains the level of current declaration. 0 is extern.
50 * Used for symbol table entries.
52 int blklev;
55 * level for memory allocation. Normaly the same as blklev.
56 * An exeption is the declaration of arguments in prototypes. Memory
57 * for these can't be freed after the declaration, but symbols must
58 * be removed from the symbol table after the declaration.
60 int mblklev;
63 * Save the no-warns state and restore it to avoid the problem where
64 * if (expr) { stmt } / * NOLINT * / stmt;
66 static int onowarn = -1;
68 static int toicon(tnode_t *, int);
69 static void idecl(sym_t *, int, sbuf_t *);
70 static void ignuptorp(void);
72 #ifdef DEBUG
73 static inline void CLRWFLGS(const char *file, size_t line);
74 static inline void CLRWFLGS(const char *file, size_t line)
76 printf("%s, %d: clear flags %s %zu\n", curr_pos.p_file,
77 curr_pos.p_line, file, line);
78 clrwflgs();
79 onowarn = -1;
82 static inline void SAVE(const char *file, size_t line);
83 static inline void SAVE(const char *file, size_t line)
85 if (onowarn != -1)
86 abort();
87 printf("%s, %d: save flags %s %zu = %d\n", curr_pos.p_file,
88 curr_pos.p_line, file, line, nowarn);
89 onowarn = nowarn;
92 static inline void RESTORE(const char *file, size_t line);
93 static inline void RESTORE(const char *file, size_t line)
95 if (onowarn != -1) {
96 nowarn = onowarn;
97 printf("%s, %d: restore flags %s %zu = %d\n", curr_pos.p_file,
98 curr_pos.p_line, file, line, nowarn);
99 onowarn = -1;
100 } else
101 CLRWFLGS(file, line);
103 #else
104 #define CLRWFLGS(f, l) clrwflgs(), onowarn = -1
105 #define SAVE(f, l) onowarn = nowarn
106 #define RESTORE(f, l) (void)(onowarn == -1 ? (clrwflgs(), 0) : (nowarn = onowarn))
107 #endif
110 %expect 3
112 %union {
113 int y_int;
114 val_t *y_val;
115 sbuf_t *y_sb;
116 sym_t *y_sym;
117 op_t y_op;
118 scl_t y_scl;
119 tspec_t y_tspec;
120 tqual_t y_tqual;
121 type_t *y_type;
122 tnode_t *y_tnode;
123 range_t y_range;
124 strg_t *y_strg;
125 pqinf_t *y_pqinf;
128 %token T_LBRACE T_RBRACE T_LBRACK T_RBRACK T_LPARN T_RPARN
129 %token <y_op> T_STROP
130 %token <y_op> T_UNOP
131 %token <y_op> T_INCDEC
132 %token T_SIZEOF
133 %token T_ALIGNOF
134 %token <y_op> T_MULT
135 %token <y_op> T_DIVOP
136 %token <y_op> T_ADDOP
137 %token <y_op> T_SHFTOP
138 %token <y_op> T_RELOP
139 %token <y_op> T_EQOP
140 %token <y_op> T_AND
141 %token <y_op> T_XOR
142 %token <y_op> T_OR
143 %token <y_op> T_LOGAND
144 %token <y_op> T_LOGOR
145 %token T_QUEST
146 %token T_COLON
147 %token <y_op> T_ASSIGN
148 %token <y_op> T_OPASS
149 %token T_COMMA
150 %token T_SEMI
151 %token T_ELLIPSE
152 %token T_REAL
153 %token T_IMAG
155 /* storage classes (extern, static, auto, register and typedef) */
156 %token <y_scl> T_SCLASS
158 /* types (char, int, short, long, unsigned, signed, float, double, void) */
159 %token <y_tspec> T_TYPE
161 /* qualifiers (const, volatile) */
162 %token <y_tqual> T_QUAL
164 /* struct or union */
165 %token <y_tspec> T_SOU
167 /* enum */
168 %token T_ENUM
170 /* remaining keywords */
171 %token T_CASE
172 %token T_DEFAULT
173 %token T_IF
174 %token T_ELSE
175 %token T_SWITCH
176 %token T_DO
177 %token T_WHILE
178 %token T_FOR
179 %token T_GOTO
180 %token T_CONTINUE
181 %token T_BREAK
182 %token T_RETURN
183 %token T_ASM
184 %token T_SYMBOLRENAME
185 %token T_PACKED
186 /* Type Attributes */
187 %token <y_type> T_ATTRIBUTE
188 %token <y_type> T_AT_ALIGNED
189 %token <y_type> T_AT_DEPRECATED
190 %token <y_type> T_AT_MAY_ALIAS
191 %token <y_type> T_AT_PACKED
192 %token <y_type> T_AT_TUINION
193 %token <y_type> T_AT_TUNION
194 %token <y_type> T_AT_UNUSED
198 %left T_COMMA
199 %right T_ASSIGN T_OPASS
200 %right T_QUEST T_COLON
201 %left T_LOGOR
202 %left T_LOGAND
203 %left T_OR
204 %left T_XOR
205 %left T_AND
206 %left T_EQOP
207 %left T_RELOP
208 %left T_SHFTOP
209 %left T_ADDOP
210 %left T_MULT T_DIVOP
211 %right T_UNOP T_INCDEC T_SIZEOF T_ALIGNOF T_REAL T_IMAG
212 %left T_LPARN T_LBRACK T_STROP
214 %token <y_sb> T_NAME
215 %token <y_sb> T_TYPENAME
216 %token <y_val> T_CON
217 %token <y_strg> T_STRING
219 %type <y_sym> func_decl
220 %type <y_sym> notype_decl
221 %type <y_sym> type_decl
222 %type <y_type> typespec
223 %type <y_type> clrtyp_typespec
224 %type <y_type> notype_typespec
225 %type <y_type> struct_spec
226 %type <y_type> enum_spec
227 %type <y_type> type_attribute
228 %type <y_type> type_attribute_spec
229 %type <y_sym> struct_tag
230 %type <y_sym> enum_tag
231 %type <y_tspec> struct
232 %type <y_sym> struct_declaration
233 %type <y_sb> identifier
234 %type <y_sym> member_declaration_list_with_rbrace
235 %type <y_sym> member_declaration_list
236 %type <y_sym> member_declaration
237 %type <y_sym> notype_member_decls
238 %type <y_sym> type_member_decls
239 %type <y_sym> notype_member_decl
240 %type <y_sym> type_member_decl
241 %type <y_tnode> constant
242 %type <y_sym> enum_declaration
243 %type <y_sym> enums_with_opt_comma
244 %type <y_sym> enums
245 %type <y_sym> enumerator
246 %type <y_sym> ename
247 %type <y_sym> notype_direct_decl
248 %type <y_sym> type_direct_decl
249 %type <y_pqinf> pointer
250 %type <y_pqinf> asterisk
251 %type <y_sym> param_decl
252 %type <y_sym> param_list
253 %type <y_sym> abs_decl_param_list
254 %type <y_sym> direct_param_decl
255 %type <y_sym> notype_param_decl
256 %type <y_sym> direct_notype_param_decl
257 %type <y_pqinf> type_qualifier_list
258 %type <y_pqinf> type_qualifier
259 %type <y_sym> identifier_list
260 %type <y_sym> abs_decl
261 %type <y_sym> direct_abs_decl
262 %type <y_sym> vararg_parameter_type_list
263 %type <y_sym> parameter_type_list
264 %type <y_sym> parameter_declaration
265 %type <y_tnode> expr
266 %type <y_tnode> expr_stmnt_val
267 %type <y_tnode> expr_stmnt_list
268 %type <y_tnode> term
269 %type <y_tnode> func_arg_list
270 %type <y_op> point_or_arrow
271 %type <y_type> type_name
272 %type <y_sym> abstract_declaration
273 %type <y_tnode> do_while_expr
274 %type <y_tnode> opt_expr
275 %type <y_strg> string
276 %type <y_strg> string2
277 %type <y_sb> opt_asm_or_symbolrename
278 %type <y_range> range
279 %type <y_range> lorange
284 program:
285 /* empty */ {
286 if (sflag) {
287 /* empty translation unit */
288 error(272);
289 } else if (!tflag) {
290 /* empty translation unit */
291 warning(272);
294 | translation_unit
297 translation_unit:
298 ext_decl
299 | translation_unit ext_decl
302 ext_decl:
303 asm_stmnt
304 | func_def {
305 glclup(0);
306 CLRWFLGS(__FILE__, __LINE__);
308 | data_def {
309 glclup(0);
310 CLRWFLGS(__FILE__, __LINE__);
314 data_def:
315 T_SEMI {
316 if (sflag) {
317 /* syntax error: empty declaration */
318 error(0);
319 } else if (!tflag) {
320 /* syntax error: empty declaration */
321 warning(0);
324 | clrtyp deftyp notype_init_decls T_SEMI {
325 if (sflag) {
326 /* old style declaration; add "int" */
327 error(1);
328 } else if (!tflag) {
329 /* old style declaration; add "int" */
330 warning(1);
333 | declmods deftyp T_SEMI {
334 if (dcs->d_scl == TYPEDEF) {
335 /* typedef declares no type name */
336 warning(72);
337 } else {
338 /* empty declaration */
339 warning(2);
342 | declmods deftyp notype_init_decls T_SEMI
343 | declspecs deftyp T_SEMI {
344 if (dcs->d_scl == TYPEDEF) {
345 /* typedef declares no type name */
346 warning(72);
347 } else if (!dcs->d_nedecl) {
348 /* empty declaration */
349 warning(2);
352 | declspecs deftyp type_init_decls T_SEMI
353 | error T_SEMI {
354 globclup();
356 | error T_RBRACE {
357 globclup();
361 func_def:
362 func_decl {
363 if ($1->s_type->t_tspec != FUNC) {
364 /* syntax error */
365 error(249, yytext);
366 YYERROR;
368 if ($1->s_type->t_typedef) {
369 /* ()-less function definition */
370 error(64);
371 YYERROR;
373 funcdef($1);
374 blklev++;
375 pushdecl(ARG);
376 if (nowarn)
377 $1->s_used = 1;
378 } opt_arg_declaration_list {
379 popdecl();
380 blklev--;
381 cluparg();
382 pushctrl(0);
383 } comp_stmnt {
384 funcend();
385 popctrl(0);
389 func_decl:
390 clrtyp deftyp notype_decl {
391 $$ = $3;
393 | declmods deftyp notype_decl {
394 $$ = $3;
396 | declspecs deftyp type_decl {
397 $$ = $3;
401 opt_arg_declaration_list:
402 /* empty */
403 | arg_declaration_list
406 arg_declaration_list:
407 arg_declaration
408 | arg_declaration_list arg_declaration
409 /* XXX or better "arg_declaration error" ? */
410 | error
414 * "arg_declaration" is separated from "declaration" because it
415 * needs other error handling.
418 arg_declaration:
419 declmods deftyp T_SEMI {
420 /* empty declaration */
421 warning(2);
423 | declmods deftyp notype_init_decls T_SEMI
424 | declspecs deftyp T_SEMI {
425 if (!dcs->d_nedecl) {
426 /* empty declaration */
427 warning(2);
428 } else {
429 tspec_t ts = dcs->d_type->t_tspec;
430 /* %s declared in argument declaration list */
431 warning(3, ts == STRUCT ? "struct" :
432 (ts == UNION ? "union" : "enum"));
435 | declspecs deftyp type_init_decls T_SEMI {
436 if (dcs->d_nedecl) {
437 tspec_t ts = dcs->d_type->t_tspec;
438 /* %s declared in argument declaration list */
439 warning(3, ts == STRUCT ? "struct" :
440 (ts == UNION ? "union" : "enum"));
443 | declmods error
444 | declspecs error
447 declaration:
448 declmods deftyp T_SEMI {
449 if (dcs->d_scl == TYPEDEF) {
450 /* typedef declares no type name */
451 warning(72);
452 } else {
453 /* empty declaration */
454 warning(2);
457 | declmods deftyp notype_init_decls T_SEMI
458 | declspecs deftyp T_SEMI {
459 if (dcs->d_scl == TYPEDEF) {
460 /* typedef declares no type name */
461 warning(72);
462 } else if (!dcs->d_nedecl) {
463 /* empty declaration */
464 warning(2);
467 | declspecs deftyp type_init_decls T_SEMI
468 | error T_SEMI
471 type_attribute_spec:
472 T_AT_DEPRECATED
473 | T_AT_ALIGNED T_LPARN constant T_RPARN
474 | T_AT_MAY_ALIAS
475 | T_AT_PACKED {
476 addpacked();
478 | T_AT_TUNION
479 | T_AT_UNUSED
482 type_attribute:
483 T_ATTRIBUTE T_LPARN T_LPARN type_attribute_spec T_RPARN T_RPARN
484 | T_PACKED {
485 addpacked();
489 clrtyp:
491 clrtyp();
495 deftyp:
496 /* empty */ {
497 deftyp();
501 declspecs:
502 clrtyp_typespec {
503 addtype($1);
505 | declmods typespec {
506 addtype($2);
508 | declspecs type_attribute
509 | declspecs declmod
510 | declspecs notype_typespec {
511 addtype($2);
515 declmods:
516 clrtyp T_QUAL {
517 addqual($2);
519 | clrtyp T_SCLASS {
520 addscl($2);
522 | declmods declmod
525 declmod:
526 T_QUAL {
527 addqual($1);
529 | T_SCLASS {
530 addscl($1);
534 clrtyp_typespec:
535 clrtyp notype_typespec {
536 $$ = $2;
538 | T_TYPENAME clrtyp {
539 $$ = getsym($1)->s_type;
543 typespec:
544 notype_typespec {
545 $$ = $1;
547 | T_TYPENAME {
548 $$ = getsym($1)->s_type;
552 notype_typespec:
553 T_TYPE {
554 $$ = gettyp($1);
556 | struct_spec {
557 popdecl();
558 $$ = $1;
560 | enum_spec {
561 popdecl();
562 $$ = $1;
566 struct_spec:
567 struct struct_tag {
569 * STDC requires that "struct a;" always introduces
570 * a new tag if "a" is not declared at current level
572 * yychar is valid because otherwise the parser would
573 * not been able to deceide if he must shift or reduce
575 $$ = mktag($2, $1, 0, yychar == T_SEMI);
577 | struct struct_tag {
578 dcs->d_tagtyp = mktag($2, $1, 1, 0);
579 } struct_declaration {
580 $$ = compltag(dcs->d_tagtyp, $4);
582 | struct {
583 dcs->d_tagtyp = mktag(NULL, $1, 1, 0);
584 } struct_declaration {
585 $$ = compltag(dcs->d_tagtyp, $3);
587 | struct error {
588 symtyp = FVFT;
589 $$ = gettyp(INT);
593 struct:
594 struct type_attribute
595 | T_SOU {
596 symtyp = FTAG;
597 pushdecl($1 == STRUCT ? MOS : MOU);
598 dcs->d_offset = 0;
599 dcs->d_stralign = CHAR_BIT;
600 $$ = $1;
604 struct_tag:
605 identifier {
606 $$ = getsym($1);
610 struct_declaration:
611 struct_decl_lbrace member_declaration_list_with_rbrace {
612 $$ = $2;
616 struct_decl_lbrace:
617 T_LBRACE {
618 symtyp = FVFT;
622 member_declaration_list_with_rbrace:
623 member_declaration_list T_SEMI T_RBRACE {
624 $$ = $1;
626 | member_declaration_list T_RBRACE {
627 if (sflag) {
628 /* syntax req. ";" after last struct/union member */
629 error(66);
630 } else {
631 /* syntax req. ";" after last struct/union member */
632 warning(66);
634 $$ = $1;
636 | T_RBRACE {
637 $$ = NULL;
641 member_declaration_list:
642 member_declaration {
643 $$ = $1;
645 | member_declaration_list T_SEMI member_declaration {
646 $$ = lnklst($1, $3);
650 member_declaration:
651 noclass_declmods deftyp {
652 /* too late, i know, but getsym() compensates it */
653 symtyp = FMOS;
654 } notype_member_decls {
655 symtyp = FVFT;
656 $$ = $4;
658 | noclass_declspecs deftyp {
659 symtyp = FMOS;
660 } type_member_decls {
661 symtyp = FVFT;
662 $$ = $4;
664 | noclass_declmods deftyp {
665 /* struct or union member must be named */
666 warning(49);
667 $$ = NULL;
669 | noclass_declspecs deftyp {
670 /* struct or union member must be named */
671 warning(49);
672 $$ = NULL;
674 | error {
675 symtyp = FVFT;
676 $$ = NULL;
680 noclass_declspecs:
681 clrtyp_typespec {
682 addtype($1);
684 | noclass_declmods typespec {
685 addtype($2);
687 | noclass_declspecs T_QUAL {
688 addqual($2);
690 | noclass_declspecs notype_typespec {
691 addtype($2);
693 | noclass_declspecs type_attribute
696 noclass_declmods:
697 clrtyp T_QUAL {
698 addqual($2);
700 | noclass_declmods T_QUAL {
701 addqual($2);
705 notype_member_decls:
706 notype_member_decl {
707 $$ = decl1str($1);
709 | notype_member_decls {
710 symtyp = FMOS;
711 } T_COMMA type_member_decl {
712 $$ = lnklst($1, decl1str($4));
716 type_member_decls:
717 type_member_decl {
718 $$ = decl1str($1);
720 | type_member_decls {
721 symtyp = FMOS;
722 } T_COMMA type_member_decl {
723 $$ = lnklst($1, decl1str($4));
727 notype_member_decl:
728 notype_decl {
729 $$ = $1;
731 | notype_decl T_COLON constant {
732 $$ = bitfield($1, toicon($3, 1));
735 symtyp = FVFT;
736 } T_COLON constant {
737 $$ = bitfield(NULL, toicon($3, 1));
741 type_member_decl:
742 type_decl {
743 $$ = $1;
745 | type_decl T_COLON constant {
746 $$ = bitfield($1, toicon($3, 1));
749 symtyp = FVFT;
750 } T_COLON constant {
751 $$ = bitfield(NULL, toicon($3, 1));
755 enum_spec:
756 enum enum_tag {
757 $$ = mktag($2, ENUM, 0, 0);
759 | enum enum_tag {
760 dcs->d_tagtyp = mktag($2, ENUM, 1, 0);
761 } enum_declaration {
762 $$ = compltag(dcs->d_tagtyp, $4);
764 | enum {
765 dcs->d_tagtyp = mktag(NULL, ENUM, 1, 0);
766 } enum_declaration {
767 $$ = compltag(dcs->d_tagtyp, $3);
769 | enum error {
770 symtyp = FVFT;
771 $$ = gettyp(INT);
775 enum:
776 T_ENUM {
777 symtyp = FTAG;
778 pushdecl(ENUMCON);
782 enum_tag:
783 identifier {
784 $$ = getsym($1);
788 enum_declaration:
789 enum_decl_lbrace enums_with_opt_comma T_RBRACE {
790 $$ = $2;
794 enum_decl_lbrace:
795 T_LBRACE {
796 symtyp = FVFT;
797 enumval = 0;
801 enums_with_opt_comma:
802 enums {
803 $$ = $1;
805 | enums T_COMMA {
806 if (sflag) {
807 /* trailing "," prohibited in enum declaration */
808 error(54);
809 } else {
810 /* trailing "," prohibited in enum declaration */
811 (void)gnuism(54);
813 $$ = $1;
817 enums:
818 enumerator {
819 $$ = $1;
821 | enums T_COMMA enumerator {
822 $$ = lnklst($1, $3);
824 | error {
825 $$ = NULL;
829 enumerator:
830 ename {
831 $$ = ename($1, enumval, 1);
833 | ename T_ASSIGN constant {
834 $$ = ename($1, toicon($3, 1), 0);
838 ename:
839 identifier {
840 $$ = getsym($1);
845 notype_init_decls:
846 notype_init_decl
847 | notype_init_decls T_COMMA type_init_decl
850 type_init_decls:
851 type_init_decl
852 | type_init_decls T_COMMA type_init_decl
855 notype_init_decl:
856 notype_decl opt_asm_or_symbolrename {
857 idecl($1, 0, $2);
858 chksz($1);
860 | notype_decl opt_asm_or_symbolrename {
861 idecl($1, 1, $2);
862 } T_ASSIGN initializer {
863 chksz($1);
867 type_init_decl:
868 type_decl opt_asm_or_symbolrename {
869 idecl($1, 0, $2);
870 chksz($1);
872 | type_decl opt_asm_or_symbolrename {
873 idecl($1, 1, $2);
874 } T_ASSIGN initializer {
875 chksz($1);
879 notype_decl:
880 notype_direct_decl {
881 $$ = $1;
883 | pointer notype_direct_decl {
884 $$ = addptr($2, $1);
888 notype_direct_decl:
889 T_NAME {
890 $$ = dname(getsym($1));
892 | T_LPARN type_decl T_RPARN {
893 $$ = $2;
895 | notype_direct_decl T_LBRACK T_RBRACK {
896 $$ = addarray($1, 0, 0);
898 | notype_direct_decl T_LBRACK constant T_RBRACK {
899 $$ = addarray($1, 1, toicon($3, 0));
901 | notype_direct_decl param_list {
902 $$ = addfunc($1, $2);
903 popdecl();
904 blklev--;
906 | notype_direct_decl type_attribute
909 type_decl:
910 type_direct_decl {
911 $$ = $1;
913 | pointer type_direct_decl {
914 $$ = addptr($2, $1);
918 type_direct_decl:
919 identifier {
920 $$ = dname(getsym($1));
922 | T_LPARN type_decl T_RPARN {
923 $$ = $2;
925 | type_direct_decl T_LBRACK T_RBRACK {
926 $$ = addarray($1, 0, 0);
928 | type_direct_decl T_LBRACK constant T_RBRACK {
929 $$ = addarray($1, 1, toicon($3, 0));
931 | type_direct_decl param_list {
932 $$ = addfunc($1, $2);
933 popdecl();
934 blklev--;
936 | type_direct_decl type_attribute
940 * param_decl and notype_param_decl exist to avoid a conflict in
941 * argument lists. A typename enclosed in parens should always be
942 * treated as a typename, not an argument.
943 * "typedef int a; f(int (a));" is "typedef int a; f(int foo(a));"
944 * not "typedef int a; f(int a);"
946 param_decl:
947 direct_param_decl {
948 $$ = $1;
950 | pointer direct_param_decl {
951 $$ = addptr($2, $1);
955 direct_param_decl:
956 identifier {
957 $$ = dname(getsym($1));
959 | T_LPARN notype_param_decl T_RPARN {
960 $$ = $2;
962 | direct_param_decl T_LBRACK T_RBRACK {
963 $$ = addarray($1, 0, 0);
965 | direct_param_decl T_LBRACK constant T_RBRACK {
966 $$ = addarray($1, 1, toicon($3, 0));
968 | direct_param_decl param_list {
969 $$ = addfunc($1, $2);
970 popdecl();
971 blklev--;
975 notype_param_decl:
976 direct_notype_param_decl {
977 $$ = $1;
979 | pointer direct_notype_param_decl {
980 $$ = addptr($2, $1);
984 direct_notype_param_decl:
985 T_NAME {
986 $$ = dname(getsym($1));
988 | T_LPARN notype_param_decl T_RPARN {
989 $$ = $2;
991 | direct_notype_param_decl T_LBRACK T_RBRACK {
992 $$ = addarray($1, 0, 0);
994 | direct_notype_param_decl T_LBRACK constant T_RBRACK {
995 $$ = addarray($1, 1, toicon($3, 0));
997 | direct_notype_param_decl param_list {
998 $$ = addfunc($1, $2);
999 popdecl();
1000 blklev--;
1004 pointer:
1005 asterisk {
1006 $$ = $1;
1008 | asterisk type_qualifier_list {
1009 $$ = mergepq($1, $2);
1011 | asterisk pointer {
1012 $$ = mergepq($1, $2);
1014 | asterisk type_qualifier_list pointer {
1015 $$ = mergepq(mergepq($1, $2), $3);
1019 asterisk:
1020 T_MULT {
1021 $$ = xcalloc(1, sizeof (pqinf_t));
1022 $$->p_pcnt = 1;
1026 type_qualifier_list:
1027 type_qualifier {
1028 $$ = $1;
1030 | type_qualifier_list type_qualifier {
1031 $$ = mergepq($1, $2);
1035 type_qualifier:
1036 T_QUAL {
1037 $$ = xcalloc(1, sizeof (pqinf_t));
1038 if ($1 == CONST) {
1039 $$->p_const = 1;
1040 } else {
1041 $$->p_volatile = 1;
1046 param_list:
1047 id_list_lparn identifier_list T_RPARN {
1048 $$ = $2;
1050 | abs_decl_param_list {
1051 $$ = $1;
1055 id_list_lparn:
1056 T_LPARN {
1057 blklev++;
1058 pushdecl(PARG);
1062 identifier_list:
1063 T_NAME {
1064 $$ = iname(getsym($1));
1066 | identifier_list T_COMMA T_NAME {
1067 $$ = lnklst($1, iname(getsym($3)));
1069 | identifier_list error {
1070 $$ = $1;
1074 abs_decl_param_list:
1075 abs_decl_lparn T_RPARN {
1076 $$ = NULL;
1078 | abs_decl_lparn vararg_parameter_type_list T_RPARN {
1079 dcs->d_proto = 1;
1080 $$ = $2;
1082 | abs_decl_lparn error T_RPARN {
1083 $$ = NULL;
1087 abs_decl_lparn:
1088 T_LPARN {
1089 blklev++;
1090 pushdecl(PARG);
1094 vararg_parameter_type_list:
1095 parameter_type_list {
1096 $$ = $1;
1098 | parameter_type_list T_COMMA T_ELLIPSE {
1099 dcs->d_vararg = 1;
1100 $$ = $1;
1102 | T_ELLIPSE {
1103 if (sflag) {
1104 /* ANSI C requires formal parameter before "..." */
1105 error(84);
1106 } else if (!tflag) {
1107 /* ANSI C requires formal parameter before "..." */
1108 warning(84);
1110 dcs->d_vararg = 1;
1111 $$ = NULL;
1115 parameter_type_list:
1116 parameter_declaration {
1117 $$ = $1;
1119 | parameter_type_list T_COMMA parameter_declaration {
1120 $$ = lnklst($1, $3);
1124 parameter_declaration:
1125 declmods deftyp {
1126 $$ = decl1arg(aname(), 0);
1128 | declspecs deftyp {
1129 $$ = decl1arg(aname(), 0);
1131 | declmods deftyp notype_param_decl {
1132 $$ = decl1arg($3, 0);
1135 * param_decl is needed because of following conflict:
1136 * "typedef int a; f(int (a));" could be parsed as
1137 * "function with argument a of type int", or
1138 * "function with an abstract argument of type function".
1139 * This grammar realizes the second case.
1141 | declspecs deftyp param_decl {
1142 $$ = decl1arg($3, 0);
1144 | declmods deftyp abs_decl {
1145 $$ = decl1arg($3, 0);
1147 | declspecs deftyp abs_decl {
1148 $$ = decl1arg($3, 0);
1152 opt_asm_or_symbolrename: /* expect only one */
1153 /* empty */ {
1154 $$ = NULL;
1156 | T_ASM T_LPARN T_STRING T_RPARN {
1157 freeyyv(&$3, T_STRING);
1158 $$ = NULL;
1160 | T_SYMBOLRENAME T_LPARN T_NAME T_RPARN {
1161 $$ = $3;
1165 initializer:
1166 init_expr
1169 init_expr:
1170 expr %prec T_COMMA {
1171 mkinit($1);
1173 | init_by_name init_expr %prec T_COMMA
1174 | init_lbrace init_expr_list init_rbrace
1175 | init_lbrace init_expr_list T_COMMA init_rbrace
1176 | error
1179 init_expr_list:
1180 init_expr %prec T_COMMA
1181 | init_expr_list T_COMMA init_expr
1184 lorange:
1185 constant T_ELLIPSE {
1186 $$.lo = toicon($1, 1);
1189 range:
1190 constant {
1191 $$.lo = toicon($1, 1);
1192 $$.hi = $$.lo + 1;
1194 | lorange constant {
1195 $$.lo = $1.lo;
1196 $$.hi = toicon($2, 1);
1200 init_by_name:
1201 T_LBRACK range T_RBRACK T_ASSIGN {
1202 if (!Sflag)
1203 warning(321);
1205 | point identifier T_ASSIGN {
1206 if (!Sflag)
1207 warning(313);
1208 memberpush($2);
1210 | identifier T_COLON {
1211 gnuism(315);
1212 memberpush($1);
1216 init_lbrace:
1217 T_LBRACE {
1218 initlbr();
1222 init_rbrace:
1223 T_RBRACE {
1224 initrbr();
1228 type_name:
1230 pushdecl(ABSTRACT);
1231 } abstract_declaration {
1232 popdecl();
1233 $$ = $2->s_type;
1237 abstract_declaration:
1238 noclass_declmods deftyp {
1239 $$ = decl1abs(aname());
1241 | noclass_declspecs deftyp {
1242 $$ = decl1abs(aname());
1244 | noclass_declmods deftyp abs_decl {
1245 $$ = decl1abs($3);
1247 | noclass_declspecs deftyp abs_decl {
1248 $$ = decl1abs($3);
1252 abs_decl:
1253 pointer {
1254 $$ = addptr(aname(), $1);
1256 | direct_abs_decl {
1257 $$ = $1;
1259 | pointer direct_abs_decl {
1260 $$ = addptr($2, $1);
1264 direct_abs_decl:
1265 T_LPARN abs_decl T_RPARN {
1266 $$ = $2;
1268 | T_LBRACK T_RBRACK {
1269 $$ = addarray(aname(), 0, 0);
1271 | T_LBRACK constant T_RBRACK {
1272 $$ = addarray(aname(), 1, toicon($2, 0));
1274 | direct_abs_decl T_LBRACK T_RBRACK {
1275 $$ = addarray($1, 0, 0);
1277 | direct_abs_decl T_LBRACK constant T_RBRACK {
1278 $$ = addarray($1, 1, toicon($3, 0));
1280 | abs_decl_param_list {
1281 $$ = addfunc(aname(), $1);
1282 popdecl();
1283 blklev--;
1285 | direct_abs_decl abs_decl_param_list {
1286 $$ = addfunc($1, $2);
1287 popdecl();
1288 blklev--;
1290 | direct_abs_decl type_attribute
1293 non_expr_stmnt:
1294 labeled_stmnt
1295 | comp_stmnt
1296 | selection_stmnt
1297 | iteration_stmnt
1298 | jump_stmnt {
1299 ftflg = 0;
1301 | asm_stmnt
1303 stmnt:
1304 expr_stmnt
1305 | non_expr_stmnt
1308 labeled_stmnt:
1309 label stmnt
1312 label:
1313 identifier T_COLON {
1314 symtyp = FLAB;
1315 label(T_NAME, getsym($1), NULL);
1317 | T_CASE constant T_COLON {
1318 label(T_CASE, NULL, $2);
1319 ftflg = 1;
1321 | T_CASE constant T_ELLIPSE constant T_COLON {
1322 /* XXX: We don't fill all cases */
1323 label(T_CASE, NULL, $2);
1324 ftflg = 1;
1326 | T_DEFAULT T_COLON {
1327 label(T_DEFAULT, NULL, NULL);
1328 ftflg = 1;
1332 comp_stmnt:
1333 comp_stmnt_lbrace declaration_list opt_stmnt_list comp_stmnt_rbrace
1334 | comp_stmnt_lbrace opt_stmnt_list comp_stmnt_rbrace
1337 comp_stmnt_lbrace:
1338 T_LBRACE {
1339 blklev++;
1340 mblklev++;
1341 pushdecl(AUTO);
1345 comp_stmnt_rbrace:
1346 T_RBRACE {
1347 popdecl();
1348 freeblk();
1349 mblklev--;
1350 blklev--;
1351 ftflg = 0;
1355 opt_stmnt_list:
1356 /* empty */
1357 | stmnt_list
1360 stmnt_list:
1361 stmnt
1362 | stmnt_list stmnt {
1363 RESTORE(__FILE__, __LINE__);
1365 | stmnt_list error T_SEMI
1368 expr_stmnt:
1369 expr T_SEMI {
1370 expr($1, 0, 0, 1);
1371 ftflg = 0;
1373 | T_SEMI {
1374 ftflg = 0;
1379 * The following two productions are used to implement
1380 * ({ [[decl-list] stmt-list] }).
1381 * XXX: This is not well tested.
1383 expr_stmnt_val:
1384 expr T_SEMI {
1385 /* XXX: We should really do that only on the last name */
1386 if ($1->tn_op == NAME)
1387 $1->tn_sym->s_used = 1;
1388 $$ = $1;
1389 expr($1, 0, 0, 0);
1390 ftflg = 0;
1392 | non_expr_stmnt {
1393 $$ = getnode();
1394 $$->tn_type = gettyp(VOID);
1398 expr_stmnt_list:
1399 expr_stmnt_val
1400 | expr_stmnt_list expr_stmnt_val {
1401 $$ = $2;
1405 selection_stmnt:
1406 if_without_else {
1407 SAVE(__FILE__, __LINE__);
1408 if2();
1409 if3(0);
1411 | if_without_else T_ELSE {
1412 SAVE(__FILE__, __LINE__);
1413 if2();
1414 } stmnt {
1415 CLRWFLGS(__FILE__, __LINE__);
1416 if3(1);
1418 | if_without_else T_ELSE error {
1419 CLRWFLGS(__FILE__, __LINE__);
1420 if3(0);
1422 | switch_expr stmnt {
1423 CLRWFLGS(__FILE__, __LINE__);
1424 switch2();
1426 | switch_expr error {
1427 CLRWFLGS(__FILE__, __LINE__);
1428 switch2();
1432 if_without_else:
1433 if_expr stmnt
1434 | if_expr error
1437 if_expr:
1438 T_IF T_LPARN expr T_RPARN {
1439 if1($3);
1440 CLRWFLGS(__FILE__, __LINE__);
1444 switch_expr:
1445 T_SWITCH T_LPARN expr T_RPARN {
1446 switch1($3);
1447 CLRWFLGS(__FILE__, __LINE__);
1451 do_stmnt:
1452 do stmnt {
1453 CLRWFLGS(__FILE__, __LINE__);
1457 iteration_stmnt:
1458 while_expr stmnt {
1459 CLRWFLGS(__FILE__, __LINE__);
1460 while2();
1462 | while_expr error {
1463 CLRWFLGS(__FILE__, __LINE__);
1464 while2();
1466 | do_stmnt do_while_expr {
1467 do2($2);
1468 ftflg = 0;
1470 | do error {
1471 CLRWFLGS(__FILE__, __LINE__);
1472 do2(NULL);
1474 | for_exprs stmnt {
1475 CLRWFLGS(__FILE__, __LINE__);
1476 for2();
1478 | for_exprs error {
1479 CLRWFLGS(__FILE__, __LINE__);
1480 for2();
1484 while_expr:
1485 T_WHILE T_LPARN expr T_RPARN {
1486 while1($3);
1487 CLRWFLGS(__FILE__, __LINE__);
1492 T_DO {
1493 do1();
1497 do_while_expr:
1498 T_WHILE T_LPARN expr T_RPARN T_SEMI {
1499 $$ = $3;
1503 for_exprs:
1504 T_FOR T_LPARN declspecs deftyp notype_init_decls T_SEMI opt_expr
1505 T_SEMI opt_expr T_RPARN {
1506 c99ism(325);
1507 for1(NULL, $7, $9);
1508 CLRWFLGS(__FILE__, __LINE__);
1510 | T_FOR T_LPARN opt_expr T_SEMI opt_expr T_SEMI opt_expr T_RPARN {
1511 for1($3, $5, $7);
1512 CLRWFLGS(__FILE__, __LINE__);
1516 opt_expr:
1517 /* empty */ {
1518 $$ = NULL;
1520 | expr {
1521 $$ = $1;
1525 jump_stmnt:
1526 goto identifier T_SEMI {
1527 dogoto(getsym($2));
1529 | goto error T_SEMI {
1530 symtyp = FVFT;
1532 | T_CONTINUE T_SEMI {
1533 docont();
1535 | T_BREAK T_SEMI {
1536 dobreak();
1538 | T_RETURN T_SEMI {
1539 doreturn(NULL);
1541 | T_RETURN expr T_SEMI {
1542 doreturn($2);
1546 goto:
1547 T_GOTO {
1548 symtyp = FLAB;
1552 asm_stmnt:
1553 T_ASM T_LPARN read_until_rparn T_SEMI {
1554 setasm();
1556 | T_ASM T_QUAL T_LPARN read_until_rparn T_SEMI {
1557 setasm();
1559 | T_ASM error
1562 read_until_rparn:
1563 /* empty */ {
1564 ignuptorp();
1568 declaration_list:
1569 declaration {
1570 CLRWFLGS(__FILE__, __LINE__);
1572 | declaration_list declaration {
1573 CLRWFLGS(__FILE__, __LINE__);
1577 constant:
1578 expr %prec T_COMMA {
1579 $$ = $1;
1583 expr:
1584 expr T_MULT expr {
1585 $$ = build(MULT, $1, $3);
1587 | expr T_DIVOP expr {
1588 $$ = build($2, $1, $3);
1590 | expr T_ADDOP expr {
1591 $$ = build($2, $1, $3);
1593 | expr T_SHFTOP expr {
1594 $$ = build($2, $1, $3);
1596 | expr T_RELOP expr {
1597 $$ = build($2, $1, $3);
1599 | expr T_EQOP expr {
1600 $$ = build($2, $1, $3);
1602 | expr T_AND expr {
1603 $$ = build(AND, $1, $3);
1605 | expr T_XOR expr {
1606 $$ = build(XOR, $1, $3);
1608 | expr T_OR expr {
1609 $$ = build(OR, $1, $3);
1611 | expr T_LOGAND expr {
1612 $$ = build(LOGAND, $1, $3);
1614 | expr T_LOGOR expr {
1615 $$ = build(LOGOR, $1, $3);
1617 | expr T_QUEST expr T_COLON expr {
1618 $$ = build(QUEST, $1, build(COLON, $3, $5));
1620 | expr T_ASSIGN expr {
1621 $$ = build(ASSIGN, $1, $3);
1623 | expr T_OPASS expr {
1624 $$ = build($2, $1, $3);
1626 | expr T_COMMA expr {
1627 $$ = build(COMMA, $1, $3);
1629 | term {
1630 $$ = $1;
1634 term:
1635 T_NAME {
1636 /* XXX really necessary? */
1637 if (yychar < 0)
1638 yychar = yylex();
1639 $$ = getnnode(getsym($1), yychar);
1641 | string {
1642 $$ = getsnode($1);
1644 | T_CON {
1645 $$ = getcnode(gettyp($1->v_tspec), $1);
1647 | T_LPARN expr T_RPARN {
1648 if ($2 != NULL)
1649 $2->tn_parn = 1;
1650 $$ = $2;
1652 | T_LPARN comp_stmnt_lbrace declaration_list expr_stmnt_list {
1653 blklev--;
1654 mblklev--;
1655 initsym = mktempsym(duptyp($4->tn_type));
1656 mblklev++;
1657 blklev++;
1658 gnuism(320);
1659 } comp_stmnt_rbrace T_RPARN {
1660 $$ = getnnode(initsym, 0);
1662 | T_LPARN comp_stmnt_lbrace expr_stmnt_list {
1663 blklev--;
1664 mblklev--;
1665 initsym = mktempsym($3->tn_type);
1666 mblklev++;
1667 blklev++;
1668 gnuism(320);
1669 } comp_stmnt_rbrace T_RPARN {
1670 $$ = getnnode(initsym, 0);
1672 | term T_INCDEC {
1673 $$ = build($2 == INC ? INCAFT : DECAFT, $1, NULL);
1675 | T_INCDEC term {
1676 $$ = build($1 == INC ? INCBEF : DECBEF, $2, NULL);
1678 | T_MULT term {
1679 $$ = build(STAR, $2, NULL);
1681 | T_AND term {
1682 $$ = build(AMPER, $2, NULL);
1684 | T_UNOP term {
1685 $$ = build($1, $2, NULL);
1687 | T_ADDOP term {
1688 if (tflag && $1 == PLUS) {
1689 /* unary + is illegal in traditional C */
1690 warning(100);
1692 $$ = build($1 == PLUS ? UPLUS : UMINUS, $2, NULL);
1694 | term T_LBRACK expr T_RBRACK {
1695 $$ = build(STAR, build(PLUS, $1, $3), NULL);
1697 | term T_LPARN T_RPARN {
1698 $$ = funccall($1, NULL);
1700 | term T_LPARN func_arg_list T_RPARN {
1701 $$ = funccall($1, $3);
1703 | term point_or_arrow T_NAME {
1704 if ($1 != NULL) {
1705 sym_t *msym;
1706 /* XXX strmemb should be integrated in build() */
1707 if ($2 == ARROW) {
1708 /* must to this before strmemb is called */
1709 $1 = cconv($1);
1711 msym = strmemb($1, $2, getsym($3));
1712 $$ = build($2, $1, getnnode(msym, 0));
1713 } else {
1714 $$ = NULL;
1717 | T_REAL term {
1718 $$ = build(REAL, $2, NULL);
1720 | T_IMAG term {
1721 $$ = build(IMAG, $2, NULL);
1723 | T_REAL T_LPARN term T_RPARN {
1724 $$ = build(REAL, $3, NULL);
1726 | T_IMAG T_LPARN term T_RPARN {
1727 $$ = build(IMAG, $3, NULL);
1729 | T_SIZEOF term %prec T_SIZEOF {
1730 if (($$ = $2 == NULL ? NULL : bldszof($2->tn_type)) != NULL)
1731 chkmisc($2, 0, 0, 0, 0, 0, 1);
1733 | T_SIZEOF T_LPARN type_name T_RPARN %prec T_SIZEOF {
1734 $$ = bldszof($3);
1736 | T_ALIGNOF T_LPARN type_name T_RPARN %prec T_ALIGNOF {
1737 $$ = bldalof($3);
1739 | T_LPARN type_name T_RPARN term %prec T_UNOP {
1740 $$ = cast($4, $2);
1742 | T_LPARN type_name T_RPARN %prec T_UNOP {
1743 sym_t *tmp = mktempsym($2);
1744 idecl(tmp, 1, NULL);
1745 } init_lbrace init_expr_list init_rbrace {
1746 if (!Sflag)
1747 gnuism(319);
1748 $$ = getnnode(initsym, 0);
1752 string:
1753 T_STRING {
1754 $$ = $1;
1756 | T_STRING string2 {
1757 $$ = catstrg($1, $2);
1761 string2:
1762 T_STRING {
1763 if (tflag) {
1764 /* concatenated strings are illegal in traditional C */
1765 warning(219);
1767 $$ = $1;
1769 | string2 T_STRING {
1770 $$ = catstrg($1, $2);
1774 func_arg_list:
1775 expr %prec T_COMMA {
1776 $$ = funcarg(NULL, $1);
1778 | func_arg_list T_COMMA expr {
1779 $$ = funcarg($1, $3);
1783 point_or_arrow:
1784 T_STROP {
1785 symtyp = FMOS;
1786 $$ = $1;
1790 point:
1791 T_STROP {
1792 if ($1 != POINT)
1793 error(249, yytext);
1797 identifier:
1798 T_NAME {
1799 $$ = $1;
1801 | T_TYPENAME {
1802 $$ = $1;
1808 /* ARGSUSED */
1810 yyerror(const char *msg)
1812 error(249, yytext);
1813 if (++sytxerr >= 5)
1814 norecover();
1815 return (0);
1818 static __inline int uq_gt(uint64_t, uint64_t);
1819 static __inline int q_gt(int64_t, int64_t);
1821 static __inline int
1822 uq_gt(uint64_t a, uint64_t b)
1825 return (a > b);
1828 static __inline int
1829 q_gt(int64_t a, int64_t b)
1832 return (a > b);
1835 #define q_lt(a, b) q_gt(b, a)
1838 * Gets a node for a constant and returns the value of this constant
1839 * as integer.
1840 * Is the node not constant or too large for int or of type float,
1841 * a warning will be printed.
1843 * toicon() should be used only inside declarations. If it is used in
1844 * expressions, it frees the memory used for the expression.
1846 static int
1847 toicon(tnode_t *tn, int required)
1849 int i;
1850 tspec_t t;
1851 val_t *v;
1853 v = constant(tn, required);
1856 * Abstract declarations are used inside expression. To free
1857 * the memory would be a fatal error.
1859 if (dcs->d_ctx != ABSTRACT)
1860 tfreeblk();
1862 if ((t = v->v_tspec) == FLOAT || t == DOUBLE || t == LDOUBLE) {
1863 i = (int)v->v_ldbl;
1864 /* integral constant expression expected */
1865 error(55);
1866 } else {
1867 i = (int)v->v_quad;
1868 if (isutyp(t)) {
1869 if (uq_gt((uint64_t)v->v_quad,
1870 (uint64_t)INT_MAX)) {
1871 /* integral constant too large */
1872 warning(56);
1874 } else {
1875 if (q_gt(v->v_quad, (int64_t)INT_MAX) ||
1876 q_lt(v->v_quad, (int64_t)INT_MIN)) {
1877 /* integral constant too large */
1878 warning(56);
1882 free(v);
1883 return (i);
1886 static void
1887 idecl(sym_t *decl, int initflg, sbuf_t *renaming)
1889 char *s;
1891 initerr = 0;
1892 initsym = decl;
1894 switch (dcs->d_ctx) {
1895 case EXTERN:
1896 if (renaming != NULL) {
1897 if (decl->s_rename != NULL)
1898 LERROR("idecl()");
1900 s = getlblk(1, renaming->sb_len + 1);
1901 (void)memcpy(s, renaming->sb_name, renaming->sb_len + 1);
1902 decl->s_rename = s;
1903 freeyyv(&renaming, T_NAME);
1905 decl1ext(decl, initflg);
1906 break;
1907 case ARG:
1908 if (renaming != NULL) {
1909 /* symbol renaming can't be used on function arguments */
1910 error(310);
1911 freeyyv(&renaming, T_NAME);
1912 break;
1914 (void)decl1arg(decl, initflg);
1915 break;
1916 case AUTO:
1917 if (renaming != NULL) {
1918 /* symbol renaming can't be used on automatic variables */
1919 error(311);
1920 freeyyv(&renaming, T_NAME);
1921 break;
1923 decl1loc(decl, initflg);
1924 break;
1925 default:
1926 LERROR("idecl()");
1929 if (initflg && !initerr)
1930 prepinit();
1934 * Discard all input tokens up to and including the next
1935 * unmatched right paren
1937 static void
1938 ignuptorp(void)
1940 int level;
1942 if (yychar < 0)
1943 yychar = yylex();
1944 freeyyv(&yylval, yychar);
1946 level = 1;
1947 while (yychar != T_RPARN || --level > 0) {
1948 if (yychar == T_LPARN) {
1949 level++;
1950 } else if (yychar <= 0) {
1951 break;
1953 freeyyv(&yylval, yychar = yylex());
1956 yyclearin;