1(define (parse-input port)
2 (let ((r (parse-readit port)))
3 (if r r (error "syntax error" port))))
4
5(define (parse-files fps)
6 (define (ensure-present fps)
7 (for-each (lambda (fp)
8 (unless (file-exists? fp)
9 (error "file does not exist" fp))) fps))
10
11 ;; According to the CHICKEN documentation, files passed to
12 ;; call-with-input-file "should already exist".
13 (ensure-present fps)
14
15 (fold (lambda (fp entries)
16 (append (call-with-input-file
17 fp parse-input) entries))
18 '() fps))
19
20(define (parse-args flags)
21 (args-fold
22 (command-line-arguments)
23 flags
24 (lambda (o n x vals)
25 (error "unrecognized option" n))
26 cons
27 '()))