improved pp-token printing
authorD Herring <dherring@at.tentpost.dot.com>
Mon, 2 Apr 2012 00:26:53 +0000 (20:26 -0400)
committerD Herring <dherring@at.tentpost.dot.com>
Mon, 2 Apr 2012 00:26:53 +0000 (20:26 -0400)
examples/extensible-parser-example.lisp

index 340b632..a948e40 100644 (file)
   value ;; an integer or other representation
   )
 
+(defparameter *print-full-pp-token* nil
+  "print the full (t) or abbreviated (nil) pp-token")
+
+(defmethod print-object ((obj pp-token) stream)
+  (if *print-full-pp-token*
+      (call-next-method obj stream)
+      (format stream "~%#S(pp-token :type ~S :string ~S~@[ :value ~S~])"
+              (pp-token-type obj)
+              (pp-token-string obj)
+              (pp-token-value obj))))
+
 (defparameter *filename* nil
   "filename to use when creating tokens")