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.2 2002/10/09 23:03:41 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 ;;;; *************************************************************************
20 (declaim (optimize (speed 3) (safety 1) (compilation-speed 0) (debug 3)))
23 (defmacro with-umls-file ((line filename) &body body)
24 "Opens a UMLS and processes each parsed line with (body) argument"
25 (let ((ustream (gensym)))
27 (,ustream (umls-pathname ,filename)
28 :direction :input :if-exists :overwrite)
29 (do ((,line (read-umls-line ,ustream) (read-umls-line ,ustream)))
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))
37 `(let ((,buffer (make-fields-buffer)))
39 (,ustream (umls-pathname ,filename)
40 :direction :input :if-exists :overwrite)
41 (do ((,line (read-buffered-fields ,buffer ,ustream) (read-buffered-fields ,buffer ,ustream)))
45 (defmacro with-buffered2-umls-file ((line filename) &body body)
46 "Opens a UMLS and processes each parsed line with (body) argument"
47 (let ((ustream (gensym))
49 `(let ((,buffer (make-fields-buffer2)))
51 (,ustream (umls-pathname ,filename)
52 :direction :input :if-exists :overwrite)
53 (do ((,line (read-buffered-fields2 ,buffer ,ustream) (read-buffered-fields2 ,buffer ,ustream)))