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 ;;;; Programmer: Kevin M. Rosenberg
8 ;;;; Date Started: Apr 2000
10 ;;;; $Id: parse-macros.lisp,v 1.4 2003/05/06 01:34:57 kevin Exp $
12 ;;;; This file, part of UMLisp, is
13 ;;;; Copyright (c) 2000-2002 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 ;;;; *************************************************************************
22 (defmacro with-umls-file ((line filename) &body body)
23 "Opens a UMLS and processes each parsed line with (body) argument"
24 (let ((ustream (gensym "STRM-"))
25 (eof (gensym "EOF-")))
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)))
40 (,ustream (umls-pathname ,filename) :direction :input)
41 (do ((,line (read-buffered-fields ,buffer ,ustream #\| ,eof)
42 (read-buffered-fields ,buffer ,ustream #\| ,eof)))
46 (defmacro with-buffered2-umls-file ((line filename) &body body)
47 "Opens a UMLS and processes each parsed line with (body) argument"
48 (let ((ustream (gensym "STRM-"))
49 (buffer (gensym "BUF-"))
50 (eof (gensym "EOF-")))
51 `(let ((,buffer (make-fields-buffer2)))
53 (,ustream (umls-pathname ,filename)
54 :direction :input :if-exists :overwrite)
55 (do ((,line (read-buffered-fields ,buffer ,ustream #\| ,eof)
56 (read-buffered-fields ,buffer ,ustream #\| ,eof)))