anchor.diff:  
   (declaim (inline error?))
   (defstruct (parser-error (:conc-name error-) (:predicate error?))
  -   type index args)
  -
  -(defmacro pass (value n)
  -   `(progn (incf *index* ,n) ,value))
  -
  -(declaim (inline fail))
  -(defun fail (type args &optional (index *index*))
  -   (make-parser-error :type type :args args :index index))
  +  (index 0 :type fixnum) data)
  +
  +(defmacro succeed (value offset)
  +  `(progn (incf *index* ,offset) ,value))
  +
  +(defmacro fail (data &optional (index *index*))
  +  `(make-parser-error :data ,data :index ,index))
   
   (defmacro on-success (exp &rest body)
      (with-gensyms (r)
  
positive.code:       (declare (character ,genchar))
        (if (test-remaining 1)
           (if (eql (char *source* *index*) ,genchar)
               (pass ,genchar 1)
               (fail (string ,genchar) nil))
           (fail (string ,genchar) nil)))))
  
  ;; str
  
  (define-parser str (string)
     (iter (for char in-string string)
           (for parse-result = (dynamic-run `(chr ,char)))
           (on-failure parse-result (leave parse-result))
           (finally (return string))))
  
  (define-compiled-parser str (string)
     (with-gensyms (genstring length)
       `(let* ((,genstring ,string) (,length (length ,genstring)))
          (declare (string ,genstring) (fixnum ,length)) 
          (if (test-remaining ,length)
              (iter (for x from 0 below ,length)
                    (declare (fixnum x))
                    (unless (eql (char ,genstring x) (char *source* (+ *index* x)))
                      (leave (fail 'expected (list ,genstring))))
                    (finally (return (pass ,genstring ,length))))
              (fail ,genstring nil)))))
  
  ;; try
  
  (define-parser try (p)
     (let* ((*index* *index*))
        (dynamic-run p)))
  
  (define-compiled-parser try (p)
     `(let* ((*index* *index*))
        ,(compile-parser p)))
  
  ;; any
  
  (define-parser any (p)
     (iter (for r = (dynamic-run p))
           (until (error? r))
           (collect r into result)
           (finally (return (merge-characters result)))))
  
  (define-compiled-parser any (p)
     (with-gensyms (result list)
  
negative.code:              (progn ,@body)
               ,r))))
  
  ;; 'interpreted' parsers, for dynamic calling at runtime
  ;; used as a fallback and for prototyping new parsers
  (defparameter interpreted-parsers (make-hash-table :test #'equalp))
  
  ;; parsers that serve as the first level of compilation,
  ;; generates code to be inserted by a macro
  (defparameter compiled-parsers (make-hash-table :test #'equalp))
  
  (defmacro define-internal-parser (name ll &rest body)
    `(setf (gethash ',name interpreted-parsers)
           (defun ,name ,ll ,@body)))
  
  (defmacro define-compiled-parser (name ll &rest body)
    `(setf (gethash ',name compiled-parsers)
           (lambda ,ll ,@body)))
  
  (defmacro run-parser (data)
  	(if (and (listp data) (eq (car data) 'quote))
  		 (compile-parser (second data))
  		 (with-gensyms (foo)
  			`(let ((,foo ,data))
  				 (apply (car ,foo) (cdr ,foo))))))
  
  (defun compile-parser (exp)
    (aif (and (listp exp) (gethash (car exp) compiled-parsers))
         (apply it (cdr exp))
         (error "unexpected form: ~a" exp)))
  
  (defmacro parse (string form)
    `(let* ((*source* ,string)
            (*source-length*
               ,(if (stringp string) (length string) '(length *source*)))
            (*index* 0))
            (run-parser ,form)))
  
  (defparameter user-parsers (make-hash-table :test #'equalp))
  
  (defmacro defparser (name ll &rest body)
    `(setf (gethash ',name user-parsers)
           (list ,ll ,body)))
  
  ;; chr      ~ matches a single character
  ;; str      ~ explicitly matches a string
  ;; choice   ~ returns the first parser that succeeds
  ;; seq      ~ matches each form sequentially
  ;; any      ~ matches zero or more of the form
  ;; many     ~ matches one or more of the form
  ;; times    ~ parses x occurances of y
  ;; try      ~ returns a parsing result, no effect on the normal parser stack
  ;; optional ~ tries x, parses it on success, succeeds either way
  ;; sep      ~ seperates by repeated matching. mostly magic
  ;; one-of   ~ matches one character from the given string
  ;; none-of  ~ matches only if none of the chars in the string match
  ;; range    ~ matches a character numerically in a given range
  
  (defmacro test-remaining (n)
    `(>= *source-length* (+ *index* ,n)))
  
  ;; chr
  
  (define-internal-parser chr (char)
     (if (test-remaining 1)
         (if (eql (char *source* *index*) char)
             (succeed char 1)
             (fail (string char)))
         (fail (string char))))
  
  (define-compiled-parser chr (char)
    (with-gensyms (genchar)
  