File: make-doc

package info (click to toggle)
stklos 0.55-0.2
  • links: PTS
  • area: main
  • in suites: sarge
  • size: 15,068 kB
  • ctags: 14,984
  • sloc: ansic: 91,480; sh: 29,217; asm: 25,654; lisp: 1,431; makefile: 1,284; cpp: 1,125; perl: 213; yacc: 150; lex: 78; fortran: 24
file content (94 lines) | stat: -rwxr-xr-x 2,748 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
#!/usr/local/bin/snow -f
;;;;							-*- scheme -*-
;;;;
;;;; m a k e - d o c			-- Build the documentation file
;;;; 
;;;; Copyright  2000 Erick Gallesio - I3S-CNRS/ESSI <eg@unice.fr>
;;;; 
;;;; 
;;;; This program is free software; you can redistribute it and/or modify
;;;; it under the terms of the GNU General Public License as published by
;;;; the Free Software Foundation; either version 2 of the License, or
;;;; (at your option) any later version.
;;;; 
;;;; This program is distributed in the hope that it will be useful,
;;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
;;;; GNU General Public License for more details.
;;;; 
;;;; You should have received a copy of the GNU General Public License
;;;; along with this program; if not, write to the Free Software
;;;; Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, 
;;;; USA.
;;;; 
;;;;           Author: Erick Gallesio [eg@unice.fr]
;;;;    Creation date:  1-Feb-2000 18:02 (eg)
;;;; Last file update: 11-Apr-2000 12:32 (eg)
;;;;

(require "regexp")

(define *doc* '())

(define start-proc-rgxp   	(string->regexp "^/\\*\\+ "))
(define end-synopsys-rgxp 	(string->regexp "^ \\*[ \t]*$"))
(define end-comment-rgxp	(string->regexp "^ \\*/"))


(define (end-of-string s from)
  (let ((len (string-length s)))
    (substring s (min from len) len)))


(define (parse-until-regexp in rgxp)
  (let ((result '()))
    (do ((l (read-line in) (read-line in)))
	((or (eof-object? l) (rgxp l)))
      (set! result (if (null? result) 
		       (list (end-of-string l 3))
		       `(,(end-of-string l 3) "\n" ,@result))))
    (apply string-append (reverse result))))


(define (parse-proc-doc first-line in)
  (define (parse-proc-names first-line)
    (read-from-string (string-append "(" (end-of-string first-line 3) ")")))

  (define (parse-synopsys in)
    (parse-until-regexp in end-synopsys-rgxp))

  (define (parse-description in) 
    (parse-until-regexp in end-comment-rgxp))

  ;;
  ;; parse-proc-starts here 
  ;;
  (let* ((procs (parse-proc-names first-line))
	 (syn   (parse-synopsys in))
	 (descr (parse-description in)))
    (for-each  (lambda(p)
		 (format #t 
			 "(~S :type procedure :synopsys ~S :description ~S)\n"
			 p syn descr))
	      procs)))

(define (parse in)
  (do ((l (read-line in) (read-line in)))
      ((eof-object? l))
    (cond 
     ((start-proc-rgxp l) (parse-proc-doc l in))
     (else 'just-skip-it)))
  (close-input-port in))


(define (main files)
  (format #t ";;;; Automatically generated. DO NOT EDIT!!   -*- scheme -*-\n\n")
  (for-each (lambda (f) (parse (open-input-file f)))
	    files)
  (format #t ";;;; <EOF>\n"))

(main *argv*)