1 /* $NetBSD: grammar.y,v 1.1.1.5 2013/04/06 14:45:27 christos Exp $ */
3 /* Id: grammar.y,v 1.5 2012/01/15 20:00:59 tom Exp
5 * yacc grammar for C function prototype generator
6 * This was derived from the grammar in Appendix A of
7 * "The C Programming Language" by Kernighan and Ritchie.
13 #define YYSTYPE_IS_DECLARED
14 #define yyerror yaccError
17 #if defined(YYBISON) || !defined(YYBYACC)
18 static void yyerror(const char *s
);
22 %token
<text
> '(' '*' '&'
23 /* identifiers that are not reserved words */
24 T_IDENTIFIER T_TYPEDEF_NAME T_DEFINE_NAME
27 T_AUTO T_EXTERN T_REGISTER T_STATIC T_TYPEDEF
28 /* This keyword included for compatibility with C++. */
30 /* This keyword included for compatibility with GCC */
34 T_CHAR T_DOUBLE T_FLOAT T_INT T_VOID
35 T_LONG T_SHORT T_SIGNED T_UNSIGNED
36 T_ENUM T_STRUCT T_UNION
38 T_Bool T_Complex T_Imaginary
43 /* paired square brackets and everything between them: [ ... ] */
49 /* all input to the matching right brace */
55 /* constant expression or paired braces following an equal sign */
63 /* ( "string literal" ) following asm keyword */
66 /* va_dcl from <varargs.h> */
69 %type
<decl_spec
> decl_specifiers decl_specifier
70 %type
<decl_spec
> storage_class type_specifier type_qualifier
71 %type
<decl_spec
> struct_or_union_specifier enum_specifier
72 %type
<decl_list
> init_declarator_list
73 %type
<declarator
> init_declarator declarator direct_declarator
74 %type
<declarator
> abs_declarator direct_abs_declarator
75 %type
<param_list
> parameter_type_list parameter_list
76 %type
<parameter
> parameter_declaration
77 %type
<param_list
> opt_identifier_list identifier_list
78 %type
<text
> struct_or_union pointer opt_type_qualifiers type_qualifier_list
79 any_id identifier_or_ref
80 %type
<text
> enumeration
87 #define OPT_LINTLIBRARY 1
97 /* #include "cproto.h" */
98 #define MAX_TEXT_SIZE 1024
100 /* Prototype styles */
102 #define PROTO_ANSI_LLIB -2 /* form ANSI lint-library source */
103 #define PROTO_LINTLIBRARY -1 /* form lint-library source */
105 #define PROTO_NONE 0 /* do not output any prototypes */
106 #define PROTO_TRADITIONAL 1 /* comment out parameters */
107 #define PROTO_ABSTRACT 2 /* comment out parameter names */
108 #define PROTO_ANSI 3 /* ANSI C prototype */
110 typedef
int PrototypeStyle
;
112 typedef
char boolean
;
114 extern boolean types_out
;
115 extern PrototypeStyle proto_style
;
117 #define ansiLintLibrary() (proto_style == PROTO_ANSI_LLIB)
118 #define knrLintLibrary() (proto_style == PROTO_LINTLIBRARY)
119 #define lintLibrary() (knrLintLibrary() || ansiLintLibrary())
122 #define FUNC_UNKNOWN -1 /* unspecified */
124 #define FUNC_UNKNOWN 0 /* unspecified (same as FUNC_NONE) */
126 #define FUNC_NONE 0 /* not a function definition */
127 #define FUNC_TRADITIONAL 1 /* traditional style */
128 #define FUNC_ANSI 2 /* ANSI style */
129 #define FUNC_BOTH 3 /* both styles */
131 typedef
int FuncDefStyle
;
133 /* Source file text */
134 typedef
struct text
{
135 char text
[MAX_TEXT_SIZE
]; /* source text */
136 long begin
; /* offset in temporary file */
139 /* Declaration specifier flags */
140 #define DS_NONE 0 /* default */
141 #define DS_EXTERN 1 /* contains "extern" specifier */
142 #define DS_STATIC 2 /* contains "static" specifier */
143 #define DS_CHAR 4 /* contains "char" type specifier */
144 #define DS_SHORT 8 /* contains "short" type specifier */
145 #define DS_FLOAT 16 /* contains "float" type specifier */
146 #define DS_INLINE 32 /* contains "inline" specifier */
147 #define DS_JUNK 64 /* we're not interested in this declaration */
149 /* This structure stores information about a declaration specifier. */
150 typedef
struct decl_spec
{
151 unsigned short flags
; /* flags defined above */
152 char *text
; /* source text */
153 long begin
; /* offset in temporary file */
156 /* This is a list of function parameters. */
157 typedef
struct _ParameterList
{
158 struct parameter
*first
; /* pointer to first parameter in list */
159 struct parameter
*last
; /* pointer to last parameter in list */
160 long begin_comment
; /* begin offset of comment */
161 long end_comment
; /* end offset of comment */
162 char *comment
; /* comment at start of parameter list */
165 /* This structure stores information about a declarator. */
166 typedef
struct _Declarator
{
167 char *name
; /* name of variable or function */
168 char *text
; /* source text */
169 long begin
; /* offset in temporary file */
170 long begin_comment
; /* begin offset of comment */
171 long end_comment
; /* end offset of comment */
172 FuncDefStyle func_def
; /* style of function definition */
173 ParameterList params
; /* function parameters */
174 boolean pointer
; /* TRUE if it declares a pointer */
175 struct _Declarator
*head
; /* head function declarator */
176 struct _Declarator
*func_stack
; /* stack of function declarators */
177 struct _Declarator
*next
; /* next declarator in list */
180 /* This structure stores information about a function parameter. */
181 typedef
struct parameter
{
182 struct parameter
*next
; /* next parameter in list */
184 Declarator
*declarator
;
185 char *comment
; /* comment following the parameter */
188 /* This is a list of declarators. */
189 typedef
struct declarator_list
{
190 Declarator
*first
; /* pointer to first declarator in list */
191 Declarator
*last
; /* pointer to last declarator in list */
194 /* #include "symbol.h" */
195 typedef
struct symbol
{
196 struct symbol
*next
; /* next symbol in list */
197 char *name
; /* name of symbol */
198 char *value
; /* value of symbol (for defines) */
199 short flags
; /* symbol attributes */
202 /* parser stack entry type */
206 Parameter
*parameter
;
207 ParameterList param_list
;
208 Declarator
*declarator
;
209 DeclaratorList decl_list
;
212 /* The hash table length should be a prime number. */
213 #define SYM_MAX_HASH 251
215 typedef
struct symbol_table
{
216 Symbol
*bucket
[SYM_MAX_HASH
]; /* hash buckets */
219 extern SymbolTable
*new_symbol_table
/* Create symbol table */
221 extern
void free_symbol_table
/* Destroy symbol table */
223 extern Symbol
*find_symbol
/* Lookup symbol name */
224 (SymbolTable
*s
, const char *n
);
225 extern Symbol
*new_symbol
/* Define new symbol */
226 (SymbolTable
*s
, const char *n
, const char *v
, int f
);
228 /* #include "semantic.h" */
229 extern
void new_decl_spec
(DeclSpec
*, const char *, long, int);
230 extern
void free_decl_spec
(DeclSpec
*);
231 extern
void join_decl_specs
(DeclSpec
*, DeclSpec
*, DeclSpec
*);
232 extern
void check_untagged
(DeclSpec
*);
233 extern Declarator
*new_declarator
(const char *, const char *, long);
234 extern
void free_declarator
(Declarator
*);
235 extern
void new_decl_list
(DeclaratorList
*, Declarator
*);
236 extern
void free_decl_list
(DeclaratorList
*);
237 extern
void add_decl_list
(DeclaratorList
*, DeclaratorList
*, Declarator
*);
238 extern Parameter
*new_parameter
(DeclSpec
*, Declarator
*);
239 extern
void free_parameter
(Parameter
*);
240 extern
void new_param_list
(ParameterList
*, Parameter
*);
241 extern
void free_param_list
(ParameterList
*);
242 extern
void add_param_list
(ParameterList
*, ParameterList
*, Parameter
*);
243 extern
void new_ident_list
(ParameterList
*);
244 extern
void add_ident_list
(ParameterList
*, ParameterList
*, const char *);
245 extern
void set_param_types
(ParameterList
*, DeclSpec
*, DeclaratorList
*);
246 extern
void gen_declarations
(DeclSpec
*, DeclaratorList
*);
247 extern
void gen_prototype
(DeclSpec
*, Declarator
*);
248 extern
void gen_func_declarator
(Declarator
*);
249 extern
void gen_func_definition
(DeclSpec
*, Declarator
*);
251 extern
void init_parser
(void);
252 extern
void process_file
(FILE *infile
, char *name
);
253 extern
char *cur_text
(void);
254 extern
char *cur_file_name
(void);
255 extern
char *implied_typedef
(void);
256 extern
void include_file
(char *name
, int convert
);
257 extern
char *supply_parm
(int count
);
258 extern
char *xstrdup
(const char *);
259 extern
int already_declared
(char *name
);
260 extern
int is_actual_func
(Declarator
*d
);
261 extern
int lint_ellipsis
(Parameter
*p
);
262 extern
int want_typedef
(void);
263 extern
void begin_tracking
(void);
264 extern
void begin_typedef
(void);
265 extern
void copy_typedef
(char *s
);
266 extern
void ellipsis_varargs
(Declarator
*d
);
267 extern
void end_typedef
(void);
268 extern
void flush_varargs
(void);
269 extern
void fmt_library
(int code
);
270 extern
void imply_typedef
(const char *s
);
271 extern
void indent
(FILE *outf
);
272 extern
void put_blankline
(FILE *outf
);
273 extern
void put_body
(FILE *outf
, DeclSpec
*decl_spec
, Declarator
*declarator
);
274 extern
void put_char
(FILE *outf
, int c
);
275 extern
void put_error
(void);
276 extern
void put_newline
(FILE *outf
);
277 extern
void put_padded
(FILE *outf
, const char *s
);
278 extern
void put_string
(FILE *outf
, const char *s
);
279 extern
void track_in
(void);
281 extern boolean file_comments
;
282 extern FuncDefStyle func_style
;
283 extern
char base_file
[];
285 extern
int yylex (void);
287 /* declaration specifier attributes for the typedef statement currently being
290 static int cur_decl_spec_flags
;
292 /* pointer to parameter list for the current function definition */
293 static ParameterList
*func_params
;
295 /* A parser semantic action sets this pointer to the current declarator in
296 * a function parameter declaration in order to catch any comments following
297 * the parameter declaration on the same line. If the lexer scans a comment
298 * and <cur_declarator> is not NULL, then the comment is attached to the
299 * declarator. To ignore subsequent comments, the lexer sets this to NULL
300 * after scanning a comment or end of line.
302 static Declarator
*cur_declarator
;
304 /* temporary string buffer */
305 static char buf
[MAX_TEXT_SIZE
];
307 /* table of typedef names */
308 static SymbolTable
*typedef_names
;
310 /* table of define names */
311 static SymbolTable
*define_names
;
313 /* table of type qualifiers */
314 static SymbolTable
*type_qualifiers
;
316 /* information about the current input file */
318 char *base_name
; /* base input file name */
319 char *file_name
; /* current file name */
320 FILE *file
; /* input file */
321 unsigned line_num
; /* current line number in input file */
322 FILE *tmp_file
; /* temporary file */
323 long begin_comment
; /* tmp file offset after last written ) or ; */
324 long end_comment
; /* tmp file offset after last comment */
325 boolean convert
; /* if TRUE, convert function definitions */
326 boolean changed
; /* TRUE if conversion done in this file */
329 static IncludeStack
*cur_file
; /* current input file */
331 /* #include "yyerror.c" */
333 static int haveAnsiParam
(void);
336 /* Flags to enable us to find if a procedure returns a value.
338 static int return_val
; /* nonzero on BRACES iff return-expression found */
343 return
(lintLibrary
() && !return_val
) ?
"void" : "int";
350 if
(func_params
!= 0) {
351 for
(p
= func_params
->first
; p
!= 0; p
= p
->next
) {
352 if
(p
->declarator
->func_def
== FUNC_ANSI
) {
368 : external_declaration
369 | translation_unit external_declaration
374 | function_definition
376 | linkage_specification
378 |
error T_MATCHRBRACE
389 : T_LBRACE T_MATCHRBRACE
392 linkage_specification
393 : T_EXTERN T_STRING_LITERAL braces
395 /* Provide an empty action here so bison will not complain about
396 * incompatible types in the default action it normally would
400 | T_EXTERN T_STRING_LITERAL declaration
407 : decl_specifiers
';'
410 if
(types_out
&& want_typedef
()) {
411 gen_declarations
(&$1, (DeclaratorList
*)0);
418 | decl_specifiers init_declarator_list
';'
420 if
(func_params
!= NULL
) {
421 set_param_types
(func_params
, &$1, &$2);
423 gen_declarations
(&$1, &$2);
432 | any_typedef decl_specifiers
434 cur_decl_spec_flags
= $2.flags
;
437 opt_declarator_list
';'
444 : T_EXTENSION T_TYPEDEF
462 int flags
= cur_decl_spec_flags
;
464 /* If the typedef is a pointer type, then reset the short type
465 * flags so it does not get promoted.
467 if
(strcmp
($1->text
, $1->name
) != 0)
468 flags
&= ~
(DS_CHAR | DS_SHORT | DS_FLOAT
);
469 new_symbol
(typedef_names
, $1->name
, NULL
, flags
);
472 | declarator_list
',' declarator
474 int flags
= cur_decl_spec_flags
;
476 if
(strcmp
($3->text
, $3->name
) != 0)
477 flags
&= ~
(DS_CHAR | DS_SHORT | DS_FLOAT
);
478 new_symbol
(typedef_names
, $3->name
, NULL
, flags
);
484 : decl_specifiers declarator
487 if
($2->func_def
== FUNC_NONE
) {
488 yyerror("syntax error");
491 func_params
= &($2->head
->params
);
492 func_params
->begin_comment
= cur_file
->begin_comment
;
493 func_params
->end_comment
= cur_file
->end_comment
;
495 opt_declaration_list T_LBRACE
497 /* If we're converting to K&R and we've got a nominally K&R
498 * function which has a parameter which is ANSI (i.e., a prototyped
499 * function pointer), then we must override the deciphered value of
500 * 'func_def' so that the parameter will be converted.
502 if
(func_style
== FUNC_TRADITIONAL
504 && $2->head
->func_def
== func_style
) {
505 $2->head
->func_def
= FUNC_BOTH
;
510 if
(cur_file
->convert
)
511 gen_func_definition
(&$1, $2);
512 gen_prototype
(&$1, $2);
522 if
($1->func_def
== FUNC_NONE
) {
523 yyerror("syntax error");
526 func_params
= &($1->head
->params
);
527 func_params
->begin_comment
= cur_file
->begin_comment
;
528 func_params
->end_comment
= cur_file
->end_comment
;
530 opt_declaration_list T_LBRACE T_MATCHRBRACE
536 new_decl_spec
(&decl_spec
, dft_decl_spec
(), $1->begin
, DS_NONE
);
537 if
(cur_file
->convert
)
538 gen_func_definition
(&decl_spec
, $1);
539 gen_prototype
(&decl_spec
, $1);
543 free_decl_spec
(&decl_spec
);
556 | declaration_list declaration
561 | decl_specifiers decl_specifier
563 join_decl_specs
(&$$
, &$1, &$2);
578 new_decl_spec
(&$$
, $1.text
, $1.begin
, DS_NONE
);
582 new_decl_spec
(&$$
, $1.text
, $1.begin
, DS_EXTERN
);
586 new_decl_spec
(&$$
, $1.text
, $1.begin
, DS_NONE
);
590 new_decl_spec
(&$$
, $1.text
, $1.begin
, DS_STATIC
);
594 new_decl_spec
(&$$
, $1.text
, $1.begin
, DS_INLINE
);
598 new_decl_spec
(&$$
, $1.text
, $1.begin
, DS_JUNK
);
605 new_decl_spec
(&$$
, $1.text
, $1.begin
, DS_CHAR
);
609 new_decl_spec
(&$$
, $1.text
, $1.begin
, DS_NONE
);
613 new_decl_spec
(&$$
, $1.text
, $1.begin
, DS_FLOAT
);
617 new_decl_spec
(&$$
, $1.text
, $1.begin
, DS_NONE
);
621 new_decl_spec
(&$$
, $1.text
, $1.begin
, DS_NONE
);
625 new_decl_spec
(&$$
, $1.text
, $1.begin
, DS_SHORT
);
629 new_decl_spec
(&$$
, $1.text
, $1.begin
, DS_NONE
);
633 new_decl_spec
(&$$
, $1.text
, $1.begin
, DS_NONE
);
637 new_decl_spec
(&$$
, $1.text
, $1.begin
, DS_NONE
);
641 new_decl_spec
(&$$
, $1.text
, $1.begin
, DS_CHAR
);
645 new_decl_spec
(&$$
, $1.text
, $1.begin
, DS_NONE
);
649 new_decl_spec
(&$$
, $1.text
, $1.begin
, DS_NONE
);
654 s
= find_symbol
(typedef_names
, $1.text
);
656 new_decl_spec
(&$$
, $1.text
, $1.begin
, s
->flags
);
658 | struct_or_union_specifier
665 new_decl_spec
(&$$
, $1.text
, $1.begin
, DS_NONE
);
669 /* This rule allows the <pointer> nonterminal to scan #define
670 * names as if they were type modifiers.
673 s
= find_symbol
(define_names
, $1.text
);
675 new_decl_spec
(&$$
, $1.text
, $1.begin
, s
->flags
);
679 struct_or_union_specifier
680 : struct_or_union any_id braces
683 if
((s
= implied_typedef
()) == 0)
684 (void)sprintf
(s
= buf
, "%s %s", $1.text
, $2.text
);
685 new_decl_spec
(&$$
, s
, $1.begin
, DS_NONE
);
687 | struct_or_union braces
690 if
((s
= implied_typedef
()) == 0)
691 (void)sprintf
(s
= buf
, "%s {}", $1.text
);
692 new_decl_spec
(&$$
, s
, $1.begin
, DS_NONE
);
694 | struct_or_union any_id
696 (void)sprintf
(buf
, "%s %s", $1.text
, $2.text
);
697 new_decl_spec
(&$$
, buf
, $1.begin
, DS_NONE
);
704 imply_typedef
($$.text
);
708 imply_typedef
($$.text
);
715 new_decl_list
(&$$
, $1);
717 | init_declarator_list
',' init_declarator
719 add_decl_list
(&$$
, &$1, $3);
726 if
($1->func_def
!= FUNC_NONE
&& func_params
== NULL
&&
727 func_style
== FUNC_TRADITIONAL
&& cur_file
->convert
) {
728 gen_func_declarator
($1);
729 fputs
(cur_text
(), cur_file
->tmp_file
);
735 if
($1->func_def
!= FUNC_NONE
&& func_params
== NULL
&&
736 func_style
== FUNC_TRADITIONAL
&& cur_file
->convert
) {
737 gen_func_declarator
($1);
738 fputs
(" =", cur_file
->tmp_file
);
745 : enumeration any_id braces
748 if
((s
= implied_typedef
()) == 0)
749 (void)sprintf
(s
= buf
, "enum %s", $2.text
);
750 new_decl_spec
(&$$
, s
, $1.begin
, DS_NONE
);
755 if
((s
= implied_typedef
()) == 0)
756 (void)sprintf
(s
= buf
, "%s {}", $1.text
);
757 new_decl_spec
(&$$
, s
, $1.begin
, DS_NONE
);
761 (void)sprintf
(buf
, "enum %s", $2.text
);
762 new_decl_spec
(&$$
, buf
, $1.begin
, DS_NONE
);
769 imply_typedef
("enum");
780 : pointer direct_declarator
783 (void)sprintf
(buf
, "%s%s", $1.text
, $$
->text
);
785 $$
->text
= xstrdup
(buf
);
786 $$
->begin
= $1.begin
;
795 $$
= new_declarator
($1.text
, $1.text
, $1.begin
);
800 (void)sprintf
(buf
, "(%s)", $$
->text
);
802 $$
->text
= xstrdup
(buf
);
803 $$
->begin
= $1.begin
;
805 | direct_declarator T_BRACKETS
808 (void)sprintf
(buf
, "%s%s", $$
->text
, $2.text
);
810 $$
->text
= xstrdup
(buf
);
812 | direct_declarator
'(' parameter_type_list
')'
814 $$
= new_declarator
("%s()", $1->name
, $1->begin
);
817 $$
->head
= ($1->func_stack
== NULL
) ? $$
: $1->head
;
818 $$
->func_def
= FUNC_ANSI
;
820 | direct_declarator
'(' opt_identifier_list
')'
822 $$
= new_declarator
("%s()", $1->name
, $1->begin
);
825 $$
->head
= ($1->func_stack
== NULL
) ? $$
: $1->head
;
826 $$
->func_def
= FUNC_TRADITIONAL
;
831 : '*' opt_type_qualifiers
833 (void)sprintf
($$.text
, "*%s", $2.text
);
836 |
'*' opt_type_qualifiers pointer
838 (void)sprintf
($$.text
, "*%s%s", $2.text
, $3.text
);
849 | type_qualifier_list
855 (void)sprintf
($$.text
, "%s ", $1.text
);
859 | type_qualifier_list type_qualifier
861 (void)sprintf
($$.text
, "%s%s ", $1.text
, $2.text
);
869 | parameter_list
',' T_ELLIPSIS
871 add_ident_list
(&$$
, &$1, "...");
876 : parameter_declaration
878 new_param_list
(&$$
, $1);
880 | parameter_list
',' parameter_declaration
882 add_param_list
(&$$
, &$1, $3);
886 parameter_declaration
887 : decl_specifiers declarator
890 $$
= new_parameter
(&$1, $2);
892 | decl_specifiers abs_declarator
895 $$
= new_parameter
(&$1, $2);
900 $$
= new_parameter
(&$1, (Declarator
*)0);
916 add_ident_list
(&$$
, &$$
, $1.text
);
918 | identifier_list
',' any_id
920 add_ident_list
(&$$
, &$1, $3.text
);
932 if
(lintLibrary
()) { /* Lint doesn't grok C++ ref variables */
936 (void)sprintf
($$.text
, "&%s", $2.text
);
944 $$
= new_declarator
($1.text
, "", $1.begin
);
946 | pointer direct_abs_declarator
949 (void)sprintf
(buf
, "%s%s", $1.text
, $$
->text
);
951 $$
->text
= xstrdup
(buf
);
952 $$
->begin
= $1.begin
;
954 | direct_abs_declarator
957 direct_abs_declarator
958 : '(' abs_declarator
')'
961 (void)sprintf
(buf
, "(%s)", $$
->text
);
963 $$
->text
= xstrdup
(buf
);
964 $$
->begin
= $1.begin
;
966 | direct_abs_declarator T_BRACKETS
969 (void)sprintf
(buf
, "%s%s", $$
->text
, $2.text
);
971 $$
->text
= xstrdup
(buf
);
975 $$
= new_declarator
($1.text
, "", $1.begin
);
977 | direct_abs_declarator
'(' parameter_type_list
')'
979 $$
= new_declarator
("%s()", "", $1->begin
);
982 $$
->head
= ($1->func_stack
== NULL
) ? $$
: $1->head
;
983 $$
->func_def
= FUNC_ANSI
;
985 | direct_abs_declarator
'(' ')'
987 $$
= new_declarator
("%s()", "", $1->begin
);
989 $$
->head
= ($1->func_stack
== NULL
) ? $$
: $1->head
;
990 $$
->func_def
= FUNC_ANSI
;
992 |
'(' parameter_type_list
')'
996 d
= new_declarator
("", "", $1.begin
);
997 $$
= new_declarator
("%s()", "", $1.begin
);
1001 $$
->func_def
= FUNC_ANSI
;
1007 d
= new_declarator
("", "", $1.begin
);
1008 $$
= new_declarator
("%s()", "", $1.begin
);
1011 $$
->func_def
= FUNC_ANSI
;
1018 #define BEGIN yy_start = 1 + 2 *
1026 #define CPP_INLINE 7
1028 extern
char *yytext
;
1029 extern
FILE *yyin
, *yyout
;
1031 static int curly
; /* number of curly brace nesting levels */
1032 static int ly_count
; /* number of occurances of %% */
1033 static int inc_depth
; /* include nesting level */
1034 static SymbolTable
*included_files
; /* files already included */
1035 static int yy_start
= 0; /* start state number */
1037 #define grammar_error(s) yaccError(s)
1040 yaccError
(const char *msg
)
1043 put_error
(); /* tell what line we're on, and what file */
1044 fprintf
(stderr
, "%s at token '%s'\n", msg
, yytext
);
1047 /* Initialize the table of type qualifier keywords recognized by the lexical
1053 static const char *keywords
[] = {
1062 #if defined(MSDOS) || defined(OS2)
1107 "__builtin_va_list",
1120 /* Initialize type qualifier table. */
1121 type_qualifiers
= new_symbol_table
();
1122 for
(i
= 0; i
< sizeof
(keywords
)/sizeof
(keywords
[0]); ++i
) {
1123 new_symbol
(type_qualifiers
, keywords
[i
], NULL
, DS_NONE
);
1127 /* Process the C source file. Write function prototypes to the standard
1128 * output. Convert function definitions and write the converted source
1129 * code to a temporary file.
1132 process_file
(FILE *infile
, char *name
)
1136 if
(strlen
(name
) > 2) {
1137 s
= name
+ strlen
(name
) - 2;
1140 if
(*s
== 'l' ||
*s
== 'y')
1142 #if defined(MSDOS) || defined(OS2)
1143 if
(*s
== 'L' ||
*s
== 'Y')
1149 included_files
= new_symbol_table
();
1150 typedef_names
= new_symbol_table
();
1151 define_names
= new_symbol_table
();
1157 include_file
(strcpy
(base_file
, name
), func_style
!= FUNC_NONE
);
1158 if
(file_comments
) {
1160 if
(lintLibrary
()) {
1161 put_blankline
(stdout
);
1165 put_string
(stdout
, "/* ");
1166 put_string
(stdout
, cur_file_name
());
1167 put_string
(stdout
, " */\n");
1170 free_symbol_table
(define_names
);
1171 free_symbol_table
(typedef_names
);
1172 free_symbol_table
(included_files
);
1179 free_symbol_table
(type_qualifiers
);
1181 if
(yy_current_buffer
!= 0)
1182 yy_delete_buffer
(yy_current_buffer
);