anchor.diff:             (new-token (i)
                (if token-map
                    (aref token-map i)
  -                 i)))
  -    (%make-fa :states  (cond ((null state-map) (fa-states fa))
  -                             (t (map 'vector #'identity
  -                                     (loop
  -                                        with i = 0
  -                                        for x across state-map
  -                                        when x
  -                                        collect i
  -                                        do (incf i)))))
  -              :tokens (if (null token-map)
  -                          (fa-tokens fa)
  -                          (let ((tokens (make-array (loop
  -                                                       for x across token-map
  -                                                       count x)
  -                                                    :initial-element nil)))
  -                            (loop with i = 0
  -                               for x across token-map
  -                               when x
  -                               do (setf (aref tokens (aref token-map i))
  -                                        (aref (fa-tokens fa) i)))
  -                            tokens))
  -              :start (sort (mapcan
  -                          (lambda (i) (when (new-state i)
  -                                   (list (new-state i))))
  -                          (fa-start fa))
  -                         #'<)
  -              :accept (sort (mapcan
  -                             (lambda (i) (when (new-state i)
  -                                      (list (new-state i))))
  -                             (fa-accept fa))
  -                            #'<)
  -              :edges (sort (mapcan
  -                            (lambda (e)
  -                              (when (and (new-state (first e))
  -                                         (new-token (second e))
  -                                         (new-state (third e)))
  -                                (list (list (new-state (first e))
  -                                            (new-token (second e))
  -                                            (new-state (third e))))))
  -                                (fa-edges fa))
  -                           #'symbol-list-compare))))
  +                 i))
  +           (state-translate (list)
  +             (mapcan (lambda (i) (when (new-state i)
  +                              (list (new-state i))))
  +                     list)))
  +    (let ((fa (%make-fa :states (cond ((null state-map) (fa-states fa))
  +                                      (t (map 'vector #'identity
  +                                              (loop
  +                                                 with i = -1
  +                                                 for x across (remove-duplicates state-map)
  +                                                 when x collect (incf i)))))
  +                        :tokens (if (null token-map)
  +                                    (fa-tokens fa)
  +                                    (let ((tokens (make-array (loop
  +                                                                 for x across
  +                                                                   (remove-duplicates token-map)
  +                                                                 count x)
  +                                                              :initial-element nil)))
  +                                      (loop with i = 0
  +                                         for x across token-map
  +                                         when x
  +                                         do (setf (aref tokens (aref token-map i))
  +                                                  (aref (fa-tokens fa) i)))
  +                                      tokens))
  +                        :start (state-translate (fa-start fa))
  +                        :accept (state-translate (fa-accept fa))
  +                        :edges (let ((hash (make-hash-table :test #'equal)))
  +                                 (fa-map-edges nil
  +                                               (lambda (q0 z q1)
  +                                                 (when (and (new-state q0)
  +                                                            (new-token z)
  +                                                            (new-state q1))
  +                                                   (setf (gethash (list (new-state q0)
  +                                                                        (new-token z)
  +                                                                        (new-state q1))
  +                                                                  hash)
  +                                                         t)))
  +                                               fa)
  +                                 (loop for key being the hash-keys of hash
  +                                    collect key)))))
  +      (when sort
  +        (setf (fa-edges fa) (sort (fa-edges fa) #'symbol-list-compare)
  +              (fa-start fa) (sort (fa-start fa) #'<)
  +              (fa-accept fa) (sort (fa-start fa) #'<)))
  +      fa)))
   
   
   ;;; Regex
  
positive.code:              (format s "~{~&  ~A [ shape=doublecircle ];~}"
                       (map 'list #'identity
                            (alexandria:ensure-list (fa-accept fa))))
               (map 'nil (lambda (x)
                           (format s "~&  ~A -> ~A [label=\"~A\"];~%"
                                   (first x) (third x)
                                   (token-label (second x))))
                    (fa-edges fa))
               (format s "~&}~%"))
             (dot (ext)
               (let ((p (sb-ext:run-program "dot" (list (concatenate 'string "-T" ext))
  
negative.code:                          (dotimes (i-z (length (fa-tokens fa)))
                             (visit (car (funcall mover i-q (aref token-old i-z))))))))
                (visit (car (fa-start fa)))))))
      (dotimes (i (length (fa-states fa)))
        (assert (>= (aref state-old i) 0)))
      ;; Build sorted FA
      (fa-renumber fa :state-map state-old :token-map token-old :sort t)))
  
  
  (defun dfa-equal (a b)
  