Index: trunk/csv.lisp
===================================================================
--- trunk/csv.lisp	(revision trunk,26)
+++ trunk/csv.lisp	(revision trunk,27)
@@ -23,15 +23,16 @@
   ("." illegal))
 
-(defun lex-all-csv (input &optional tokens)
-  (format t "~&Lexing '~A...'~%" (subseq input 0 40))
-  (multiple-value-bind (class image left) (lex-csv input)
-    (cond
-      ((and class (eq class 'illegal))
-       (princ "oops")
-       (error "Illegal input"))
-      (class
-       (lex-all-csv left (cons (list class image) tokens)))
-      (t
-       (nreverse tokens)))))
+(defun lex-all-csv (input)
+  (labels ((lex-all (start tokens)
+	     (multiple-value-bind (class image next-offset)
+		 (lex-csv input start)
+	       (cond
+		 ((and class (eq class 'illegal))
+		  (error "Illegal input"))
+		 (class
+		  (lex-all next-offset (cons (cons class image) tokens)))
+		 (t
+		  (nreverse tokens))))))
+    (lex-all 0 nil)))
 
 (defmacro defmatcher (class)
@@ -39,5 +40,5 @@
     `(defun ,fn-sym (token-list)
       (when token-list
-	(destructuring-bind (class image) (first token-list)
+	(destructuring-bind (class . image) (first token-list)
 	  (when (eq class ',class)
 	    (values t (rest token-list) (list image))))))))
@@ -52,6 +53,5 @@
   (file (+ row))
   (row (t-value (* row-rest) (= t-newline))
-       (lambda (row)
-	 (mapcar #'car (cons (first row) (mapcar #'second (second row))))))
+       (lambda (row) (cons (caar row) (mapcar #'second (second row)))))
   (row-rest ((= t-comma) t-value) car))
 
