Index: trunk/parse3.lisp
===================================================================
--- trunk/parse3.lisp	(revision trunk,7)
+++ trunk/parse3.lisp	(revision trunk,9)
@@ -17,16 +17,17 @@
   `(if (and (string/= "" ,input) (char= ,char (char ,input 0)))
     (let ((,next (substring ,input :start 1))
-	  (,match ,char))
+	  (,match '(,char)))
       ,then)
     ,else))
 
 (defmacro if-matches-string (input string (next match)
-				   &body (&optional (then t) else))
+			     &body (&optional (then t) else))
   (declare (symbol next match)
 	   (string string))
   (let ((len (length string)))
-    `(if (string= ,string (substring ,input :length ,len))
+    `(if (and (>= (length ,input) ,len)
+	  (string= ,string (substring ,input :length ,len)))
       (let ((,next (substring ,input :start ,len))
-	    (,match ,string))
+	    (,match '(,string)))
 	,then)
       ,else)))
@@ -42,5 +43,5 @@
 	(if ,start
 	    (let ((,next (substring ,input :start ,end))
-		  (,match (substring ,input :end ,end)))
+		  (,match (list (substring ,input :end ,end))))
 	      ,then)
 	    ,else)))))
@@ -59,5 +60,5 @@
 
 (defmacro if-matches-sequence (input seq (next match)
-				     &body (&optional (then t) else))
+			       &body (&optional (then t) else))
   (destructuring-bind (head . tail) seq
     (if tail
@@ -65,11 +66,11 @@
 	  `(if-matches ,input ,head (,head-next ,head-match)
 	    (if-matches-sequence ,head-next ,tail (,next ,tail-match)
-	     (let ((,match (cons ,head-match ,tail-match)))
-	       ,then)
-	     ,else)
+	      (let ((,match (append ,head-match ,tail-match)))
+		,then)
+	      ,else)
 	    ,else))
 	(with-gensyms (head-match)
 	  `(if-matches ,input ,head (,next ,head-match)
-	    (let ((,match (cons ,head-match nil)))
+	    (let ((,match ,head-match))
 	      ,then)
 	    ,else)))))
@@ -91,5 +92,4 @@
 	,then))))
 
-;;; This doesn't quite work yet.
 (defmacro if-matches-maxcount (input count rule (next match)
 				     &body (&optional (then t) else))
@@ -125,5 +125,5 @@
 
 (defmacro if-matches-required (input rule (next match)
-				     &body (&optional (then t) else))
+			       &body (&optional (then t) else))
   `(if-matches ,input ,rule (,(gensym) ,(gensym))
     (let ((,next ,input)
@@ -133,5 +133,5 @@
 
 (defmacro if-matches-forbidden (input rule (next match)
-				      &body (&optional (then t) else))
+				&body (&optional (then t) else))
   `(if-matches ,input ,rule (,(gensym) ,(gensym))
     ,else
@@ -139,4 +139,12 @@
 	  (,match nil))
       ,then)))
+
+(defmacro if-matches-only (input rule (next match)
+			   &body (&optional (then t) else))
+  (with-gensyms (match2)
+    `(if-matches ,input ,rule (,next ,match2)
+      (let ((,match nil))
+	,then)
+      ,else)))
 
 (defmacro if-matches (input rule (next match) &body (&optional (then t) else))
@@ -166,4 +174,6 @@
 	 (! (destructuring-bind (sub) tail
 	      `(if-matches-forbidden ,input ,sub (,next ,match) ,then ,else)))
+	 (= (destructuring-bind (sub) tail
+	      `(if-matches-only ,input ,sub (,next ,match) ,then ,else)))
 	 (t `(if-matches-sequence ,input ,rule (,next ,match)
 	      ,then ,else)))))))
