;;;; -*- Mode: Lisp; Syntax: ANSI-Common-Lisp; Base: 10; Package: umlisp -*- ;;;; ************************************************************************* ;;;; FILE IDENTIFICATION ;;;; ;;;; Name: parse-macros.lisp ;;;; Purpose: Macros for UMLS file parsing ;;;; Programmer: Kevin M. Rosenberg ;;;; Date Started: Apr 2000 ;;;; ;;;; $Id: parse-macros.lisp,v 1.2 2002/10/09 23:03:41 kevin Exp $ ;;;; ;;;; This file, part of UMLisp, is ;;;; Copyright (c) 2000-2002 by Kevin M. Rosenberg, M.D. ;;;; ;;;; UMLisp users are granted the rights to distribute and use this software ;;;; as governed by the terms of the GNU General Public License. ;;;; ************************************************************************* (in-package :umlisp) (declaim (optimize (speed 3) (safety 1) (compilation-speed 0) (debug 3))) (defmacro with-umls-file ((line filename) &body body) "Opens a UMLS and processes each parsed line with (body) argument" (let ((ustream (gensym))) `(with-open-file (,ustream (umls-pathname ,filename) :direction :input :if-exists :overwrite) (do ((,line (read-umls-line ,ustream) (read-umls-line ,ustream))) ((eq ,line 'eof) t) ,@body)))) (defmacro with-buffered-umls-file ((line filename) &body body) "Opens a UMLS and processes each parsed line with (body) argument" (let ((ustream (gensym)) (buffer (gensym))) `(let ((,buffer (make-fields-buffer))) (with-open-file (,ustream (umls-pathname ,filename) :direction :input :if-exists :overwrite) (do ((,line (read-buffered-fields ,buffer ,ustream) (read-buffered-fields ,buffer ,ustream))) ((eq ,line 'eof) t) ,@body))))) (defmacro with-buffered2-umls-file ((line filename) &body body) "Opens a UMLS and processes each parsed line with (body) argument" (let ((ustream (gensym)) (buffer (gensym))) `(let ((,buffer (make-fields-buffer2))) (with-open-file (,ustream (umls-pathname ,filename) :direction :input :if-exists :overwrite) (do ((,line (read-buffered-fields2 ,buffer ,ustream) (read-buffered-fields2 ,buffer ,ustream))) ((eq ,line 'eof) t) ,@body)))))