*** empty log message ***
[bpt/guile.git] / libguile / guile-snarf.awk.in
CommitLineData
e8e9b690
GB
1# Written by Greg J. Badros, <gjb@cs.washington.edu>
2# 12-Dec-1999
3
4BEGIN { FS="|";
11a5232f
GB
5 dot_doc_file = ARGV[1]; ARGV[1] = "";
6 ARGC = 0;
7 std_err = "/dev/stderr";
e8e9b690
GB
8 # be sure to put something in the files to help make out
9 print "";
10 printf "" > dot_doc_file;
11}
12
d80f396e
MD
13/^[ \t]*SCM__I/ { copy = $0;
14 gsub(/[ \t]*SCM__I/, "", copy);
15 gsub(/SCM__D.*$/, "", copy);
e8e9b690
GB
16 print copy; }
17
d80f396e
MD
18/SCM__D/,/SCM__S/ { copy = $0;
19 if (match(copy,/SCM__DR/)) { registering = 1; }
e8e9b690 20 else {registering = 0; }
d80f396e
MD
21 gsub(/.*SCM__D./,"", copy);
22 gsub(/SCM__S.*/,"",copy);
e8e9b690
GB
23 gsub(/[ \t]+/," ", copy);
24 sub(/^[ \t]*/,"(", copy);
25 gsub(/\"/,"",copy);
c751e5e3 26 sub(/\([ \t]*void[ \t]*\)/,"()", copy);
e8e9b690
GB
27 sub(/ \(/," ",copy);
28 numargs = gsub(/SCM /,"", copy);
29 numcommas = gsub(/,/,"", copy);
30 numactuals = $2 + $3 + $4;
31 location = $5;
32 gsub(/\"/,"",location);
33 sub(/^[ \t]*/,"",location);
34 sub(/[ \t]*$/,"",location);
35 sub(/: /,":",location);
c751e5e3
GB
36 # Now whittle copy down to just the $1 field
37 # (but do not use $1, since it hasn't been
38 # altered by the above regexps)
e8e9b690
GB
39 gsub(/[ \t]*\|.*$/,"",copy);
40 sub(/ \)/,")",copy);
c751e5e3
GB
41 # Now `copy' contains the nice scheme proc "prototype", e.g.
42 # (set-car! pair value)
43 # print copy > "/dev/stderr"; # for debugging
44 proc_and_args = copy;
45 curr_function_proto = copy;
46 sub(/[^ \n]* /,"",proc_and_args);
47 sub(/\)[ \t]*/,"",proc_and_args);
48 split(proc_and_args,args," ");
49 # now args is an array of the arguments
50 # args[1] is the formal name of the first argument, etc.
e8e9b690 51 if (numargs != numactuals && !registering)
11a5232f 52 { print location ":*** `" copy "' is improperly registered as having " numactuals " arguments" > std_err; }
e8e9b690
GB
53 print "\f\n" copy (registering?")":"") > dot_doc_file ; }
54
d80f396e
MD
55/SCM__S/,/SCM__E.*$/ { copy = $0;
56 gsub(/.*SCM__S/,"",copy);
e8e9b690 57 sub(/^[ \t]*"?/,"", copy);
d80f396e 58 sub(/\"?[ \t]*SCM__E.*$/,"", copy);
09aebdb5
GB
59 gsub(/\\n\\n"?/,"\n",copy);
60 gsub(/\\n"?[ \t]*$/,"",copy);
61 gsub(/\\\"[ \t]*$/,"\"",copy);
e8e9b690 62 gsub(/[ \t]*$/,"", copy);
c751e5e3
GB
63 if (copy != "") { print copy > dot_doc_file }
64 }
65
d80f396e 66/SCM__E[ \t]/ { print "\ 1[" location "]" >> dot_doc_file; }
e8e9b690 67
c751e5e3
GB
68/\*&\*&\*&\*SCM_ARG_BETTER_BE_IN_POSITION/ { copy = $0;
69 sub(/.*\*&\*&\*&\*SCM_ARG_BETTER_BE_IN_POSITION\([ \t]*/,"",copy);
70 if (copy ~ /\"/) { next }
71 gsub(/[ \t]*,[ \t]*/,":",copy);
72 sub(/[ \t]*\).*/,"",copy);
73 split(copy,argpos,":");
74 argname = argpos[1];
75 pos = argpos[2];
76 if (pos ~ /[A-Za-z]/) { next }
77 if (pos ~ /^[ \t]*$/) { next }
78 if (argname ~ / /) { next }
79 line = argpos[3];
80# print pos " " args[pos] " vs. " argname > "/dev/stderr";
81 if (args[pos] != argname) { print filename ":" line ":*** Argument name/number mismatch in `" curr_function_proto "' -- " argname " is not formal #" pos > "/dev/stderr"; }
82 }