X-Git-Url: http://git.kpe.io/?a=blobdiff_plain;f=parse-macros.lisp;h=902b3cf5f2f6d1e4c73627fea618068b932d3a90;hb=a4851b680b8430b9792d1e86318657de16cf0a96;hp=f3a8408719a4a0f5714a4ce294ed2beb740f13a2;hpb=0ececd07987c48de78c14a60136014a2df7b280b;p=umlisp.git diff --git a/parse-macros.lisp b/parse-macros.lisp index f3a8408..902b3cf 100644 --- a/parse-macros.lisp +++ b/parse-macros.lisp @@ -1,44 +1,60 @@ -;;; UMLS-Parse General -;;; General purpose Lisp Routines for parsing UMLS files -;;; and inserting into SQL databases -;;; -;;; Copyright (c) 2001 Kevin M. Rosenberg, M.D. -;;; $Id: parse-macros.lisp,v 1.1 2002/10/05 20:17:14 kevin Exp $ - -(in-package :umlisp) +;;;; -*- Mode: Lisp; Syntax: ANSI-Common-Lisp; Base: 10; Package: umlisp -*- +;;;; ************************************************************************* +;;;; FILE IDENTIFICATION +;;;; +;;;; Name: parse-macros.lisp +;;;; Purpose: Macros for UMLS file parsing +;;;; Author: Kevin M. Rosenberg +;;;; Date Started: Apr 2000 +;;;; +;;;; $Id: parse-macros.lisp,v 1.8 2003/06/10 22:30:16 kevin Exp $ +;;;; +;;;; This file, part of UMLisp, is +;;;; Copyright (c) 2000-2003 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) (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)))) + (let ((ustream (gensym "STRM-")) + (eof (gensym "EOF-"))) + `(let ((,eof (gensym "EOFSYM-"))) + (with-open-file + (,ustream (umls-pathname ,filename) :direction :input) + (do ((,line (read-umls-line ,ustream ,eof) + (read-umls-line ,ustream ,eof))) + ((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))))) + "Opens a UMLS and processes each parsed line with (body) argument" + (let ((ustream (gensym "STRM-")) + (buffer (gensym "BUF-")) + (eof (gensym "EOF-"))) + `(let ((,buffer (make-fields-buffer)) + (,eof (gensym "EOFSYM-"))) + (with-open-file + (,ustream (umls-pathname ,filename) :direction :input) + (do ((,line (read-buffered-fields ,buffer ,ustream #\| ,eof) + (read-buffered-fields ,buffer ,ustream #\| ,eof))) + ((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))))) - + "Opens a UMLS and processes each parsed line with (body) argument" + (let ((ustream (gensym "STRM-")) + (buffer (gensym "BUF-")) + (eof (gensym "EOF-"))) + `(let ((,buffer (make-fields-buffer2)) + (,eof (gensym "EOFSYM-"))) + (with-open-file + (,ustream (umls-pathname ,filename) + :direction :input :if-exists :overwrite) + (do ((,line (read-buffered-fields ,buffer ,ustream #\| ,eof) + (read-buffered-fields ,buffer ,ustream #\| ,eof))) + ((eq ,line ,eof) t) + ,@body)))))