Index: trunk/dso-parse.asd
===================================================================
--- trunk/dso-parse.asd	(revision trunk,18)
+++ trunk/dso-parse.asd	(revision trunk,18)
@@ -0,0 +1,5 @@
+;;;; -*- Mode: Lisp; Syntax: ANSI-Common-Lisp -*-
+
+(asdf:defsystem #:parse
+  :depends-on (#:cl-ppcre)
+  :components ((:file "parse")))
Index: runk/parse.asd
===================================================================
--- trunk/parse.asd	(revision trunk,2)
+++ 	(revision )
@@ -1,5 +1,0 @@
-;;;; -*- Mode: Lisp; Syntax: ANSI-Common-Lisp -*-
-
-(asdf:defsystem #:parse
-  :depends-on (#:cl-ppcre)
-  :components ((:file "parse")))
Index: runk/parse2.lisp
===================================================================
--- trunk/parse2.lisp	(revision trunk,7)
+++ 	(revision )
@@ -1,230 +1,0 @@
-#|(copyright)|#
-
-(require '#:parse)
-
-(use-package '#:parse)
-(import '(parse::with-gensyms parse::substring))
-
-(defvar *follow* nil)
-
-(defmacro follow (fmt &rest args)
-  (when *follow*
-    `(format t ,fmt ,@args)))
-
-(defun whole (n)
-  (declare ((or null (integer 0)) n))
-  (when (and n (/= n 0)) n))
-
-(defun min- (n)
-  (declare ((or null (integer 1)) n))
-  (when (and n (> n 1)) (1- n)))
-
-(defun max- (n)
-  (declare ((or null (integer 0)) n))
-  (when n (1- n)))
-
-(defmacro with-character-parser ((name char) &body body)
-  (declare (symbol name)
-	   (character char))
-  (follow "with-character-parser~%")
-  (with-gensyms (input)
-    `(flet ((,name (,input)
-	     ,(format nil "Character parser for ~S." char)
-	     (declare (string ,input))
-	     (when (and (> (length ,input) 0) (char= (char ,input 0) ,char))
-	       (values t (substring ,input :start 1) '(,char)))))
-      (declare (inline ,name))
-      ,@body)))
-
-(defmacro with-string-parser ((name string) &body body)
-  (declare (symbol name)
-	   (string string))
-  (follow "with-string-parser~%")
-  (let ((len (length string)))
-    (with-gensyms (input)
-      `(flet ((,name (,input)
-	       ,(format nil "String parser for ~S." string)
-	       (declare (string ,input))
-	       (when (and (>= (length ,input) ,len)
-			  (string= ,input ,string :end1 ,len))
-		 (values t (substring ,input :start ,len) '(,string)))))
-	(declare (inline ,name))
-	,@body))))
-
-(defmacro with-regex-parser ((name regex) &body body)
-  (declare ((symbol name)
-	    (string regex)))
-  (follow "with-regex-parser~%")
-  (let ((regex2 `(:sequence (:flags) :start-anchor
-		  (:register (:regex ,regex)))))
-    (with-gensyms (input start end)
-      `(flet ((,name (,input)
-	       ,(format nil "Regex parser for ~S." regex)
-	       (declare (string ,input))
-	       (multiple-value-bind (,start ,end) (scan (quote ,regex2) ,input)
-		 (when ,start
-		   (values
-		    t
-		    (substring ,input :start ,end)
-		    (list (substring ,input :end ,end)))))))
-	,@body))))
-
-(defmacro with-user-parser ((name parser) &body body)
-  (declare (symbol name parser))
-  (follow "with-user-parser~%")
-  (with-gensyms (input)
-    `(flet ((,name (,input)
-	     ,(format nil "User parser for ~S." parser)
-	     (,parser ,input)))
-      (declare (inline ,name))
-      ,@body)))
-
-(defmacro with-sequence-parser% ((name seq) &body body)
-  (declare (symbol name)
-	   (list seq))
-  (follow "with-sequence-parser%~%")
-  (with-gensyms (input tree head tail matched left found)
-    (if seq
-	`(with-sequence-parser% (,tail ,(rest seq))
-	  (with-parser (,head ,(first seq))
-	    (flet ((,name (,input ,tree)
-		     ,(format nil "Sequence parser for ~S." seq)
-		     (declare (list ,tree))
-		     (multiple-value-bind (,matched ,left ,found)
-			 (,head ,input)
-		       (when ,matched (,tail ,left (append ,tree ,found))))))
-	      (declare (inline ,name))
-	      ,@body)))
-	`(flet ((,name (,input ,tree)
-		 "Sequence parser base case."
-		 (declare (list ,tree))
-		 (values t ,input ,tree)))
-	  (declare (inline ,name))
-	  ,@body))))
-
-(defmacro with-sequence-parser ((name seq) &body body)
-  (declare (symbol name)
-	   (list seq))
-  (follow "with-sequence-parser~%")
-  (with-gensyms (subname input matched left found)
-    `(with-sequence-parser% (,subname ,seq)
-      (flet ((,name (,input)
-	       ,(format nil "Sequence parser head for ~S." seq)
-	       (multiple-value-bind (,matched ,left ,found)
-		   (,subname ,input nil)
-		 (when ,matched (values t ,left (list ,found))))))
-	(declare (inline ,name))
-	,@body))))
-
-(defmacro with-choice-parser ((name alts) &body body)
-  (declare (symbol name)
-	   (list alts))
-  (follow "with-choice-parser~%")
-  (with-gensyms (head tail input matched left found)
-    (if alts
-	`(with-choice-parser (,tail ,(rest alts))
-	  (with-parser (,head ,(first alts))
-	    (flet ((,name (,input)
-		     ,(format nil "Choice parser for ~S." alts)
-		     (multiple-value-bind (,matched ,left ,found)
-			 (,head ,input)
-		       (if ,matched
-			   (values t ,left ,found)
-			   (,tail ,input)))))
-	      (declare (inline ,name))
-	      ,@body)))
-	`(flet ((,name (,input)
-		 "Choice parser for base case."
-		 (declare (ignore ,input))))
-	  (declare (inline ,name))
-	  ,@body))))
-
-(defmacro with-required-parser ((name rule) &body body)
-  (declare (symbol name))
-  (follow "with-required-parser~%")
-  (with-gensyms (sub input)
-    `(with-parser (,sub ,rule)
-      (flet ((,name (,input)
-	       ,(format nil "Required parser for ~S." rule)
-	       (when (,sub ,input) (values t ,input nil))))
-	(declare (inline ,name))
-	,@body))))
-
-(defmacro with-forbidden-parser ((name rule) &body body)
-  (declare (symbol name))
-  (follow "with-forbidden-parser~%")
-  (with-gensyms (sub input)
-    `(with-parser (,sub ,rule)
-      (flet ((,name (,input)
-	       ,(format nil "Forbidden parser for ~S." rule)
-	       (unless (,sub ,input) (values t ,input nil))))
-	(declare (inline ,name))
-	,@body))))
-
-(defmacro with-range-parser ((name mincount maxcount rule) &body body)
-  (declare (symbol name)
-	   ((or null (integer 0)) mincount)
-	   ((or null (integer 1)) maxcount))
-  (assert (or (not maxcount) (not mincount) (>= maxcount mincount)))
-  (follow "with-range-parser~%")
-  (with-gensyms (sub subname input min max tree matched left found)
-    `(with-parser (,sub ,rule)
-      (labels ((,subname (,min ,max ,input ,tree)
-		 (declare ((or null (integer 0)) ,min)
-			  ((or null (integer 0)) ,max))
-		 ,(format nil "Range parser {~S, ~S} for ~S."
-			  mincount maxcount rule)
-
-		 (if (and ,max (= ,max 0))
-
-		     ;; Only time this can happen (because we can't
-		     ;; create a {*,0} parser) is after already
-		     ;; collecting some matches.  Because MAX >= MIN
-		     ;; always, we've also already collected *enough*.
-		     (values t ,input ,tree)
-
-		     ;; We haven't hit the limit (if any), so try
-		     ;; another match.
-		     (multiple-value-bind (,matched ,left ,found) (,sub ,input)
-		       (cond
-			 (,matched (,subname (min- ,min) (max- ,max)
-					     ,left (append ,tree ,found)))
-			 ;; Either no minimum, or already filled it
-			 ;; (by the saturating MIN-), so succeed.
-			 ((not ,min) (values t ,input ,tree))
-
-			 ;; Return NIL
-			 )))))
-
-	(flet ((,name (,input)
-		 (,subname ,(whole mincount) ,(whole maxcount) ,input nil)))
-	  (declare (inline ,name))
-	  ,@body)))))
-
-(defmacro with-parser ((name rule) &body body)
-  (declare (symbol name))
-  (follow "with-parser~%")
-  (etypecase rule
-    (character `(with-character-parser (,name ,rule) ,@body))
-    (string `(with-string-parser (,name ,rule) ,@body))
-    (symbol `(with-user-parser (,name ,rule) ,@body))
-    (list
-     (destructuring-bind (head . tail) rule
-       (case head
-	 (^ (destructuring-bind (regex) tail
-	      `(with-regex-parser (,name ,regex) ,@body)))
-	 (/ `(with-choice-parser (,name ,tail) ,@body))
-	 (& (destructuring-bind (subrule) tail
-	      `(with-required-parser (,name ,subrule) ,@body)))
-	 (! (destructuring-bind (subrule) tail
-	      `(with-forbidden-parser (,name ,subrule) ,@body)))
-	 ({} (destructuring-bind (mincount maxcount subrule) tail
-	       `(with-range-parser (,name ,mincount ,maxcount ,subrule)
-		 ,@body)))
-	 (* (destructuring-bind (subrule) tail
-	      `(with-range-parser (,name nil nil ,subrule) ,@body)))
-	 (+ (destructuring-bind (subrule) tail
-	      `(with-range-parser (,name 1 nil ,subrule) ,@body)))
-	 (? (destructuring-bind (subrule) tail
-	      `(with-range-parser (,name 0 1 ,subrule) ,@body)))
-	 (t `(with-sequence-parser (,name ,rule) ,@body)))))))
