1 ;;;; -*- Mode: Lisp; Syntax: ANSI-Common-Lisp; Base: 10; Package: umlisp -*-
2 ;;;; *************************************************************************
3 ;;;; FILE IDENTIFICATION
5 ;;;; Name: parse-macros.lisp
6 ;;;; Purpose: Macros for UMLS file parsing
7 ;;;; Author: Kevin M. Rosenberg
12 ;;;; This file, part of UMLisp, is
13 ;;;; Copyright (c) 2000-2004 by Kevin M. Rosenberg, M.D.
15 ;;;; UMLisp users are granted the rights to distribute and use this software
16 ;;;; as governed by the terms of the GNU General Public License.
17 ;;;; *************************************************************************
21 (defmacro with-umls-file ((line filename) &body body)
22 "Opens a UMLS and processes each parsed line with (body) argument"
23 (let ((ustream (gensym "STRM-"))
24 (eof (gensym "EOF-")))
25 `(let ((,eof (gensym "EOFSYM-")))
27 (,ustream (umls-pathname ,filename) :direction :input)
28 (do ((,line (read-umls-line ,ustream ,eof)
29 (read-umls-line ,ustream ,eof)))
33 (defmacro with-buffered-umls-file ((line filename) &body body)
34 "Opens a UMLS and processes each parsed line with (body) argument"
35 (let ((ustream (gensym "STRM-"))
36 (buffer (gensym "BUF-"))
37 (eof (gensym "EOF-")))
38 `(let ((,buffer (make-fields-buffer))
39 (,eof (gensym "EOFSYM-")))
41 (,ustream (umls-pathname ,filename) :direction :input)
42 (do ((,line (read-buffered-fields ,buffer ,ustream #\| ,eof)
43 (read-buffered-fields ,buffer ,ustream #\| ,eof)))
47 (defmacro with-buffered2-umls-file ((line filename) &body body)
48 "Opens a UMLS and processes each parsed line with (body) argument"
49 (let ((ustream (gensym "STRM-"))
50 (buffer (gensym "BUF-"))
51 (eof (gensym "EOF-")))
52 `(let ((,buffer (make-fields-buffer2))
53 (,eof (gensym "EOFSYM-")))
55 (,ustream (umls-pathname ,filename)
56 :direction :input :if-exists :overwrite)
57 (do ((,line (read-buffered-fields ,buffer ,ustream #\| ,eof)
58 (read-buffered-fields ,buffer ,ustream #\| ,eof)))