anchor.diff:  ;;;;   EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
   
   
  -;;; DFA
  -;;;  -(Q, E, d, q0, F),
  -;;;    - Q: states
  -;;;    - E: alphabet
  -;;;    - d: Q*E :-> Q
  -;;;    - q0: start state
  -;;;    - F: accept state
  -
  -
  -(defun dfa-dot (d &key output final start)
  +;;; FA
  +;;;  -(states, tokens, edges, start, accept),
  +;;;    - edges: (list state-0 token state-1)
  +
  +(defstruct (fa (:constructor %make-fa))
  +  states
  +  tokens
  +  edges
  +  start
  +  accept
  +  reject)
  +
  +(defun make-fa (edges start accept)
  +  (let (states tokens)
  +    (map nil (lambda (x)
  +               (destructuring-bind (q0 z q1) x
  +                 (pushnew q0 states :test #'equal)
  +                 (pushnew q1 states :test #'equal)
  +                 (pushnew z tokens :test #'equal)))
  +         edges)
  +    (%make-fa :states states
  +              :tokens tokens
  +              :edges edges
  +              :start (alexandria:ensure-list start)
  +              :accept (alexandria:ensure-list accept))))
  +
  +
  +(defun fa-dot (fa &optional output )
     "Graphviz output of dfa.
   d: list of transitions '((state-0 token state-1)...)
   final: list of accept states
  
positive.code:     h))
  
  
  (defun fa-numerize (edges start)
    "Returns an edge list with all states and transitions as fixnums.
  0 is epsilon"
    (let ((state-hash (make-hash-table :test #'equal))
          (token-hash (make-hash-table :test #'equal))
          (state-counter 0)
          (token-counter 0)
          nedges)
      (setf (gethash :epsilon token-hash) 0)
      (setf (gethash start state-hash) 0)
      ;; build hashes
      (dolist (e edges)
        (destructuring-bind (q0 z q1) e
          (unless (gethash q0 state-hash)
            (setf (gethash q0 state-hash) (incf state-counter)))
  
negative.code:                  name))
             (helper (s)
               (format s "~&digraph {~%")
               (when (fa-start fa)
                 (format s "~&  start[shape=none];")
                 (format s "~{~&  start -> ~A;~}" (alexandria:ensure-list (fa-start fa))))
               (format s "~{~&  ~A [ shape=doublecircle ];~}" (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))
  