Recently Written · git

CSV

Convert CSV (in a reader macro, or in a file) in to Lisp lists.

git clone https://github.com/equwal/CSV

Log | Files | Refs


utils.lisp (796 bytes)

1 (in-package :csv)
2 (defmacro dolines ((var stream) &body body)
3   `(do ((,var #1=(read-line ,stream nil nil) #1#))
4        ((null ,var))
5      ,@body))
6 (defmacro with-gensyms (symbols &body body)
7   "Create gensyms for those symbols."
8   `(let (,@(mapcar #'(lambda (sym)
9 		       `(,sym ',(gensym))) symbols))
10      ,@body))
11 (defmacro make-reader (name (stream-var dispatch-1 dispatch-2) &body body)
12   "Simplify the reader macro creation process in most cases."
13   (with-gensyms (sub-char numarg)
14     `(progn (defun ,name (,stream-var ,sub-char ,numarg)
15 	      (declare (ignore ,sub-char ,numarg))
16 	      ,@body)
17 	    (set-dispatch-macro-character ,dispatch-1 ,dispatch-2 #',name))))
18 (defun push-on (elt stack)
19   (vector-push-extend elt stack) stack)
20 (define-modify-macro toggle () not "Flipping vars.")