* guile-snarf.awk.in: Tweak to work with Sun/HP awk, removed some
[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]*%%%/ { copy = $0;
14 gsub(/[ \t]*%%%/, "", copy);
15 gsub(/\$\$\$.*$/, "", copy);
16 print copy; }
17
18 /\$\$\$/,/@@@/ { copy = $0;
19 if (match(copy,/\$\$\$R/)) { registering = 1; }
20 else {registering = 0; }
21 gsub(/.*\$\$\$./,"", copy);
22 gsub(/@@@.*/,"",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 /@@@/,/@!!!.*$/ { copy = $0;
56 gsub(/.*@@@/,"",copy);
57 sub(/^[ \t]*"?/,"", copy);
58 sub(/\"?[ \t]*@!!!.*$/,"", copy);
59 gsub(/\\\"/,"\"",copy);
60 gsub(/[ \t]*$/,"", copy);
61 if (copy != "") { print copy > dot_doc_file }
62 }
63
64 /@!!![ \t]/ { print "\ 1[" location "]" >> dot_doc_file; }
65
66 /\*&\*&\*&\*SCM_ARG_BETTER_BE_IN_POSITION/ { copy = $0;
67 sub(/.*\*&\*&\*&\*SCM_ARG_BETTER_BE_IN_POSITION\([ \t]*/,"",copy);
68 if (copy ~ /\"/) { next }
69 gsub(/[ \t]*,[ \t]*/,":",copy);
70 sub(/[ \t]*\).*/,"",copy);
71 split(copy,argpos,":");
72 argname = argpos[1];
73 pos = argpos[2];
74 if (pos ~ /[A-Za-z]/) { next }
75 if (pos ~ /^[ \t]*$/) { next }
76 if (argname ~ / /) { next }
77 line = argpos[3];
78 # print pos " " args[pos] " vs. " argname > "/dev/stderr";
79 if (args[pos] != argname) { print filename ":" line ":*** Argument name/number mismatch in `" curr_function_proto "' -- " argname " is not formal #" pos > "/dev/stderr"; }
80 }