r2947: *** empty log message ***
[umlisp.git] / parse-macros.lisp
1 ;;; UMLS-Parse General
2 ;;; General purpose Lisp Routines for parsing UMLS files
3 ;;;   and inserting into SQL databases
4 ;;;
5 ;;; Copyright (c) 2001 Kevin M. Rosenberg, M.D.
6 ;;; $Id: parse-macros.lisp,v 1.1 2002/10/05 20:17:14 kevin Exp $
7
8 (in-package :umlisp)
9
10
11 (defmacro with-umls-file ((line filename) &body body)
12 "Opens a UMLS and processes each parsed line with (body) argument"
13   (let ((ustream (gensym)))
14     `(with-open-file
15       (,ustream (umls-pathname ,filename)
16                 :direction :input :if-exists :overwrite)
17       (do ((,line (read-umls-line ,ustream) (read-umls-line ,ustream)))
18           ((eq ,line 'eof) t)
19         ,@body))))
20
21 (defmacro with-buffered-umls-file ((line filename) &body body)
22 "Opens a UMLS and processes each parsed line with (body) argument"
23   (let ((ustream (gensym))
24         (buffer (gensym)))
25     `(let ((,buffer (make-fields-buffer)))
26        (with-open-file
27            (,ustream (umls-pathname ,filename)
28             :direction :input :if-exists :overwrite)
29          (do ((,line (read-buffered-fields ,buffer ,ustream) (read-buffered-fields ,buffer ,ustream)))
30              ((eq ,line 'eof) t)
31            ,@body)))))
32
33 (defmacro with-buffered2-umls-file ((line filename) &body body)
34 "Opens a UMLS and processes each parsed line with (body) argument"
35   (let ((ustream (gensym))
36         (buffer (gensym)))
37     `(let ((,buffer (make-fields-buffer2)))
38        (with-open-file
39            (,ustream (umls-pathname ,filename)
40             :direction :input :if-exists :overwrite)
41          (do ((,line (read-buffered-fields2 ,buffer ,ustream) (read-buffered-fields2 ,buffer ,ustream)))
42              ((eq ,line 'eof) t)
43            ,@body)))))
44