anchor.diff:  ;; A simple top-down, backtracking parser
   ;; Modelled after EBNF notation
  +
  +
  +;; Internal utilities
  +
  +
  +(defmacro grammar-call (x)
  +  "Call function or macro x"
  +  (cond ((null x) (error "Cannot execute nil."))
  +        ((symbolp x) `(,x string :start start))
  +        ((listp x) x)
  +        (t (error "Cannot call ~S" x))))
  +
  +(defmacro grammar-wrap (x)
  +  "Wrap function or macro x as a callback"
  +  (cond ((null x) (error "Cannot execute nil."))
  +        ((symbolp x) (list 'quote x))
  +        ((listp x) `(lambda (string &key (start 0)) ,x))
  +        (t (error "Cannot call ~S" x))))
  +
  +
  +;; Parser construction
  +
   
   (defun starts-with (string prefix &key (start 0))
     "Does 'string' begin with 'prefix'?"
  
positive.code:              (values (+ start ,(length str)) ,str))))))
  
  (defmacro grammar-optional (x)
    `(multiple-value-bind (end value) (grammar-call ,x)
      (if end
          (values end value)
          start)))
  
  (defmacro grammar-and (first &rest rest)
    (if (null rest)
        `(grammar-call ,first)
        `(multiple-value-bind (end value) (grammar-call ,first)
  
negative.code:       (values end (,f value)))))
  
  
  ;; Helper macros
  
  
  (defmacro grammar-rule (name &rest body)
    "defun wrapper to simplify rule production"
    `(defun ,name (string &key (start 0))
      ,@body))
  