Index: trunk/parsing.lisp
===================================================================
--- trunk/parsing.lisp	(revision trunk,27)
+++ trunk/parsing.lisp	(revision trunk,31)
@@ -2,19 +2,18 @@
 
 #|
-Copyright (C) 2007  David Owen <dsowen@fugue88.ws>
+Copyright (C) 2007, 2008  David Owen <dsowen@fugue88.ws>
 
-This library is free software; you can redistribute it and/or
-modify it under the terms of the GNU Lesser General Public
-License as published by the Free Software Foundation; either
-version 2.1 of the License, or (at your option) any later version.
+This program is free software: you can redistribute it and/or modify
+it under the terms of the GNU Lesser Public License as published by
+the Free Software Foundation, either version 3 of the License, or
+(at your option) any later version.
 
-This library is distributed in the hope that it will be useful,
+This program is distributed in the hope that it will be useful,
 but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-Lesser General Public License for more details.
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU Lesser Public License for more details.
 
-You should have received a copy of the GNU Lesser General Public
-License along with this library; if not, write to the Free Software
-Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
+You should have received a copy of the GNU Lesser Public License
+along with this program.  If not, see <http://www.gnu.org/licenses/>.
 |#
 
@@ -23,14 +22,15 @@
 
 
-(defmacro defparser (name rule &optional filter)
+(defmacro defparser (name rule &key cclass filter)
   "Defines a function named NAME that parses its input according to
 RULE (see IF-MATCHES).  On success, returns the values T, the
-unconsumed input, and the tree (labeled with NAME).  On failure ,
-returns NIL.
+unconsumed input, and the tree (labeled with NAME, unless CCLASS is
+true).  On failure, returns NIL.
 
 The tree may optionally be filtered by FILTER before being labeled."
-  `(defun ,name (input)
-    (if-matches input ,rule (next match)
-     (values t next (cons ',name ,(if filter `(,filter match) 'match))))))
+  (let ((filtered (if filter `(,filter match) `match)))
+    `(defun ,name (input)
+       (if-matches input ,rule (next match)
+         (values t next ,(if cclass `,filtered `(cons ',name ,filtered)))))))
 
 (defmacro defgrammar (() &body definitions)
@@ -38,7 +38,5 @@
 
 (DEFGRAMMAR (options*) definitions*)
-definitions: (name rule filter?)"
-  (flet ((x (definition)
-	   (destructuring-bind (name rule &optional filter) definition
-	     `(defparser ,name ,rule ,filter))))
+definitions: (name rule &key filter cclass)"
+  (flet ((x (definition) `(defparser ,@definition)))
     `(progv () ,@(mapcar #'x definitions))))
