* snarf.h, guile-snarf.awk.in, guile-snarf.in: Replaced snarf
[bpt/guile.git] / libguile / guile-snarf.awk.in
1 # Written by Greg J. Badros, <gjb@cs.washington.edu>
2 # 12-Dec-1999
3
4 BEGIN { FS="|";
5 dot_doc_file = ARGV[1]; ARGV[1] = "";
6 ARGC = 0;
7 std_err = "/dev/stderr";
8 # be sure to put something in the files to help make out
9 print "";
10 printf "" > dot_doc_file;
11 }
12
13 /^[ \t]*SCM__I/ { copy = $0;
14 gsub(/[ \t]*SCM__I/, "", copy);
15 gsub(/SCM__D.*$/, "", copy);
16 print copy; }
17
18 /SCM__D/,/SCM__S/ { copy = $0;
19 if (match(copy,/SCM__DR/)) { registering = 1; }
20 else {registering = 0; }
21 gsub(/.*SCM__D./,"", copy);
22 gsub(/SCM__S.*/,"",copy);
23 gsub(/[ \t]+/," ", copy);
24 sub(/^[ \t]*/,"(", copy);
25 gsub(/\"/,"",copy);
26 sub(/\([ \t]*void[ \t]*\)/,"()", copy);
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);
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)
39 gsub(/[ \t]*\|.*$/,"",copy);
40 sub(/ \)/,")",copy);
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.
51 if (numargs != numactuals && !registering)
52 { print location ":*** `" copy "' is improperly registered as having " numactuals " arguments" > std_err; }
53 print "\f\n" copy (registering?")":"") > dot_doc_file ; }
54
55 /SCM__S/,/SCM__E.*$/ { copy = $0;
56 gsub(/.*SCM__S/,"",copy);
57 sub(/^[ \t]*"?/,"", copy);
58 sub(/\"?[ \t]*SCM__E.*$/,"", copy);
59 gsub(/\\n\\n"?/,"\n",copy);
60 gsub(/\\n"?[ \t]*$/,"",copy);
61 gsub(/\\\"[ \t]*$/,"\"",copy);
62 gsub(/[ \t]*$/,"", copy);
63 if (copy != "") { print copy > dot_doc_file }
64 }
65
66 /SCM__E[ \t]/ { print "\ 1[" location "]" >> dot_doc_file; }
67
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 }