29 KEYWORDS
["switch"]=
10;
32 KEYWORDS
["continue"]=
10;
36 KEYWORDS
["typedef"]=
1;
38 KEYWORDS
["unsigned"]=
3;
53 while ((token=yylex
()) != "EOF")
55 #print "0 -" token "-" yyval "-"
56 if ((token==
"keyword" && KEYWORDS
[yyval
]<10) || token==
"typedef")
59 token=read_type
(token
);
69 ret=rt_type
" " rt_ptr
;
87 token=read_type
(token
);
95 while((token==yylex
())!=")" || plevel
!=1)
106 par_type
[npar
]=rt_type
;
107 par_ptr
[npar
]=rt_ptr
;
109 print "-" rt_type
"-" rt_ptr
"-" name
113 print "Processing "fname
"..." npar
114 file=
"test/" tolower(fname
) ".c"
115 print "/*****************************************************************************\n"
117 print "\t"ret
" "fname
" (\n"
118 print "/* SYNOPSIS */"
120 if (npar==
1 && par_type
[1]==
"void" && par_ptr
[1] ==
"" &&
128 for (t=
1; t
<=npar
; t
++)
130 len=
length(par_type
[t
]);
131 len2=
length(par_ptr
[t
]);
132 len
+=len2 ? len2
+1 : 0;
137 for (t=
1; t
<=npar
; t
++)
139 len=
length(par_type
[t
]);
140 len2=
length(par_ptr
[t
]);
142 printf("\t%s", par_type
[t
]);
143 printf("%s", substr(spaces
,1,maxlen
-len
-len2
));
144 printf("%s %s",par_ptr
[t
],par_name
[t
]);
157 function read_type
(pretoken
,token
) {
159 print "token3 " token
"-" yyval
162 while ((token==
"keyword" && KEYWORDS
[yyval
]<10) || token==
"typedef")
164 rt_type=rt_type
" " yyval
;
165 if (KEYWORDS
[yyval
]==
2)
168 rt_type=rt_type
" " yyval
;
171 print "token2 " token
173 rt_type=
substr(rt_type
,2);
174 print "type " rt_type
177 while (token==
"*" || token==
"(")
183 print "token1 " token
190 function yyinit
(str
) {
195 for (yyagain=
1; yyagain
; )
198 if (yyrest==
"" || match(yyrest
,/^
[ \t\014\r]+/))
204 if (getline yyrest
!= 1)
206 #print "1 -" yyrest "-"
207 if (substr(yyrest
,1,1) ==
"#")
210 if (!
match(yyrest
,"^[ \t\014\r]+"))
212 yyrest=
substr(yyrest
,RSTART+RLENGTH);
215 if (match(yyrest
,/^\
/\
*/))
217 yyrest=
substr(yyrest
,3);
218 while (!
match(yyrest
,"\*\/"))
220 if (getline yyrest
!= 1)
222 #print "2 -" yyrest "-"
224 yyrest=
substr(yyrest
,RSTART+RLENGTH);
228 if (match(yyrest
,"^[a-zA-Z_][a-zA-Z0-9_]*"))
230 yyval=
substr(yyrest
,RSTART,RLENGTH);
231 yyrest=
substr(yyrest
,RSTART+RLENGTH);
235 else if (yyval in KEYWORDS
)
240 if (match(yyrest
,"^0[xX][0-9a-f]+[lL]?"))
242 yyval=
substr(yyrest
,RSTART,RLENGTH);
243 yyrest=
substr(yyrest
,RSTART+RLENGTH);
246 if (match(yyrest
,/^
([0-9]*\.
[0-9]+|[0-9]+\.
[0-9]*)([eE
][0-9]+)?
[fF
]?
/))
248 yyval=
substr(yyrest
,RSTART,RLENGTH);
249 yyrest=
substr(yyrest
,RSTART+RLENGTH);
250 return "float_const";
252 if (match(yyrest
,"^0[0-7]+[lL]?"))
254 yyval=
substr(yyrest
,RSTART,RLENGTH);
255 yyrest=
substr(yyrest
,RSTART+RLENGTH);
258 if (match(yyrest
,"^[1-9][0-9]*[lL]?"))
260 yyval=
substr(yyrest
,RSTART,RLENGTH);
261 yyrest=
substr(yyrest
,RSTART+RLENGTH);
264 if (match(yyrest
,"^\""))
266 if (match(yyrest
,"^\"(\\\"|[^\"])*\""))
268 yyval=
substr(yyrest
,RSTART,RLENGTH);
269 yyrest=
substr(yyrest
,RSTART+RLENGTH);
274 yyval=
substr(yyrest
,1,length(yyrest
)-1);
277 if (getline yyrest
!= 1)
279 if (match(yyrest
,"^(\\\"|[^\"])*\""))
281 yyval=yyval
substr(yyrest
,1,length(yyrest
)-1);
283 yyval=yyval
substr(yyrest
,RSTART,RLENGTH);
284 yyrest=
substr(yyrest
,RSTART+RLENGTH);
288 if (substr(yyrest
,1,3)==
"...")
291 yyrest=
substr(yyrest
,4);
294 yyval=
substr(yyrest
,1,1);
295 yyrest=
substr(yyrest
,2);